add getter for contact_id field of SolverContact#824
add getter for contact_id field of SolverContact#824bcolloran wants to merge 1 commit intodimforge:masterfrom
contact_id field of SolverContact#824Conversation
|
This PR is controversial, because of the way rapier works: Several steps can occur in a given simulation, when that happens, the I'm curious how other physics engines (box2d..?) handle this fine-grained collision detection. |
|
Thanks for getting back to me @Vrixyz ! Dang, I didn't realize this would be controversial at all. I have been using my own Rapier fork with this workaround in my project, but it sounds like it may be unreliable? It has seemed to be working fine so far, but I'm not sure of all the edge cases you may be thinking of. Can you think of any other workaround for getting local coords of a collision point relative to the bodies involved that already works in Rapier without needing this? I tried to dig around, but there is a lot of API surface, so I might have missed the way I'm suppose to do this :-) Perhaps another option would be to just add a better doc comment to this proposed getter? I simply copied the comment from the existing field in the struct, but it could be expanded to add warning and caveats about whatever issues you think might be most concerning. For example, I think it should be clear to most users of a physics engine that a Perhaps adding a warning like that would allow people like myself who need this low-level access to the existing local collision coords to get it, but at least warn people less experience about a potential pitfall? Or alternatively, in addition to that warning in the docs, this could even be made an I'm just trying to think of some way to:
Thank you again for looking at this, please let me know if you have any ideas! :-) |
|
Hi @Vrixyz any thought on this? Please let me know if you think the warning in the method comments would be enough, or if you have other recommendations on how to proceed. Thanks! :-) |
Adds a simple getter for the
contact_idfield ofSolverContact. (Alternatively, could set that field topubinstead ofpub(crate).)My use case is that I need to access the local coords of a contact relative to each collider involved in the contact. To get that data, I need the
contact_idto look up the entry incontact_pair.manifolds[i].pointsthat corresponds to a specificSolverContact, because theSolverContactonly has the world space position of the contact point. Example:Near as I can tell, there is not any existing shortcut API for accessing the local coords that I need. But that's ok as long as we can get this id; however there is no way of accessing the id either.
Since this is just a simple getter, and doesn't e.g. allow mutation of this id, I think this should be a trivial, non-risky way of satisfying my use case. (But then again I'm not sure why this field wasn't
pubin the first place, so there may be some detail I'm not aware of.)Please LMK if any changes are needed! Thanks!