| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <Jolt/Physics/Collision/BroadPhase/BroadPhaseLayer.h> |
| 8 |
|
| 9 |
JPH_NAMESPACE_BEGIN |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
class BroadPhaseLayerInterfaceTable : public BroadPhaseLayerInterface |
| 15 |
{ |
| 16 |
public: |
| 17 |
JPH_OVERRIDE_NEW_DELETE |
| 18 |
|
| 19 |
BroadPhaseLayerInterfaceTable(uint inNumObjectLayers, uint inNumBroadPhaseLayers) : |
| 20 |
mNumBroadPhaseLayers(inNumBroadPhaseLayers) |
| 21 |
{ |
| 22 |
mObjectToBroadPhase.resize(inNumObjectLayers, BroadPhaseLayer(0)); |
| 23 |
#if defined(JPH_EXTERNAL_PROFILE) || defined(JPH_PROFILE_ENABLED) |
| 24 |
mBroadPhaseLayerNames.resize(inNumBroadPhaseLayers, "Undefined"); |
| 25 |
#endif |
| 26 |
} |
| 27 |
|
| 28 |
void MapObjectToBroadPhaseLayer(ObjectLayer inObjectLayer, BroadPhaseLayer inBroadPhaseLayer) |
| 29 |
{ |
| 30 |
JPH_ASSERT((BroadPhaseLayer::Type)inBroadPhaseLayer < mNumBroadPhaseLayers); |
| 31 |
mObjectToBroadPhase[inObjectLayer] = inBroadPhaseLayer; |
| 32 |
} |
| 33 |
|
| 34 |
virtual uint GetNumBroadPhaseLayers() const override |
| 35 |
{ |
| 36 |
return mNumBroadPhaseLayers; |
| 37 |
} |
| 38 |
|
| 39 |
virtual BroadPhaseLayer GetBroadPhaseLayer(ObjectLayer inLayer) const override |
| 40 |
{ |
| 41 |
return mObjectToBroadPhase[inLayer]; |
| 42 |
} |
| 43 |
|
| 44 |
#if defined(JPH_EXTERNAL_PROFILE) || defined(JPH_PROFILE_ENABLED) |
| 45 |
void SetBroadPhaseLayerName(BroadPhaseLayer inLayer, const char *inName) |
| 46 |
{ |
| 47 |
mBroadPhaseLayerNames[(BroadPhaseLayer::Type)inLayer] = inName; |
| 48 |
} |
| 49 |
|
| 50 |
virtual const char * GetBroadPhaseLayerName(BroadPhaseLayer inLayer) const override |
| 51 |
{ |
| 52 |
return mBroadPhaseLayerNames[(BroadPhaseLayer::Type)inLayer]; |
| 53 |
} |
| 54 |
#endif |
| 55 |
|
| 56 |
private: |
| 57 |
uint mNumBroadPhaseLayers; |
| 58 |
Array<BroadPhaseLayer> mObjectToBroadPhase; |
| 59 |
#if defined(JPH_EXTERNAL_PROFILE) || defined(JPH_PROFILE_ENABLED) |
| 60 |
Array<const char *> mBroadPhaseLayerNames; |
| 61 |
#endif |
| 62 |
}; |
| 63 |
|
| 64 |
JPH_NAMESPACE_END |