Browse Source

Merge pull request #53482 from timothyqiu/soft-body-ready

Re-prepare RenderingServer if SoftDynamicBody mesh changed
Camille Mohr-Daurat 3 years ago
parent
commit
69f80b6631
2 changed files with 4 additions and 3 deletions
  1. 3 2
      scene/3d/soft_dynamic_body_3d.cpp
  2. 1 1
      scene/3d/soft_dynamic_body_3d.h

+ 3 - 2
scene/3d/soft_dynamic_body_3d.cpp

@@ -411,8 +411,9 @@ void SoftDynamicBody3D::_draw_soft_mesh() {
 		return;
 		return;
 	}
 	}
 
 
-	if (!rendering_server_handler.is_ready()) {
-		rendering_server_handler.prepare(get_mesh()->get_rid(), 0);
+	const RID mesh_rid = get_mesh()->get_rid();
+	if (!rendering_server_handler.is_ready(mesh_rid)) {
+		rendering_server_handler.prepare(mesh_rid, 0);
 
 
 		/// Necessary in order to render the mesh correctly (Soft body nodes are in global space)
 		/// Necessary in order to render the mesh correctly (Soft body nodes are in global space)
 		simulation_started = true;
 		simulation_started = true;

+ 1 - 1
scene/3d/soft_dynamic_body_3d.h

@@ -50,7 +50,7 @@ class SoftDynamicBodyRenderingServerHandler : public RenderingServerHandler {
 
 
 private:
 private:
 	SoftDynamicBodyRenderingServerHandler();
 	SoftDynamicBodyRenderingServerHandler();
-	bool is_ready() { return mesh.is_valid(); }
+	bool is_ready(RID p_mesh_rid) const { return mesh.is_valid() && mesh == p_mesh_rid; }
 	void prepare(RID p_mesh_rid, int p_surface);
 	void prepare(RID p_mesh_rid, int p_surface);
 	void clear();
 	void clear();
 	void open();
 	void open();