Plasma Engine  2.0
Loading...
Searching...
No Matches
JoltDynamicActorComponent.h
1#pragma once
2
3#include <JoltPlugin/Actors/JoltActorComponent.h>
4
6
7class PL_JOLTPLUGIN_DLL plJoltDynamicActorComponentManager : public plComponentManager<class plJoltDynamicActorComponent, plBlockStorageType::FreeList>
8{
9public:
12
13private:
14 friend class plJoltWorldModule;
15 friend class plJoltDynamicActorComponent;
16
17 void UpdateKinematicActors(plTime deltaTime);
18 void UpdateDynamicActors();
19
20 plDynamicArray<plJoltDynamicActorComponent*> m_KinematicActorComponents;
21};
22
24
34class PL_JOLTPLUGIN_DLL plJoltDynamicActorComponent : public plJoltActorComponent
35{
37
39 // plComponent
40
41public:
42 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
43 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
44
45protected:
46 virtual void OnSimulationStarted() override;
47 virtual void OnDeactivated() override;
48
50 // plJoltDynamicActorComponent
51
52public:
55
59 void AddImpulseAtPos(plMsgPhysicsAddImpulse& ref_msg); // [ message ]
60
64 void AddForceAtPos(plMsgPhysicsAddForce& ref_msg); // [ message ]
65
76 void SetKinematic(bool b); // [ property ]
77 bool GetKinematic() const { return m_bKinematic; } // [ property ]
78
82 void SetGravityFactor(float fFactor); // [ property ]
83 float GetGravityFactor() const { return m_fGravityFactor; } // [ property ]
84
85 void SetSurfaceFile(const char* szFile); // [ property ]
86 const char* GetSurfaceFile() const; // [ property ]
87
90 bool m_bCCD = false; // [ property ]
91
94 bool m_bStartAsleep = false; // [ property ]
95
97 float m_fInitialMass = 0.0f; // [ property ]
98
100 float m_fDensity = 1.0f; // [ property ]
101
103 float m_fLinearDamping = 0.1f; // [ property ]
104
106 float m_fAngularDamping = 0.05f; // [ property ]
107
110
113
115 plVec3 m_vCenterOfMass = plVec3::MakeZero(); // [ property ]
116
118 void SetUseCustomCoM(bool b) { SetUserFlag(0, b); } // [ property ]
119 bool GetUseCustomCoM() const { return GetUserFlag(0); } // [ property ]
120
122 void AddLinearForce(const plVec3& vForce); // [ scriptable ]
123
125 void AddLinearImpulse(const plVec3& vImpulse); // [ scriptable ]
126
128 void AddAngularForce(const plVec3& vForce); // [ scriptable ]
129
131 void AddAngularImpulse(const plVec3& vImpulse); // [ scriptable ]
132
137 void AddConstraint(plComponentHandle hComponent);
138
140 void RemoveConstraint(plComponentHandle hComponent);
141
144 float GetMass() const;
145
146protected:
147 const plJoltMaterial* GetJoltMaterial() const;
148
149 bool m_bKinematic = false;
150 float m_fGravityFactor = 1.0f; // [ property ]
151
153};
Definition ComponentManager.h:88
Definition DynamicArray.h:81
Base class for all Jolt actors.
Definition JoltActorComponent.h:23
Turns an object into a fully physically simulated movable object.
Definition JoltDynamicActorComponent.h:35
plSurfaceResourceHandle m_hSurface
Which surface to use for all shapes. The surface defines various physical properties and interactions...
Definition JoltDynamicActorComponent.h:109
void SetUseCustomCoM(bool b)
Whether a custom center-of-mass shall be used.
Definition JoltDynamicActorComponent.h:118
plBitflags< plOnJoltContact > m_OnContact
What reactions should be triggered when an actor gets into contact with another.
Definition JoltDynamicActorComponent.h:112
Definition JoltDynamicActorComponent.h:8
Definition JoltMaterial.h:7
Definition JoltWorldModule.h:29
Definition SmallArray.h:219
static plVec3Template< float > MakeZero()
Definition Vec3.h:38
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
virtual void OnSimulationStarted()
This method is called at the start of the next world update when the world is simulated....
Definition WorldModule.h:105
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
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
A handle to a component.
Definition Declarations.h:138
Used to apply a physical force on the object.
Definition PhysicsWorldModule.h:201
Used to apply a physical impulse on the object.
Definition PhysicsWorldModule.h:187
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12