Fix transition meshes not removed from the world

This commit is contained in:
Marc Gilleron 2022-05-16 22:07:57 +01:00
parent 8f243f6121
commit aad2f0df2d
3 changed files with 17 additions and 0 deletions

View File

@ -102,6 +102,19 @@ void VoxelMeshBlockVLT::set_transition_mesh(Ref<Mesh> mesh, int side, DirectMesh
}
}
void VoxelMeshBlockVLT::set_world(Ref<World3D> p_world) {
if (_world != p_world) {
_world = p_world;
// To update world. I replaced visibility by presence in world because Godot 3 culling performance is horrible
_set_visible(_visible && _parent_visible);
if (_static_body.is_valid()) {
_static_body.set_world(*p_world);
}
}
}
void VoxelMeshBlockVLT::set_visible(bool visible) {
if (_visible == visible) {
return;

View File

@ -36,6 +36,7 @@ public:
VoxelMeshBlockVLT(const Vector3i bpos, unsigned int size, unsigned int p_lod_index);
~VoxelMeshBlockVLT();
void set_world(Ref<World3D> p_world);
void set_visible(bool visible);
bool update_fading(float speed);

View File

@ -8,6 +8,9 @@
#include "../util/godot/direct_static_body.h"
#include "../util/ref_count.h"
#include "../util/span.h"
#include <scene/resources/world_3d.h>
#include <atomic>
class Node3D;