23 return (0 < val) - (val < 0);
40 FRandomStream &random) {
42 std::vector<Graph::HalfEdge *> edges;
45 auto *edge = &firstEdge;
47 edges.emplace_back(edge);
49 }
while (edge != &firstEdge);
50 check(edges.size() == 4u);
51 auto randomIndex = random.RandRange(0, edges.size() - 1);
52 return {edges[randomIndex], edges[(randomIndex + 2u) % edges.size()]};
60 check((dir.x == -1 * otherDir.x) && (dir.y == -1 * otherDir.y));
62 if ((std::abs(dir.x) < 2*MARGIN+1) && (std::abs(dir.y) < 2*MARGIN+1))
65 auto randX = (dir.x != 0 ?
signOf(dir.x) * random.RandRange(MARGIN, std::abs(dir.x) - MARGIN) : 0);
66 auto randY = (dir.y != 0 ?
signOf(dir.y) * random.RandRange(MARGIN, std::abs(dir.y) - MARGIN) : 0);
80 FRandomStream random(seed);
87 #ifdef CARLA_ROAD_GENERATOR_EXTRA_LOG 89 #endif // CARLA_ROAD_GENERATOR_EXTRA_LOG 90 }
while (face !=
nullptr);
103 std::array<Position, 4u> box;
108 auto Dcel = MakeUnique<DoublyConnectedEdgeList>(box);
Node & SplitEdge(const Position &Position, HalfEdge &HalfEdge)
Split HalfEdge (and its pair) at Position.
static HalfEdge & GetHalfEdge(Face &face)
static int32 signOf(int32 val)
size_t CountNodes() const
Simple doubly-connected edge list structure.
static TUniquePtr< DoublyConnectedEdgeList > Generate(uint32 SizeX, uint32 SizeY, int32 Seed)
Create a squared DoublyConnectedEdgeList of size SizeX times SizeY and generate random connections in...
static Graph::Position getDirection(const Graph::HalfEdge &edge)
static Node & GetSource(HalfEdge &halfEdge)
static const Graph::Position & getTargetPosition(const Graph::HalfEdge &edge)
MapGen::Position< int32 > Position
const DoublyConnectedEdgeList::Position & GetPosition() const
static std::pair< Graph::HalfEdge *, Graph::HalfEdge * > getRandomOpposingEdges(Graph::Face &face, FRandomStream &random)
size_t CountFaces() const
static Graph::Face * splitFace(Graph &graph, Graph::Face &face, FRandomStream &random)
static constexpr int32 MARGIN
static HalfEdge & GetNextInFace(HalfEdge &halfEdge)
size_t CountHalfEdges() const
static void randomize(Graph &graph, const int32 seed)
static Node & GetTarget(HalfEdge &halfEdge)
static const Graph::Position & getSourcePosition(const Graph::HalfEdge &edge)
ListView< FaceIterator > GetFaces()
Face & ConnectNodes(Node &Node0, Node &Node1)
Connect two nodes by a pair of edges.