2#ifdef StevEngine_PHYSICS
3#include <unordered_map>
6#include <Jolt/Physics/Collision/BroadPhase/BroadPhaseLayer.h>
9namespace StevEngine::Physics {
10 typedef JPH::ObjectLayer LayerID;
12 namespace BroadPhaseLayers
15 static constexpr JPH::BroadPhaseLayer NON_MOVING(0);
17 static constexpr JPH::BroadPhaseLayer MOVING(1);
27 friend class LayerManager;
78 std::unordered_map<LayerID, Layer> layers;
109 virtual JPH::BroadPhaseLayer
GetBroadPhaseLayer(JPH::ObjectLayer inLayer)
const override;
126 virtual bool ShouldCollide(JPH::ObjectLayer inLayer1, JPH::BroadPhaseLayer inLayer2)
const override;
143 virtual bool ShouldCollide(JPH::ObjectLayer inObject1, JPH::ObjectLayer inObject2)
const override;
147template<>
struct std::hash<StevEngine::Physics::Layer> {
154 return std::hash<StevEngine::Physics::LayerID>()(k.
id);
virtual unsigned int GetNumBroadPhaseLayers() const override
Get number of broad phase layers.
Definition Layers.cpp:33
virtual JPH::BroadPhaseLayer GetBroadPhaseLayer(JPH::ObjectLayer inLayer) const override
Get broad phase layer for object layer.
Definition Layers.cpp:36
BPLayerInterfaceImpl()
Create broad phase interface.
Definition Layers.cpp:32
const Layer & GetLayer(LayerID id)
Get layer by ID.
Definition Layers.cpp:27
LayerID CreateLayer(bool isStatic=true)
Create a new physics layer.
Definition Layers.cpp:22
Physics collision layer.
Definition Layers.hpp:26
Layer(const Layer ©)
Copy physics layer.
Definition Layers.cpp:12
const bool isStatic
Whether objects are static.
Definition Layers.hpp:30
const JPH::BroadPhaseLayer BroadPhaseLayer
Broad phase settings.
Definition Layers.hpp:32
const LayerID id
Unique layer ID.
Definition Layers.hpp:31
Filter for object layer collisions.
Definition Layers.hpp:135
virtual bool ShouldCollide(JPH::ObjectLayer inObject1, JPH::ObjectLayer inObject2) const override
Check if layers should collide.
Definition Layers.cpp:47
Filter for broad phase layer collisions.
Definition Layers.hpp:118
virtual bool ShouldCollide(JPH::ObjectLayer inLayer1, JPH::BroadPhaseLayer inLayer2) const override
Check if layers should collide.
Definition Layers.cpp:39
std::size_t operator()(const StevEngine::Physics::Layer &k) const
Hash function for Physics layer.
Definition Layers.hpp:153