@@ -22,33 +22,6 @@ static const Fvector local_points[8] = {Fvector().set(-1.f, -1.f, -1.f), Fvector
2222
2323extern MagicBox3 MagicMinBox (int iQuantity, const Fvector* akPoint);
2424
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-
5225IC bool ai_obstacle::inside (const Fvector& position, const float & radius) const
5326{
5427 for (u32 i = 0 ; i < PLANE_COUNT; ++i)
@@ -233,7 +206,16 @@ void ai_obstacle::compute_impl()
233206 const_iterator E = level_graph.end ();
234207
235208 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+
237219 for (u32 x = x_min; x <= x_max; ++x)
238220 {
239221 for (u32 z = z_min; z <= z_max; ++z)
@@ -243,14 +225,14 @@ void ai_obstacle::compute_impl()
243225 if ((I == E) || ((*I).position ().xz () != xz))
244226 continue ;
245227
246- predicate (*I);
228+ merge (*I);
247229
248230 for (++I; I != E; ++I)
249231 {
250232 if ((*I).position ().xz () != xz)
251233 break ;
252234
253- predicate (*I);
235+ merge (*I);
254236 }
255237 }
256238 }
0 commit comments