65 virtual bool MustBeStatic()
const override;
71 virtual uint GetSubShapeIDBitsRecursive()
const override;
74 virtual AABox GetWorldSpaceBounds(
Mat44Arg inCenterOfMassTransform,
Vec3Arg inScale)
const override;
90 virtual uint64 GetSubShapeUserData(
const SubShapeID &inSubShapeID)
const override;
96 virtual Vec3 GetSurfaceNormal(
const SubShapeID &inSubShapeID,
Vec3Arg inLocalSurfacePosition)
const override;
99 virtual void GetSupportingFace(
const SubShapeID &inSubShapeID,
Vec3Arg inDirection,
Vec3Arg inScale,
Mat44Arg inCenterOfMassTransform, SupportingFace &outVertices)
const override;
104#ifdef JPH_DEBUG_RENDERER
160 outResult = child_result;
246 static_assert(
sizeof(
SubShape) == (
sizeof(
void *) == 8? 40 : 36),
"Compiler added unexpected padding");
295 virtual void SaveBinaryState(
StreamOut &inStream)
const override;
296 virtual void SaveSubShapeState(
ShapeList &outSubShapes)
const override;
297 virtual void RestoreSubShapeState(
const ShapeRefC *inSubShapes,
uint inNumShapes)
override;
300 virtual Stats GetStatsRecursive(VisitedShapes &ioVisitedShapes)
const override;
303 virtual float GetVolume()
const override;
306 virtual bool IsValidScale(
Vec3Arg inScale)
const override;
309 virtual Vec3 MakeScaleValid(
Vec3Arg inScale)
const override;
312 static void sRegister();
316 virtual void RestoreBinaryState(
StreamIn &inStream)
override;
319 struct CastRayVisitor;
320 struct CastRayVisitorCollector;
321 struct CollidePointVisitor;
322 struct CastShapeVisitor;
323 struct CollectTransformedShapesVisitor;
324 struct CollideCompoundVsShapeVisitor;
325 struct CollideShapeVsCompoundVisitor;
326 template <
class BoxType>
struct GetIntersectingSubShapesVisitor;
Color ColorArg
Type to use for passing arguments to a function.
Definition Color.h:12
#define JPH_EXPORT
Definition Core.h:275
std::uint64_t uint64
Definition Core.h:504
unsigned int uint
Definition Core.h:500
#define JPH_NAMESPACE_END
Definition Core.h:425
std::uint32_t uint32
Definition Core.h:503
#define JPH_IF_DEBUG_RENDERER(...)
Definition Core.h:589
#define JPH_NAMESPACE_BEGIN
Definition Core.h:419
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
uint CountLeadingZeros(uint32 inValue)
Compute the number of leading zero bits (how many high bits are zero).
Definition Math.h:134
const Quat QuatArg
Definition MathTypes.h:28
const Vec3 Vec3Arg
Definition MathTypes.h:19
const Mat44 & Mat44Arg
Definition MathTypes.h:29
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:50
Vec3Arg RVec3Arg
Definition Real.h:30
Mat44Arg RMat44Arg
Definition Real.h:32
#define JPH_DECLARE_SERIALIZABLE_ABSTRACT(linkage, class_name)
Definition SerializableObject.h:120
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:80
CollisionCollector< ShapeCastResult, CollisionCollectorTraitsCastShape > CastShapeCollector
Definition Shape.h:45
RefConst< Shape > ShapeRefC
Definition Shape.h:50
EShapeSubType
This enumerates all shape types, each shape can return its type through Shape::GetSubType.
Definition Shape.h:77
Array< ShapeRefC > ShapeList
Definition Shape.h:51
CollisionCollector< TransformedShape, CollisionCollectorTraitsCollideShape > TransformedShapeCollector
Definition Shape.h:48
EShapeType
Shapes are categorized in groups, each shape can return which group it belongs to through its Shape::...
Definition Shape.h:57
@ Compound
Used by CompoundShape.
Definition Shape.h:59
Axis aligned box.
Definition AABox.h:16
Settings to be passed with a collision query.
Definition CollideShape.h:94
Definition CollideSoftBodyVertexIterator.h:15
virtual void GetTrianglesStart(GetTrianglesContext &ioContext, const AABox &inBox, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale) const override
Definition CompoundShape.h:122
AABox mLocalBounds
Definition CompoundShape.h:345
float mInnerRadius
Smallest radius of GetInnerRadius() of child shapes.
Definition CompoundShape.h:347
const SubShapes & GetSubShapes() const
Access to the sub shapes of this compound.
Definition CompoundShape.h:251
virtual int GetIntersectingSubShapes(const OrientedBox &inBox, uint *outSubShapeIndices, int inMaxSubShapeIndices) const =0
uint GetSubShapeIDBits() const
Determine amount of bits needed to encode sub shape id.
Definition CompoundShape.h:329
bool IsSubShapeIDValid(SubShapeID inSubShapeID) const
Definition CompoundShape.h:268
Array< SubShape > SubShapes
Definition CompoundShape.h:248
uint32 GetCompoundUserData(uint inIdx) const
Get the user data associated with a shape in this compound.
Definition CompoundShape.h:260
SubShapeIDCreator GetSubShapeIDFromIndex(int inIdx, const SubShapeIDCreator &inParentSubShapeID) const
Convert a sub shape index to a sub shape ID.
Definition CompoundShape.h:289
JPH_OVERRIDE_NEW_DELETE CompoundShape(EShapeSubType inSubType)
Constructor.
Definition CompoundShape.h:58
Vec3 mCenterOfMass
Center of mass of the compound.
Definition CompoundShape.h:344
uint32 GetSubShapeIndexFromID(SubShapeID inSubShapeID, SubShapeID &outRemainder) const
Definition CompoundShape.h:278
void SetCompoundUserData(uint inIdx, uint32 inUserData)
Set the user data associated with a shape in this compound.
Definition CompoundShape.h:263
virtual int GetTrianglesNext(GetTrianglesContext &ioContext, int inMaxTrianglesRequested, Float3 *outTriangleVertices, const PhysicsMaterial **outMaterials=nullptr) const override
Definition CompoundShape.h:125
void CalculateInnerRadius()
Determine the inner radius of this shape.
Definition CompoundShape.h:337
uint GetNumSubShapes() const
Get the total number of sub shapes.
Definition CompoundShape.h:254
virtual int GetIntersectingSubShapes(const AABox &inBox, uint *outSubShapeIndices, int inMaxSubShapeIndices) const =0
CompoundShape(EShapeSubType inSubType, const ShapeSettings &inSettings, ShapeResult &outResult)
Definition CompoundShape.h:59
SubShapes mSubShapes
Definition CompoundShape.h:346
virtual float GetInnerRadius() const override
Definition CompoundShape.h:78
virtual AABox GetLocalBounds() const override
Get local bounding box including convex radius, this box is centered around the center of mass rather...
Definition CompoundShape.h:68
virtual Vec3 GetCenterOfMass() const override
All shapes are centered around their center of mass. This function returns the center of mass positio...
Definition CompoundShape.h:62
const SubShape & GetSubShape(uint inIdx) const
Access to a particular sub shape.
Definition CompoundShape.h:257
SubShapes mSubShapes
Definition CompoundShape.h:48
CompoundShapeSettings()=default
Constructor. Use AddShape to add the parts.
Array< SubShapeSettings > SubShapes
Definition CompoundShape.h:46
void AddShape(Vec3Arg inPosition, QuatArg inRotation, const ShapeSettings *inShape, uint32 inUserData=0)
Add a shape to the compound.
Definition CompoundShape.cpp:37
Definition DebugRenderer.h:47
Class that holds 3 floats. Used as a storage class. Convert to Vec3 for calculations.
Definition Float3.h:13
Describes the mass and inertia properties of a body. Used during body construction only.
Definition MassProperties.h:16
Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.
Definition Mat44.h:13
static JPH_INLINE Mat44 sRotationTranslation(QuatArg inR, Vec3Arg inT)
Get matrix that rotates and translates.
Definition Mat44.inl:149
Oriented box.
Definition OrientedBox.h:18
Definition PhysicsMaterial.h:23
An infinite plane described by the formula X . Normal + Constant = 0.
Definition Plane.h:11
static JPH_INLINE Quat sLoadFloat3Unsafe(const Float3 &inV)
Load 3 floats from memory (X, Y and Z component and then calculates W) reads 32 bits extra which it d...
Definition Quat.inl:399
static JPH_INLINE Quat sIdentity()
Definition Quat.h:104
bool IsClose(QuatArg inRHS, float inMaxDistSq=1.0e-12f) const
If this quaternion is close to inRHS. Note that q and -q represent the same rotation,...
Definition Quat.h:57
JPH_INLINE void StoreFloat3(Float3 *outV) const
Store as 3 floats to memory (X, Y and Z component). Ensures that W is positive before storing.
Definition Quat.inl:388
Definition Reference.h:163
bool IsValid() const
Checks if the result is valid.
Definition Result.h:134
const Type & Get() const
Get the result value.
Definition Result.h:137
Settings to be passed with a shape cast.
Definition ShapeCast.h:92
Filter class.
Definition ShapeFilter.h:17
Base class for all shapes (collision volume of a body). Defines a virtual interface for collision det...
Definition Shape.h:186
ShapeSettings::ShapeResult ShapeResult
Definition Shape.h:190
Shape(EShapeType inType, EShapeSubType inSubType)
Constructor.
Definition Shape.h:193
virtual AABox GetWorldSpaceBounds(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale) const
Definition Shape.h:222
virtual ShapeResult Create() const =0
Create a shape according to the settings specified by this object.
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
Definition SubShapeID.h:108
SubShapeIDCreator PushID(uint inValue, uint inBits) const
Add a new id to the chain of id's and return it.
Definition SubShapeID.h:111
A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compou...
Definition SubShapeID.h:23
Type PopID(uint inBits, SubShapeID &outRemainder) const
Get the next id in the chain of ids (pops parents before children).
Definition SubShapeID.h:42
JPH_INLINE void StoreFloat3(Float3 *outV) const
Store 3 floats to memory.
Definition Vec3.inl:772
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:103
static JPH_INLINE Vec3 sLoadFloat3Unsafe(const Float3 &inV)
Load 3 floats from memory (reads 32 bits extra which it doesn't use).
Definition Vec3.inl:135
bool CanScaleBeRotated(QuatArg inRotation, Vec3Arg inScale)
Definition ScaleHelpers.h:51
Vec3 RotateScale(QuatArg inRotation, Vec3Arg inScale)
Definition ScaleHelpers.h:75
bool IsUniformScale(Vec3Arg inScale)
Test if a scale is uniform.
Definition ScaleHelpers.h:24
Definition CompoundShape.h:142
JPH_INLINE Quat GetRotation() const
Uncompress the rotation.
Definition CompoundShape.h:233
Float3 mPositionCOM
Note: Position of center of mass of sub shape!
Definition CompoundShape.h:239
JPH_INLINE Mat44 GetLocalTransformNoScale(Vec3Arg inScale) const
Definition CompoundShape.h:188
bool mIsRotationIdentity
If mRotation is close to identity (put here because it falls in padding bytes).
Definition CompoundShape.h:242
bool FromSettings(const CompoundShapeSettings::SubShapeSettings &inSettings, ShapeResult &outResult)
Definition CompoundShape.h:147
bool IsValidScale(Vec3Arg inScale) const
Test if inScale is valid for this sub shape.
Definition CompoundShape.h:195
JPH_INLINE void SetTransform(Vec3Arg inPosition, QuatArg inRotation, Vec3Arg inCenterOfMass)
Definition CompoundShape.h:177
Float3 mRotation
Note: X, Y, Z of rotation quaternion - note we read 4 bytes beyond this so make sure there's somethin...
Definition CompoundShape.h:240
uint32 mUserData
User data value (put here because it falls in padding bytes).
Definition CompoundShape.h:241
Vec3 TransformScale(Vec3Arg inScale) const
Transform the scale to the local space of the child shape.
Definition CompoundShape.h:205
JPH_INLINE Vec3 GetPositionCOM() const
Uncompress the center of mass position.
Definition CompoundShape.h:221
JPH_INLINE void SetPositionCOM(Vec3Arg inPositionCOM)
Compress the center of mass position.
Definition CompoundShape.h:215
JPH_INLINE void SetRotation(QuatArg inRotation)
Compress the rotation.
Definition CompoundShape.h:227
RefConst< Shape > mShape
Definition CompoundShape.h:238
Definition CompoundShape.h:32
uint32 mUserData
Definition CompoundShape.h:43
Quat mRotation
Rotation of the sub shape.
Definition CompoundShape.h:38
RefConst< ShapeSettings > mShape
Sub shape (either this or mShapePtr needs to be filled up).
Definition CompoundShape.h:35
Vec3 mPosition
Position of the sub shape.
Definition CompoundShape.h:37
RefConst< Shape > mShapePtr
Sub shape (either this or mShape needs to be filled up).
Definition CompoundShape.h:36
An opaque buffer that holds shape specific information during GetTrianglesStart/Next.
Definition Shape.h:348
Definition ShapeCast.h:69