Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
BroadPhaseLayerInterfaceTable.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2023 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
8
10
15{
16public:
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 // JPH_EXTERNAL_PROFILE || JPH_PROFILE_ENABLED
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 // JPH_EXTERNAL_PROFILE || JPH_PROFILE_ENABLED
55
56private:
57 uint mNumBroadPhaseLayers;
58 Array<BroadPhaseLayer> mObjectToBroadPhase;
59#if defined(JPH_EXTERNAL_PROFILE) || defined(JPH_PROFILE_ENABLED)
60 Array<const char *> mBroadPhaseLayerNames;
61#endif // JPH_EXTERNAL_PROFILE || JPH_PROFILE_ENABLED
62};
63
unsigned int uint
Definition Core.h:453
#define JPH_NAMESPACE_END
Definition Core.h:379
#define JPH_NAMESPACE_BEGIN
Definition Core.h:373
#define JPH_ASSERT(...)
Definition IssueReporting.h:33
#define JPH_OVERRIDE_NEW_DELETE
Macro to override the new and delete functions.
Definition Memory.h:31
uint16 ObjectLayer
Definition ObjectLayer.h:16
Definition Array.h:36
void resize(size_type inNewSize)
Resize array to new length.
Definition Array.h:120
Definition BroadPhaseLayer.h:18
uint8 Type
Definition BroadPhaseLayer.h:20
Interface that the application should implement to allow mapping object layers to broadphase layers.
Definition BroadPhaseLayer.h:61
Definition BroadPhaseLayerInterfaceTable.h:15
virtual BroadPhaseLayer GetBroadPhaseLayer(ObjectLayer inLayer) const override
Convert an object layer to the corresponding broadphase layer.
Definition BroadPhaseLayerInterfaceTable.h:39
virtual uint GetNumBroadPhaseLayers() const override
Return the number of broadphase layers there are.
Definition BroadPhaseLayerInterfaceTable.h:34
void MapObjectToBroadPhaseLayer(ObjectLayer inObjectLayer, BroadPhaseLayer inBroadPhaseLayer)
Definition BroadPhaseLayerInterfaceTable.h:28
void SetBroadPhaseLayerName(BroadPhaseLayer inLayer, const char *inName)
Definition BroadPhaseLayerInterfaceTable.h:45
virtual const char * GetBroadPhaseLayerName(BroadPhaseLayer inLayer) const override
Get the user readable name of a broadphase layer (debugging purposes)
Definition BroadPhaseLayerInterfaceTable.h:50
JPH_OVERRIDE_NEW_DELETE BroadPhaseLayerInterfaceTable(uint inNumObjectLayers, uint inNumBroadPhaseLayers)
Definition BroadPhaseLayerInterfaceTable.h:19