-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLayers.h
135 lines (133 loc) · 4.84 KB
/
Layers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
// SPDX-License-Identifier: MIT
#pragma once
#include <Jolt/Physics/Collision/ObjectLayer.h>
#include <Jolt/Physics/Collision/BroadPhase/BroadPhaseLayer.h>
//
///// Layer that objects can be in, determines which other objects it can collide with
//namespace Layers
//{
// static constexpr ObjectLayer UNUSED1 = 0; // 4 unused values so that broadphase layers values don't match with object layer values (for testing purposes)
// static constexpr ObjectLayer UNUSED2 = 1;
// static constexpr ObjectLayer UNUSED3 = 2;
// static constexpr ObjectLayer UNUSED4 = 3;
// static constexpr ObjectLayer NON_MOVING = 4;
// static constexpr ObjectLayer MOVING = 5;
// static constexpr ObjectLayer DEBRIS = 6; // Example: Debris collides only with NON_MOVING
// static constexpr ObjectLayer SENSOR = 7; // Sensors only collide with MOVING objects
// static constexpr ObjectLayer NUM_LAYERS = 8;
//};
//
///// Class that determines if two object layers can collide
//class ObjectLayerPairFilterImpl : public ObjectLayerPairFilter
//{
//public:
// virtual bool ShouldCollide(ObjectLayer inObject1, ObjectLayer inObject2) const override
// {
// switch (inObject1)
// {
// case Layers::UNUSED1:
// case Layers::UNUSED2:
// case Layers::UNUSED3:
// case Layers::UNUSED4:
// return false;
// case Layers::NON_MOVING:
// return inObject2 == Layers::MOVING || inObject2 == Layers::DEBRIS;
// case Layers::MOVING:
// return inObject2 == Layers::NON_MOVING || inObject2 == Layers::MOVING || inObject2 == Layers::SENSOR;
// case Layers::DEBRIS:
// return inObject2 == Layers::NON_MOVING;
// case Layers::SENSOR:
// return inObject2 == Layers::MOVING;
// default:
// JPH_ASSERT(false);
// return false;
// }
// }
//};
//
///// Broadphase layers
//namespace BroadPhaseLayers
//{
// static constexpr BroadPhaseLayer NON_MOVING(0);
// static constexpr BroadPhaseLayer MOVING(1);
// static constexpr BroadPhaseLayer DEBRIS(2);
// static constexpr BroadPhaseLayer SENSOR(3);
// static constexpr BroadPhaseLayer UNUSED(4);
// static constexpr uint NUM_LAYERS(5);
//};
//
///// BroadPhaseLayerInterface implementation
//class BPLayerInterfaceImpl final : public BroadPhaseLayerInterface
//{
//public:
// BPLayerInterfaceImpl()
// {
// // Create a mapping table from object to broad phase layer
// mObjectToBroadPhase[Layers::UNUSED1] = BroadPhaseLayers::UNUSED;
// mObjectToBroadPhase[Layers::UNUSED2] = BroadPhaseLayers::UNUSED;
// mObjectToBroadPhase[Layers::UNUSED3] = BroadPhaseLayers::UNUSED;
// mObjectToBroadPhase[Layers::UNUSED4] = BroadPhaseLayers::UNUSED;
// mObjectToBroadPhase[Layers::NON_MOVING] = BroadPhaseLayers::NON_MOVING;
// mObjectToBroadPhase[Layers::MOVING] = BroadPhaseLayers::MOVING;
// mObjectToBroadPhase[Layers::DEBRIS] = BroadPhaseLayers::DEBRIS;
// mObjectToBroadPhase[Layers::SENSOR] = BroadPhaseLayers::SENSOR;
// }
//
// virtual uint GetNumBroadPhaseLayers() const override
// {
// return BroadPhaseLayers::NUM_LAYERS;
// }
//
// virtual BroadPhaseLayer GetBroadPhaseLayer(ObjectLayer inLayer) const override
// {
// JPH_ASSERT(inLayer < Layers::NUM_LAYERS);
// return mObjectToBroadPhase[inLayer];
// }
//
//#if defined(JPH_EXTERNAL_PROFILE) || defined(JPH_PROFILE_ENABLED)
// virtual const char * GetBroadPhaseLayerName(BroadPhaseLayer inLayer) const override
// {
// switch ((BroadPhaseLayer::Type)inLayer)
// {
// case (BroadPhaseLayer::Type)BroadPhaseLayers::NON_MOVING: return "NON_MOVING";
// case (BroadPhaseLayer::Type)BroadPhaseLayers::MOVING: return "MOVING";
// case (BroadPhaseLayer::Type)BroadPhaseLayers::DEBRIS: return "DEBRIS";
// case (BroadPhaseLayer::Type)BroadPhaseLayers::SENSOR: return "SENSOR";
// case (BroadPhaseLayer::Type)BroadPhaseLayers::UNUSED: return "UNUSED";
// default: JPH_ASSERT(false); return "INVALID";
// }
// }
//#endif // JPH_EXTERNAL_PROFILE || JPH_PROFILE_ENABLED
//
//private:
// BroadPhaseLayer mObjectToBroadPhase[Layers::NUM_LAYERS];
//};
//
///// Class that determines if an object layer can collide with a broadphase layer
//class ObjectVsBroadPhaseLayerFilterImpl : public ObjectVsBroadPhaseLayerFilter
//{
//public:
// virtual bool ShouldCollide(ObjectLayer inLayer1, BroadPhaseLayer inLayer2) const override
// {
// switch (inLayer1)
// {
// case Layers::NON_MOVING:
// return inLayer2 == BroadPhaseLayers::MOVING;
// case Layers::MOVING:
// return inLayer2 == BroadPhaseLayers::NON_MOVING || inLayer2 == BroadPhaseLayers::MOVING || inLayer2 == BroadPhaseLayers::SENSOR;
// case Layers::DEBRIS:
// return inLayer2 == BroadPhaseLayers::NON_MOVING;
// case Layers::SENSOR:
// return inLayer2 == BroadPhaseLayers::MOVING;
// case Layers::UNUSED1:
// case Layers::UNUSED2:
// case Layers::UNUSED3:
// return false;
// default:
// JPH_ASSERT(false);
// return false;
// }
// }
//};