summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCamille Mohr-Daurat <pouleyKetchoup@gmail.com>2021-10-06 14:57:53 -0700
committerGitHub <noreply@github.com>2021-10-06 14:57:53 -0700
commit69f80b6631489472b06145a83f2b78b932e8467c (patch)
tree81bf92c5e859d3db3a3b5bcc748cb5dd0069172b
parent26f4848d013c5a234c2399717372ef72985cb655 (diff)
parentd000ce91306bd53d8ff9fa48b6050c27297c6c77 (diff)
Merge pull request #53482 from timothyqiu/soft-body-ready
Re-prepare RenderingServer if SoftDynamicBody mesh changed
-rw-r--r--scene/3d/soft_dynamic_body_3d.cpp5
-rw-r--r--scene/3d/soft_dynamic_body_3d.h2
2 files changed, 4 insertions, 3 deletions
diff --git a/scene/3d/soft_dynamic_body_3d.cpp b/scene/3d/soft_dynamic_body_3d.cpp
index 21f9b0a35d..9fceb21790 100644
--- a/scene/3d/soft_dynamic_body_3d.cpp
+++ b/scene/3d/soft_dynamic_body_3d.cpp
@@ -411,8 +411,9 @@ void SoftDynamicBody3D::_draw_soft_mesh() {
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)
simulation_started = true;
diff --git a/scene/3d/soft_dynamic_body_3d.h b/scene/3d/soft_dynamic_body_3d.h
index 0b4b3021cd..5e7fbfe29e 100644
--- a/scene/3d/soft_dynamic_body_3d.h
+++ b/scene/3d/soft_dynamic_body_3d.h
@@ -50,7 +50,7 @@ class SoftDynamicBodyRenderingServerHandler : public RenderingServerHandler {
private:
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 clear();
void open();