diff --git a/CHANGELOG.md b/CHANGELOG.md index ea0b597ed..18ae81557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ * Upgraded to Unreal Engine 4.24 * Fixed autonomous agents' incorrect detection of red traffic lights affecting them - * Added walkable pedestrian crossings to OpenDRIVE standalone mode + * Added walkable pedestrian crosswalks in OpenDRIVE standalone mode * Improved manual_control by adding realistic throttle and brake * Added new Behavior agent diff --git a/LibCarla/source/carla/geom/Mesh.cpp b/LibCarla/source/carla/geom/Mesh.cpp index cfa9a0628..c9dccf9ac 100644 --- a/LibCarla/source/carla/geom/Mesh.cpp +++ b/LibCarla/source/carla/geom/Mesh.cpp @@ -306,10 +306,6 @@ namespace geom { return *this; } - // Mesh operator+(Mesh &lhs, const Mesh &rhs) { - // return lhs += rhs; - // } - Mesh operator+(const Mesh &lhs, const Mesh &rhs) { Mesh m = lhs; return m += rhs; diff --git a/LibCarla/source/carla/geom/Mesh.h b/LibCarla/source/carla/geom/Mesh.h index d068e9d0e..24b69a963 100644 --- a/LibCarla/source/carla/geom/Mesh.h +++ b/LibCarla/source/carla/geom/Mesh.h @@ -134,7 +134,6 @@ namespace geom { /// Merges two meshes into a single mesh Mesh &operator+=(const Mesh &rhs); - Mesh &operator+(const Mesh &rhs); friend Mesh operator+(const Mesh &lhs, const Mesh &rhs); @@ -153,18 +152,6 @@ namespace geom { std::vector _uvs; std::vector _materials; - -#ifdef LIBCARLA_INCLUDED_FROM_UE4 - - // Location(const FVector &vector) // from centimeters to meters. - // : Location(1e-2f * vector.X, 1e-2f * vector.Y, 1e-2f * vector.Z) {} - - // operator FVector() const { - // return FVector{1e2f * x, 1e2f * y, 1e2f * z}; // from meters to centimeters. - // } - -#endif // LIBCARLA_INCLUDED_FROM_UE4 - }; } // namespace geom diff --git a/LibCarla/source/carla/road/Map.cpp b/LibCarla/source/carla/road/Map.cpp index 4efff3428..d4b8146ab 100644 --- a/LibCarla/source/carla/road/Map.cpp +++ b/LibCarla/source/carla/road/Map.cpp @@ -941,34 +941,6 @@ namespace road { return _data.GetJunction(id); } - static void ExtrudeMeshEdge( - geom::Mesh &mesh, - geom::Vector3D new_vertex1, - geom::Vector3D new_vertex2, - size_t connection_index_1, - size_t connection_index_2) { - // Add the vertices - mesh.AddVertex(new_vertex1); - mesh.AddVertex(new_vertex2); - - // Find the indexes - const size_t last_index = mesh.GetLastVertexIndex(); - const size_t bottom_left_index = connection_index_1; // local quad index: 1 - const size_t bottom_right_index = connection_index_2; // local quad index: 2 - const size_t top_left_index = last_index - 1; // local quad index: 3 - const size_t top_right_index = last_index; // local quad index: 4 - - // Vertex order is counter clockwise: - // First triangle: 1 -> 2 -> 4 - mesh.AddIndex(bottom_left_index); // local quad index: 1 - mesh.AddIndex(bottom_right_index); // local quad index: 2 - mesh.AddIndex(top_right_index); // local quad index: 4 - // Second triangle: 1 -> 4 -> 3 - mesh.AddIndex(bottom_left_index); // local quad index: 1 - mesh.AddIndex(top_right_index); // local quad index: 4 - mesh.AddIndex(top_left_index); // local quad index: 3 - } - /// Computes the location of the edges of the current lane at the current waypoint static std::pair GetWaypointCornerPositions( const Map &map, const Waypoint &waypoint, const Lane &lane) { @@ -1016,42 +988,29 @@ namespace road { lane.GetId(), lane_section.GetDistance() + EPSILON }; - if (lane.GetType() == Lane::LaneType::Sidewalk) { - out_mesh.AddMaterial("sidewalk"); - } else { - out_mesh.AddMaterial("road"); - } + // Iterate over the lane distance and store the vertices based on it's width + std::vector vertices; + 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); - std::pair edges; - if (!IsLaneStraight(lane)) { - do { - // Get the location of the edges of the current lane at the current waypoint - edges = GetWaypointCornerPositions(*this, current_wp, lane); - if (out_mesh.GetVerticesNum() < 2) { - // Add 2 first vertices only - out_mesh.AddVertex(edges.first); - out_mesh.AddVertex(edges.second); - } else { - // Extrude adding vertices and joining the using indices - const size_t last_index = out_mesh.GetLastVertexIndex(); - ExtrudeMeshEdge( - out_mesh, edges.first, edges.second, last_index - 1, last_index); - } + // Update the current waypoint's "s" + current_wp.s += distance; + } while(current_wp.s < end_distance); - // Update the current waypoint's "s" - current_wp.s += distance; - - } while(current_wp.s < end_distance); - } - // This ensures the mesh is constant and have no gaps between - // segments and roads + // This ensures the mesh is constant and have no gaps between roads if (end_distance - (current_wp.s - distance) > EPSILON) { current_wp.s = end_distance; - edges = GetWaypointCornerPositions(*this, current_wp, lane); - const size_t last_index = out_mesh.GetLastVertexIndex(); - ExtrudeMeshEdge( - out_mesh, edges.first, edges.second, last_index - 1, last_index); + const auto edges = GetWaypointCornerPositions(*this, current_wp, lane); + vertices.push_back(edges.first); + vertices.push_back(edges.second); } + // Add the adient material, create the strip and close the material + out_mesh.AddMaterial( + lane.GetType() == Lane::LaneType::Sidewalk ? "sidewalk" : "road"); + out_mesh.AddTriangleStrip(vertices); out_mesh.EndMaterial(); } } diff --git a/LibCarla/source/carla/road/Map.h b/LibCarla/source/carla/road/Map.h index 3f06cb0f9..2da7f4312 100644 --- a/LibCarla/source/carla/road/Map.h +++ b/LibCarla/source/carla/road/Map.h @@ -20,15 +20,6 @@ #include -// TODO delete this -#include -#include -#include -// - - - - namespace carla { namespace road { @@ -43,17 +34,6 @@ namespace road { Map(MapData m) : _data(std::move(m)) { CreateRtree(); - // todo: delete ----------- - // | | | | - // v v v v - - std::ofstream out_road("road.obj"); - out_road << GenerateMesh(2).GenerateOBJForRecast(); - out_road.close(); - - std::ofstream out_cross("cross.obj"); - out_cross << GetAllCrosswalkMesh().GenerateOBJForRecast(); - out_cross.close(); } /// ========================================================================