3#include <Core/Interfaces/NavmeshGeoWorldModule.h>
4#include <Core/Interfaces/PhysicsWorldModule.h>
5#include <Core/World/Declarations.h>
6#include <Core/World/WorldModule.h>
7#include <Foundation/Types/UniquePtr.h>
8#include <JoltPlugin/Declarations.h>
9#include <JoltPlugin/JoltPluginDLL.h>
10#include <JoltPlugin/System/JoltCollisionFiltering.h>
11#include <JoltPlugin/Utilities/JoltUserData.h>
12#include <RendererCore/Meshes/DynamicMeshBufferResource.h>
30 PL_DECLARE_WORLD_MODULE();
41 JPH::PhysicsSystem* GetJoltSystem() {
return m_pSystem.get(); }
42 const JPH::PhysicsSystem* GetJoltSystem()
const {
return m_pSystem.get(); }
44 plUInt32 CreateObjectFilterID();
45 void DeleteObjectFilterID(plUInt32& ref_uiObjectFilterID);
48 void DeallocateUserData(plUInt32& ref_uiUserDataId);
51 void SetGravity(
const plVec3& vObjectGravity,
const plVec3& vCharacterGravity);
52 virtual plVec3 GetGravity()
const override {
return plVec3(0, 0, -10); }
53 plVec3 GetCharacterGravity()
const {
return m_Settings.m_vCharacterGravity; }
69 virtual bool SweepTestCapsule(
plPhysicsCastResult& out_result,
float fCapsuleRadius,
float fCapsuleHeight,
const plTransform& transform,
const plVec3& vDir,
float fDistance,
const plPhysicsQueryParameters& params, plPhysicsHitCollection collection = plPhysicsHitCollection::Closest)
const override;
91 plUInt32 QueueBodyToAdd(JPH::Body* pBody,
bool bAwake);
97 bool IsBodyStillQueuedToAdd(plUInt32 uiBodiesAddCounter)
const {
return uiBodiesAddCounter == m_uiBodiesAddCounter; }
99 JPH::GroupFilter* GetGroupFilter()
const {
return m_pGroupFilter; }
100 JPH::GroupFilter* GetGroupFilterIgnoreSame()
const {
return m_pGroupFilterIgnoreSame; }
102 void EnableJoinedBodiesCollisions(plUInt32 uiObjectFilterID1, plUInt32 uiObjectFilterID2,
bool bEnable);
104 JPH::TempAllocator* GetTempAllocator()
const {
return m_pTempAllocator.get(); }
113 void CheckBreakableConstraints();
121 bool OverlapTest(
const JPH::Shape& shape,
const JPH::Mat44& transform,
const plPhysicsQueryParameters& params)
const;
123 void FreeUserDataAfterSimulationStep();
130 void UpdateSettingsCfg();
131 void ApplySettingsCfg();
133 void UpdateConstraints();
135 plTime CalculateUpdateSteps();
137 void DebugDrawGeometry();
138 void DebugDrawGeometry(
const plVec3& vCenter,
float fRadius, plPhysicsShapeType::Enum shapeType,
const plTag& tag);
143 plUInt32 m_uiLastSeenCounter = 0;
144 bool m_bMutableGeometry =
false;
151 plUInt32 m_uiLastSeenCounter = 0;
154 struct DebugBodyShapeKey
157 const void* m_pShapePtr;
159 bool operator<(
const DebugBodyShapeKey& rhs)
const
161 if (m_uiBodyID == rhs.m_uiBodyID)
162 return m_pShapePtr < rhs.m_pShapePtr;
164 return m_uiBodyID < rhs.m_uiBodyID;
167 bool operator==(
const DebugBodyShapeKey& rhs)
const
169 return (m_uiBodyID == rhs.m_uiBodyID) && (m_pShapePtr == rhs.m_pShapePtr);
173 plUInt32 m_uiDebugGeoLastSeenCounter = 0;
177 plUInt32 m_uiNextObjectFilterID = 1;
184 plTime m_AccumulatedTimeSinceUpdate;
190 plTime m_SimulatedTimeStep;
192 std::unique_ptr<JPH::PhysicsSystem> m_pSystem;
193 std::unique_ptr<JPH::TempAllocator> m_pTempAllocator;
199 void* m_pContactListener =
nullptr;
200 void* m_pActivationListener =
nullptr;
206 JPH::GroupFilter* m_pGroupFilter =
nullptr;
207 JPH::GroupFilter* m_pGroupFilterIgnoreSame =
nullptr;
209 plUInt32 m_uiBodiesAddedSinceOptimize = 100;
210 plUInt32 m_uiBodiesAddCounter = 1;
223 PL_DECLARE_WORLD_MODULE();
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition DynamicArray.h:81
This class represents an object inside the world.
Definition GameObject.h:32
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Base class for character controllers (CC).
Definition JoltCharacterControllerComponent.h:27
Implementation of the plNavmeshGeoWorldModuleInterface that uses Jolt physics to retrieve the geometr...
Definition JoltWorldModule.h:222
Definition JoltCollisionFiltering.h:95
Definition JoltCollisionFiltering.h:46
Definition JoltCollisionFiltering.h:87
Creates a physics ragdoll for an animated mesh and creates animation poses from the physics simulatio...
Definition JoltRagdollComponent.h:75
Creates a physically simulated rope that is made up of multiple segments.
Definition JoltRopeComponent.h:57
Definition JoltUserData.h:18
Definition JoltWorldModule.h:29
bool IsBodyStillQueuedToAdd(plUInt32 uiBodiesAddCounter) const
Checks whether the last QueueBodyToAdd() has been processed already, or not.
Definition JoltWorldModule.h:97
A world module that retrieves triangle data that should be used for building navmeshes at runtime.
Definition NavmeshGeoWorldModule.h:22
Definition PhysicsWorldModule.h:109
virtual void AddStaticCollisionBox(plGameObject *pOwner, plVec3 vBoxSize)
Adds a static actor with a box shape to pOwner.
Definition PhysicsWorldModule.h:150
virtual plUInt32 GetCollisionLayerByName(plStringView sName) const =0
Searches for a collision layer with the given name and returns its index.
virtual plBoundingBoxSphere GetWorldSpaceBounds(plGameObject *pOwner, plUInt32 uiCollisionLayer, plBitflags< plPhysicsShapeType > shapeTypes, bool bIncludeChildObjects) const
Gets world space bounds of a physics object if its shape type is included in shapeTypes and its colli...
Definition PhysicsWorldModule.h:168
virtual void AddFixedJointComponent(plGameObject *pOwner, const plPhysicsWorldModuleInterface::FixedJointConfig &cfg)
Adds a fixed joint to pOwner.
Definition PhysicsWorldModule.h:165
A Shared ptr manages a shared object and destroys that object when no one references it anymore....
Definition SharedPtr.h:10
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
The tag class stores the necessary lookup information for a single tag which can be used in conjuncti...
Definition Tag.h:16
Given out by plTaskSystem::CreateTaskGroup to identify a task group.
Definition TaskSystemDeclarations.h:103
Encapsulates a view on the given world through the given camera and rendered with the specified Rende...
Definition View.h:21
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
virtual void Initialize()
This method is called after the constructor. A derived type can override this method to do initializa...
Definition WorldModule.h:98
virtual void Deinitialize()
This method is called before the destructor. A derived type can override this method to do deinitiali...
Definition WorldModule.h:101
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
A handle to a game object.
Definition Declarations.h:76
Definition Declarations.h:75
Definition PhysicsWorldModule.h:43
Used for raycast and sweep tests.
Definition PhysicsWorldModule.h:23
Definition PhysicsWorldModule.h:63
Definition PhysicsWorldModule.h:86
Definition PhysicsWorldModule.h:161
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
Definition WorldModule.h:33