Merge branch 'master' into sensor-interface#200

This commit is contained in:
juaxix 2018-03-01 16:50:08 +01:00 committed by GitHub
commit a84debd50f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 32 deletions

View File

@ -94,13 +94,6 @@ F.A.Q.
If you run into problems, check our If you run into problems, check our
[FAQ](http://carla.readthedocs.io/en/latest/faq/). [FAQ](http://carla.readthedocs.io/en/latest/faq/).
Jobs
----
We are currently looking for a new programmer to join our team
* [C++ (UE4) Programmer](https://drive.google.com/open?id=1Hx0eUgpXl95d4IL9meEGhJECgSRos1T1)
License License
------- -------

View File

@ -16,11 +16,32 @@
#include "Paths.h" #include "Paths.h"
#include <algorithm> #include <algorithm>
#include <unordered_set>
#ifdef CARLA_ROAD_GENERATOR_EXTRA_LOG #ifdef CARLA_ROAD_GENERATOR_EXTRA_LOG
#include <sstream> #include <sstream>
#endif // CARLA_ROAD_GENERATOR_EXTRA_LOG #endif // CARLA_ROAD_GENERATOR_EXTRA_LOG
// =============================================================================
// -- Private types ------------------------------------------------------------
// =============================================================================
class FHalfEdgeCounter {
public:
using HalfEdge = MapGen::DoublyConnectedEdgeList::HalfEdge;
bool Insert(const HalfEdge &InHalfEdge)
{
return Set.insert(&InHalfEdge).second &&
Set.insert(&MapGen::DoublyConnectedEdgeList::GetPair(InHalfEdge)).second;
}
private:
std::unordered_set<const HalfEdge *> Set;
};
// ============================================================================= // =============================================================================
// -- Constructor and destructor ----------------------------------------------- // -- Constructor and destructor -----------------------------------------------
// ============================================================================= // =============================================================================
@ -135,35 +156,39 @@ void ACityMapGenerator::GenerateRoads()
const uint32 margin = CityMapMeshTag::GetRoadIntersectionSize() / 2u; const uint32 margin = CityMapMeshTag::GetRoadIntersectionSize() / 2u;
FHalfEdgeCounter HalfEdgeCounter;
// For each edge add road segment. // For each edge add road segment.
for (auto &edge : graph.GetHalfEdges()) { for (auto &edge : graph.GetHalfEdges()) {
auto source = Graph::GetSource(edge).GetPosition(); if (HalfEdgeCounter.Insert(edge)) {
auto target = Graph::GetTarget(edge).GetPosition(); auto source = Graph::GetSource(edge).GetPosition();
auto target = Graph::GetTarget(edge).GetPosition();
if (source.x == target.x) { if (source.x == target.x) {
// vertical // vertical
auto y = 1u + margin + std::min(source.y, target.y); auto y = 1u + margin + std::min(source.y, target.y);
auto end = std::max(source.y, target.y) - margin; auto end = std::max(source.y, target.y) - margin;
for (; y < end; ++y) { for (; y < end; ++y) {
AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneLeft, source.x, y, HALF_PI); AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneLeft, source.x, y, HALF_PI);
AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneRight, source.x, y, HALF_PI); AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneRight, source.x, y, HALF_PI);
AddInstance(ECityMapMeshTag::RoadTwoLanes_SidewalkLeft, source.x, y, HALF_PI); AddInstance(ECityMapMeshTag::RoadTwoLanes_SidewalkLeft, source.x, y, HALF_PI);
AddInstance(ECityMapMeshTag::RoadTwoLanes_SidewalkRight, source.x, y, HALF_PI); AddInstance(ECityMapMeshTag::RoadTwoLanes_SidewalkRight, source.x, y, HALF_PI);
AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneMarkingBroken, source.x, y, HALF_PI); AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneMarkingBroken, source.x, y, HALF_PI);
}
} else if (source.y == target.y) {
// horizontal
auto x = 1u + margin + std::min(source.x, target.x);
auto end = std::max(source.x, target.x) - margin;
for (; x < end; ++x) {
AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneLeft, x, source.y);
AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneRight, x, source.y);
AddInstance(ECityMapMeshTag::RoadTwoLanes_SidewalkLeft, x, source.y);
AddInstance(ECityMapMeshTag::RoadTwoLanes_SidewalkRight, x, source.y);
AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneMarkingBroken, x, source.y);
}
} else {
UE_LOG(LogCarla, Warning, TEXT("Diagonal edge ignored"));
} }
} else if (source.y == target.y) {
// horizontal
auto x = 1u + margin + std::min(source.x, target.x);
auto end = std::max(source.x, target.x) - margin;
for (; x < end; ++x) {
AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneLeft, x, source.y);
AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneRight, x, source.y);
AddInstance(ECityMapMeshTag::RoadTwoLanes_SidewalkLeft, x, source.y);
AddInstance(ECityMapMeshTag::RoadTwoLanes_SidewalkRight, x, source.y);
AddInstance(ECityMapMeshTag::RoadTwoLanes_LaneMarkingBroken, x, source.y);
}
} else {
UE_LOG(LogCarla, Warning, TEXT("Diagonal edge ignored"));
} }
} }