mirror of
https://github.com/Relintai/godot_voxel.git
synced 2024-11-19 02:47:18 +01:00
Remove obsolete physics, will be re-implemented later
This commit is contained in:
parent
05dfddfa20
commit
e74d64335c
@ -14,15 +14,6 @@ MeshInstance * VoxelBlock::get_mesh_instance(const Node & root) {
|
||||
return n->cast_to<MeshInstance>();
|
||||
}
|
||||
|
||||
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<StaticBody>();
|
||||
}
|
||||
|
||||
// Helper
|
||||
VoxelBlock * VoxelBlock::create(Vector3i bpos, Ref<VoxelBuffer> buffer) {
|
||||
const int bs = VoxelBlock::SIZE;
|
||||
|
@ -18,12 +18,10 @@ public:
|
||||
Ref<VoxelBuffer> voxels; // SIZE*SIZE*SIZE voxels
|
||||
Vector3i pos;
|
||||
NodePath mesh_instance_path;
|
||||
NodePath body_path; // TODO
|
||||
|
||||
static VoxelBlock * create(Vector3i bpos, Ref<VoxelBuffer> buffer);
|
||||
|
||||
MeshInstance * get_mesh_instance(const Node & root);
|
||||
StaticBody * get_physics_body(const Node & root);
|
||||
|
||||
private:
|
||||
VoxelBlock();
|
||||
|
@ -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<Mesh>());
|
||||
}
|
||||
if(body) {
|
||||
body->set_shape(0, Ref<Shape>());
|
||||
}
|
||||
}
|
||||
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> 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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user