34
34
#include " ../jolt_project_settings.h"
35
35
#include " jolt_space_3d.h"
36
36
37
- #include " core/templates/local_vector.h"
38
-
39
37
#include " Jolt/Jolt.h"
40
38
39
+ #include " Jolt/Core/STLLocalAllocator.h"
41
40
#include " Jolt/Physics/Collision/InternalEdgeRemovingCollector.h"
42
41
#include " Jolt/Physics/Collision/Shape/Shape.h"
43
42
44
43
template <typename TBase, int TDefaultCapacity>
45
44
class JoltQueryCollectorAll final : public TBase {
46
45
public:
47
46
typedef typename TBase::ResultType Hit;
47
+ typedef JPH::Array<Hit, JPH::STLLocalAllocator<Hit, TDefaultCapacity>> HitArray;
48
48
49
49
private:
50
- JPH::Array<Hit> hits;
50
+ HitArray hits;
51
51
52
52
public:
53
+ JoltQueryCollectorAll () {
54
+ hits.reserve (TDefaultCapacity);
55
+ }
56
+
53
57
bool had_hit () const {
54
58
return !hits.is_empty ();
55
59
}
@@ -109,14 +113,17 @@ template <typename TBase, int TDefaultCapacity>
109
113
class JoltQueryCollectorAnyMulti final : public TBase {
110
114
public:
111
115
typedef typename TBase::ResultType Hit;
116
+ typedef JPH::Array<Hit, JPH::STLLocalAllocator<Hit, TDefaultCapacity>> HitArray;
112
117
113
118
private:
114
- JPH::Array<Hit> hits;
119
+ HitArray hits;
115
120
int max_hits = 0 ;
116
121
117
122
public:
118
123
explicit JoltQueryCollectorAnyMulti (int p_max_hits = TDefaultCapacity) :
119
- max_hits(p_max_hits) {}
124
+ max_hits(p_max_hits) {
125
+ hits.reserve (TDefaultCapacity);
126
+ }
120
127
121
128
bool had_hit () const {
122
129
return hits.size () > 0 ;
@@ -189,14 +196,17 @@ template <typename TBase, int TDefaultCapacity>
189
196
class JoltQueryCollectorClosestMulti final : public TBase {
190
197
public:
191
198
typedef typename TBase::ResultType Hit;
199
+ typedef JPH::Array<Hit, JPH::STLLocalAllocator<Hit, TDefaultCapacity + 1 >> HitArray;
192
200
193
201
private:
194
- JPH::Array<Hit> hits;
202
+ HitArray hits;
195
203
int max_hits = 0 ;
196
204
197
205
public:
198
206
explicit JoltQueryCollectorClosestMulti (int p_max_hits = TDefaultCapacity) :
199
- max_hits(p_max_hits) {}
207
+ max_hits(p_max_hits) {
208
+ hits.reserve (TDefaultCapacity + 1 );
209
+ }
200
210
201
211
bool had_hit () const {
202
212
return hits.size () > 0 ;
@@ -220,7 +230,7 @@ class JoltQueryCollectorClosestMulti final : public TBase {
220
230
}
221
231
222
232
virtual void AddHit (const Hit &p_hit) override {
223
- typename JPH::Array<Hit> ::const_iterator E = hits.cbegin ();
233
+ typename HitArray ::const_iterator E = hits.cbegin ();
224
234
for (; E != hits.cend (); ++E) {
225
235
if (p_hit.GetEarlyOutFraction () < E->GetEarlyOutFraction ()) {
226
236
break ;
0 commit comments