From 851b4efb5207b7d05dd8339f5470a03f8edd9bb8 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 26 Oct 2020 17:24:22 +0100 Subject: [PATCH] Same change to the collider-related method in VoxelChunk. --- world/default/voxel_chunk_default.cpp | 10 +++--- world/jobs/voxel_prop_job.cpp | 10 +++--- world/voxel_chunk.cpp | 48 +++++++++++++-------------- world/voxel_chunk.h | 24 +++++++------- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/world/default/voxel_chunk_default.cpp b/world/default/voxel_chunk_default.cpp index 67cb171..61e9e55 100644 --- a/world/default/voxel_chunk_default.cpp +++ b/world/default/voxel_chunk_default.cpp @@ -502,8 +502,8 @@ void VoxelChunkDefault::update_transforms() { } } - for (int i = 0; i < get_collider_count(); ++i) { - PhysicsServer::get_singleton()->body_set_state(get_collider_body(i), PhysicsServer::BODY_STATE_TRANSFORM, get_transform() * get_collider_transform(i)); + for (int i = 0; i < collider_get_count(); ++i) { + PhysicsServer::get_singleton()->body_set_state(collider_get_body(i), PhysicsServer::BODY_STATE_TRANSFORM, get_transform() * collider_get_transform(i)); } if (_debug_mesh_instance != RID()) { @@ -683,13 +683,13 @@ void VoxelChunkDefault::draw_debug_mdr_colliders() { debug_mesh_allocate(); } - for (int i = 0; i < get_collider_count(); ++i) { - Ref shape = get_collider_shape(i); + for (int i = 0; i < collider_get_count(); ++i) { + Ref shape = collider_get_shape(i); if (!shape.is_valid()) continue; - Transform t = get_collider_transform(i); + Transform t = collider_get_transform(i); shape->add_vertices_to_array(_debug_mesh_array, t); } diff --git a/world/jobs/voxel_prop_job.cpp b/world/jobs/voxel_prop_job.cpp index dc5ab11..5b8723c 100644 --- a/world/jobs/voxel_prop_job.cpp +++ b/world/jobs/voxel_prop_job.cpp @@ -51,11 +51,11 @@ void VoxelPropJob::phase_physics_process() { Ref chunk = _chunk; //TODO this should only update the differences - for (int i = 0; i < chunk->get_collider_count(); ++i) { - PhysicsServer::get_singleton()->free(chunk->get_collider_body(i)); + for (int i = 0; i < chunk->collider_get_count(); ++i) { + PhysicsServer::get_singleton()->free(chunk->collider_get_body(i)); } - chunk->clear_colliders(); + chunk->colliders_clear(); #ifdef MESH_DATA_RESOURCE_PRESENT for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { @@ -90,13 +90,13 @@ void VoxelPropJob::phase_physics_process() { PhysicsServer::get_singleton()->body_set_state(body, PhysicsServer::BODY_STATE_TRANSFORM, chunk->get_transform() * transform); - chunk->add_collider(transform, shape, shape->get_rid(), body); + chunk->collider_add(transform, shape, shape->get_rid(), body); } } #endif #if TOOLS_ENABLED - if (SceneTree::get_singleton()->is_debugging_collisions_hint() && chunk->get_collider_count() > 0) { + if (SceneTree::get_singleton()->is_debugging_collisions_hint() && chunk->collider_get_count() > 0) { chunk->draw_debug_mdr_colliders(); } #endif diff --git a/world/voxel_chunk.cpp b/world/voxel_chunk.cpp index 750181b..29a5393 100644 --- a/world/voxel_chunk.cpp +++ b/world/voxel_chunk.cpp @@ -851,7 +851,7 @@ void VoxelChunk::mesh_data_resource_clear() { #endif -int VoxelChunk::add_collider(const Transform &local_transform, const Ref &shape, const RID &shape_rid, const RID &body) { +int VoxelChunk::collider_add(const Transform &local_transform, const Ref &shape, const RID &shape_rid, const RID &body) { ERR_FAIL_COND_V(!shape.is_valid() && shape_rid == RID(), 0); int index = _colliders.size(); @@ -867,60 +867,60 @@ int VoxelChunk::add_collider(const Transform &local_transform, const Ref return index; } -Transform VoxelChunk::get_collider_transform(const int index) { +Transform VoxelChunk::collider_get_transform(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), Transform()); return _colliders[index].transform; } -void VoxelChunk::set_collider_transform(const int index, const Transform &transform) { +void VoxelChunk::collider_set_transform(const int index, const Transform &transform) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.write[index].transform = transform; } -Ref VoxelChunk::get_collider_shape(const int index) { +Ref VoxelChunk::collider_get_shape(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), Ref()); return _colliders[index].shape; } -void VoxelChunk::set_collider_shape(const int index, const Ref &shape) { +void VoxelChunk::collider_set_shape(const int index, const Ref &shape) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.write[index].shape = shape; } -RID VoxelChunk::get_collider_shape_rid(const int index) { +RID VoxelChunk::collider_get_shape_rid(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), RID()); return _colliders[index].shape_rid; } -void VoxelChunk::set_collider_shape_rid(const int index, const RID &rid) { +void VoxelChunk::collider_set_shape_rid(const int index, const RID &rid) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.write[index].shape_rid = rid; } -RID VoxelChunk::get_collider_body(const int index) { +RID VoxelChunk::collider_get_body(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), RID()); return _colliders[index].body; } -void VoxelChunk::set_collider_body(const int index, const RID &rid) { +void VoxelChunk::collider_set_body(const int index, const RID &rid) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.write[index].body = rid; } -int VoxelChunk::get_collider_count() const { +int VoxelChunk::collider_get_count() const { return _colliders.size(); } -void VoxelChunk::remove_collider(const int index) { +void VoxelChunk::collider_remove(const int index) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.remove(index); } -void VoxelChunk::clear_colliders() { +void VoxelChunk::colliders_clear() { _colliders.clear(); } @@ -1411,23 +1411,23 @@ void VoxelChunk::_bind_methods() { ClassDB::bind_method(D_METHOD("mesh_data_resource_clear"), &VoxelChunk::mesh_data_resource_clear); #endif - ClassDB::bind_method(D_METHOD("add_collider", "local_transform", "shape", "shape_rid", "body"), &VoxelChunk::add_collider, DEFVAL(RID()), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("collider_add", "local_transform", "shape", "shape_rid", "body"), &VoxelChunk::collider_add, DEFVAL(RID()), DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("get_collider_transform", "index"), &VoxelChunk::get_collider_transform); - ClassDB::bind_method(D_METHOD("set_collider_transform", "index", "transform"), &VoxelChunk::set_collider_transform); + ClassDB::bind_method(D_METHOD("collider_get_transform", "index"), &VoxelChunk::collider_get_transform); + ClassDB::bind_method(D_METHOD("collider_set_transform", "index", "transform"), &VoxelChunk::collider_set_transform); - ClassDB::bind_method(D_METHOD("get_collider_shape", "index"), &VoxelChunk::get_collider_shape); - ClassDB::bind_method(D_METHOD("set_collider_shape", "index", "shape"), &VoxelChunk::set_collider_shape); + ClassDB::bind_method(D_METHOD("collider_get_shape", "index"), &VoxelChunk::collider_get_shape); + ClassDB::bind_method(D_METHOD("collider_set_shape", "index", "shape"), &VoxelChunk::collider_set_shape); - ClassDB::bind_method(D_METHOD("get_collider_shape_rid", "index"), &VoxelChunk::get_collider_shape_rid); - ClassDB::bind_method(D_METHOD("set_collider_shape_rid", "index", "rid"), &VoxelChunk::set_collider_shape_rid); + ClassDB::bind_method(D_METHOD("collider_get_shape_rid", "index"), &VoxelChunk::collider_get_shape_rid); + ClassDB::bind_method(D_METHOD("collider_set_shape_rid", "index", "rid"), &VoxelChunk::collider_set_shape_rid); - ClassDB::bind_method(D_METHOD("get_collider_body", "index"), &VoxelChunk::get_collider_body); - ClassDB::bind_method(D_METHOD("set_collider_body", "index", "rid"), &VoxelChunk::set_collider_body); + ClassDB::bind_method(D_METHOD("collider_get_body", "index"), &VoxelChunk::collider_get_body); + ClassDB::bind_method(D_METHOD("collider_set_body", "index", "rid"), &VoxelChunk::collider_set_body); - ClassDB::bind_method(D_METHOD("get_collider_count"), &VoxelChunk::get_collider_count); - ClassDB::bind_method(D_METHOD("remove_collider", "index"), &VoxelChunk::remove_collider); - ClassDB::bind_method(D_METHOD("clear_colliders"), &VoxelChunk::clear_colliders); + ClassDB::bind_method(D_METHOD("collider_get_count"), &VoxelChunk::collider_get_count); + ClassDB::bind_method(D_METHOD("collider_remove", "index"), &VoxelChunk::collider_remove); + ClassDB::bind_method(D_METHOD("colliders_clear"), &VoxelChunk::colliders_clear); BIND_VMETHOD(MethodInfo("_build")); ClassDB::bind_method(D_METHOD("build"), &VoxelChunk::build); diff --git a/world/voxel_chunk.h b/world/voxel_chunk.h index 90c8ab6..bf4779c 100644 --- a/world/voxel_chunk.h +++ b/world/voxel_chunk.h @@ -247,23 +247,23 @@ public: #endif //Colliders - int add_collider(const Transform &local_transform, const Ref &shape, const RID &shape_rid = RID(), const RID &body = RID()); + int collider_add(const Transform &local_transform, const Ref &shape, const RID &shape_rid = RID(), const RID &body = RID()); - Transform get_collider_transform(const int index); - void set_collider_transform(const int index, const Transform &transform); + Transform collider_get_transform(const int index); + void collider_set_transform(const int index, const Transform &transform); - Ref get_collider_shape(const int index); - void set_collider_shape(const int index, const Ref &shape); + Ref collider_get_shape(const int index); + void collider_set_shape(const int index, const Ref &shape); - RID get_collider_shape_rid(const int index); - void set_collider_shape_rid(const int index, const RID &rid); + RID collider_get_shape_rid(const int index); + void collider_set_shape_rid(const int index, const RID &rid); - RID get_collider_body(const int index); - void set_collider_body(const int index, const RID &rid); + RID collider_get_body(const int index); + void collider_set_body(const int index, const RID &rid); - int get_collider_count() const; - void remove_collider(const int index); - void clear_colliders(); + int collider_get_count() const; + void collider_remove(const int index); + void colliders_clear(); //handlers void enter_tree();