Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
EmptyShape.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2024 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
9
11
14{
16
17public:
18 EmptyShapeSettings() = default;
19 explicit EmptyShapeSettings(Vec3Arg inCenterOfMass) : mCenterOfMass(inCenterOfMass) { }
20
21 ShapeResult Create() const override;
22
23 Vec3 mCenterOfMass = Vec3::sZero();
24};
25
34class JPH_EXPORT EmptyShape final : public Shape
35{
36public:
37 // Constructor
39 explicit EmptyShape(Vec3Arg inCenterOfMass) : Shape(EShapeType::Empty, EShapeSubType::Empty), mCenterOfMass(inCenterOfMass) { }
40 EmptyShape(const EmptyShapeSettings &inSettings, ShapeResult &outResult) : Shape(EShapeType::Empty, EShapeSubType::Empty, inSettings, outResult), mCenterOfMass(inSettings.mCenterOfMass) { outResult.Set(this); }
41
42 // See: Shape
43 Vec3 GetCenterOfMass() const override { return mCenterOfMass; }
44 AABox GetLocalBounds() const override { return { Vec3::sZero(), Vec3::sZero() }; }
45 uint GetSubShapeIDBitsRecursive() const override { return 0; }
46 float GetInnerRadius() const override { return 0.0f; }
47 MassProperties GetMassProperties() const override;
48 const PhysicsMaterial * GetMaterial([[maybe_unused]] const SubShapeID &inSubShapeID) const override { return PhysicsMaterial::sDefault; }
49 virtual Vec3 GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inLocalSurfacePosition) const override { return Vec3::sZero(); }
50 virtual void GetSubmergedVolume(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, const Plane &inSurface, float &outTotalVolume, float &outSubmergedVolume, Vec3 &outCenterOfBuoyancy
51#ifdef JPH_DEBUG_RENDERER // Not using JPH_IF_DEBUG_RENDERER for Doxygen
52 , RVec3Arg inBaseOffset
53#endif
54 ) const override { outTotalVolume = 0.0f; outSubmergedVolume = 0.0f; outCenterOfBuoyancy = Vec3::sZero(); }
55#ifdef JPH_DEBUG_RENDERER
56 virtual void Draw([[maybe_unused]] DebugRenderer *inRenderer, [[maybe_unused]] RMat44Arg inCenterOfMassTransform, [[maybe_unused]] Vec3Arg inScale, [[maybe_unused]] ColorArg inColor, [[maybe_unused]] bool inUseMaterialColors, [[maybe_unused]] bool inDrawWireframe) const override;
57#endif // JPH_DEBUG_RENDERER
58 virtual bool CastRay([[maybe_unused]] const RayCast &inRay, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator, [[maybe_unused]] RayCastResult &ioHit) const override { return false; }
59 virtual void CastRay([[maybe_unused]] const RayCast &inRay, [[maybe_unused]] const RayCastSettings &inRayCastSettings, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator, [[maybe_unused]] CastRayCollector &ioCollector, [[maybe_unused]] const ShapeFilter &inShapeFilter = { }) const override { /* Do nothing */ }
60 virtual void CollidePoint([[maybe_unused]] Vec3Arg inPoint, [[maybe_unused]] const SubShapeIDCreator &inSubShapeIDCreator, [[maybe_unused]] CollidePointCollector &ioCollector, [[maybe_unused]] const ShapeFilter &inShapeFilter = { }) const override { /* Do nothing */ }
61 virtual void CollideSoftBodyVertices([[maybe_unused]] Mat44Arg inCenterOfMassTransform, [[maybe_unused]] Vec3Arg inScale, [[maybe_unused]] const CollideSoftBodyVertexIterator &inVertices, [[maybe_unused]] uint inNumVertices, [[maybe_unused]] int inCollidingShapeIndex) const override { /* Do nothing */ }
62 virtual void GetTrianglesStart([[maybe_unused]] GetTrianglesContext &ioContext, [[maybe_unused]] const AABox &inBox, [[maybe_unused]] Vec3Arg inPositionCOM, [[maybe_unused]] QuatArg inRotation, [[maybe_unused]] Vec3Arg inScale) const override { /* Do nothing */ }
63 virtual int GetTrianglesNext([[maybe_unused]] GetTrianglesContext &ioContext, [[maybe_unused]] int inMaxTrianglesRequested, [[maybe_unused]] Float3 *outTriangleVertices, [[maybe_unused]] const PhysicsMaterial **outMaterials = nullptr) const override { return 0; }
64 Stats GetStats() const override { return { sizeof(*this), 0 }; }
65 float GetVolume() const override { return 0.0f; }
66 bool IsValidScale([[maybe_unused]] Vec3Arg inScale) const override { return true; }
67
68 // Register shape functions with the registry
69 static void sRegister();
70
71private:
72 Vec3 mCenterOfMass = Vec3::sZero();
73};
74
#define JPH_EXPORT
Definition Core.h:236
unsigned int uint
Definition Core.h:453
#define JPH_NAMESPACE_END
Definition Core.h:379
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
#define JPH_DECLARE_SERIALIZABLE_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:109
EShapeSubType
This enumerates all shape types, each shape can return its type through Shape::GetSubType.
Definition Shape.h:77
EShapeType
Shapes are categorized in groups, each shape can return which group it belongs to through its Shape::...
Definition Shape.h:57
@ Empty
Used by EmptyShape.
Axis aligned box.
Definition AABox.h:16
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
Definition DebugRenderer.h:47
Definition EmptyShape.h:35
virtual void CollidePoint(Vec3Arg inPoint, const SubShapeIDCreator &inSubShapeIDCreator, CollidePointCollector &ioCollector, const ShapeFilter &inShapeFilter={ }) const override
Definition EmptyShape.h:60
virtual void GetTrianglesStart(GetTrianglesContext &ioContext, const AABox &inBox, Vec3Arg inPositionCOM, QuatArg inRotation, Vec3Arg inScale) const override
Definition EmptyShape.h:62
EmptyShape()
Definition EmptyShape.h:38
virtual Vec3 GetSurfaceNormal(const SubShapeID &inSubShapeID, Vec3Arg inLocalSurfacePosition) const override
Definition EmptyShape.h:49
virtual void CollideSoftBodyVertices(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, const CollideSoftBodyVertexIterator &inVertices, uint inNumVertices, int inCollidingShapeIndex) const override
Definition EmptyShape.h:61
float GetVolume() const override
Definition EmptyShape.h:65
virtual void CastRay(const RayCast &inRay, const RayCastSettings &inRayCastSettings, const SubShapeIDCreator &inSubShapeIDCreator, CastRayCollector &ioCollector, const ShapeFilter &inShapeFilter={ }) const override
Definition EmptyShape.h:59
float GetInnerRadius() const override
Definition EmptyShape.h:46
EmptyShape(Vec3Arg inCenterOfMass)
Definition EmptyShape.h:39
AABox GetLocalBounds() const override
Get local bounding box including convex radius, this box is centered around the center of mass rather...
Definition EmptyShape.h:44
Stats GetStats() const override
Get stats of this shape. Use for logging / data collection purposes only. Does not add values from ch...
Definition EmptyShape.h:64
bool IsValidScale(Vec3Arg inScale) const override
Definition EmptyShape.h:66
virtual int GetTrianglesNext(GetTrianglesContext &ioContext, int inMaxTrianglesRequested, Float3 *outTriangleVertices, const PhysicsMaterial **outMaterials=nullptr) const override
Definition EmptyShape.h:63
EmptyShape(const EmptyShapeSettings &inSettings, ShapeResult &outResult)
Definition EmptyShape.h:40
virtual bool CastRay(const RayCast &inRay, const SubShapeIDCreator &inSubShapeIDCreator, RayCastResult &ioHit) const override
Definition EmptyShape.h:58
const PhysicsMaterial * GetMaterial(const SubShapeID &inSubShapeID) const override
Get the material assigned to a particular sub shape ID.
Definition EmptyShape.h:48
Vec3 GetCenterOfMass() const override
All shapes are centered around their center of mass. This function returns the center of mass positio...
Definition EmptyShape.h:43
uint GetSubShapeIDBitsRecursive() const override
Get the max number of sub shape ID bits that are needed to be able to address any leaf shape in this ...
Definition EmptyShape.h:45
virtual void GetSubmergedVolume(Mat44Arg inCenterOfMassTransform, Vec3Arg inScale, const Plane &inSurface, float &outTotalVolume, float &outSubmergedVolume, Vec3 &outCenterOfBuoyancy, RVec3Arg inBaseOffset) const override
Definition EmptyShape.h:50
Class that constructs an EmptyShape.
Definition EmptyShape.h:14
EmptyShapeSettings()=default
EmptyShapeSettings(Vec3Arg inCenterOfMass)
Definition EmptyShape.h:19
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
Definition PhysicsMaterial.h:23
static RefConst< PhysicsMaterial > sDefault
Default material that is used when a shape has no materials defined.
Definition PhysicsMaterial.h:31
An infinite plane described by the formula X . Normal + Constant = 0.
Definition Plane.h:11
Definition Quat.h:33
Specialization of cast result against a shape.
Definition CastResult.h:30
Settings to be passed with a ray cast.
Definition RayCast.h:70
void Set(const Type &inResult)
Set the result value.
Definition Result.h:140
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
Definition Shape.h:147
virtual ShapeResult Create() const =0
Create a shape according to the settings specified by this object.
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 Vec3.h:17
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:107
Definition RayCast.h:47
An opaque buffer that holds shape specific information during GetTrianglesStart/Next.
Definition Shape.h:348
Class that holds information about the shape that can be used for logging / data collection purposes.
Definition Shape.h:408