17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 07:29:20 +02:00
Files
maszyna/widgets/map_objects.cpp
maj00r b8f040e6fd propagate template headers transitively, import Console where used
AnimModel.cpp reaches cParser through the simulation core, not a direct
import, so the previous pass missed it; the propagation now follows the
whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call
Console:: inside _WIN32 guards without importing eu07.console - invisible
on Linux, where those blocks are skipped.
2026-09-10 01:41:24 +02:00

72 lines
1.5 KiB
C++

module;
#include <chrono>
#include <cstddef>
#include <deque>
#include <limits>
#include <mutex>
#include <ostream>
#include <sstream>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <array>
#include <map>
#include <string>
#include <vector>
#include <memory>
#include "vehicle/DynObj_macros.h"
module eu07.widgets.map_objects;
import eu07.simulation.simulation;
map::objects map::Objects;
map::sorted_object_list map::objects::find_in_range(glm::vec3 from, float distance)
{
sorted_object_list items;
float max_distance2 = distance * distance;
for (auto const entry : entries)
{
glm::vec3 entry_location = entry->location;
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)
{
items.emplace(dist, entry);
}
}
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;
}