Debian Codegraph @

thirdparty/jolt_physics/Jolt/Physics/Collision/Shape/DecoratedShape.h

raw symbols SCIP
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
7 #include <Jolt/Physics/Collision/Shape/Shape.h>
8
9 JPH_NAMESPACE_BEGIN
10
11 /// Class that constructs a DecoratedShape
12 class JPH_EXPORT DecoratedShapeSettings : public ShapeSettings
13 {
14 JPH_DECLARE_SERIALIZABLE_VIRTUAL(JPH_EXPORT, DecoratedShapeSettings)
15
16 public:
17 /// Default constructor for deserialization
18 DecoratedShapeSettings() = default;
19
20 /// Constructor that decorates another shape
21 explicit DecoratedShapeSettings(const ShapeSettings *inShape) : mInnerShape(inShape) { }
22 explicit DecoratedShapeSettings(const Shape *inShape) : mInnerShapePtr(inShape) { }
23
24 RefConst<ShapeSettings> mInnerShape; ///< Sub shape (either this or mShapePtr needs to be filled up)
25 RefConst<Shape> mInnerShapePtr; ///< Sub shape (either this or mShape needs to be filled up)
26 };
27
28 /// Base class for shapes that decorate another shape with extra functionality (e.g. scale, translation etc.)
29 class JPH_EXPORT DecoratedShape : public Shape
30 {
31 public:
32 JPH_OVERRIDE_NEW_DELETE
33
34 /// Constructor
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
39 /// Access to the decorated inner shape
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
76 protected:
77 RefConst<Shape> mInnerShape;
78 };
79
80 JPH_NAMESPACE_END