Improved straight mesh generation
This commit is contained in:
parent
393f6dd527
commit
b0038182e6
|
@ -988,19 +988,28 @@ namespace road {
|
||||||
lane.GetId(),
|
lane.GetId(),
|
||||||
lane_section.GetDistance() + EPSILON };
|
lane_section.GetDistance() + EPSILON };
|
||||||
|
|
||||||
// Iterate over the lane distance and store the vertices based on it's width
|
|
||||||
std::vector<geom::Vector3D> vertices;
|
std::vector<geom::Vector3D> vertices;
|
||||||
do {
|
if (IsLaneStraight(lane)) {
|
||||||
// Get the location of the edges of the current lane at the current waypoint
|
// Mesh optimization: If the lane is straight just add vertices at the
|
||||||
|
// begining and at the end of it
|
||||||
const auto edges = GetWaypointCornerPositions(*this, current_wp, lane);
|
const auto edges = GetWaypointCornerPositions(*this, current_wp, lane);
|
||||||
vertices.push_back(edges.first);
|
vertices.push_back(edges.first);
|
||||||
vertices.push_back(edges.second);
|
vertices.push_back(edges.second);
|
||||||
|
} else {
|
||||||
|
// Iterate over the lane's 's' and store the vertices based on it's width
|
||||||
|
do {
|
||||||
|
// Get the location of the edges of the current lane at the current waypoint
|
||||||
|
const auto edges = GetWaypointCornerPositions(*this, current_wp, lane);
|
||||||
|
vertices.push_back(edges.first);
|
||||||
|
vertices.push_back(edges.second);
|
||||||
|
|
||||||
// Update the current waypoint's "s"
|
// Update the current waypoint's "s"
|
||||||
current_wp.s += distance;
|
current_wp.s += distance;
|
||||||
} while(current_wp.s < end_distance);
|
} while(current_wp.s < end_distance);
|
||||||
|
}
|
||||||
|
|
||||||
// This ensures the mesh is constant and have no gaps between roads
|
// This ensures the mesh is constant and have no gaps between roads,
|
||||||
|
// adding geometry at the very end of the lane
|
||||||
if (end_distance - (current_wp.s - distance) > EPSILON) {
|
if (end_distance - (current_wp.s - distance) > EPSILON) {
|
||||||
current_wp.s = end_distance;
|
current_wp.s = end_distance;
|
||||||
const auto edges = GetWaypointCornerPositions(*this, current_wp, lane);
|
const auto edges = GetWaypointCornerPositions(*this, current_wp, lane);
|
||||||
|
|
Loading…
Reference in New Issue