Adding rotation support for offsets
This commit is contained in:
@@ -503,7 +503,8 @@ void RoadLinesData::update_line_segments(const String &line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RoadLinesData::line_add_building(const String &line, const String &key,
|
void RoadLinesData::line_add_building(const String &line, const String &key,
|
||||||
float curve_offset, float normal_offset)
|
float curve_offset, float normal_offset,
|
||||||
|
float y_rotation)
|
||||||
{
|
{
|
||||||
int index = BuildingsData::get_singleton()->get_building_by_key(key);
|
int index = BuildingsData::get_singleton()->get_building_by_key(key);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
@@ -513,6 +514,7 @@ void RoadLinesData::line_add_building(const String &line, const String &key,
|
|||||||
lb.building_key_hash = key.hash64();
|
lb.building_key_hash = key.hash64();
|
||||||
lb.line_offset = curve_offset;
|
lb.line_offset = curve_offset;
|
||||||
lb.normal_offset = normal_offset;
|
lb.normal_offset = normal_offset;
|
||||||
|
lb.y_rotation = y_rotation;
|
||||||
lines[line].buildings.push_back(lb);
|
lines[line].buildings.push_back(lb);
|
||||||
// TODO: save/load
|
// TODO: save/load
|
||||||
BuildingsData::get_singleton()->buildings[index].line_name = line;
|
BuildingsData::get_singleton()->buildings[index].line_name = line;
|
||||||
@@ -606,8 +608,14 @@ void RoadLinesData::assign_close_buildings(const String &line)
|
|||||||
print_line("adding: key: " + building_key +
|
print_line("adding: key: " + building_key +
|
||||||
" dst: " + String::num(dst));
|
" dst: " + String::num(dst));
|
||||||
assert(result_offset >= 0);
|
assert(result_offset >= 0);
|
||||||
|
Vector3 reference(0, 0, -1);
|
||||||
|
Vector3 rotated =
|
||||||
|
data.xform.basis.xform(reference).normalized();
|
||||||
|
float angle = reference.signed_angle_to(
|
||||||
|
rotated, Vector3(0, 1, 0));
|
||||||
|
|
||||||
line_add_building(line, building_key, result_offset,
|
line_add_building(line, building_key, result_offset,
|
||||||
side);
|
side, angle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
uint64_t building_key_hash;
|
uint64_t building_key_hash;
|
||||||
float line_offset;
|
float line_offset;
|
||||||
float normal_offset;
|
float normal_offset;
|
||||||
|
float y_rotation;
|
||||||
};
|
};
|
||||||
struct line_segment {
|
struct line_segment {
|
||||||
Vector3 p1;
|
Vector3 p1;
|
||||||
@@ -55,7 +56,8 @@ public:
|
|||||||
int get_debug_flags() const;
|
int get_debug_flags() const;
|
||||||
void update_line_segments(const String &line);
|
void update_line_segments(const String &line);
|
||||||
void line_add_building(const String &line, const String &key,
|
void line_add_building(const String &line, const String &key,
|
||||||
float curve_offset, float normal_offset);
|
float curve_offset, float normal_offset,
|
||||||
|
float y_rotation);
|
||||||
void assign_close_buildings(const String &line);
|
void assign_close_buildings(const String &line);
|
||||||
bool line_has_building(const String &line, const String &building_key);
|
bool line_has_building(const String &line, const String &building_key);
|
||||||
Vector3 get_point_by_offsets(const String &line, float dir_offset,
|
Vector3 get_point_by_offsets(const String &line, float dir_offset,
|
||||||
|
|||||||
Reference in New Issue
Block a user