Expand the number of tags for city generation meshes
This commit is contained in:
parent
7f456d1e2b
commit
5f9d83de36
|
@ -102,12 +102,6 @@ void ACityMapGenerator::GenerateGraph() {
|
|||
}
|
||||
|
||||
void ACityMapGenerator::GenerateRoads() {
|
||||
constexpr auto basicRoadTag = ECityMapMeshTag::RoadTwoLanes;
|
||||
constexpr auto basicIntersectionTag = ECityMapMeshTag::RoadXIntersection;
|
||||
|
||||
// Rotation for vertical roads.
|
||||
const FQuat rotation(FVector(0.0f, 0.0f, 1.0f), HALF_PI);
|
||||
|
||||
check(Dcel != nullptr);
|
||||
using Graph = MapGen::DoublyConnectedEdgeList;
|
||||
const Graph &graph = *Dcel;
|
||||
|
@ -124,46 +118,53 @@ void ACityMapGenerator::GenerateRoads() {
|
|||
auto y = 1u + margin + std::min(source.y, target.y);
|
||||
auto end = std::max(source.y, target.y) - margin;
|
||||
for (; y < end; ++y) {
|
||||
AddInstance(basicRoadTag, 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_SidewalkLeft, source.x, y, HALF_PI);
|
||||
AddInstance(ECityMapMeshTag::RoadTwoLanes_SidewalkRight, 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(basicRoadTag, x, source.y);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
UE_LOG(LogCarla, Warning, TEXT("Diagonal edge ignored"));
|
||||
}
|
||||
}
|
||||
|
||||
#define ADD_INTERSECTION(tag, x, y, angle) \
|
||||
AddInstance(tag ##_Lane0, x, y, angle); \
|
||||
AddInstance(tag ##_Lane1, x, y, angle); \
|
||||
AddInstance(tag ##_Lane2, x, y, angle); \
|
||||
AddInstance(tag ##_Lane3, x, y, angle); \
|
||||
AddInstance(tag ##_Sidewalk0, x, y, angle); \
|
||||
AddInstance(tag ##_Sidewalk1, x, y, angle); \
|
||||
AddInstance(tag ##_Sidewalk2, x, y, angle); \
|
||||
AddInstance(tag ##_Sidewalk3, x, y, angle);
|
||||
|
||||
// For each node add the intersection.
|
||||
for (auto &node : graph.GetNodes()) {
|
||||
const auto coords = node.GetPosition();
|
||||
ECityMapMeshTag tag = basicIntersectionTag;
|
||||
switch (node.IntersectionType) {
|
||||
case MapGen::EIntersectionType::Turn90Deg:
|
||||
tag = ECityMapMeshTag::Road90DegTurn;
|
||||
ADD_INTERSECTION(ECityMapMeshTag::Road90DegTurn, coords.x, coords.y, node.Rotation);
|
||||
break;
|
||||
case MapGen::EIntersectionType::TIntersection:
|
||||
tag = ECityMapMeshTag::RoadTIntersection;
|
||||
ADD_INTERSECTION(ECityMapMeshTag::RoadTIntersection, coords.x, coords.y, node.Rotation);
|
||||
break;
|
||||
case MapGen::EIntersectionType::XIntersection:
|
||||
tag = ECityMapMeshTag::RoadXIntersection;
|
||||
ADD_INTERSECTION(ECityMapMeshTag::RoadXIntersection, coords.x, coords.y, node.Rotation);
|
||||
break;
|
||||
default:
|
||||
UE_LOG(LogCarla, Warning, TEXT("Intersection type not implemented"));
|
||||
}
|
||||
FString tagStr = CityMapMeshTag::ToString(tag);
|
||||
std::wstringstream sout;
|
||||
for (float a : node.Rots)
|
||||
sout << a << " ";
|
||||
UE_LOG(
|
||||
LogCarla,
|
||||
Log,
|
||||
TEXT("Add instance \"%s\" at {%d, %d} with rotation %f, { %s }"),
|
||||
*tagStr, coords.x, coords.y, node.Rotation, sout.str().c_str());
|
||||
AddInstance(tag, coords.x, coords.y, node.Rotation);
|
||||
}
|
||||
|
||||
#undef ADD_INTERSECTION
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
ECityMapMeshTag CityMapMeshTag::GetBaseMeshTag()
|
||||
{
|
||||
return ECityMapMeshTag::RoadTwoLanes;
|
||||
return ECityMapMeshTag::RoadTwoLanes_LaneLeft;
|
||||
}
|
||||
|
||||
uint32 CityMapMeshTag::GetRoadIntersectionSize()
|
||||
|
|
|
@ -9,11 +9,37 @@
|
|||
UENUM(BlueprintType)
|
||||
enum class ECityMapMeshTag : uint8
|
||||
{
|
||||
RoadTwoLanes UMETA(DisplayName = "Road: Two Lanes"),
|
||||
RoadFourLanes UMETA(DisplayName = "Road: Four Lanes"),
|
||||
Road90DegTurn UMETA(DisplayName = "Road: 90 Degree Turn"),
|
||||
RoadTIntersection UMETA(DisplayName = "Road: T-Intersection"),
|
||||
RoadXIntersection UMETA(DisplayName = "Road: X-Intersection"),
|
||||
RoadTwoLanes_LaneLeft UMETA(DisplayName = "Road: Two Lanes - Lane Left"),
|
||||
RoadTwoLanes_LaneRight UMETA(DisplayName = "Road: Two Lanes - Lane Right"),
|
||||
RoadTwoLanes_SidewalkLeft UMETA(DisplayName = "Road: Two Lanes - Sidewalk Left"),
|
||||
RoadTwoLanes_SidewalkRight UMETA(DisplayName = "Road: Two Lanes - Sidewalk Right"),
|
||||
|
||||
Road90DegTurn_Lane0 UMETA(DisplayName = "Road: 90 Degree Turn - Lane 0"),
|
||||
Road90DegTurn_Lane1 UMETA(DisplayName = "Road: 90 Degree Turn - Lane 1"),
|
||||
Road90DegTurn_Lane2 UMETA(DisplayName = "Road: 90 Degree Turn - Lane 2"),
|
||||
Road90DegTurn_Lane3 UMETA(DisplayName = "Road: 90 Degree Turn - Lane 3"),
|
||||
Road90DegTurn_Sidewalk0 UMETA(DisplayName = "Road: 90 Degree Turn - Sidewalk 0"),
|
||||
Road90DegTurn_Sidewalk1 UMETA(DisplayName = "Road: 90 Degree Turn - Sidewalk 1"),
|
||||
Road90DegTurn_Sidewalk2 UMETA(DisplayName = "Road: 90 Degree Turn - Sidewalk 2"),
|
||||
Road90DegTurn_Sidewalk3 UMETA(DisplayName = "Road: 90 Degree Turn - Sidewalk 3"),
|
||||
|
||||
RoadTIntersection_Lane0 UMETA(DisplayName = "Road: T-Intersection - Lane 0"),
|
||||
RoadTIntersection_Lane1 UMETA(DisplayName = "Road: T-Intersection - Lane 1"),
|
||||
RoadTIntersection_Lane2 UMETA(DisplayName = "Road: T-Intersection - Lane 2"),
|
||||
RoadTIntersection_Lane3 UMETA(DisplayName = "Road: T-Intersection - Lane 3"),
|
||||
RoadTIntersection_Sidewalk0 UMETA(DisplayName = "Road: T-Intersection - Sidewalk 0"),
|
||||
RoadTIntersection_Sidewalk1 UMETA(DisplayName = "Road: T-Intersection - Sidewalk 1"),
|
||||
RoadTIntersection_Sidewalk2 UMETA(DisplayName = "Road: T-Intersection - Sidewalk 2"),
|
||||
RoadTIntersection_Sidewalk3 UMETA(DisplayName = "Road: T-Intersection - Sidewalk 3"),
|
||||
|
||||
RoadXIntersection_Lane0 UMETA(DisplayName = "Road: X-Intersection - Lane 0"),
|
||||
RoadXIntersection_Lane1 UMETA(DisplayName = "Road: X-Intersection - Lane 1"),
|
||||
RoadXIntersection_Lane2 UMETA(DisplayName = "Road: X-Intersection - Lane 2"),
|
||||
RoadXIntersection_Lane3 UMETA(DisplayName = "Road: X-Intersection - Lane 3"),
|
||||
RoadXIntersection_Sidewalk0 UMETA(DisplayName = "Road: X-Intersection - Sidewalk 0"),
|
||||
RoadXIntersection_Sidewalk1 UMETA(DisplayName = "Road: X-Intersection - Sidewalk 1"),
|
||||
RoadXIntersection_Sidewalk2 UMETA(DisplayName = "Road: X-Intersection - Sidewalk 2"),
|
||||
RoadXIntersection_Sidewalk3 UMETA(DisplayName = "Road: X-Intersection - Sidewalk 3"),
|
||||
|
||||
NUMBER_OF_TAGS UMETA(Hidden)
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue