85 lines
2.5 KiB
C++
85 lines
2.5 KiB
C++
#ifndef ROAD_LINES_DATA_H
|
|
#define ROAD_LINES_DATA_H
|
|
#include "callable.h"
|
|
class ImmediateGeometry;
|
|
class RoadLinesData {
|
|
int debug_flags;
|
|
String road_lines_path;
|
|
uint32_t road_lines_hash(const Vector3 &v);
|
|
static ImmediateGeometry *debug_im;
|
|
|
|
protected:
|
|
RoadLinesData();
|
|
static RoadLinesData *singleton;
|
|
_Signal<void> lines_updated;
|
|
|
|
public:
|
|
struct line_building_data {
|
|
String building_key;
|
|
uint64_t building_key_hash;
|
|
float line_offset;
|
|
float normal_offset;
|
|
float y_rotation;
|
|
};
|
|
struct line_segment {
|
|
Vector3 p1;
|
|
Vector3 p2;
|
|
float length;
|
|
Vector3 dir;
|
|
Vector3 tangent;
|
|
float offset;
|
|
};
|
|
struct road_line {
|
|
std::vector<Transform> points;
|
|
std::vector<int> indices;
|
|
std::vector<struct line_building_data> buildings;
|
|
std::vector<struct line_segment> segments;
|
|
int lanes;
|
|
int pattern;
|
|
int flags;
|
|
Dictionary metadata;
|
|
_Signal<void> line_updated;
|
|
};
|
|
static ImmediateGeometry *get_debug_node();
|
|
HashMap<String, struct road_line> lines;
|
|
HashMap<String, Ref<Curve3D> > curves;
|
|
static RoadLinesData *get_singleton();
|
|
virtual ~RoadLinesData();
|
|
static void cleanup();
|
|
String get_road_lines_path();
|
|
void get_road_lines_key_list(List<String> *keys);
|
|
void save_data();
|
|
void process_lines(std::unordered_map<uint32_t, std::vector<Vector3> >
|
|
&road_lines_nodes_hash,
|
|
std::vector<Vector3> &road_lines_nodes);
|
|
void set_debug_flags(int debug_flags);
|
|
int get_debug_flags() const;
|
|
void update_line_segments(const String &line);
|
|
void line_add_building(const String &line, const String &key,
|
|
float curve_offset, float normal_offset,
|
|
float y_rotation);
|
|
void assign_close_buildings(const String &line);
|
|
bool line_has_building(const String &line, const String &building_key);
|
|
Vector3 get_point_by_offsets(const String &line, float dir_offset,
|
|
float normal_offset);
|
|
|
|
private:
|
|
void create_segments_from_lines();
|
|
void index_lines(std::unordered_map<uint32_t, std::vector<Vector3> >
|
|
&road_lines_nodes_hash,
|
|
std::vector<Vector3> &road_lines_nodes);
|
|
|
|
void create_segments(const String &road, std::vector<int> &segments);
|
|
void insert_close_points(std::vector<Vector3> &road_lines_nodes,
|
|
float distance_squared);
|
|
|
|
void update_road_lines_nodes(std::vector<Vector3> &road_lines_nodes);
|
|
|
|
void dump_road_lines(const std::vector<Vector3> &road_lines_nodes);
|
|
void road_lines_curve_index(
|
|
struct RoadLinesData::road_line &rline,
|
|
std::unordered_map<uint32_t, std::vector<Vector3> >
|
|
&road_lines_nodes_hash,
|
|
std::vector<Vector3> &road_lines_nodes);
|
|
};
|
|
#endif |