TransformedShape

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

Link copied to clipboard
constructor()
constructor(positionCOM: Vec3, rotation: Quat, shape: Shape?, bodyID: BodyID, subShapeIDCreator: SubShapeIDCreator)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Optional body ID from which this shape comes

Link copied to clipboard

Calculates the transform for this shape's center of mass (excluding scale)

Link copied to clipboard

Calculates the inverse of the transform for this shape's center of mass (excluding scale)

Link copied to clipboard
var shape: Shape?

The shape itself

Link copied to clipboard

Center of mass world position of the shape

Link copied to clipboard

Rotation of the shape

Link copied to clipboard

Get/set the scale of the shape as a Vec3

Link copied to clipboard

Optional sub shape ID creator for the shape (can be used when expanding compound shapes into multiple transformed shapes)

Link copied to clipboard

Get the world space bounding box for this transformed shape

Link copied to clipboard

Calculates the world transform including scale of this shape (not from the center of mass but in the space the shape was created)

Functions

Link copied to clipboard

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.

fun castRay(ray: RRayCast, rayCastSettings: RayCastSettings, collector: CastRayCollector, shapeFilter: ShapeFilter)

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.

Link copied to clipboard
fun castShape(shapeCast: RShapeCast, shapeCastSettings: ShapeCastSettings, baseOffset: Vec3, collector: CastShapeCollector, shapeFilter: ShapeFilter)

Cast a shape and report any hits to ioCollector

Link copied to clipboard
open override fun close()
Link copied to clipboard

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

Link copied to clipboard
fun collidePoint(point: Vec3, collector: CollidePointCollector, shapeFilter: ShapeFilter)

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

Link copied to clipboard
fun collideShape(shape: Shape?, shapeScale: Vec3, centerOfMassTransform: Mat44, collideShapeSettings: CollideShapeSettings, baseOffset: Vec3, collector: CollideShapeCollector, shapeFilter: ShapeFilter)

Collide a shape and report any hits to ioCollector

Link copied to clipboard

Get material of a particular sub shape

Link copied to clipboard

Get the direct child sub shape and its transform for a sub shape ID.

Link copied to clipboard

Get the user data of a particular sub shape

Link copied to clipboard
fun getSupportingFace(subShapeID: SubShapeID, direction: Vec3, baseOffset: Vec3): List<Vec3>

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.

Link copied to clipboard
fun getTrianglesNext(context: Shape.GetTrianglesContext, maxTrianglesRequested: Int, triangleVertices: MutableList<Float3>, materials: MutableList<PhysicsMaterial?>): Int

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

Link copied to clipboard
fun getTrianglesStart(context: Shape.GetTrianglesContext, box: AABox, baseOffset: Vec3)

To start iterating over triangles, call this function first. To get the actual triangles call GetTrianglesNext.

Link copied to clipboard
fun getWorldSpaceSurfaceNormal(subShapeID: SubShapeID, position: Vec3): Vec3

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).

Link copied to clipboard

Make inSubShapeID relative to mShape. When mSubShapeIDCreator is not empty, this is needed in order to get the correct path to the sub shape.

Link copied to clipboard
fun setWorldTransform(transform: Mat44)
fun setWorldTransform(position: Vec3, rotation: Quat, scale: Vec3)

Sets the world transform (including scale) of this transformed shape (not from the center of mass but in the space the shape was created)