16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 12:19:19 +02:00

ai alert mode

This commit is contained in:
milek7
2019-04-10 10:45:22 +02:00
parent ef3a66dc0b
commit 7261fe9fbd
9 changed files with 172 additions and 14 deletions

View File

@@ -1,5 +1,7 @@
#include "stdafx.h"
#include "widgets/map_objects.h"
#include "simulation.h"
#include "DynObj.h"
map::objects map::Objects;
@@ -27,5 +29,28 @@ map::sorted_object_list map::objects::find_in_range(glm::vec3 from, float distan
}
}
for (TDynamicObject *dynobj : simulation::Vehicles.sequence()) {
if (!dynobj->Controller || dynobj->Prev())
continue;
glm::vec3 entry_location = dynobj->GetPosition();
glm::vec3 search_point = from;
if (glm::isnan(from.y))
{
entry_location.y = 0.0f;
search_point.y = 0.0f;
}
float dist = glm::distance2(entry_location, search_point);
if (dist < max_distance2)
{
auto entry = std::make_shared<map::vehicle>();
entry->dynobj = dynobj;
entry->name = dynobj->name();
items.emplace(dist, std::move(entry));
}
}
return items;
}