Fix dangling material RID error

This commit is contained in:
Marc Gilleron 2021-12-14 00:23:26 +00:00
parent 3596c13475
commit efc12ffefb
2 changed files with 9 additions and 1 deletions

View File

@ -233,6 +233,13 @@ DebugMultiMeshRenderer::DebugMultiMeshRenderer() {
_multimesh_instance.set_material_override(_material);
}
DebugMultiMeshRenderer::~DebugMultiMeshRenderer() {
// A MultiMeshInstance created without nodes does not hold ownership on its material.
// So we need to destroy it before we release ownership at the end of this destructor.
// Otherwise RenderingServer produces errors.
_multimesh_instance.destroy();
}
void DebugMultiMeshRenderer::set_world(World3D *world) {
_multimesh_instance.set_world(world);
_world = world;

View File

@ -11,7 +11,7 @@ class World3D;
namespace VoxelDebug {
enum ColorID {
enum ColorID { //
ID_VOXEL_BOUNDS = 0,
ID_OCTREE_BOUNDS,
ID_VOXEL_GRAPH_DEBUG_BOUNDS,
@ -25,6 +25,7 @@ void free_resources();
class DebugMultiMeshRenderer {
public:
DebugMultiMeshRenderer();
~DebugMultiMeshRenderer();
void set_world(World3D *world);
void begin();