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
16public:
19
21 explicit DecoratedShapeSettings(const ShapeSettings *inShape) : mInnerShape(inShape) { }
22 explicit DecoratedShapeSettings(const Shape *inShape) : mInnerShapePtr(inShape) { }
23
26};
27
30{
31public:
33
35 explicit DecoratedShape(EShapeSubType inSubType) : Shape(EShapeType::Decorated, inSubType) { }
36 DecoratedShape(EShapeSubType inSubType, const Shape *inInnerShape) : Shape(EShapeType::Decorated, inSubType), mInnerShape(inInnerShape) { }
37 DecoratedShape(EShapeSubType inSubType, const DecoratedShapeSettings &inSettings, ShapeResult &outResult);
38
40 const Shape * GetInnerShape() const { return mInnerShape; }
41
42 // See Shape::MustBeStatic
43 virtual bool MustBeStatic() const override { return mInnerShape->MustBeStatic(); }
44
45 // See Shape::GetCenterOfMass
46 virtual Vec3 GetCenterOfMass() const override { return mInnerShape->GetCenterOfMass(); }
47
48 // See Shape::GetSubShapeIDBitsRecursive
49 virtual uint GetSubShapeIDBitsRecursive() const override { return mInnerShape->GetSubShapeIDBitsRecursive(); }
50
51 // See Shape::GetLeafShape
52 virtual const Shape * GetLeafShape(const SubShapeID &inSubShapeID, SubShapeID &outRemainder) const override { return mInnerShape->GetLeafShape(inSubShapeID, outRemainder); }
53
54 // See Shape::GetMaterial
55 virtual const PhysicsMaterial * GetMaterial(const SubShapeID &inSubShapeID) const override;
56
57 // See Shape::GetSupportingFace
58 virtual void GetSupportingFace(const SubShapeID &inSubShapeID, Vec3Arg inDirection, Vec3Arg inScale, Mat44Arg inCenterOfMassTransform, SupportingFace &outVertices) const override;
59
60 // See Shape::GetSubShapeUserData
61 virtual uint64 GetSubShapeUserData(const SubShapeID &inSubShapeID) const override;
62
63 // See Shape
64 virtual void SaveSubShapeState(ShapeList &outSubShapes) const override;
65 virtual void RestoreSubShapeState(const ShapeRefC *inSubShapes, uint inNumShapes) override;
66
67 // See Shape::GetStatsRecursive
68 virtual Stats GetStatsRecursive(VisitedShapes &ioVisitedShapes) const override;
69
70 // See Shape::IsValidScale
71 virtual bool IsValidScale(Vec3Arg inScale) const override { return mInnerShape->IsValidScale(inScale); }
72
73 // See Shape::MakeScaleValid
74 virtual Vec3 MakeScaleValid(Vec3Arg inScale) const override { return mInnerShape->MakeScaleValid(inScale); }
75
76protected:
78};
79
#define JPH_EXPORT
Definition Core.h:236
std::uint64_t uint64
Definition Core.h:457
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_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:31
#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
@ Decorated
Used by DecoratedShape.
Definition Array.h:36
Base class for shapes that decorate another shape with extra functionality (e.g. scale,...
Definition DecoratedShape.h:30
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:49
const Shape * GetInnerShape() const
Access to the decorated inner shape.
Definition DecoratedShape.h:40
virtual const Shape * GetLeafShape(const SubShapeID &inSubShapeID, SubShapeID &outRemainder) const override
Definition DecoratedShape.h:52
RefConst< Shape > mInnerShape
Definition DecoratedShape.h:77
virtual bool IsValidScale(Vec3Arg inScale) const override
Definition DecoratedShape.h:71
JPH_OVERRIDE_NEW_DELETE DecoratedShape(EShapeSubType inSubType)
Constructor.
Definition DecoratedShape.h:35
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:46
virtual Vec3 MakeScaleValid(Vec3Arg inScale) const override
Definition DecoratedShape.h:74
DecoratedShape(EShapeSubType inSubType, const Shape *inInnerShape)
Definition DecoratedShape.h:36
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:43
Class that constructs a DecoratedShape.
Definition DecoratedShape.h:13
RefConst< Shape > mInnerShapePtr
Sub shape (either this or mShape needs to be filled up)
Definition DecoratedShape.h:25
DecoratedShapeSettings(const Shape *inShape)
Definition DecoratedShape.h:22
RefConst< ShapeSettings > mInnerShape
Sub shape (either this or mShapePtr needs to be filled up)
Definition DecoratedShape.h:24
DecoratedShapeSettings(const ShapeSettings *inShape)
Constructor that decorates another shape.
Definition DecoratedShape.h:21
DecoratedShapeSettings()=default
Default constructor for deserialization.
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:163
Base class for all shapes (collision volume of a body). Defines a virtual interface for collision det...
Definition Shape.h:186
virtual const Shape * GetLeafShape(const SubShapeID &inSubShapeID, SubShapeID &outRemainder) const
Definition Shape.cpp:35
Definition Shape.h:147
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