-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Simplify flipping in contact manifold generators #341
base: master
Are you sure you want to change the base?
Conversation
Tests pass fine locally, so I'm guessing the CI is just broken, though the |
191751d
to
f6a107d
Compare
Hi! Thank you for this PR! The The internal contact generation method (often named if !flip {
contact = Contact::new(world1, world2, plane_normal, depth);
kinematic.set_approx1(f1, local1, approx_plane);
kinematic.set_approx2(f2, local2, approx_ball);
kinematic.set_dilation2(ball.radius());
let _ = manifold.push(contact, kinematic, Point::origin(), proc1, proc2);
} else {
contact = Contact::new(world2, world1, -plane_normal, depth);
kinematic.set_approx1(f2, local2, approx_ball);
kinematic.set_dilation1(ball.radius());
kinematic.set_approx2(f1, local1, approx_plane);
let _ = manifold.push(contact, kinematic, Point::origin(), proc2, proc1);
} The It would be possible to handle this in your Why do you want to get rid of the |
Good catch, thanks! The original approach would work fine for shapes that are defined in terms of other shapes, e.g. heightfields, because they never directly generate contacts, but for primitive shapes like triangles it would break down.
I've refactored the change to instead flip contacts and kinematics inside
Yep; there is rather a lot, and the duplication it involves is a bit error prone. My hope is this will significantly improve maintainability; e.g. any future changes to the interfaces used inside duplicate code will be much easier with this change. |
At the cost of one extra dynamic dispatch in
get_contact_algorithm
, this allows for a dramatic reduction in boilerplate inContactManifoldGenerator
implementations by encoding flipping into the preexisting dynamic dispatch throughContactAlgorithm
.The extra dynamic dispatch could be removed with a more invasive refactoring, but it's not clear that that's justified, so it's left for future work.
WIP because not all manifold generators have been updated to benefit, but I'd like feedback on the idea before proceeding with that tedious work.