Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
DecoratedShape.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
8
10
13{
15
16
17 DecoratedShapeSettings() = default;
18
20 explicit DecoratedShapeSettings(const ShapeSettings *inShape) : mInnerShape(inShape) { }
21 explicit DecoratedShapeSettings(const Shape *inShape) : mInnerShapePtr(inShape) { }
22
23 RefConst<ShapeSettings> mInnerShape;
24 RefConst<Shape> mInnerShapePtr;
25};
26
28class DecoratedShape : public Shape
29{
30public:
32
34 explicit DecoratedShape(EShapeSubType inSubType) : Shape(EShapeType::Decorated, inSubType) { }
35 DecoratedShape(EShapeSubType inSubType, const Shape *inInnerShape) : Shape(EShapeType::Decorated, inSubType), mInnerShape(inInnerShape) { }
36 DecoratedShape(EShapeSubType inSubType, const DecoratedShapeSettings &inSettings, ShapeResult &outResult);
37
39 const Shape * GetInnerShape() const { return mInnerShape; }
40
41 // See Shape::MustBeStatic
42 virtual bool MustBeStatic() const override { return mInnerShape->MustBeStatic(); }
43
44 // See Shape::GetCenterOfMass
45 virtual Vec3 GetCenterOfMass() const override { return mInnerShape->GetCenterOfMass(); }
46
47 // See Shape::GetSubShapeIDBitsRecursive
49
50 // See Shape::GetMaterial
51 virtual const PhysicsMaterial * GetMaterial(const SubShapeID &inSubShapeID) const override;
52
53 // See Shape::GetSupportingFace
54 virtual void GetSupportingFace(const SubShapeID &inSubShapeID, Vec3Arg inDirection, Vec3Arg inScale, Mat44Arg inCenterOfMassTransform, SupportingFace &outVertices) const override;
55
56 // See Shape::GetSubShapeUserData
57 virtual uint64 GetSubShapeUserData(const SubShapeID &inSubShapeID) const override;
58
59 // See Shape
60 virtual void SaveSubShapeState(ShapeList &outSubShapes) const override;
61 virtual void RestoreSubShapeState(const ShapeRefC *inSubShapes, uint inNumShapes) override;
62
63 // See Shape::GetStatsRecursive
64 virtual Stats GetStatsRecursive(VisitedShapes &ioVisitedShapes) const override;
65
66protected:
68};
69
unsigned int uint
Definition: Core.h:309
#define JPH_NAMESPACE_END
Definition: Core.h:240
uint64_t uint64
Definition: Core.h:313
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:234
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition: Memory.h:29
#define JPH_DECLARE_SERIALIZABLE_VIRTUAL(class_name)
Definition: SerializableObject.h:100
EShapeSubType
This enumerates all shape types, each shape can return its type through Shape::GetSubType.
Definition: Shape.h:71
Array< ShapeRefC > ShapeList
Definition: Shape.h:49
EShapeType
Shapes are categorized in groups, each shape can return which group it belongs to through its Shape::...
Definition: Shape.h:55
@ Decorated
Used by DecoratedShape.
Base class for shapes that decorate another shape with extra functionality (e.g. scale,...
Definition: DecoratedShape.h:29
virtual 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: DecoratedShape.h:48
virtual const PhysicsMaterial * GetMaterial(const SubShapeID &inSubShapeID) const override
Get the material assigned to a particular sub shape ID.
Definition: DecoratedShape.cpp:47
const Shape * GetInnerShape() const
Access to the decorated inner shape.
Definition: DecoratedShape.h:39
virtual Stats GetStatsRecursive(VisitedShapes &ioVisitedShapes) const override
Volume of this shape (m^3). Note that for compound shapes the volume may be incorrect since child sha...
Definition: DecoratedShape.cpp:74
virtual void RestoreSubShapeState(const ShapeRefC *inSubShapes, uint inNumShapes) override
Restore the shape references after calling sRestoreFromBinaryState. Note that the exact same shapes n...
Definition: DecoratedShape.cpp:68
virtual void SaveSubShapeState(ShapeList &outSubShapes) const override
Outputs the shape references that this shape has to outSubShapes.
Definition: DecoratedShape.cpp:62
RefConst< Shape > mInnerShape
Definition: DecoratedShape.h:67
JPH_OVERRIDE_NEW_DELETE DecoratedShape(EShapeSubType inSubType)
Constructor.
Definition: DecoratedShape.h:34
virtual Vec3 GetCenterOfMass() const override
All shapes are centered around their center of mass. This function returns the center of mass positio...
Definition: DecoratedShape.h:45
DecoratedShape(EShapeSubType inSubType, const Shape *inInnerShape)
Definition: DecoratedShape.h:35
virtual void GetSupportingFace(const SubShapeID &inSubShapeID, Vec3Arg inDirection, Vec3Arg inScale, Mat44Arg inCenterOfMassTransform, SupportingFace &outVertices) const override
Definition: DecoratedShape.cpp:52
virtual bool MustBeStatic() const override
Check if this shape can only be used to create a static body or if it can also be dynamic/kinematic.
Definition: DecoratedShape.h:42
virtual uint64 GetSubShapeUserData(const SubShapeID &inSubShapeID) const override
Get the user data of a particular sub shape ID.
Definition: DecoratedShape.cpp:57
Class that constructs a DecoratedShape.
Definition: DecoratedShape.h:13
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
Definition: Reference.h:154
Base class for all shapes (collision volume of a body). Defines a virtual interface for collision det...
Definition: Shape.h:170
ShapeSettings::ShapeResult ShapeResult
Definition: Shape.h:174
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:192
virtual Vec3 GetCenterOfMass() const
All shapes are centered around their center of mass. This function returns the center of mass positio...
Definition: Shape.h:195
StaticArray< Vec3, 32 > SupportingFace
Type definition for a supporting face.
Definition: Shape.h:235
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 ...
UnorderedSet< const Shape * > VisitedShapes
Definition: Shape.h:387
Definition: Shape.h:135
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:16