Plasma Engine  2.0
Loading...
Searching...
No Matches
JoltActorComponent.h
1#pragma once
2
3#include <Core/World/Component.h>
4#include <Core/World/World.h>
5#include <Foundation/Types/Bitflags.h>
6#include <JoltPlugin/Declarations.h>
7#include <JoltPlugin/JoltPluginDLL.h>
8#include <JoltPlugin/Shapes/JoltShapeComponent.h>
9
10namespace JPH
11{
12 class Shape;
13 class BodyCreationSettings;
14} // namespace JPH
15
22class PL_JOLTPLUGIN_DLL plJoltActorComponent : public plComponent
23{
24 PL_DECLARE_ABSTRACT_COMPONENT_TYPE(plJoltActorComponent, plComponent);
25
27 // plComponent
28
29public:
30 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
31 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
32
33protected:
34 virtual void OnSimulationStarted() override;
35 virtual void OnDeactivated() override;
36
38 // plJoltActorComponent
39
40public:
43
48 plUInt8 m_uiCollisionLayer = 0; // [ property ]
49
51 void SetInitialObjectFilterID(plUInt32 uiObjectFilterID);
52
54 plUInt32 GetObjectFilterID() const { return m_uiObjectFilterID; }
55
57 plUInt32 GetJoltBodyID() const { return m_uiJoltBodyID; }
58
59protected:
60 const plJoltUserData* GetUserData() const;
61
62 void ExtractSubShapeGeometry(const plGameObject* pObject, plMsgExtractGeometry& msg) const;
63
64 static void GatherShapes(plDynamicArray<plJoltSubShape>& shapes, plGameObject* pObject, const plTransform& rootTransform, float fDensity, const plJoltMaterial* pMaterial);
65 plResult CreateShape(JPH::BodyCreationSettings* pSettings, float fDensity, const plJoltMaterial* pMaterial);
66
67 virtual void CreateShapes(plDynamicArray<plJoltSubShape>& out_Shapes, const plTransform& rootTransform, float fDensity, const plJoltMaterial* pMaterial) {}
68
69 plUInt32 m_uiUserDataIndex = plInvalidIndex;
70 plUInt32 m_uiJoltBodyID = plInvalidIndex;
71 plUInt32 m_uiObjectFilterID = plInvalidIndex;
72};
Base class of all component types.
Definition Component.h:25
virtual void SerializeComponent(plWorldWriter &inout_stream) const
Override this to save the current state of the component to the given stream.
Definition Component.cpp:54
virtual void OnDeactivated()
This method is called when the component gets deactivated.
Definition Component.cpp:142
virtual void OnSimulationStarted()
This method is called once for active components, at the start of the next world update,...
Definition Component.cpp:144
virtual void DeserializeComponent(plWorldReader &inout_stream)
Override this to load the current state of the component from the given stream.
Definition Component.cpp:58
Definition DynamicArray.h:81
This class represents an object inside the world.
Definition GameObject.h:32
Base class for all Jolt actors.
Definition JoltActorComponent.h:23
plUInt32 GetObjectFilterID() const
The object filter ID can be used to ignore collisions specifically with this one object.
Definition JoltActorComponent.h:54
plUInt32 GetJoltBodyID() const
Returns the internal ID used by Jolt to identify this actor/body.
Definition JoltActorComponent.h:57
Definition JoltMaterial.h:7
Definition JoltUserData.h:18
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
Sent by plWorldGeoExtractionUtil to gather geometry information about objects in a world.
Definition WorldGeoExtractionUtil.h:56
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54