瀏覽代碼

Re-prepare VisualServer if SoftBody mesh changed

Haoyu Qiu 3 年之前
父節點
當前提交
ff27b994cd
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 3 2
      scene/3d/soft_body.cpp
  2. 1 1
      scene/3d/soft_body.h

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

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

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

@@ -49,7 +49,7 @@ class SoftBodyVisualServerHandler {
 
 private:
 	SoftBodyVisualServerHandler();
-	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 clear();
 	void open();