-
I've been able to figure out how to do a ShapeCast -- I love how it is the same flow as doing raycasting, thank you! I looked through the ShapeCastResult class though, and I'm unsure what value(s) could be used to determine a 'safe' resting location after the shape is casted (assuming a restitution of zero). Are there some utility functions available to determine this from a result? Is mFraction what I'm looking for (assuming I take the closest hit from the shapecast?) Would also appreciate your thoughts also on when not taking the closest hit (for example, a situation where a sphere may collide with one triangle that is closest to it, but the corrected position requires it to then collide with another nearby triangle, which also influences the final resting position from the cast). `
` |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
One other thought -- when using JPH::RShapeCast collisionShape = JPH::RShapeCast::sFromWorldTransform(bi.GetShape(object->collisionObjectID), JPH::Vec3::sReplicate(1.0f), bi.GetWorldTransform(object->collisionObjectID), dir), does mFraction work differently to get my new world transform position, since the comments seem to indicate it returns the center of mass instead? |
Beta Was this translation helpful? Give feedback.
-
If you do |
Beta Was this translation helpful? Give feedback.
If you do
shapeCast.GetPointOnRay(hit.mFraction)
you'll get the position of the center of mass of the shape when it is touching the target object. If you want to get a 'safe position' you need to subtract a bit from that value (but how much exactly is hard to say as it depends on the size of the object you're casting and the length of the ray along which you cast - floating point errors are really hard to predict). Usually a couple of mm is enough.