28 return (0 < val) - (val < 0);
53 FRandomStream &random) {
55 std::vector<Graph::HalfEdge *> edges;
61 auto *edge = &firstEdge;
64 edges.emplace_back(edge);
67 }
while (edge != &firstEdge);
69 check(edges.size() == 4u);
71 auto randomIndex = random.RandRange(0, edges.size() - 1);
73 return {edges[randomIndex], edges[(randomIndex + 2u) % edges.size()]};
86 check((dir.x == -1 * otherDir.x) && (dir.y == -1 * otherDir.y));
88 if ((std::abs(dir.x) < 2*
MARGIN+1) && (std::abs(dir.y) < 2*
MARGIN+1))
91 auto randX = (dir.x != 0 ?
signOf(dir.x) * random.RandRange(
MARGIN, std::abs(dir.x) -
MARGIN) : 0);
93 auto randY = (dir.y != 0 ?
signOf(dir.y) * random.RandRange(
MARGIN, std::abs(dir.y) -
MARGIN) : 0);
117 FRandomStream random(seed);
125#ifdef CARLA_ROAD_GENERATOR_EXTRA_LOG
128 }
while (face !=
nullptr);
145 std::array<Position, 4u> box;
151 auto Dcel = MakeUnique<DoublyConnectedEdgeList>(box);
简单的双连通边链表结构。它只允许添加元素,不允许删除元素。
ListView< FaceIterator > GetFaces()
Face & ConnectNodes(Node &Node0, Node &Node1)
用一对边连接两个节点。
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)
在 位置分割 HalfEdge (和它的配对)
size_t CountFaces() const
static TUniquePtr< DoublyConnectedEdgeList > Generate(uint32 SizeX, uint32 SizeY, int32 Seed)
创建一个大小为 SizeX 乘以 SizeY 的平方双连通边链表 DoublyConnectedEdgeList, 并使用固定的随机数生成种子 Seed 在内部生成随机连接。
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