Skip to content

Commit

Permalink
Merge pull request #53481 from timothyqiu/soft-body-ready-3.x
Browse files Browse the repository at this point in the history
[3.x] Re-prepare VisualServer if SoftBody mesh changed
  • Loading branch information
pouleyKetchoupp authored Oct 6, 2021
2 parents 3e2bb41 + ff27b99 commit e1de198
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions scene/3d/soft_body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion scene/3d/soft_body.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e1de198

Please sign in to comment.