@@ -22,33 +22,6 @@ static const Fvector local_points[8] = {Fvector().set(-1.f, -1.f, -1.f), Fvector
22
22
23
23
extern MagicBox3 MagicMinBox (int iQuantity, const Fvector* akPoint);
24
24
25
- struct merge_predicate
26
- {
27
- public:
28
- typedef moving_objects::AREA AREA;
29
-
30
- public:
31
- ai_obstacle* m_object;
32
- AREA* m_area;
33
- const CLevelGraph* m_level_graph;
34
-
35
- IC merge_predicate (ai_obstacle* object, AREA& area)
36
- {
37
- m_object = object;
38
- m_area = &area;
39
- m_level_graph = &ai ().level_graph ();
40
- }
41
-
42
- IC void operator ()(const CLevelGraph::CLevelVertex& vertex) const
43
- {
44
- u32 vertex_id = m_level_graph->vertex_id (&vertex);
45
- if (!m_object->inside (vertex_id))
46
- return ;
47
-
48
- m_area->push_back (vertex_id);
49
- }
50
- };
51
-
52
25
IC bool ai_obstacle::inside (const Fvector& position, const float & radius) const
53
26
{
54
27
for (u32 i = 0 ; i < PLANE_COUNT; ++i)
@@ -233,7 +206,16 @@ void ai_obstacle::compute_impl()
233
206
const_iterator E = level_graph.end ();
234
207
235
208
m_area.clear ();
236
- merge_predicate predicate (this , m_area);
209
+
210
+ const auto merge = [this , &level_graph](const CLevelGraph::CLevelVertex& vertex)
211
+ {
212
+ const u32 vertex_id = level_graph.vertex_id (&vertex);
213
+ if (!this ->inside (vertex_id))
214
+ return ;
215
+
216
+ m_area.emplace_back (vertex_id);
217
+ };
218
+
237
219
for (u32 x = x_min; x <= x_max; ++x)
238
220
{
239
221
for (u32 z = z_min; z <= z_max; ++z)
@@ -243,14 +225,14 @@ void ai_obstacle::compute_impl()
243
225
if ((I == E) || ((*I).position ().xz () != xz))
244
226
continue ;
245
227
246
- predicate (*I);
228
+ merge (*I);
247
229
248
230
for (++I; I != E; ++I)
249
231
{
250
232
if ((*I).position ().xz () != xz)
251
233
break ;
252
234
253
- predicate (*I);
235
+ merge (*I);
254
236
}
255
237
}
256
238
}
0 commit comments