Transformed Shape
Temporary data structure that contains a shape and a transform. This structure can be obtained from a body (e.g. after a broad phase query) under lock protection. The lock can then be released and collision detection operations can be safely performed since the class takes a reference on the shape and does not use anything from the body anymore.
C++ JPH::TransformedShape.
Constructors
Properties
Calculates the transform for this shape's center of mass (excluding scale)
Calculates the inverse of the transform for this shape's center of mass (excluding scale)
Center of mass world position of the shape
Rotation of the shape
Get/set the scale of the shape as a Vec3
Optional sub shape ID creator for the shape (can be used when expanding compound shapes into multiple transformed shapes)
Get the world space bounding box for this transformed shape
Calculates the world transform including scale of this shape (not from the center of mass but in the space the shape was created)
Functions
Cast a ray and find the closest hit. Returns true if it finds a hit. Hits further than ioHit.mFraction will not be considered and in this case ioHit will remain unmodified (and the function will return false). Convex objects will be treated as solid (meaning if the ray starts inside, you'll get a hit fraction of 0) and back face hits are returned. If you want the surface normal of the hit use GetWorldSpaceSurfaceNormal(ioHit.mSubShapeID2, inRay.GetPointOnRay(ioHit.mFraction)) on this object.
Cast a ray, allows collecting multiple hits. Note that this version is more flexible but also slightly slower than the CastRay function that returns only a single hit. If you want the surface normal of the hit use GetWorldSpaceSurfaceNormal(collected sub shape ID, inRay.GetPointOnRay(collected fraction)) on this object.
Cast a shape and report any hits to ioCollector
Collect the leaf transformed shapes of all leaf shapes of this shape inBox is the world space axis aligned box which leaf shapes should collide with
Check if inPoint is inside any shapes. For this tests all shapes are treated as if they were solid. For a mesh shape, this test will only provide sensible information if the mesh is a closed manifold. For each shape that collides, ioCollector will receive a hit
Collide a shape and report any hits to ioCollector
Get material of a particular sub shape
Get the direct child sub shape and its transform for a sub shape ID.
Get the user data of a particular sub shape
Get the vertices of the face that faces inDirection the most (includes any convex radius). Note that this function can only return faces of convex shapes or triangles, which is why a sub shape ID to get to that leaf must be provided.
Call this repeatedly to get all triangles in the box. outTriangleVertices should be large enough to hold 3 * inMaxTriangleRequested entries outMaterials (if it is not null) should contain inMaxTrianglesRequested entries The function returns the amount of triangles that it found (which will be < = inMaxTrianglesRequested), or 0 if there are no more triangles. Note that the function can return a value < inMaxTrianglesRequested and still have more triangles to process (triangles can be returned in blocks) Note that the function may return triangles outside of the requested box, only coarse culling is performed on the returned triangles
To start iterating over triangles, call this function first. To get the actual triangles call GetTrianglesNext.
Get surface normal of a particular sub shape and its world space surface position on this body. Note: When you have a CollideShapeResult or ShapeCastResult you should use -mPenetrationAxis.Normalized() as contact normal as GetWorldSpaceSurfaceNormal will only return face normals (and not vertex or edge normals).
Make inSubShapeID relative to mShape. When mSubShapeIDCreator is not empty, this is needed in order to get the correct path to the sub shape.
Sets the world transform (including scale) of this transformed shape (not from the center of mass but in the space the shape was created)