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
90 }
while (face !=
nullptr);
103 std::array<Position, 4u> box;
108 auto Dcel = MakeUnique<DoublyConnectedEdgeList>(box);
Simple doubly-connected edge list structure.
ListView< FaceIterator > GetFaces()
Face & ConnectNodes(Node &Node0, Node &Node1)
Connect two nodes by a pair of edges.
static HalfEdge & GetHalfEdge(Face &face)
static Node & GetTarget(HalfEdge &halfEdge)
static Node & GetSource(HalfEdge &halfEdge)
size_t CountNodes() const
MapGen::Position< int32 > Position
static HalfEdge & GetNextInFace(HalfEdge &halfEdge)
size_t CountHalfEdges() const
Node & SplitEdge(const Position &Position, HalfEdge &HalfEdge)
Split HalfEdge (and its pair) at Position.
size_t CountFaces() const
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 void randomize(Graph &graph, const int32 seed)
static std::pair< Graph::HalfEdge *, Graph::HalfEdge * > getRandomOpposingEdges(Graph::Face &face, FRandomStream &random)
static constexpr int32 MARGIN
static Graph::Face * splitFace(Graph &graph, Graph::Face &face, FRandomStream &random)
static const Graph::Position & getTargetPosition(const Graph::HalfEdge &edge)
static const Graph::Position & getSourcePosition(const Graph::HalfEdge &edge)
static int32 signOf(int32 val)
static Graph::Position getDirection(const Graph::HalfEdge &edge)
const DoublyConnectedEdgeList::Position & GetPosition() const