Jolt Physics
A multi core friendly Game Physics Engine
|
#include <TransformedShape.h>
Public Types | |
using | GetTrianglesContext = Shape::GetTrianglesContext |
Use the context from Shape. More... | |
Public Member Functions | |
JPH_OVERRIDE_NEW_DELETE | TransformedShape ()=default |
Constructor. More... | |
TransformedShape (RVec3Arg inPositionCOM, QuatArg inRotation, const Shape *inShape, const BodyID &inBodyID, const SubShapeIDCreator &inSubShapeIDCreator=SubShapeIDCreator()) | |
bool | CastRay (const RRayCast &inRay, RayCastResult &ioHit) const |
void | CastRay (const RRayCast &inRay, const RayCastSettings &inRayCastSettings, CastRayCollector &ioCollector, const ShapeFilter &inShapeFilter={ }) const |
void | CollidePoint (RVec3Arg inPoint, CollidePointCollector &ioCollector, const ShapeFilter &inShapeFilter={ }) const |
void | CollideShape (const Shape *inShape, Vec3Arg inShapeScale, RMat44Arg inCenterOfMassTransform, const CollideShapeSettings &inCollideShapeSettings, RVec3Arg inBaseOffset, CollideShapeCollector &ioCollector, const ShapeFilter &inShapeFilter={ }) const |
void | CastShape (const RShapeCast &inShapeCast, const ShapeCastSettings &inShapeCastSettings, RVec3Arg inBaseOffset, CastShapeCollector &ioCollector, const ShapeFilter &inShapeFilter={ }) const |
void | CollectTransformedShapes (const AABox &inBox, TransformedShapeCollector &ioCollector, const ShapeFilter &inShapeFilter={ }) const |
void | GetTrianglesStart (GetTrianglesContext &ioContext, const AABox &inBox, RVec3Arg inBaseOffset) const |
int | GetTrianglesNext (GetTrianglesContext &ioContext, int inMaxTrianglesRequested, Float3 *outTriangleVertices, const PhysicsMaterial **outMaterials=nullptr) const |
Vec3 | GetShapeScale () const |
Get/set the scale of the shape as a Vec3. More... | |
void | SetShapeScale (Vec3Arg inScale) |
RMat44 | GetCenterOfMassTransform () const |
Calculates the transform for this shapes's center of mass (excluding scale) More... | |
RMat44 | GetInverseCenterOfMassTransform () const |
Calculates the inverse of the transform for this shape's center of mass (excluding scale) More... | |
void | SetWorldTransform (RVec3Arg inPosition, QuatArg inRotation, Vec3Arg inScale) |
Sets the world transform (including scale) of this transformed shape (not from the center of mass but in the space the shape was created) More... | |
void | SetWorldTransform (RMat44Arg inTransform) |
Sets the world transform (including scale) of this transformed shape (not from the center of mass but in the space the shape was created) More... | |
RMat44 | GetWorldTransform () const |
Calculates the world transform including scale of this shape (not from the center of mass but in the space the shape was created) More... | |
AABox | GetWorldSpaceBounds () const |
Get the world space bounding box for this transformed shape. More... | |
SubShapeID | MakeSubShapeIDRelativeToShape (const SubShapeID &inSubShapeID) const |
Make inSubShapeID relative to mShape. When mSubShapeIDCreator is not empty, this is needed in order to get the correct path to the sub shape. More... | |
Vec3 | GetWorldSpaceSurfaceNormal (const SubShapeID &inSubShapeID, RVec3Arg inPosition) const |
void | GetSupportingFace (const SubShapeID &inSubShapeID, Vec3Arg inDirection, RVec3Arg inBaseOffset, Shape::SupportingFace &outVertices) const |
const PhysicsMaterial * | GetMaterial (const SubShapeID &inSubShapeID) const |
Get material of a particular sub shape. More... | |
uint64 | GetSubShapeUserData (const SubShapeID &inSubShapeID) const |
Get the user data of a particular sub shape. More... | |
TransformedShape | GetSubShapeTransformedShape (const SubShapeID &inSubShapeID, SubShapeID &outRemainder) const |
Static Public Member Functions | |
static BodyID | sGetBodyID (const TransformedShape *inTS) |
Helper function to return the body id from a transformed shape. If the transformed shape is null an invalid body ID will be returned. More... | |
Public Attributes | |
RVec3 | mShapePositionCOM |
Center of mass world position of the shape. More... | |
Quat | mShapeRotation |
Rotation of the shape. More... | |
RefConst< Shape > | mShape |
The shape itself. More... | |
Float3 | mShapeScale { 1, 1, 1 } |
Not stored as Vec3 to get a nicely packed structure. More... | |
BodyID | mBodyID |
Optional body ID from which this shape comes. More... | |
SubShapeIDCreator | mSubShapeIDCreator |
Optional sub shape ID creator for the shape (can be used when expanding compound shapes into multiple transformed shapes) More... | |
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.
Use the context from Shape.
|
default |
Constructor.
|
inline |
void TransformedShape::CastRay | ( | const RRayCast & | inRay, |
const RayCastSettings & | inRayCastSettings, | ||
CastRayCollector & | ioCollector, | ||
const ShapeFilter & | inShapeFilter = { } |
||
) | const |
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.
JPH_NAMESPACE_BEGIN bool TransformedShape::CastRay | ( | const RRayCast & | inRay, |
RayCastResult & | ioHit | ||
) | const |
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.
void TransformedShape::CastShape | ( | const RShapeCast & | inShapeCast, |
const ShapeCastSettings & | inShapeCastSettings, | ||
RVec3Arg | inBaseOffset, | ||
CastShapeCollector & | ioCollector, | ||
const ShapeFilter & | inShapeFilter = { } |
||
) | const |
Cast a shape and report any hits to ioCollector
inShapeCast | The shape cast and its position and direction |
inShapeCastSettings | Settings for the shape cast |
inBaseOffset | All hit results will be returned relative to this offset, can be zero to get results in world position, but when you're testing far from the origin you get better precision by picking a position that's closer e.g. mShapePositionCOM or inShapeCast.mCenterOfMassStart.GetTranslation() since floats are most accurate near the origin |
ioCollector | Collector that receives the hits |
inShapeFilter | Filter that allows you to reject collisions |
void TransformedShape::CollectTransformedShapes | ( | const AABox & | inBox, |
TransformedShapeCollector & | ioCollector, | ||
const ShapeFilter & | inShapeFilter = { } |
||
) | const |
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
void TransformedShape::CollidePoint | ( | RVec3Arg | inPoint, |
CollidePointCollector & | ioCollector, | ||
const ShapeFilter & | inShapeFilter = { } |
||
) | const |
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
void TransformedShape::CollideShape | ( | const Shape * | inShape, |
Vec3Arg | inShapeScale, | ||
RMat44Arg | inCenterOfMassTransform, | ||
const CollideShapeSettings & | inCollideShapeSettings, | ||
RVec3Arg | inBaseOffset, | ||
CollideShapeCollector & | ioCollector, | ||
const ShapeFilter & | inShapeFilter = { } |
||
) | const |
Collide a shape and report any hits to ioCollector
inShape | Shape to test |
inShapeScale | Scale in local space of shape |
inCenterOfMassTransform | Center of mass transform for the shape |
inCollideShapeSettings | Settings |
inBaseOffset | All hit results will be returned relative to this offset, can be zero to get results in world position, but when you're testing far from the origin you get better precision by picking a position that's closer e.g. mShapePositionCOM since floats are most accurate near the origin |
ioCollector | Collector that receives the hits |
inShapeFilter | Filter that allows you to reject collisions |
|
inline |
Calculates the transform for this shapes's center of mass (excluding scale)
|
inline |
Calculates the inverse of the transform for this shape's center of mass (excluding scale)
|
inline |
Get material of a particular sub shape.
|
inline |
Get the direct child sub shape and its transform for a sub shape ID.
inSubShapeID | Sub shape ID that indicates the path to the leaf shape |
outRemainder | The remainder of the sub shape ID after removing the sub shape |
|
inline |
Get the user data of a particular sub shape.
|
inline |
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.
inSubShapeID | Sub shape ID of target shape |
inDirection | Direction that the face should be facing (in world space) |
inBaseOffset | The vertices will be returned relative to this offset, can be zero to get results in world position, but when you're testing far from the origin you get better precision by picking a position that's closer e.g. mShapePositionCOM since floats are most accurate near the origin |
outVertices | Resulting face. Note the returned face can have a single point if the shape doesn't have polygons to return (e.g. because it's a sphere). The face will be returned in world space. |
int TransformedShape::GetTrianglesNext | ( | GetTrianglesContext & | ioContext, |
int | inMaxTrianglesRequested, | ||
Float3 * | outTriangleVertices, | ||
const PhysicsMaterial ** | outMaterials = nullptr |
||
) | const |
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
void TransformedShape::GetTrianglesStart | ( | GetTrianglesContext & | ioContext, |
const AABox & | inBox, | ||
RVec3Arg | inBaseOffset | ||
) | const |
To start iterating over triangles, call this function first. To get the actual triangles call GetTrianglesNext.
ioContext | A temporary buffer and should remain untouched until the last call to GetTrianglesNext. |
inBox | The world space bounding in which you want to get the triangles. |
inBaseOffset | All hit results will be returned relative to this offset, can be zero to get results in world position, but when you're testing far from the origin you get better precision by picking a position that's closer e.g. inBox.GetCenter() since floats are most accurate near the origin |
|
inline |
Get the world space bounding box for this transformed shape.
|
inline |
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).
|
inline |
Calculates the world transform including scale of this shape (not from the center of mass but in the space the shape was created)
|
inline |
Make inSubShapeID relative to mShape. When mSubShapeIDCreator is not empty, this is needed in order to get the correct path to the sub shape.
|
inline |
|
inline |
Sets the world transform (including scale) of this transformed shape (not from the center of mass but in the space the shape was created)
|
inline |
Sets the world transform (including scale) of this transformed shape (not from the center of mass but in the space the shape was created)
|
inlinestatic |
Helper function to return the body id from a transformed shape. If the transformed shape is null an invalid body ID will be returned.
BodyID TransformedShape::mBodyID |
Optional body ID from which this shape comes.
RVec3 TransformedShape::mShapePositionCOM |
Center of mass world position of the shape.
Quat TransformedShape::mShapeRotation |
Rotation of the shape.
Float3 TransformedShape::mShapeScale { 1, 1, 1 } |
Not stored as Vec3 to get a nicely packed structure.
SubShapeIDCreator TransformedShape::mSubShapeIDCreator |
Optional sub shape ID creator for the shape (can be used when expanding compound shapes into multiple transformed shapes)