-
-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix shape modification not updating graphics in testbed #708
base: master
Are you sure you want to change the base?
Conversation
if let Some(sns) = self.b2sn.remove(&body) { | ||
let mut new_sns = vec![]; | ||
for sn in sns.into_iter() { | ||
if let Some(sn_c) = sn.collider { | ||
if sn_c == collider { | ||
commands.entity(sn.entity).despawn(); | ||
} else { | ||
new_sns.push(sn); | ||
} | ||
} | ||
} | ||
self.b2sn.insert(body, new_sns); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let Some(sns) = self.b2sn.remove(&body) { | |
let mut new_sns = vec![]; | |
for sn in sns.into_iter() { | |
if let Some(sn_c) = sn.collider { | |
if sn_c == collider { | |
commands.entity(sn.entity).despawn(); | |
} else { | |
new_sns.push(sn); | |
} | |
} | |
} | |
self.b2sn.insert(body, new_sns); | |
if let Some(mut sns) = self.b2sn.remove(&body) { | |
sns = sns | |
.into_iter() | |
.filter(|sn| { | |
let Some(sn_c) = sn.collider else { | |
return false; | |
}; | |
if sn_c == collider { | |
commands.entity(sn.entity).despawn(); | |
return false; | |
} else { | |
return true; | |
} | |
}) | |
.collect(); | |
self.b2sn.insert(body, sns); | |
} |
Small nitpick, I did that just to help me understand the change, not sure if which is better, don´t worry about it I'll merge one or the other after discussion with seb.
For the record, I think the best solution is to monitor changes over the shapes, and then modify the mesh handle: In practice, running these snippets of code:
rapier/src_testbed/objects/node.rs Lines 82 to 85 in eba44e7
But as we're in testbed, I think this solution is good enough :) |
I had thought that it might be good to factor these sorts of updates into the testbed loop, but wasn't sure how to track incremental computation of the state. Especially since I noticed you have a vector of flags already tracking collider updates in rapier/src/geometry/collider.rs Lines 445 to 449 in eba44e7
It seems like monitoring those changes from the testbed requires a new function like |
This PR is for a fix for the
GraphicsManager::remove_collider_nodes
function in the testbed. The problem was that the entity was despawned but not removed fromGraphicsManager::b2sn
, creating an invalid state. See this thread for the discussion.TestbedApp::add_callback
still requires a manual refresh withgfx.add_collider
if the user wants to see the 3D entity update correctly.debug_shape_modification3
before:debug_shape_modification3
after: