diff --git a/voxel_map.cpp b/voxel_map.cpp index 99ec507..872ab2e 100644 --- a/voxel_map.cpp +++ b/voxel_map.cpp @@ -14,15 +14,6 @@ MeshInstance * VoxelBlock::get_mesh_instance(const Node & root) { return n->cast_to(); } -StaticBody * VoxelBlock::get_physics_body(const Node & root) { - if (mesh_instance_path.is_empty()) - return NULL; - Node * n = root.get_node(body_path); - if (n == NULL) - return NULL; - return n->cast_to(); -} - // Helper VoxelBlock * VoxelBlock::create(Vector3i bpos, Ref buffer) { const int bs = VoxelBlock::SIZE; diff --git a/voxel_map.h b/voxel_map.h index 664def3..5433b93 100644 --- a/voxel_map.h +++ b/voxel_map.h @@ -18,12 +18,10 @@ public: Ref voxels; // SIZE*SIZE*SIZE voxels Vector3i pos; NodePath mesh_instance_path; - NodePath body_path; // TODO static VoxelBlock * create(Vector3i bpos, Ref buffer); MeshInstance * get_mesh_instance(const Node & root); - StaticBody * get_physics_body(const Node & root); private: VoxelBlock(); diff --git a/voxel_terrain.cpp b/voxel_terrain.cpp index 231c251..6ee6867 100644 --- a/voxel_terrain.cpp +++ b/voxel_terrain.cpp @@ -361,15 +361,11 @@ void VoxelTerrain::update_block_mesh(Vector3i block_pos) { _mesher_smooth->build(nbuffer, Voxel::CHANNEL_ISOLEVEL, mesh); MeshInstance * mesh_instance = block->get_mesh_instance(*this); - StaticBody * body = block->get_physics_body(*this); if(is_mesh_empty(mesh)) { if(mesh_instance) { mesh_instance->set_mesh(Ref()); } - if(body) { - body->set_shape(0, Ref()); - } } else { // The mesh exist and it has vertices @@ -392,26 +388,8 @@ void VoxelTerrain::update_block_mesh(Vector3i block_pos) { if(get_tree()->is_editor_hint() == false && _generate_collisions) { - // Generate collisions + // TODO Generate collisions using PhysicsServer // TODO Need to select only specific surfaces because some may not have collisions - VOXEL_PROFILE_BEGIN("create_trimesh_shape") - Ref shape = mesh->create_trimesh_shape(); - VOXEL_PROFILE_END("create_trimesh_shape") - - if(body == NULL) { - // Create body - body = memnew(StaticBody); - body->set_translation(block_node_pos); - body->add_shape(shape); - add_child(body); - block->body_path = body->get_path(); - } - else { - // Update body - VOXEL_PROFILE_BEGIN("body_set_shape") - body->set_shape(0, shape); - VOXEL_PROFILE_END("body_set_shape") - } } } }