From fa5e419549bebf0666483d156edd23e41e7dd348 Mon Sep 17 00:00:00 2001 From: Marc Gilleron Date: Sat, 25 Mar 2017 01:23:36 +0100 Subject: [PATCH] Upgraded to Godot 3.0 --- register_types.cpp | 16 ++++++++-------- vector3i.h | 4 ++-- voxel.cpp | 30 +++++++++++++++--------------- voxel.h | 22 +++++++++++----------- voxel_buffer.cpp | 28 ++++++++++++++-------------- voxel_buffer.h | 2 +- voxel_library.cpp | 8 +++++--- voxel_library.h | 2 +- voxel_map.cpp | 20 ++++++++++---------- voxel_map.h | 3 ++- voxel_mesher.cpp | 32 ++++++++++++++++---------------- voxel_mesher.h | 2 +- voxel_provider.cpp | 4 ++-- voxel_provider.h | 2 +- voxel_provider_test.cpp | 16 ++++++++-------- voxel_provider_test.h | 2 +- voxel_terrain.cpp | 16 ++++++++-------- voxel_terrain.h | 2 +- 18 files changed, 107 insertions(+), 104 deletions(-) diff --git a/register_types.cpp b/register_types.cpp index 9ca01c4..4313807 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -8,14 +8,14 @@ void register_voxel_types() { - ObjectTypeDB::register_type(); - ObjectTypeDB::register_type(); - ObjectTypeDB::register_type(); - ObjectTypeDB::register_type(); - ObjectTypeDB::register_type(); - ObjectTypeDB::register_type(); - ObjectTypeDB::register_type(); - ObjectTypeDB::register_type(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); } diff --git a/vector3i.h b/vector3i.h index 212ce88..7f896d5 100644 --- a/vector3i.h +++ b/vector3i.h @@ -40,8 +40,8 @@ struct Vector3i { return x*x + y*y + z*z; } - _FORCE_INLINE_ float length() const { - return Math::sqrt(length_sq()); + _FORCE_INLINE_ real_t length() const { + return Math::sqrt((real_t)length_sq()); } _FORCE_INLINE_ Vector3i & operator=(const Vector3i & other) { diff --git a/voxel.cpp b/voxel.cpp index caf29ce..2a693e8 100644 --- a/voxel.cpp +++ b/voxel.cpp @@ -99,7 +99,7 @@ Ref Voxel::set_cube_geometry(float sy) { for (unsigned int side = 0; side < SIDE_COUNT; ++side) { _model_side_vertices[side].resize(6); - DVector::Write w = _model_side_vertices[side].write(); + PoolVector::Write w = _model_side_vertices[side].write(); for (unsigned int i = 0; i < 6; ++i) { w[i] = vertices[side][i]; } @@ -138,7 +138,7 @@ Ref Voxel::_set_cube_uv_sides(const Vector2 atlas_pos[6]) { for (unsigned int side = 0; side < SIDE_COUNT; ++side) { _model_side_uv[side].resize(6); - DVector::Write w = _model_side_uv[side].write(); + PoolVector::Write w = _model_side_uv[side].write(); for (unsigned int i = 0; i < 6; ++i) { w[i] = (atlas_pos[side] + uv[uv6[side][i]]) * s; } @@ -178,24 +178,24 @@ Ref Voxel::set_cube_uv_tbs_sides(Vector2 top_atlas_pos, Vector2 side_atla void Voxel::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_name:Voxel", "name"), &Voxel::set_name); - ObjectTypeDB::bind_method(_MD("get_name"), &Voxel::get_name); + ClassDB::bind_method(D_METHOD("set_name:Voxel", "name"), &Voxel::set_name); + ClassDB::bind_method(D_METHOD("get_name"), &Voxel::get_name); - ObjectTypeDB::bind_method(_MD("set_id:Voxel", "id"), &Voxel::set_id); - ObjectTypeDB::bind_method(_MD("get_id"), &Voxel::get_id); + ClassDB::bind_method(D_METHOD("set_id:Voxel", "id"), &Voxel::set_id); + ClassDB::bind_method(D_METHOD("get_id"), &Voxel::get_id); - ObjectTypeDB::bind_method(_MD("set_color:Voxel", "color"), &Voxel::set_color); - ObjectTypeDB::bind_method(_MD("get_color"), &Voxel::get_color); + ClassDB::bind_method(D_METHOD("set_color:Voxel", "color"), &Voxel::set_color); + ClassDB::bind_method(D_METHOD("get_color"), &Voxel::get_color); - ObjectTypeDB::bind_method(_MD("set_transparent:Voxel", "color"), &Voxel::set_transparent, DEFVAL(true)); - ObjectTypeDB::bind_method(_MD("is_transparent"), &Voxel::is_transparent); + ClassDB::bind_method(D_METHOD("set_transparent:Voxel", "color"), &Voxel::set_transparent, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("is_transparent"), &Voxel::is_transparent); - ObjectTypeDB::bind_method(_MD("set_material_id", "id"), &Voxel::set_material_id); - ObjectTypeDB::bind_method(_MD("get_material_id"), &Voxel::get_material_id); + ClassDB::bind_method(D_METHOD("set_material_id", "id"), &Voxel::set_material_id); + ClassDB::bind_method(D_METHOD("get_material_id"), &Voxel::get_material_id); - ObjectTypeDB::bind_method(_MD("set_cube_geometry:Voxel", "height"), &Voxel::set_cube_geometry, DEFVAL(1.f)); - ObjectTypeDB::bind_method(_MD("set_cube_uv_all_sides:Voxel", "atlas_pos"), &Voxel::set_cube_uv_all_sides); - ObjectTypeDB::bind_method(_MD("set_cube_uv_tbs_sides:Voxel", "top_atlas_pos", "side_atlas_pos", "bottom_atlas_pos"), &Voxel::set_cube_uv_tbs_sides); + ClassDB::bind_method(D_METHOD("set_cube_geometry:Voxel", "height"), &Voxel::set_cube_geometry, DEFVAL(1.f)); + ClassDB::bind_method(D_METHOD("set_cube_uv_all_sides:Voxel", "atlas_pos"), &Voxel::set_cube_uv_all_sides); + ClassDB::bind_method(D_METHOD("set_cube_uv_tbs_sides:Voxel", "top_atlas_pos", "side_atlas_pos", "bottom_atlas_pos"), &Voxel::set_cube_uv_tbs_sides); } diff --git a/voxel.h b/voxel.h index 52370e2..f49367f 100644 --- a/voxel.h +++ b/voxel.h @@ -9,7 +9,7 @@ class VoxelLibrary; // A voxel can be a simple coloured cube, or a more complex model. // Important: it is recommended that you create voxels from a library rather than using new(). class Voxel : public Reference { - OBJ_TYPE(Voxel, Reference) + GDCLASS(Voxel, Reference) public: enum Side { @@ -51,11 +51,11 @@ public: // Getters for native usage only - const DVector & get_model_vertices() const { return _model_vertices; } - const DVector & get_model_normals() const { return _model_normals; } - const DVector & get_model_uv() const { return _model_uv; } - const DVector & get_model_side_vertices(unsigned int side) const { return _model_side_vertices[side]; } - const DVector & get_model_side_uv(unsigned int side) const { return _model_side_uv[side]; } + const PoolVector & get_model_vertices() const { return _model_vertices; } + const PoolVector & get_model_normals() const { return _model_normals; } + const PoolVector & get_model_uv() const { return _model_uv; } + const PoolVector & get_model_side_vertices(unsigned int side) const { return _model_side_vertices[side]; } + const PoolVector & get_model_side_uv(unsigned int side) const { return _model_side_uv[side]; } void set_library_ptr(VoxelLibrary * lib) { _library = lib; } @@ -77,11 +77,11 @@ private: // Model Color _color; - DVector _model_vertices; - DVector _model_normals; - DVector _model_uv; - DVector _model_side_vertices[SIDE_COUNT]; - DVector _model_side_uv[SIDE_COUNT]; + PoolVector _model_vertices; + PoolVector _model_normals; + PoolVector _model_uv; + PoolVector _model_side_vertices[SIDE_COUNT]; + PoolVector _model_side_uv[SIDE_COUNT]; // TODO Child voxel types diff --git a/voxel_buffer.cpp b/voxel_buffer.cpp index 6f93289..cd0123a 100644 --- a/voxel_buffer.cpp +++ b/voxel_buffer.cpp @@ -239,24 +239,24 @@ void VoxelBuffer::delete_channel(int i) { void VoxelBuffer::_bind_methods() { - ObjectTypeDB::bind_method(_MD("create", "sx", "sy", "sz"), &VoxelBuffer::create); - ObjectTypeDB::bind_method(_MD("clear"), &VoxelBuffer::clear); + ClassDB::bind_method(D_METHOD("create", "sx", "sy", "sz"), &VoxelBuffer::create); + ClassDB::bind_method(D_METHOD("clear"), &VoxelBuffer::clear); - ObjectTypeDB::bind_method(_MD("get_size_x"), &VoxelBuffer::get_size_x); - ObjectTypeDB::bind_method(_MD("get_size_y"), &VoxelBuffer::get_size_y); - ObjectTypeDB::bind_method(_MD("get_size_z"), &VoxelBuffer::get_size_z); + ClassDB::bind_method(D_METHOD("get_size_x"), &VoxelBuffer::get_size_x); + ClassDB::bind_method(D_METHOD("get_size_y"), &VoxelBuffer::get_size_y); + ClassDB::bind_method(D_METHOD("get_size_z"), &VoxelBuffer::get_size_z); - ObjectTypeDB::bind_method(_MD("set_voxel", "value", "x", "y", "z", "channel"), &VoxelBuffer::_set_voxel_binding, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("set_voxel_v", "value", "pos", "channel"), &VoxelBuffer::set_voxel_v, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("get_voxel", "x", "y", "z", "channel"), &VoxelBuffer::_get_voxel_binding, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("set_voxel", "value", "x", "y", "z", "channel"), &VoxelBuffer::_set_voxel_binding, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("set_voxel_v", "value", "pos", "channel"), &VoxelBuffer::set_voxel_v, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("get_voxel", "x", "y", "z", "channel"), &VoxelBuffer::_get_voxel_binding, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("fill", "value", "channel"), &VoxelBuffer::fill, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("fill_area", "value", "min", "max", "channel"), &VoxelBuffer::_fill_area_binding, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("copy_from", "other:VoxelBuffer", "channel"), &VoxelBuffer::_copy_from_binding, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("copy_from_area", "other:VoxelBuffer", "src_min", "src_max", "dst_min", "channel"), &VoxelBuffer::_copy_from_area_binding, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("fill", "value", "channel"), &VoxelBuffer::fill, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("fill_area", "value", "min", "max", "channel"), &VoxelBuffer::_fill_area_binding, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("copy_from", "other:VoxelBuffer", "channel"), &VoxelBuffer::_copy_from_binding, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("copy_from_area", "other:VoxelBuffer", "src_min", "src_max", "dst_min", "channel"), &VoxelBuffer::_copy_from_area_binding, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("is_uniform", "channel"), &VoxelBuffer::is_uniform, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("optimize"), &VoxelBuffer::optimize); + ClassDB::bind_method(D_METHOD("is_uniform", "channel"), &VoxelBuffer::is_uniform, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("optimize"), &VoxelBuffer::optimize); } diff --git a/voxel_buffer.h b/voxel_buffer.h index 7481c4b..51cdbb2 100644 --- a/voxel_buffer.h +++ b/voxel_buffer.h @@ -10,7 +10,7 @@ // Note: for float storage (marching cubes for example), you can map [0..256] to [0..1] and save 3 bytes per cell class VoxelBuffer : public Reference { - OBJ_TYPE(VoxelBuffer, Reference) + GDCLASS(VoxelBuffer, Reference) public: // Arbitrary value, 8 should be enough. Tweak for your needs. diff --git a/voxel_library.cpp b/voxel_library.cpp index 15710a6..72227d3 100644 --- a/voxel_library.cpp +++ b/voxel_library.cpp @@ -1,7 +1,9 @@ #include "voxel_library.h" VoxelLibrary::VoxelLibrary() : Reference(), _atlas_size(1) { + // Defaults create_voxel(0, "air")->set_transparent(true); + create_voxel(1, "solid")->set_transparent(false)->set_cube_geometry(); } VoxelLibrary::~VoxelLibrary() { @@ -34,10 +36,10 @@ Ref VoxelLibrary::_get_voxel_bind(int id) { void VoxelLibrary::_bind_methods() { - ObjectTypeDB::bind_method(_MD("create_voxel:Voxel", "id", "name"), &VoxelLibrary::create_voxel); - ObjectTypeDB::bind_method(_MD("get_voxel", "id"), &VoxelLibrary::_get_voxel_bind); + ClassDB::bind_method(D_METHOD("create_voxel:Voxel", "id", "name"), &VoxelLibrary::create_voxel); + ClassDB::bind_method(D_METHOD("get_voxel", "id"), &VoxelLibrary::_get_voxel_bind); - ObjectTypeDB::bind_method(_MD("set_atlas_size", "square_size"), &VoxelLibrary::set_atlas_size); + ClassDB::bind_method(D_METHOD("set_atlas_size", "square_size"), &VoxelLibrary::set_atlas_size); } diff --git a/voxel_library.h b/voxel_library.h index 8d4b04a..2b200b4 100644 --- a/voxel_library.h +++ b/voxel_library.h @@ -5,7 +5,7 @@ #include "voxel.h" class VoxelLibrary : public Reference { - OBJ_TYPE(VoxelLibrary, Reference) + GDCLASS(VoxelLibrary, Reference) public: static const unsigned int MAX_VOXEL_TYPES = 256; // Required limit because voxel types are stored in 8 bits diff --git a/voxel_map.cpp b/voxel_map.cpp index 5feef21..e8f6255 100644 --- a/voxel_map.cpp +++ b/voxel_map.cpp @@ -242,16 +242,16 @@ void VoxelMap::clear() { void VoxelMap::_bind_methods() { - ObjectTypeDB::bind_method(_MD("get_voxel", "x", "y", "z", "c"), &VoxelMap::_get_voxel_binding, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("set_voxel", "value", "x", "y", "z", "c"), &VoxelMap::_set_voxel_binding, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("get_default_voxel", "channel"), &VoxelMap::get_default_voxel, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("set_default_voxel", "value", "channel"), &VoxelMap::set_default_voxel, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("has_block", "x", "y", "z"), &VoxelMap::_has_block_binding); - ObjectTypeDB::bind_method(_MD("get_buffer_copy", "min_pos", "out_buffer:VoxelBuffer", "channel"), &VoxelMap::_get_buffer_copy_binding, DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("set_block_buffer", "block_pos", "buffer:VoxelBuffer"), &VoxelMap::_set_block_buffer_binding); - ObjectTypeDB::bind_method(_MD("voxel_to_block", "voxel_pos"), &VoxelMap::_voxel_to_block_binding); - ObjectTypeDB::bind_method(_MD("block_to_voxel", "block_pos"), &VoxelMap::_block_to_voxel_binding); - ObjectTypeDB::bind_method(_MD("get_block_size"), &VoxelMap::get_block_size); + ClassDB::bind_method(D_METHOD("get_voxel", "x", "y", "z", "c"), &VoxelMap::_get_voxel_binding, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("set_voxel", "value", "x", "y", "z", "c"), &VoxelMap::_set_voxel_binding, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("get_default_voxel", "channel"), &VoxelMap::get_default_voxel, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("set_default_voxel", "value", "channel"), &VoxelMap::set_default_voxel, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("has_block", "x", "y", "z"), &VoxelMap::_has_block_binding); + ClassDB::bind_method(D_METHOD("get_buffer_copy", "min_pos", "out_buffer:VoxelBuffer", "channel"), &VoxelMap::_get_buffer_copy_binding, DEFVAL(0)); + ClassDB::bind_method(D_METHOD("set_block_buffer", "block_pos", "buffer:VoxelBuffer"), &VoxelMap::_set_block_buffer_binding); + ClassDB::bind_method(D_METHOD("voxel_to_block", "voxel_pos"), &VoxelMap::_voxel_to_block_binding); + ClassDB::bind_method(D_METHOD("block_to_voxel", "block_pos"), &VoxelMap::_block_to_voxel_binding); + ClassDB::bind_method(D_METHOD("get_block_size"), &VoxelMap::get_block_size); //ADD_PROPERTY(PropertyInfo(Variant::INT, "iterations"), _SCS("set_iterations"), _SCS("get_iterations")); diff --git a/voxel_map.h b/voxel_map.h index cb78f94..a7cf175 100644 --- a/voxel_map.h +++ b/voxel_map.h @@ -16,6 +16,7 @@ public: Ref voxels; // SIZE*SIZE*SIZE voxels Vector3i pos; NodePath mesh_instance_path; + //NodePath body_path; // TODO static VoxelBlock * create(Vector3i bpos, Ref buffer); @@ -29,7 +30,7 @@ private: // Infinite voxel storage by means of octants like Gridmap class VoxelMap : public Reference { - OBJ_TYPE(VoxelMap, Reference) + GDCLASS(VoxelMap, Reference) public: // Converts voxel coodinates into block coordinates static _FORCE_INLINE_ Vector3i voxel_to_block(Vector3i pos) { diff --git a/voxel_mesher.cpp b/voxel_mesher.cpp index 8d5c1f6..a5404a6 100644 --- a/voxel_mesher.cpp +++ b/voxel_mesher.cpp @@ -218,7 +218,7 @@ Ref VoxelMesher::build(const VoxelBuffer & buffer) { // Sides for (unsigned int side = 0; side < Voxel::SIDE_COUNT; ++side) { - const DVector & vertices = voxel.get_model_side_vertices(side); + const PoolVector & vertices = voxel.get_model_side_vertices(side); if (vertices.size() != 0) { Vector3i normal = g_side_normals[side]; @@ -266,8 +266,8 @@ Ref VoxelMesher::build(const VoxelBuffer & buffer) { } } - DVector::Read rv = vertices.read(); - DVector::Read rt = voxel.get_model_side_uv(side).read(); + PoolVector::Read rv = vertices.read(); + PoolVector::Read rt = voxel.get_model_side_uv(side).read(); Vector3 pos(x - 1, y - 1, z - 1); for (unsigned int i = 0; i < vertices.size(); ++i) { @@ -305,10 +305,10 @@ Ref VoxelMesher::build(const VoxelBuffer & buffer) { // Inside if (voxel.get_model_vertices().size() != 0) { - const DVector & vertices = voxel.get_model_vertices(); - DVector::Read rv = voxel.get_model_vertices().read(); - DVector::Read rn = voxel.get_model_normals().read(); - DVector::Read rt = voxel.get_model_uv().read(); + const PoolVector & vertices = voxel.get_model_vertices(); + PoolVector::Read rv = voxel.get_model_vertices().read(); + PoolVector::Read rn = voxel.get_model_normals().read(); + PoolVector::Read rt = voxel.get_model_uv().read(); Vector3 pos(x - 1, y - 1, z - 1); for (unsigned int i = 0; i < vertices.size(); ++i) { @@ -344,18 +344,18 @@ Ref VoxelMesher::build(const VoxelBuffer & buffer) { void VoxelMesher::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_material", "material", "id"), &VoxelMesher::set_material); - ObjectTypeDB::bind_method(_MD("get_material:Material", "id"), &VoxelMesher::get_material); + ClassDB::bind_method(D_METHOD("set_material", "material", "id"), &VoxelMesher::set_material); + ClassDB::bind_method(D_METHOD("get_material:Material", "id"), &VoxelMesher::get_material); - ObjectTypeDB::bind_method(_MD("set_library", "voxel_library"), &VoxelMesher::set_library); - ObjectTypeDB::bind_method(_MD("get_library:VoxelLibrary"), &VoxelMesher::get_library); + ClassDB::bind_method(D_METHOD("set_library", "voxel_library"), &VoxelMesher::set_library); + ClassDB::bind_method(D_METHOD("get_library:VoxelLibrary"), &VoxelMesher::get_library); - ObjectTypeDB::bind_method(_MD("set_occlusion_enabled", "enable"), &VoxelMesher::set_occlusion_enabled); - ObjectTypeDB::bind_method(_MD("get_occlusion_enabled"), &VoxelMesher::get_occlusion_enabled); + ClassDB::bind_method(D_METHOD("set_occlusion_enabled", "enable"), &VoxelMesher::set_occlusion_enabled); + ClassDB::bind_method(D_METHOD("get_occlusion_enabled"), &VoxelMesher::get_occlusion_enabled); - ObjectTypeDB::bind_method(_MD("set_occlusion_darkness", "value"), &VoxelMesher::set_occlusion_darkness); - ObjectTypeDB::bind_method(_MD("get_occlusion_darkness"), &VoxelMesher::get_occlusion_darkness); + ClassDB::bind_method(D_METHOD("set_occlusion_darkness", "value"), &VoxelMesher::set_occlusion_darkness); + ClassDB::bind_method(D_METHOD("get_occlusion_darkness"), &VoxelMesher::get_occlusion_darkness); - ObjectTypeDB::bind_method(_MD("build", "voxel_buffer"), &VoxelMesher::build_ref); + ClassDB::bind_method(D_METHOD("build", "voxel_buffer"), &VoxelMesher::build_ref); } diff --git a/voxel_mesher.h b/voxel_mesher.h index 78f832c..892ae8d 100644 --- a/voxel_mesher.h +++ b/voxel_mesher.h @@ -9,7 +9,7 @@ #include "voxel_library.h" class VoxelMesher : public Reference { - OBJ_TYPE(VoxelMesher, Reference) + GDCLASS(VoxelMesher, Reference) public: static const unsigned int MAX_MATERIALS = 8; // Arbitrary. Tweak if needed. diff --git a/voxel_provider.cpp b/voxel_provider.cpp index 13d8885..9efdc2c 100644 --- a/voxel_provider.cpp +++ b/voxel_provider.cpp @@ -38,8 +38,8 @@ void VoxelProvider::_immerge_block(Ref buffer, Vector3 block_pos) { void VoxelProvider::_bind_methods() { - ObjectTypeDB::bind_method(_MD("emerge_block", "out_buffer:VoxelBuffer", "block_pos:Vector3"), &VoxelProvider::_emerge_block); - ObjectTypeDB::bind_method(_MD("immerge_block", "buffer:VoxelBuffer", "block_pos:Vector3"), &VoxelProvider::_immerge_block); + ClassDB::bind_method(D_METHOD("emerge_block", "out_buffer:VoxelBuffer", "block_pos:Vector3"), &VoxelProvider::_emerge_block); + ClassDB::bind_method(D_METHOD("immerge_block", "buffer:VoxelBuffer", "block_pos:Vector3"), &VoxelProvider::_immerge_block); } diff --git a/voxel_provider.h b/voxel_provider.h index 8415888..40af381 100644 --- a/voxel_provider.h +++ b/voxel_provider.h @@ -6,7 +6,7 @@ class VoxelProvider : public Reference { - OBJ_TYPE(VoxelProvider, Reference) + GDCLASS(VoxelProvider, Reference) public: virtual void emerge_block(Ref out_buffer, Vector3i block_pos); virtual void immerge_block(Ref buffer, Vector3i block_pos); diff --git a/voxel_provider_test.cpp b/voxel_provider_test.cpp index 7223853..a19787b 100644 --- a/voxel_provider_test.cpp +++ b/voxel_provider_test.cpp @@ -93,17 +93,17 @@ void VoxelProviderTest::generate_block_waves(VoxelBuffer & out_buffer, Vector3i void VoxelProviderTest::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_mode", "mode"), &VoxelProviderTest::set_mode); - ObjectTypeDB::bind_method(_MD("get_mode"), &VoxelProviderTest::get_mode); + ClassDB::bind_method(D_METHOD("set_mode", "mode"), &VoxelProviderTest::set_mode); + ClassDB::bind_method(D_METHOD("get_mode"), &VoxelProviderTest::get_mode); - ObjectTypeDB::bind_method(_MD("set_voxel_type", "id"), &VoxelProviderTest::set_voxel_type); - ObjectTypeDB::bind_method(_MD("get_voxel_type"), &VoxelProviderTest::get_voxel_type); + ClassDB::bind_method(D_METHOD("set_voxel_type", "id"), &VoxelProviderTest::set_voxel_type); + ClassDB::bind_method(D_METHOD("get_voxel_type"), &VoxelProviderTest::get_voxel_type); - ObjectTypeDB::bind_method(_MD("set_pattern_size", "size"), &VoxelProviderTest::_set_pattern_size); - ObjectTypeDB::bind_method(_MD("get_pattern_size"), &VoxelProviderTest::_get_pattern_size); + ClassDB::bind_method(D_METHOD("set_pattern_size", "size"), &VoxelProviderTest::_set_pattern_size); + ClassDB::bind_method(D_METHOD("get_pattern_size"), &VoxelProviderTest::_get_pattern_size); - ObjectTypeDB::bind_method(_MD("set_pattern_offset", "offset"), &VoxelProviderTest::_set_pattern_offset); - ObjectTypeDB::bind_method(_MD("get_pattern_offset"), &VoxelProviderTest::_get_pattern_offset); + ClassDB::bind_method(D_METHOD("set_pattern_offset", "offset"), &VoxelProviderTest::_set_pattern_offset); + ClassDB::bind_method(D_METHOD("get_pattern_offset"), &VoxelProviderTest::_get_pattern_offset); BIND_CONSTANT(MODE_FLAT); BIND_CONSTANT(MODE_WAVES); diff --git a/voxel_provider_test.h b/voxel_provider_test.h index b241683..964e39f 100644 --- a/voxel_provider_test.h +++ b/voxel_provider_test.h @@ -5,7 +5,7 @@ class VoxelProviderTest : public VoxelProvider { - OBJ_TYPE(VoxelProviderTest, VoxelProvider) + GDCLASS(VoxelProviderTest, VoxelProvider) public: enum Mode { diff --git a/voxel_terrain.cpp b/voxel_terrain.cpp index cfc8f7d..261bb0b 100644 --- a/voxel_terrain.cpp +++ b/voxel_terrain.cpp @@ -186,19 +186,19 @@ void VoxelTerrain::update_block_mesh(Vector3i block_pos) { void VoxelTerrain::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_provider", "provider:VoxelProvider"), &VoxelTerrain::set_provider); - ObjectTypeDB::bind_method(_MD("get_provider:VoxelProvider"), &VoxelTerrain::get_provider); + ClassDB::bind_method(D_METHOD("set_provider", "provider:VoxelProvider"), &VoxelTerrain::set_provider); + ClassDB::bind_method(D_METHOD("get_provider:VoxelProvider"), &VoxelTerrain::get_provider); - ObjectTypeDB::bind_method(_MD("get_block_update_count"), &VoxelTerrain::get_block_update_count); - ObjectTypeDB::bind_method(_MD("get_mesher:VoxelMesher"), &VoxelTerrain::get_mesher); + ClassDB::bind_method(D_METHOD("get_block_update_count"), &VoxelTerrain::get_block_update_count); + ClassDB::bind_method(D_METHOD("get_mesher:VoxelMesher"), &VoxelTerrain::get_mesher); - ObjectTypeDB::bind_method(_MD("get_map:VoxelMap"), &VoxelTerrain::get_map); + ClassDB::bind_method(D_METHOD("get_map:VoxelMap"), &VoxelTerrain::get_map); // TODO Make those two static in VoxelMap? - ObjectTypeDB::bind_method(_MD("voxel_to_block", "voxel_pos"), &VoxelTerrain::_voxel_to_block_binding); - ObjectTypeDB::bind_method(_MD("block_to_voxel", "block_pos"), &VoxelTerrain::_block_to_voxel_binding); + ClassDB::bind_method(D_METHOD("voxel_to_block", "voxel_pos"), &VoxelTerrain::_voxel_to_block_binding); + ClassDB::bind_method(D_METHOD("block_to_voxel", "block_pos"), &VoxelTerrain::_block_to_voxel_binding); - ObjectTypeDB::bind_method(_MD("force_load_blocks", "center", "extents"), &VoxelTerrain::_force_load_blocks_binding); + ClassDB::bind_method(D_METHOD("force_load_blocks", "center", "extents"), &VoxelTerrain::_force_load_blocks_binding); } diff --git a/voxel_terrain.h b/voxel_terrain.h index 5becc20..a8bc166 100644 --- a/voxel_terrain.h +++ b/voxel_terrain.h @@ -9,7 +9,7 @@ // Infinite static terrain made of voxels. // It is loaded around VoxelTerrainStreamers. class VoxelTerrain : public Node /*, public IVoxelMapObserver*/ { - OBJ_TYPE(VoxelTerrain, Node) + GDCLASS(VoxelTerrain, Node) public: VoxelTerrain();