Plasma Engine  2.0
Loading...
Searching...
No Matches
JoltSwingTwistConstraintComponent.h
1#pragma once
2
3#include <JoltPlugin/Constraints/JoltConstraintComponent.h>
4
6
13{
15
17 // plComponent
18
19public:
20 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
21 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
22
24 // plJoltConstraintComponent
25
26protected:
27 virtual void CreateContstraintType(JPH::Body* pBody0, JPH::Body* pBody1) override;
28 virtual void ApplySettings() final override;
29 virtual bool ExceededBreakingPoint() final override;
30
32 // plJoltSwingTwistConstraintComponent
33
34public:
37
39 void SetSwingLimitY(plAngle f); // [ property ]
40 plAngle GetSwingLimitY() const { return m_SwingLimitY; } // [ property ]
41
43 void SetSwingLimitZ(plAngle f); // [ property ]
44 plAngle GetSwingLimitZ() const { return m_SwingLimitZ; } // [ property ]
45
47 void SetFriction(float f); // [ property ]
48 float GetFriction() const { return m_fFriction; } // [ property ]
49
51 void SetLowerTwistLimit(plAngle f); // [ property ]
52 plAngle GetLowerTwistLimit() const { return m_LowerTwistLimit; } // [ property ]
53
55 void SetUpperTwistLimit(plAngle f); // [ property ]
56 plAngle GetUpperTwistLimit() const { return m_UpperTwistLimit; } // [ property ]
57
58 // void SetTwistDriveMode(plJoltConstraintDriveMode::Enum mode); // [ property ]
59 // plJoltConstraintDriveMode::Enum GetTwistDriveMode() const { return m_TwistDriveMode; } // [ property ]
60
61 // void SetTwistDriveTargetValue(plAngle f); // [ property ]
62 // plAngle GetTwistDriveTargetValue() const { return m_TwistDriveTargetValue; } // [ property ]
63
64 // void SetTwistDriveStrength(float f); // [ property ]
65 // float GetTwistDriveStrength() const { return m_fTwistDriveStrength; } // [ property ]
66
67protected:
68 plAngle m_SwingLimitY;
69 plAngle m_SwingLimitZ;
70
71 float m_fFriction = 0.0f;
72
73 plAngle m_LowerTwistLimit = plAngle::MakeFromDegree(90);
74 plAngle m_UpperTwistLimit = plAngle::MakeFromDegree(90);
75
76 // not sure whether these are useful
77 // maybe just expose an 'untwist' feature, with strength/frequency and drive to position 0 ?
78 // driving to velocity makes no sense, since the constraint always has a lower/upper twist limit
79 // probably would need a 6DOF joint for more advanced use cases
80 // plEnum<plJoltConstraintDriveMode> m_TwistDriveMode;
81 // plAngle m_TwistDriveTargetValue;
82 // float m_fTwistDriveStrength = 0; // 0 means maximum strength
83};
Float wrapper struct for a safe usage and conversions of angles.
Definition Angle.h:10
static constexpr plAngle MakeFromDegree(float fDegree)
Creates an instance of plAngle that was initialized from degree. (Performs a conversion)
Definition Angle_inl.h:33
Definition ComponentManager.h:88
Base class for all Jolt physics joints (constraints).
Definition JoltConstraintComponent.h:73
virtual void DeserializeComponent(plWorldReader &inout_stream) override
Override this to load the current state of the component from the given stream.
Definition JoltConstraintComponent.cpp:214
virtual void SerializeComponent(plWorldWriter &inout_stream) const override
Override this to save the current state of the component to the given stream.
Definition JoltConstraintComponent.cpp:194
Implements a swing-twist physics constraint.
Definition JoltSwingTwistConstraintComponent.h:13
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13