mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
-Removed Voxel, not needed.
-Huge cleanup. -Moved the voxel query to a new folder, also it's not in the build anymore. Will be removed shortly.
This commit is contained in:
parent
9fb6a4e1c1
commit
ba05f93aa2
3
SCsub
3
SCsub
@ -7,15 +7,12 @@ env.add_source_files(env.modules_sources,"collections/vector3i.cpp")
|
||||
env.add_source_files(env.modules_sources,"library/voxelman_library.cpp")
|
||||
env.add_source_files(env.modules_sources,"library/voxel_surface.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"data/voxel.cpp")
|
||||
env.add_source_files(env.modules_sources,"data/voxel_light.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"meshers/voxel_mesher.cpp")
|
||||
env.add_source_files(env.modules_sources,"meshers/voxel_mesher_transvoxel.cpp")
|
||||
env.add_source_files(env.modules_sources,"meshers/transvoxel_tables.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"utility/marching_cubes_voxel_query.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"world/voxel_buffer.cpp")
|
||||
env.add_source_files(env.modules_sources,"world/voxel_world.cpp")
|
||||
env.add_source_files(env.modules_sources,"world/voxel_chunk.cpp")
|
||||
|
@ -1,78 +0,0 @@
|
||||
#include "voxel.h"
|
||||
|
||||
Ref<VoxelSurface> Voxel::get_surface() {
|
||||
return _surface;
|
||||
}
|
||||
|
||||
Vector3i Voxel::get_local_position() const {
|
||||
return _local_position;
|
||||
}
|
||||
void Voxel::set_local_position(Vector3i value) {
|
||||
_local_position = value;
|
||||
}
|
||||
|
||||
Vector3 Voxel::get_local_position_bind() const {
|
||||
return _local_position.to_vec3();
|
||||
}
|
||||
void Voxel::set_local_position_bind(Vector3 value) {
|
||||
_local_position = value;
|
||||
}
|
||||
|
||||
char Voxel::get_fill() {
|
||||
return _fill;
|
||||
}
|
||||
void Voxel::set_fill(char fill) {
|
||||
_fill = fill;
|
||||
}
|
||||
|
||||
int Voxel::get_fill_bind() {
|
||||
return (unsigned int) _fill;
|
||||
}
|
||||
void Voxel::set_fill_bind(int fill) {
|
||||
_fill = (char) fill;
|
||||
}
|
||||
|
||||
float Voxel::get_light() const {
|
||||
return _light;
|
||||
}
|
||||
void Voxel::set_light(float value) {
|
||||
_light = value;
|
||||
}
|
||||
|
||||
Voxel::Voxel() {
|
||||
_light = (float)1;
|
||||
}
|
||||
|
||||
Voxel::Voxel(Vector3i position, char fill, Ref<VoxelSurface> surface) {
|
||||
_light = (float)1;
|
||||
_fill = fill;
|
||||
|
||||
set_surface(surface);
|
||||
|
||||
_local_position = position;
|
||||
}
|
||||
|
||||
Voxel::~Voxel() {
|
||||
}
|
||||
|
||||
void Voxel::set_surface(Ref<VoxelSurface> surface) {
|
||||
_surface = Ref<VoxelSurface>(surface);
|
||||
}
|
||||
|
||||
void Voxel::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_surface"), &Voxel::get_surface);
|
||||
ClassDB::bind_method(D_METHOD("set_surface", "Mesher"), &Voxel::set_surface);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "surface", PROPERTY_HINT_RESOURCE_TYPE, "VoxelSurface"), "set_surface", "get_surface");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_fill"), &Voxel::get_fill_bind);
|
||||
ClassDB::bind_method(D_METHOD("set_fill", "value"), &Voxel::set_fill_bind);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "fill"), "set_fill", "get_fill");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_local_position"), &Voxel::get_local_position_bind);
|
||||
ClassDB::bind_method(D_METHOD("set_local_position", "value"), &Voxel::set_local_position_bind);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "local_position"), "set_fill", "get_local_position");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_light"), &Voxel::get_light);
|
||||
ClassDB::bind_method(D_METHOD("set_light", "value"), &Voxel::set_light);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "light"), "set_light", "get_light");
|
||||
}
|
50
data/voxel.h
50
data/voxel.h
@ -1,50 +0,0 @@
|
||||
#ifndef VOXEL_H
|
||||
#define VOXEL_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "../math/vector3i.h"
|
||||
#include "core/math/quat.h"
|
||||
#include "core/resource.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "../library/voxel_surface.h"
|
||||
|
||||
class VoxelSurface;
|
||||
|
||||
class Voxel : public Reference {
|
||||
GDCLASS(Voxel, Reference);
|
||||
|
||||
public:
|
||||
Ref<VoxelSurface> get_surface();
|
||||
void set_surface(Ref<VoxelSurface> surface);
|
||||
|
||||
Vector3i get_local_position() const;
|
||||
void set_local_position(Vector3i value);
|
||||
|
||||
Vector3 get_local_position_bind() const;
|
||||
void set_local_position_bind(Vector3 value);
|
||||
|
||||
char get_fill();
|
||||
void set_fill(char fill);
|
||||
|
||||
int get_fill_bind();
|
||||
void set_fill_bind(int fill);
|
||||
|
||||
float get_light() const;
|
||||
void set_light(float value);
|
||||
|
||||
Voxel();
|
||||
Voxel(Vector3i position, char fill, Ref<VoxelSurface> surface);
|
||||
~Voxel();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
char _fill;
|
||||
Ref<VoxelSurface> _surface;
|
||||
Vector3i _local_position;
|
||||
float _light;
|
||||
};
|
||||
|
||||
#endif
|
@ -25,7 +25,12 @@ VoxelMesher::~VoxelMesher() {
|
||||
_uvs.clear();
|
||||
_indices.clear();
|
||||
_bones.clear();
|
||||
|
||||
memdelete(_surface_tool);
|
||||
|
||||
if (_library.is_valid()) {
|
||||
_library.unref();
|
||||
}
|
||||
}
|
||||
|
||||
Ref<ArrayMesh> VoxelMesher::build_mesh() {
|
||||
@ -70,17 +75,10 @@ void VoxelMesher::reset() {
|
||||
_bones.clear();
|
||||
}
|
||||
|
||||
void VoxelMesher::create_mesh_for_marching_cubes_query(Ref<MarchingCubesVoxelQuery> query) {
|
||||
ERR_FAIL_COND(!query.is_valid());
|
||||
ERR_FAIL_COND(!has_method("_create_mesh_for_marching_cubes_query"));
|
||||
|
||||
call("_create_mesh_for_marching_cubes_query", query);
|
||||
}
|
||||
|
||||
void VoxelMesher::add_buffer(Ref<VoxelBuffer> voxels) {
|
||||
ERR_FAIL_COND(!has_method("_add_voxel"));
|
||||
ERR_FAIL_COND(!has_method("_add_buffer"));
|
||||
|
||||
call("_add_voxel", voxels);
|
||||
call("_add_buffer", voxels);
|
||||
}
|
||||
|
||||
void VoxelMesher::create_trimesh_shape(Ref<ConcavePolygonShape> shape) const {
|
||||
@ -308,9 +306,9 @@ void VoxelMesher::remove_indices(int idx) {
|
||||
|
||||
|
||||
void VoxelMesher::_bind_methods() {
|
||||
//BIND_VMETHOD(MethodInfo("_build_mesh", PropertyInfo(Variant::BOOL, "recal", PROPERTY_HINT_RESOURCE_TYPE, "SpellCastInfo")));
|
||||
BIND_VMETHOD(MethodInfo("_add_voxels", PropertyInfo(Variant::OBJECT, "buffer", PROPERTY_HINT_RESOURCE_TYPE, "VoxelBuffer")));
|
||||
BIND_VMETHOD(MethodInfo("_create_mesh_for_marching_cubes_query", PropertyInfo(Variant::OBJECT, "query", PROPERTY_HINT_RESOURCE_TYPE, "MarchingCubesVoxelQuery")));
|
||||
BIND_VMETHOD(MethodInfo("_add_buffer", PropertyInfo(Variant::OBJECT, "buffer", PROPERTY_HINT_RESOURCE_TYPE, "VoxelBuffer")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_buffer", "buffer"), &VoxelMesher::add_buffer);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_library"), &VoxelMesher::get_library);
|
||||
ClassDB::bind_method(D_METHOD("set_library", "value"), &VoxelMesher::set_library);
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef VOXEL_TOOLS_H
|
||||
#define VOXEL_TOOLS_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "core/resource.h"
|
||||
#include "core/color.h"
|
||||
#include "core/math/vector2.h"
|
||||
#include "core/math/vector3.h"
|
||||
@ -17,7 +17,6 @@
|
||||
|
||||
#include "../library/voxelman_library.h"
|
||||
#include "../math/vector3i.h"
|
||||
#include "../utility/marching_cubes_voxel_query.h"
|
||||
#include "../world/voxel_buffer.h"
|
||||
|
||||
const double PI_2 = 3.141592653589793238463 / 2;
|
||||
@ -26,8 +25,8 @@ const double PI = 3.141592653589793238463;
|
||||
class VoxelmanLibrary;
|
||||
class Voxel;
|
||||
|
||||
class VoxelMesher : public Reference {
|
||||
GDCLASS(VoxelMesher, Reference);
|
||||
class VoxelMesher : public Resource {
|
||||
GDCLASS(VoxelMesher, Resource);
|
||||
|
||||
public:
|
||||
Ref<VoxelmanLibrary> get_library() { return _library; }
|
||||
@ -36,7 +35,6 @@ public:
|
||||
void reset();
|
||||
|
||||
void add_buffer(Ref<VoxelBuffer> voxels);
|
||||
void create_mesh_for_marching_cubes_query(Ref<MarchingCubesVoxelQuery> query);
|
||||
|
||||
void create_trimesh_shape(Ref<ConcavePolygonShape> shape) const;
|
||||
void bake_lights(MeshInstance *node, Vector<Ref<VoxelLight> > &lights);
|
||||
|
@ -214,4 +214,24 @@ void VoxelMesherTransvoxel::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_transition_vertex_data_second_vertex", "index1", "index2"), &VoxelMesherTransvoxel::get_transition_vertex_data_second_vertex);
|
||||
ClassDB::bind_method(D_METHOD("get_transition_vertex_start_position", "index1", "index2"), &VoxelMesherTransvoxel::get_transition_vertex_start_position);
|
||||
ClassDB::bind_method(D_METHOD("get_transition_vertex_direction", "index1", "index2"), &VoxelMesherTransvoxel::get_transition_vertex_direction);
|
||||
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_000);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_100);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_010);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_110);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_001);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_101);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_011);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_111);
|
||||
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRIES_SIZE);
|
||||
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_000);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_100);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_010);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_110);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_001);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_101);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_011);
|
||||
BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_111);
|
||||
}
|
||||
|
@ -52,6 +52,36 @@ class VoxelMesherTransvoxel : public VoxelMesher {
|
||||
GDCLASS(VoxelMesherTransvoxel, VoxelMesher)
|
||||
|
||||
public:
|
||||
static const String BINDING_STRING_VOXEL_ENTRY_INDICES;
|
||||
static const String BINDING_STRING_VOXEL_ENTRY_MASK;
|
||||
|
||||
enum VoxelEntryIndices {
|
||||
VOXEL_ENTRY_INDEX_000 = 0,
|
||||
VOXEL_ENTRY_INDEX_100 = 1,
|
||||
VOXEL_ENTRY_INDEX_001 = 2,
|
||||
VOXEL_ENTRY_INDEX_101 = 3,
|
||||
|
||||
VOXEL_ENTRY_INDEX_010 = 4,
|
||||
VOXEL_ENTRY_INDEX_110 = 5,
|
||||
VOXEL_ENTRY_INDEX_011 = 6,
|
||||
VOXEL_ENTRY_INDEX_111 = 7,
|
||||
|
||||
VOXEL_ENTRIES_SIZE = 8,
|
||||
};
|
||||
|
||||
enum VoxelEntryMask {
|
||||
VOXEL_ENTRY_MASK_000 = 1 << 0,
|
||||
VOXEL_ENTRY_MASK_100 = 1 << 1,
|
||||
VOXEL_ENTRY_MASK_001 = 1 << 2,
|
||||
VOXEL_ENTRY_MASK_101 = 1 << 3,
|
||||
|
||||
VOXEL_ENTRY_MASK_010 = 1 << 4,
|
||||
VOXEL_ENTRY_MASK_110 = 1 << 5,
|
||||
VOXEL_ENTRY_MASK_011 = 1 << 6,
|
||||
VOXEL_ENTRY_MASK_111 = 1 << 7,
|
||||
};
|
||||
|
||||
|
||||
int get_regular_cell_class(int index) const;
|
||||
|
||||
Ref<TransvoxelRegularCellData> get_regular_cell_data(int index) const;
|
||||
@ -81,4 +111,7 @@ protected:
|
||||
Ref<TransvoxelTransitionCellData> _transition_cell_data[56];
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VoxelMesherTransvoxel::VoxelEntryIndices);
|
||||
VARIANT_ENUM_CAST(VoxelMesherTransvoxel::VoxelEntryMask);
|
||||
|
||||
#endif // VOXEL_MESHER_SMOOTH_H
|
||||
|
@ -3,13 +3,10 @@
|
||||
#include "library/voxel_surface.h"
|
||||
#include "library/voxelman_library.h"
|
||||
|
||||
#include "data/voxel.h"
|
||||
#include "data/voxel_light.h"
|
||||
#include "meshers/voxel_mesher.h"
|
||||
#include "meshers/voxel_mesher_transvoxel.h"
|
||||
|
||||
#include "utility/marching_cubes_voxel_query.h"
|
||||
|
||||
#include "world/voxel_buffer.h"
|
||||
#include "world/voxel_world.h"
|
||||
#include "world/voxel_chunk.h"
|
||||
@ -23,11 +20,8 @@ void register_voxelman_types() {
|
||||
ClassDB::register_class<VoxelSurface>();
|
||||
ClassDB::register_class<VoxelmanLibrary>();
|
||||
|
||||
ClassDB::register_class<Voxel>();
|
||||
ClassDB::register_class<VoxelLight>();
|
||||
|
||||
ClassDB::register_class<MarchingCubesVoxelQuery>();
|
||||
|
||||
ClassDB::register_class<VoxelBuffer>();
|
||||
ClassDB::register_class<VoxelWorld>();
|
||||
ClassDB::register_class<VoxelChunk>();
|
||||
|
@ -56,34 +56,6 @@ void VoxelChunk::set_bake_lights(bool value) {
|
||||
_bake_lights = value;
|
||||
}
|
||||
|
||||
bool VoxelChunk::get_bake_ambient_occlusion() {
|
||||
return _bake_ambient_occlusion;
|
||||
}
|
||||
void VoxelChunk::set_bake_ambient_occlusion(bool value) {
|
||||
_bake_ambient_occlusion = value;
|
||||
}
|
||||
|
||||
float VoxelChunk::get_ao_radius() {
|
||||
return _ao_radius;
|
||||
}
|
||||
void VoxelChunk::set_ao_radius(float value) {
|
||||
_ao_radius = value;
|
||||
}
|
||||
|
||||
float VoxelChunk::get_ao_intensity() {
|
||||
return _ao_intensity;
|
||||
}
|
||||
void VoxelChunk::set_ao_intensity(float value) {
|
||||
_ao_intensity = value;
|
||||
}
|
||||
|
||||
int VoxelChunk::get_ao_sample_count() {
|
||||
return _ao_sample_count;
|
||||
}
|
||||
void VoxelChunk::set_ao_sample_count(int value) {
|
||||
_ao_sample_count = value;
|
||||
}
|
||||
|
||||
NodePath VoxelChunk::get_debug_drawer_path() {
|
||||
return _debug_drawer_path;
|
||||
}
|
||||
@ -106,19 +78,19 @@ void VoxelChunk::build() {
|
||||
_mesher->set_library(_library);
|
||||
|
||||
if (_debug_drawer == NULL) {
|
||||
Node *n = get_node(_debug_drawer_path);
|
||||
Node *n = get_node_or_null(_debug_drawer_path);
|
||||
|
||||
if (n != NULL) {
|
||||
_debug_drawer = Object::cast_to<ImmediateGeometry>(n);
|
||||
}
|
||||
}
|
||||
|
||||
_mesher->add_buffer(_buffer);
|
||||
|
||||
if (get_build_mesh()) {
|
||||
ERR_FAIL_COND(!has_method("_build_mesh"));
|
||||
|
||||
call("_build_mesh");
|
||||
if (has_method("_create_mesh")) {
|
||||
call("_create_mesh");
|
||||
} else {
|
||||
_mesher->add_buffer(_buffer);
|
||||
}
|
||||
|
||||
finalize_mesh();
|
||||
}
|
||||
@ -133,11 +105,12 @@ void VoxelChunk::finalize_mesh() {
|
||||
|
||||
Node *node = get_node(_mesh_instance_path);
|
||||
|
||||
if (node != NULL) {
|
||||
ERR_FAIL_COND(node == NULL);
|
||||
|
||||
_mesh_instance = Object::cast_to<MeshInstance>(node);
|
||||
|
||||
if (_mesh_instance != NULL) {
|
||||
ERR_FAIL_COND(_mesh_instance == NULL);
|
||||
|
||||
//if (get_bake_ambient_occlusion()) {
|
||||
// set_enabled(true);
|
||||
//} else {
|
||||
@ -145,8 +118,6 @@ void VoxelChunk::finalize_mesh() {
|
||||
|
||||
_mesh_instance->set_mesh(mesh);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelChunk::update_collider() {
|
||||
@ -178,25 +149,6 @@ StaticBody *VoxelChunk::create_trimesh_collision_node() {
|
||||
return static_body;
|
||||
}
|
||||
|
||||
void VoxelChunk::query_marching_cubes_data(Ref<MarchingCubesVoxelQuery> query) {
|
||||
ERR_FAIL_COND(!query.is_valid());
|
||||
|
||||
Vector3i position = query->get_position();
|
||||
int size = query->get_size();
|
||||
/*
|
||||
query->set_entries(Ref<Voxel>(_VoxelChunk->getptr(position)), Ref<Voxel>(_VoxelChunk->getptr(Vector3i(size, 0, 0) + position)),
|
||||
Ref<Voxel>(_VoxelChunk->getptr(Vector3i(0, size, 0) + position)), Ref<Voxel>(_VoxelChunk->getptr(Vector3i(size, size, 0) + position)),
|
||||
Ref<Voxel>(_VoxelChunk->getptr(Vector3i(0, 0, size) + position)), Ref<Voxel>(_VoxelChunk->getptr(Vector3i(size, 0, size) + position)),
|
||||
Ref<Voxel>(_VoxelChunk->getptr(Vector3i(0, size, size) + position)), Ref<Voxel>(_VoxelChunk->getptr(Vector3i(size, size, size) + position)));*/
|
||||
}
|
||||
|
||||
void VoxelChunk::create_mesh_for_marching_cubes_query(Ref<MarchingCubesVoxelQuery> query) {
|
||||
ERR_FAIL_COND(!query.is_valid());
|
||||
ERR_FAIL_COND(!_mesher.is_valid());
|
||||
|
||||
_mesher->create_mesh_for_marching_cubes_query(query);
|
||||
}
|
||||
|
||||
void VoxelChunk::set_enabled(bool p_enabled) {
|
||||
|
||||
_enabled = p_enabled;
|
||||
@ -209,51 +161,6 @@ bool VoxelChunk::is_enabled() const {
|
||||
return _enabled;
|
||||
}
|
||||
|
||||
void VoxelChunk::_notification(int p_what) {
|
||||
|
||||
switch (p_what) {
|
||||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
if (!_mesher.is_valid()) {
|
||||
if (has_method("_create_mesher")) {
|
||||
call("_create_mesher");
|
||||
|
||||
if (!Engine::get_singleton()->is_editor_hint()) {
|
||||
ERR_FAIL_COND(!_mesher.is_valid());
|
||||
}
|
||||
} else {
|
||||
_mesher = Ref<VoxelMesher>(memnew(VoxelMesher()));
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
|
||||
//if (_mesher != NULL) {
|
||||
// memdelete(_mesher);
|
||||
//}
|
||||
|
||||
} break;
|
||||
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
||||
|
||||
//if (!_enabled)
|
||||
// break;
|
||||
|
||||
//if (_mesh_instance != NULL) {
|
||||
// if (get_bake_ambient_occlusion()) {
|
||||
//get_mesher()->calculate_vertex_ambient_occlusion(_mesh_instance, get_ao_radius(), get_ao_intensity(), get_ao_sample_count());
|
||||
// }
|
||||
|
||||
//Ref<ArrayMesh> mesh = get_mesher()->build_mesh();
|
||||
|
||||
//_mesh_instance->set_mesh(mesh);
|
||||
//}
|
||||
|
||||
//set_enabled(false);
|
||||
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelChunk::add_voxel_light_bind(Vector3 position, Color color, float strength) {
|
||||
add_voxel_light(position, color, strength);
|
||||
}
|
||||
@ -393,8 +300,7 @@ void VoxelChunk::draw_debug_voxel_lights(int max, bool localPosition) {
|
||||
}
|
||||
|
||||
void VoxelChunk::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_create_mesher"));
|
||||
BIND_VMETHOD(MethodInfo("_build_mesh"));
|
||||
BIND_VMETHOD(MethodInfo("_create_mesh"));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_library_path"), &VoxelChunk::get_library_path);
|
||||
ClassDB::bind_method(D_METHOD("set_library_path", "value"), &VoxelChunk::set_library_path);
|
||||
@ -428,29 +334,12 @@ void VoxelChunk::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("meshing_set_bake_lights", "value"), &VoxelChunk::set_bake_lights);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meshing_bake_lights"), "meshing_set_bake_lights", "meshing_get_bake_lights");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("meshing_get_bake_ambient_occlusion"), &VoxelChunk::get_bake_ambient_occlusion);
|
||||
ClassDB::bind_method(D_METHOD("meshing_set_bake_ambient_occlusion", "value"), &VoxelChunk::set_bake_ambient_occlusion);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "meshing_bake_ambient_occlusion"), "meshing_set_bake_ambient_occlusion", "meshing_get_bake_ambient_occlusion");
|
||||
|
||||
ADD_GROUP("Settings", "setting");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_debug_drawer_path"), &VoxelChunk::get_debug_drawer_path);
|
||||
ClassDB::bind_method(D_METHOD("set_debug_drawer_path", "value"), &VoxelChunk::set_debug_drawer_path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "debug_drawer_path"), "set_debug_drawer_path", "get_debug_drawer_path");
|
||||
|
||||
ADD_GROUP("Ambient Occlusion", "ao");
|
||||
ClassDB::bind_method(D_METHOD("get_ao_radius"), &VoxelChunk::get_ao_radius);
|
||||
ClassDB::bind_method(D_METHOD("set_ao_radius", "value"), &VoxelChunk::set_ao_radius);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_radius"), "set_ao_radius", "get_ao_radius");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_ao_intensity"), &VoxelChunk::get_ao_intensity);
|
||||
ClassDB::bind_method(D_METHOD("set_ao_intensity", "value"), &VoxelChunk::set_ao_intensity);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_intensity"), "set_ao_intensity", "get_ao_intensity");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_ao_sample_count"), &VoxelChunk::get_ao_sample_count);
|
||||
ClassDB::bind_method(D_METHOD("set_ao_sample_count", "value"), &VoxelChunk::set_ao_sample_count);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "ao_sample_count"), "set_ao_sample_count", "get_ao_sample_count");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_mesher"), &VoxelChunk::get_mesher);
|
||||
ClassDB::bind_method(D_METHOD("set_mesher", "Mesher"), &VoxelChunk::set_mesher);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), "set_mesher", "get_mesher");
|
||||
@ -460,9 +349,6 @@ void VoxelChunk::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("clear"), &VoxelChunk::clear);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("query_marching_cubes_data", "query"), &VoxelChunk::query_marching_cubes_data);
|
||||
ClassDB::bind_method(D_METHOD("create_mesh_for_marching_cubes_query", "query"), &VoxelChunk::create_mesh_for_marching_cubes_query);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("draw_debug_voxels", "max"), &VoxelChunk::draw_debug_voxels, DEFVAL(Color(1, 1, 1)));
|
||||
ClassDB::bind_method(D_METHOD("draw_debug_voxel_lights", "max", "localPosition"), &VoxelChunk::draw_debug_voxel_lights);
|
||||
}
|
||||
@ -471,11 +357,6 @@ VoxelChunk::VoxelChunk() {
|
||||
_build_mesh = true;
|
||||
_create_collider = true;
|
||||
_bake_lights = true;
|
||||
_bake_ambient_occlusion = true;
|
||||
|
||||
_ao_radius = 6;
|
||||
_ao_intensity = 1;
|
||||
_ao_sample_count = 5;
|
||||
|
||||
_voxel_scale = 1;
|
||||
|
||||
@ -494,4 +375,12 @@ VoxelChunk::~VoxelChunk() {
|
||||
_buffer.unref();
|
||||
|
||||
_debug_drawer = NULL;
|
||||
|
||||
if (_library.is_valid()) {
|
||||
_library.unref();
|
||||
}
|
||||
|
||||
if (_mesh.is_valid()) {
|
||||
_mesh.unref();
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "scene/3d/physics_body.h"
|
||||
#include "scene/resources/concave_polygon_shape.h"
|
||||
|
||||
#include "../data/voxel.h"
|
||||
#include "../data/voxel_light.h"
|
||||
|
||||
#include "../meshers/voxel_mesher.h"
|
||||
@ -18,7 +17,6 @@
|
||||
#include "../library/voxel_surface.h"
|
||||
#include "../library/voxelman_library.h"
|
||||
|
||||
#include "../utility/marching_cubes_voxel_query.h"
|
||||
#include "voxel_buffer.h"
|
||||
|
||||
|
||||
@ -50,18 +48,6 @@ public:
|
||||
bool get_bake_lights();
|
||||
void set_bake_lights(bool value);
|
||||
|
||||
bool get_bake_ambient_occlusion();
|
||||
void set_bake_ambient_occlusion(bool value);
|
||||
|
||||
float get_ao_radius();
|
||||
void set_ao_radius(float value);
|
||||
|
||||
float get_ao_intensity();
|
||||
void set_ao_intensity(float value);
|
||||
|
||||
int get_ao_sample_count();
|
||||
void set_ao_sample_count(int value);
|
||||
|
||||
NodePath get_debug_drawer_path();
|
||||
void set_debug_drawer_path(NodePath value);
|
||||
|
||||
@ -82,9 +68,6 @@ public:
|
||||
|
||||
StaticBody *create_trimesh_collision_node();
|
||||
|
||||
void query_marching_cubes_data(Ref<MarchingCubesVoxelQuery> query);
|
||||
void create_mesh_for_marching_cubes_query(Ref<MarchingCubesVoxelQuery> query);
|
||||
|
||||
VoxelChunk();
|
||||
virtual ~VoxelChunk();
|
||||
|
||||
@ -95,7 +78,6 @@ public:
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
void _notification(int p_what);
|
||||
|
||||
bool _enabled;
|
||||
|
||||
@ -119,11 +101,6 @@ protected:
|
||||
bool _create_collider;
|
||||
|
||||
bool _bake_lights;
|
||||
bool _bake_ambient_occlusion;
|
||||
|
||||
float _ao_radius;
|
||||
float _ao_intensity;
|
||||
int _ao_sample_count;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -8,6 +8,10 @@ void VoxelWorld::set_player_path(NodePath player_path) {
|
||||
_player_path = player_path;
|
||||
}
|
||||
|
||||
VoxelWorld ::~VoxelWorld() {
|
||||
_chunks.clear();
|
||||
}
|
||||
|
||||
void VoxelWorld::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_player_path"), &VoxelWorld::get_player_path);
|
||||
ClassDB::bind_method(D_METHOD("set_player_path", "value"), &VoxelWorld::set_player_path);
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
void set_player_path(NodePath player_path);
|
||||
|
||||
VoxelWorld() {}
|
||||
~VoxelWorld();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
Loading…
Reference in New Issue
Block a user