Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Shape.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
11#include <Jolt/Geometry/AABox.h>
12#include <Jolt/Core/Reference.h>
13#include <Jolt/Core/Color.h>
14#include <Jolt/Core/Result.h>
19
21
22struct RayCast;
23class RayCastSettings;
24struct ShapeCast;
26class RayCastResult;
27class ShapeCastResult;
31class SubShapeID;
32class PhysicsMaterial;
34class Plane;
36class Shape;
37class StreamOut;
38class StreamIn;
39#ifdef JPH_DEBUG_RENDERER
40class DebugRenderer;
41#endif // JPH_DEBUG_RENDERER
42
48
53
73
125
126// Sets of shape sub types
129static constexpr EShapeSubType sCompoundSubShapeTypes[] = { EShapeSubType::StaticCompound, EShapeSubType::MutableCompound };
131
133static constexpr uint NumSubShapeTypes = uint(std::size(sAllSubShapeTypes));
134
136static constexpr const char *sSubShapeTypeNames[] = { "Sphere", "Box", "Triangle", "Capsule", "TaperedCapsule", "Cylinder", "ConvexHull", "StaticCompound", "MutableCompound", "RotatedTranslated", "Scaled", "OffsetCenterOfMass", "Mesh", "HeightField", "SoftBody", "User1", "User2", "User3", "User4", "User5", "User6", "User7", "User8", "UserConvex1", "UserConvex2", "UserConvex3", "UserConvex4", "UserConvex5", "UserConvex6", "UserConvex7", "UserConvex8", "Plane", "TaperedCylinder", "Empty" };
137static_assert(std::size(sSubShapeTypeNames) == NumSubShapeTypes);
138
145class JPH_EXPORT ShapeSettings : public SerializableObject, public RefTarget<ShapeSettings>
146{
148
149public:
151
153 virtual ShapeResult Create() const = 0;
154
158
161
162protected:
164};
165
168{
169public:
171 Shape * (*mConstruct)() = nullptr;
172
175
177 static inline ShapeFunctions & sGet(EShapeSubType inSubType) { return sRegistry[int(inSubType)]; }
178
179private:
180 static ShapeFunctions sRegistry[NumSubShapeTypes];
181};
182
184class JPH_EXPORT Shape : public RefTarget<Shape>, public NonCopyable
185{
186public:
188
190
192 Shape(EShapeType inType, EShapeSubType inSubType) : mShapeType(inType), mShapeSubType(inSubType) { }
193 Shape(EShapeType inType, EShapeSubType inSubType, const ShapeSettings &inSettings, [[maybe_unused]] ShapeResult &outResult) : mUserData(inSettings.mUserData), mShapeType(inType), mShapeSubType(inSubType) { }
194
196 virtual ~Shape() = default;
197
199 inline EShapeType GetType() const { return mShapeType; }
200 inline EShapeSubType GetSubType() const { return mShapeSubType; }
201
203 uint64 GetUserData() const { return mUserData; }
204 void SetUserData(uint64 inUserData) { mUserData = inUserData; }
205
207 virtual bool MustBeStatic() const { return false; }
208
210 virtual Vec3 GetCenterOfMass() const { return Vec3::sZero(); }
211
213 virtual AABox GetLocalBounds() const = 0;
214
216 virtual uint GetSubShapeIDBitsRecursive() const = 0;
217
221 virtual AABox GetWorldSpaceBounds(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale) const { return GetLocalBounds().Scaled(inScale).Transformed(inCenterOfMassTransform); }
222
224 AABox GetWorldSpaceBounds(DMat44Arg inCenterOfMassTransform, Vec3Arg inScale) const
225 {
226 // Use single precision version using the rotation only
227 AABox bounds = GetWorldSpaceBounds(inCenterOfMassTransform.GetRotation(), inScale);
228
229 // Apply translation
230 bounds.Translate(inCenterOfMassTransform.GetTranslation());
231
232 return bounds;
233 }
234
237 virtual float GetInnerRadius() const = 0;
238
241
246 virtual const Shape * GetLeafShape([[maybe_unused]] const SubShapeID &inSubShapeID, SubShapeID &outRemainder) const;
247
249 virtual const PhysicsMaterial * GetMaterial(const SubShapeID &inSubShapeID) const = 0;
250
253 virtual Vec3 GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inLocalSurfacePosition) const = 0;
254
257
265 virtual void GetSupportingFace([[maybe_unused]] const SubShapeID &inSubShapeID, [[maybe_unused]] Vec3Arg inDirection, [[maybe_unused]] Vec3Arg inScale, [[maybe_unused]] Mat44Arg inCenterOfMassTransform, [[maybe_unused]] SupportingFace &outVertices) const { /* Nothing */ }
266
268 virtual uint64 GetSubShapeUserData([[maybe_unused]] const SubShapeID &inSubShapeID) const { return mUserData; }
269
277 virtual TransformedShape GetSubShapeTransformedShape(const SubShapeID &inSubShapeID, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale, SubShapeID &outRemainder) const;
278
286#ifdef JPH_DEBUG_RENDERER
288#endif
289 virtual void GetSubmergedVolume(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, const Plane &inSurface, float &outTotalVolume, float &outSubmergedVolume, Vec3 &outCenterOfBuoyancy
290#ifdef JPH_DEBUG_RENDERER // Not using JPH_IF_DEBUG_RENDERER for Doxygen
291 , RVec3Arg inBaseOffset
292#endif
293 ) const = 0;
294
295#ifdef JPH_DEBUG_RENDERER
297 virtual void Draw(DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, Vec3Arg inScale, ColorArg inColor, bool inUseMaterialColors, bool inDrawWireframe) const = 0;
298
300 virtual void DrawGetSupportFunction([[maybe_unused]] DebugRenderer *inRenderer, [[maybe_unused]] RMat44Arg inCenterOfMassTransform, [[maybe_unused]] Vec3Arg inScale, [[maybe_unused]] ColorArg inColor, [[maybe_unused]] bool inDrawSupportDirection) const { /* Only implemented for convex shapes */ }
301
303 virtual void DrawGetSupportingFace([[maybe_unused]] DebugRenderer *inRenderer, [[maybe_unused]] RMat44Arg inCenterOfMassTransform, [[maybe_unused]] Vec3Arg inScale) const { /* Only implemented for convex shapes */ }
304#endif // JPH_DEBUG_RENDERER
305
310 virtual bool CastRay(const RayCast &inRay, const SubShapeIDCreator &inSubShapeIDCreator, RayCastResult &ioHit) const = 0;
311
314 virtual void CastRay(const RayCast &inRay, const RayCastSettings &inRayCastSettings, const SubShapeIDCreator &inSubShapeIDCreator, CastRayCollector &ioCollector, const ShapeFilter &inShapeFilter = { }) const = 0;
315
320 virtual void CollidePoint(Vec3Arg inPoint, const SubShapeIDCreator &inSubShapeIDCreator, CollidePointCollector &ioCollector, const ShapeFilter &inShapeFilter = { }) const = 0;
321
328 virtual void CollideSoftBodyVertices(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, const CollideSoftBodyVertexIterator &inVertices, uint inNumVertices, int inCollidingShapeIndex) const = 0;
329
334 virtual void CollectTransformedShapes(const AABox &inBox, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale, const SubShapeIDCreator &inSubShapeIDCreator, TransformedShapeCollector &ioCollector, const ShapeFilter &inShapeFilter) const;
335
340 virtual void TransformShape(Mat44Arg inCenterOfMassTransform, TransformedShapeCollector &ioCollector) const;
341
344 ShapeResult ScaleShape(Vec3Arg inScale) const;
345
347 struct alignas(16) GetTrianglesContext { uint8 mData[4288]; };
348
350 static constexpr int cGetTrianglesMinTrianglesRequested = 32;
351
357 virtual void GetTrianglesStart(GetTrianglesContext &ioContext, const AABox &inBox, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale) const = 0;
358
365 virtual int GetTrianglesNext(GetTrianglesContext &ioContext, int inMaxTrianglesRequested, Float3 *outTriangleVertices, const PhysicsMaterial **outMaterials = nullptr) const = 0;
366
373
375 virtual void SaveBinaryState(StreamOut &inStream) const;
376
379
381 virtual void SaveMaterialState([[maybe_unused]] PhysicsMaterialList &outMaterials) const { /* By default do nothing */ }
382
384 virtual void RestoreMaterialState([[maybe_unused]] const PhysicsMaterialRefC *inMaterials, [[maybe_unused]] uint inNumMaterials) { JPH_ASSERT(inNumMaterials == 0); }
385
387 virtual void SaveSubShapeState([[maybe_unused]] ShapeList &outSubShapes) const { /* By default do nothing */ }
388
390 virtual void RestoreSubShapeState([[maybe_unused]] const ShapeRefC *inSubShapes, [[maybe_unused]] uint inNumShapes) { JPH_ASSERT(inNumShapes == 0); }
391
396
398 void SaveWithChildren(StreamOut &inStream, ShapeToIDMap &ioShapeMap, MaterialToIDMap &ioMaterialMap) const;
399
401 static ShapeResult sRestoreWithChildren(StreamIn &inStream, IDToShapeMap &ioShapeMap, IDToMaterialMap &ioMaterialMap);
402
404
406 struct Stats
407 {
408 Stats(size_t inSizeBytes, uint inNumTriangles) : mSizeBytes(inSizeBytes), mNumTriangles(inNumTriangles) { }
409
410 size_t mSizeBytes;
412 };
413
415 virtual Stats GetStats() const = 0;
416
418
421 virtual Stats GetStatsRecursive(VisitedShapes &ioVisitedShapes) const;
422
424 virtual float GetVolume() const = 0;
425
438 virtual bool IsValidScale(Vec3Arg inScale) const;
439
445 virtual Vec3 MakeScaleValid(Vec3Arg inScale) const;
446
447#ifdef JPH_DEBUG_RENDERER
450#endif // JPH_DEBUG_RENDERER
451
452protected:
454 virtual void RestoreBinaryState(StreamIn &inStream);
455
457 static void sCollidePointUsingRayCast(const Shape &inShape, Vec3Arg inPoint, const SubShapeIDCreator &inSubShapeIDCreator, CollidePointCollector &ioCollector, const ShapeFilter &inShapeFilter);
458
459private:
460 uint64 mUserData = 0;
461 EShapeType mShapeType;
462 EShapeSubType mShapeSubType;
463};
464
Color ColorArg
Type to use for passing arguments to a function.
Definition Color.h:12
std::uint8_t uint8
Definition Core.h:547
#define JPH_EXPORT
Definition Core.h:286
std::uint64_t uint64
Definition Core.h:551
unsigned int uint
Definition Core.h:546
#define JPH_NAMESPACE_END
Definition Core.h:469
#define JPH_NAMESPACE_BEGIN
Definition Core.h:463
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
const Quat QuatArg
Definition MathTypes.h:28
const Vec3 Vec3Arg
Definition MathTypes.h:19
const DMat44 & DMat44Arg
Definition MathTypes.h:30
const Mat44 & Mat44Arg
Definition MathTypes.h:29
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:50
Array< RefConst< PhysicsMaterial > > PhysicsMaterialList
Definition PhysicsMaterial.h:55
Vec3Arg RVec3Arg
Definition Real.h:30
Mat44Arg RMat44Arg
Definition Real.h:32
#define JPH_DECLARE_SERIALIZABLE_ABSTRACT(linkage, class_name)
Definition SerializableObject.h:120
CollisionCollector< RayCastResult, CollisionCollectorTraitsCastRay > CastRayCollector
Definition Shape.h:43
CollisionCollector< ShapeCastResult, CollisionCollectorTraitsCastShape > CastShapeCollector
Definition Shape.h:44
RefConst< Shape > ShapeRefC
Definition Shape.h:49
EShapeSubType
This enumerates all shape types, each shape can return its type through Shape::GetSubType.
Definition Shape.h:76
@ TaperedCylinder
Definition Shape.h:122
@ UserConvex8
Definition Shape.h:118
@ Plane
Definition Shape.h:121
@ User6
Definition Shape.h:106
@ UserConvex7
Definition Shape.h:117
@ StaticCompound
Definition Shape.h:87
@ RotatedTranslated
Definition Shape.h:91
@ TaperedCapsule
Definition Shape.h:82
@ Cylinder
Definition Shape.h:83
@ Box
Definition Shape.h:79
@ ConvexHull
Definition Shape.h:84
@ Capsule
Definition Shape.h:81
@ UserConvex2
Definition Shape.h:112
@ UserConvex4
Definition Shape.h:114
@ User5
Definition Shape.h:105
@ UserConvex5
Definition Shape.h:115
@ UserConvex1
Definition Shape.h:111
@ User4
Definition Shape.h:104
@ Triangle
Definition Shape.h:80
@ User1
Definition Shape.h:101
@ Mesh
Definition Shape.h:96
@ Scaled
Definition Shape.h:92
@ MutableCompound
Definition Shape.h:88
@ User7
Definition Shape.h:107
@ HeightField
Definition Shape.h:97
@ User2
Definition Shape.h:102
@ SoftBody
Definition Shape.h:98
@ UserConvex3
Definition Shape.h:113
@ OffsetCenterOfMass
Definition Shape.h:93
@ Sphere
Definition Shape.h:78
@ Empty
Definition Shape.h:123
@ User8
Definition Shape.h:108
@ User3
Definition Shape.h:103
@ UserConvex6
Definition Shape.h:116
Array< ShapeRefC > ShapeList
Definition Shape.h:50
CollisionCollector< TransformedShape, CollisionCollectorTraitsCollideShape > TransformedShapeCollector
Definition Shape.h:47
EShapeType
Shapes are categorized in groups, each shape can return which group it belongs to through its Shape::...
Definition Shape.h:56
@ Compound
Used by CompoundShape.
Definition Shape.h:58
@ Decorated
Used by DecoratedShape.
Definition Shape.h:59
@ User4
Definition Shape.h:68
@ User1
Definition Shape.h:65
@ Mesh
Used by MeshShape.
Definition Shape.h:60
@ Convex
Used by ConvexShape, all shapes that use the generic convex vs convex collision detection system (box...
Definition Shape.h:57
@ HeightField
Used by HeightFieldShape.
Definition Shape.h:61
@ User2
Definition Shape.h:66
@ SoftBody
Used by SoftBodyShape.
Definition Shape.h:62
@ Empty
Used by EmptyShape.
Definition Shape.h:71
@ User3
Definition Shape.h:67
Array< PhysicsMaterialRefC > PhysicsMaterialList
Definition Shape.h:52
RefConst< PhysicsMaterial > PhysicsMaterialRefC
Definition Shape.h:51
CollisionCollector< CollidePointResult, CollisionCollectorTraitsCollidePoint > CollidePointCollector
Definition Shape.h:45
CollisionCollector< CollideShapeResult, CollisionCollectorTraitsCollideShape > CollideShapeCollector
Definition Shape.h:46
Axis aligned box.
Definition AABox.h:16
void Translate(Vec3Arg inTranslation)
Translate bounding box.
Definition AABox.h:179
Definition Array.h:36
Structure that holds the result of colliding a point against a shape.
Definition CollidePointResult.h:14
Class that contains all information of two colliding shapes.
Definition CollideShape.h:19
Definition CollideSoftBodyVertexIterator.h:15
Virtual interface that allows collecting multiple collision results.
Definition CollisionCollector.h:45
Class that holds an RGBA color with 8-bits per component.
Definition Color.h:16
static const Color sBlack
Predefined colors.
Definition Color.h:67
JPH_INLINE DVec3 GetTranslation() const
Definition DMat44.h:111
JPH_INLINE Mat44 GetRotation() const
Get rotation part only (note: retains the first 3 values from the bottom row).
Definition DMat44.h:128
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
NonCopyable()=default
Definition PhysicsMaterial.h:23
An infinite plane described by the formula X . Normal + Constant = 0.
Definition Plane.h:11
Specialization of cast result against a shape.
Definition CastResult.h:30
Settings to be passed with a ray cast.
Definition RayCast.h:70
Definition Reference.h:166
Helper class that either contains a valid result or an error.
Definition Result.h:12
SerializableObject()=default
Don't allow (copy) constructing this base class, but allow derived classes to (copy) construct themse...
Result of a shape cast test.
Definition ShapeCast.h:117
Settings to be passed with a shape cast.
Definition ShapeCast.h:92
Filter class.
Definition ShapeFilter.h:17
Function table for functions on shapes.
Definition Shape.h:168
Color mColor
Color of the shape when drawing.
Definition Shape.h:174
static ShapeFunctions & sGet(EShapeSubType inSubType)
Get an entry in the registry for a particular sub type.
Definition Shape.h:177
Base class for all shapes (collision volume of a body). Defines a virtual interface for collision det...
Definition Shape.h:185
virtual void SaveBinaryState(StreamOut &inStream) const
Saves the contents of the shape in binary form to inStream.
Definition Shape.cpp:71
virtual MassProperties GetMassProperties() const =0
Calculate the mass and inertia of this shape.
StreamUtils::IDToObjectMap< PhysicsMaterial > IDToMaterialMap
Definition Shape.h:395
StreamUtils::IDToObjectMap< Shape > IDToShapeMap
Definition Shape.h:393
virtual void SaveSubShapeState(ShapeList &outSubShapes) const
Outputs the shape references that this shape has to outSubShapes.
Definition Shape.h:387
virtual const Shape * GetLeafShape(const SubShapeID &inSubShapeID, SubShapeID &outRemainder) const
Definition Shape.cpp:34
ShapeSettings::ShapeResult ShapeResult
Definition Shape.h:189
Shape(EShapeType inType, EShapeSubType inSubType)
Constructor.
Definition Shape.h:192
virtual float GetInnerRadius() const =0
void SaveWithChildren(StreamOut &inStream, ShapeToIDMap &ioShapeMap, MaterialToIDMap &ioMaterialMap) const
Save this shape, all its children and its materials. Pass in an empty map in ioShapeMap / ioMaterialM...
Definition Shape.cpp:109
virtual uint64 GetSubShapeUserData(const SubShapeID &inSubShapeID) const
Get the user data of a particular sub shape ID. Corresponds with the value stored in Shape::GetUserDa...
Definition Shape.h:268
virtual float GetVolume() const =0
static void sCollidePointUsingRayCast(const Shape &inShape, Vec3Arg inPoint, const SubShapeIDCreator &inSubShapeIDCreator, CollidePointCollector &ioCollector, const ShapeFilter &inShapeFilter)
A fallback version of CollidePoint that uses a ray cast and counts the number of hits to determine if...
Definition Shape.cpp:288
virtual AABox GetLocalBounds() const =0
Get local bounding box including convex radius, this box is centered around the center of mass rather...
EShapeType GetType() const
Get type.
Definition Shape.h:199
virtual void CollectTransformedShapes(const AABox &inBox, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale, const SubShapeIDCreator &inSubShapeIDCreator, TransformedShapeCollector &ioCollector, const ShapeFilter &inShapeFilter) const
Definition Shape.cpp:51
static ShapeResult sRestoreWithChildren(StreamIn &inStream, IDToShapeMap &ioShapeMap, IDToMaterialMap &ioMaterialMap)
Restore a shape, all its children and materials. Pass in an empty map in ioShapeMap / ioMaterialMap o...
Definition Shape.cpp:146
virtual void TransformShape(Mat44Arg inCenterOfMassTransform, TransformedShapeCollector &ioCollector) const
Definition Shape.cpp:62
virtual int GetTrianglesNext(GetTrianglesContext &ioContext, int inMaxTrianglesRequested, Float3 *outTriangleVertices, const PhysicsMaterial **outMaterials=nullptr) const =0
virtual void GetSupportingFace(const SubShapeID &inSubShapeID, Vec3Arg inDirection, Vec3Arg inScale, Mat44Arg inCenterOfMassTransform, SupportingFace &outVertices) const
Definition Shape.h:265
virtual void DrawGetSupportingFace(DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, Vec3Arg inScale) const
Draw the results of the GetSupportingFace function to show any errors introduced by this process (onl...
Definition Shape.h:303
virtual void CastRay(const RayCast &inRay, const RayCastSettings &inRayCastSettings, const SubShapeIDCreator &inSubShapeIDCreator, CastRayCollector &ioCollector, const ShapeFilter &inShapeFilter={ }) const =0
StreamUtils::ObjectToIDMap< Shape > ShapeToIDMap
Definition Shape.h:392
virtual bool IsValidScale(Vec3Arg inScale) const
Definition Shape.cpp:223
Shape(EShapeType inType, EShapeSubType inSubType, const ShapeSettings &inSettings, ShapeResult &outResult)
Definition Shape.h:193
static constexpr int cGetTrianglesMinTrianglesRequested
This is the minimum amount of triangles that should be requested through GetTrianglesNext.
Definition Shape.h:350
virtual bool MustBeStatic() const
Check if this shape can only be used to create a static body or if it can also be dynamic/kinematic.
Definition Shape.h:207
static ShapeResult sRestoreFromBinaryState(StreamIn &inStream)
Creates a Shape of the correct type and restores its contents from the binary stream inStream.
Definition Shape.cpp:83
virtual void RestoreMaterialState(const PhysicsMaterialRefC *inMaterials, uint inNumMaterials)
Restore the material references after calling sRestoreFromBinaryState. Note that the exact same mater...
Definition Shape.h:384
virtual void SaveMaterialState(PhysicsMaterialList &outMaterials) const
Outputs the material references that this shape has to outMaterials.
Definition Shape.h:381
virtual void GetTrianglesStart(GetTrianglesContext &ioContext, const AABox &inBox, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale) const =0
uint64 GetUserData() const
User data (to be used freely by the application).
Definition Shape.h:203
StreamUtils::ObjectToIDMap< PhysicsMaterial > MaterialToIDMap
Definition Shape.h:394
virtual Vec3 GetCenterOfMass() const
All shapes are centered around their center of mass. This function returns the center of mass positio...
Definition Shape.h:210
virtual const PhysicsMaterial * GetMaterial(const SubShapeID &inSubShapeID) const =0
Get the material assigned to a particular sub shape ID.
EShapeSubType GetSubType() const
Definition Shape.h:200
virtual Stats GetStats() const =0
Get stats of this shape. Use for logging / data collection purposes only. Does not add values from ch...
virtual Vec3 MakeScaleValid(Vec3Arg inScale) const
Definition Shape.cpp:228
virtual bool CastRay(const RayCast &inRay, const SubShapeIDCreator &inSubShapeIDCreator, RayCastResult &ioHit) const =0
StaticArray< Vec3, 32 > SupportingFace
Type definition for a supporting face.
Definition Shape.h:256
virtual void RestoreBinaryState(StreamIn &inStream)
This function should not be called directly, it is used by sRestoreFromBinaryState.
Definition Shape.cpp:77
virtual void GetSubmergedVolume(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, const Plane &inSurface, float &outTotalVolume, float &outSubmergedVolume, Vec3 &outCenterOfBuoyancy, RVec3Arg inBaseOffset) const =0
virtual AABox GetWorldSpaceBounds(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale) const
Definition Shape.h:221
virtual void CollideSoftBodyVertices(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, const CollideSoftBodyVertexIterator &inVertices, uint inNumVertices, int inCollidingShapeIndex) const =0
virtual void RestoreSubShapeState(const ShapeRefC *inSubShapes, uint inNumShapes)
Restore the shape references after calling sRestoreFromBinaryState. Note that the exact same shapes n...
Definition Shape.h:390
virtual void DrawGetSupportFunction(DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, Vec3Arg inScale, ColorArg inColor, bool inDrawSupportDirection) const
Draw the results of the GetSupportFunction with the convex radius added back on to show any errors in...
Definition Shape.h:300
void SetUserData(uint64 inUserData)
Definition Shape.h:204
virtual ~Shape()=default
Destructor.
AABox GetWorldSpaceBounds(DMat44Arg inCenterOfMassTransform, Vec3Arg inScale) const
Get world space bounds including convex radius.
Definition Shape.h:224
virtual Vec3 GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inLocalSurfacePosition) const =0
ShapeResult ScaleShape(Vec3Arg inScale) const
Definition Shape.cpp:233
virtual Stats GetStatsRecursive(VisitedShapes &ioVisitedShapes) const
Volume of this shape (m^3). Note that for compound shapes the volume may be incorrect since child sha...
Definition Shape.cpp:212
virtual uint GetSubShapeIDBitsRecursive() const =0
Get the max number of sub shape ID bits that are needed to be able to address any leaf shape in this ...
virtual void Draw(DebugRenderer *inRenderer, RMat44Arg inCenterOfMassTransform, Vec3Arg inScale, ColorArg inColor, bool inUseMaterialColors, bool inDrawWireframe) const =0
Draw the shape at a particular location with a particular color (debugging purposes).
static bool sDrawSubmergedVolumes
Debug helper which draws the intersection between water and the shapes, the center of buoyancy and th...
Definition Shape.h:449
virtual void CollidePoint(Vec3Arg inPoint, const SubShapeIDCreator &inSubShapeIDCreator, CollidePointCollector &ioCollector, const ShapeFilter &inShapeFilter={ }) const =0
UnorderedSet< const Shape * > VisitedShapes
Definition Shape.h:417
Definition Shape.h:146
virtual ShapeResult Create() const =0
Create a shape according to the settings specified by this object.
Result< Ref< Shape > > ShapeResult
Definition Shape.h:150
void ClearCachedResult()
Definition Shape.h:157
ShapeResult mCachedResult
Definition Shape.h:163
uint64 mUserData
User data (to be used freely by the application).
Definition Shape.h:160
Definition Sphere.h:12
Simple variable length array backed by a fixed size buffer.
Definition StaticArray.h:14
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
Definition SubShapeID.h:108
A sub shape id contains a path to an element (usually a triangle or other primitive type) of a compou...
Definition SubShapeID.h:23
Definition TransformedShape.h:26
A simple triangle and its material.
Definition Triangle.h:11
Definition UnorderedSet.h:30
Definition Vec3.h:17
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:125
UnorderedMap< const Type *, uint32 > ObjectToIDMap
Definition ObjectToIDMap.h:14
Array< Ref< Type > > IDToObjectMap
Definition ObjectToIDMap.h:17
Definition RayCast.h:47
An opaque buffer that holds shape specific information during GetTrianglesStart/Next.
Definition Shape.h:347
uint8 mData[4288]
Definition Shape.h:347
Class that holds information about the shape that can be used for logging / data collection purposes.
Definition Shape.h:407
uint mNumTriangles
Number of triangles in this shape (when applicable).
Definition Shape.h:411
Stats(size_t inSizeBytes, uint inNumTriangles)
Definition Shape.h:408
size_t mSizeBytes
Amount of memory used by this shape (size in bytes).
Definition Shape.h:410
Definition ShapeCast.h:69