Add collisionShapeId to RayIntersectionT for raycast hit entity ident…#879
Add collisionShapeId to RayIntersectionT for raycast hit entity ident…#879khalidbourr wants to merge 5 commits intogazebosim:mainfrom
Conversation
…ification Signed-off-by: khalid <khalid.bourr@unicam.it>
|
|
||
| /// \brief The identity of the collision shape that was hit. | ||
| /// Set to 0 if no shape was hit or not supported by the physics engine. | ||
| std::size_t collisionShapeId{0}; |
There was a problem hiding this comment.
This would break ABI and would not be backward portable. Alternatively, we can add an optional data to RayIntersection similar to how force, normal, and depth are added to contact data in
gz-physics/include/gz/physics/GetContacts.hh
Lines 71 to 73 in a1e7ae5
and
gz-physics/dartsim/src/SimulationFeatures.cc
Lines 278 to 283 in a1e7ae5
There was a problem hiding this comment.
I got it, I will do that asap
There was a problem hiding this comment.
I’ve refactored the code to follow the same CompositeData / ExpectData pattern used in GetContacts.
collisionShapeId is now passed as optional extra data through ExtraRayIntersectionDataT, so RayIntersectionT stays unchanged.
There was a problem hiding this comment.
@azeey Just a gentle ping, in case further modifications are needed, I'm available. Happy to iterate whenever you get the chance to review.
…ation Signed-off-by: khalid <khalid.bourr@unicam.it>
922f807 to
b582816
Compare
azeey
left a comment
There was a problem hiding this comment.
Just one minor comment, otherwise, LGTM! Thanks for the contribution!!
| RayIntersection intersection{ | ||
| result.intersection.point, | ||
| result.intersection.fraction, | ||
| result.intersection.normal}; |
Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
azeey
left a comment
There was a problem hiding this comment.
Actually, on second look, I realized this doesn't have any tests. Would you mind adding one in test/common_test?
Sure ! |
Signed-off-by: khalid <khalid.bourr@unicam.it>
|
I extended the already existed tests: SupportedRayIntersections and UnsupportedRayIntersections. In SupportedRayIntersections: if Ray hits sphere then collisionShapeId != 0 (valid hit) In UnsupportedRayIntersections: Ray would hit sphere but detector can't raycast then collisionShapeId == 0 (must be treated as miss) |
🎉 New feature
Closes #3314
Summary
DART's
RayHitalready containsmCollisionObjectbut it was being dropped inGetRayIntersectionFromLastStep(). This PR adds acollisionShapeIdfield toRayIntersectionTand populates it using the sameCollisionObject → getShapeFrame() → asShapeNode() → shapes.IdentityOf()mapping thatconvertContact()already uses.Changes
include/gz/physics/GetRayIntersection.hhinclude/gz/physics/detail/GetRayIntersection.hhdartsim/src/SimulationFeatures.ccChecklist
codecheckpassed (See contributing)Note
Companion PR for gz-sim: gazebosim/gz-sim#3336