载入中...
搜索中...
未找到
HouseGenerationAlgorithms.cpp
浏览该文件的文档.
4const HouseComponent *pick(const std::vector<std::reference_wrapper<const HouseComponent>> &choices,
18bool has(const std::vector<std::reference_wrapper<const HouseComponent>> &values) { return !values.empty(); }
111std::vector<uint8_t> polygonMask(const std::vector<HousePolygonPoint> &poly, int width, int depth, int inset) {
133 const std::vector<std::reference_wrapper<const HouseComponent>> &choices, SocketDirection face, int rotation) {
155std::optional<std::pair<int, int>> findInteriorCell(const std::vector<uint8_t> &mask, int width, int depth) {
169void appendRoomRegions(int width, int depth, const std::vector<uint8_t> &mask, const std::string &roomType, int floorZ,
223 while (x1 + 1 < width && mask[size_t(y * width + x1 + 1)] && !claimed[size_t(y * width + x1 + 1)]) ++x1;
242 "requested room count cannot represent the irregular footprint without outside cells", "requiredRooms", {},
270 rooms.push_back({roomTypes[i], rect.x0, rect.y0, floorZ, rect.x1 - rect.x0 + 1, rect.y1 - rect.y0 + 1});
282 const auto emitBoundary = [&](int x, int y, int rotation, int roomA, int roomB) -> eve::Result<void> {
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
std::string directionName(SocketDirection direction)
Definition HouseGenerationAlgorithms.cpp:61
std::vector< uint8_t > polygonMask(const std::vector< HousePolygonPoint > &poly, int width, int depth, int inset)
Rasterize an arbitrary closed polygon onto the cell grid (cell centers inside).
Definition HouseGenerationAlgorithms.cpp:111
void appendRoomRegions(int width, int depth, const std::vector< uint8_t > &mask, const std::string &roomType, int floorZ, std::vector< HouseRoom > &rooms)
Definition HouseGenerationAlgorithms.cpp:169
bool isOneOf(const std::string &value, std::initializer_list< const char * > options)
Definition HouseGenerationAlgorithms.cpp:48
SocketDirection directionFromName(const std::string &name)
Definition HouseGenerationAlgorithms.cpp:54
SocketDirection rotate(SocketDirection direction, int degrees)
Definition HouseGenerationAlgorithms.cpp:119
std::optional< std::pair< int, int > > findInteriorCell(const std::vector< uint8_t > &mask, int width, int depth)
First active cell that is interior (all four orthogonal neighbours active).
Definition HouseGenerationAlgorithms.cpp:155
std::vector< std::reference_wrapper< const HouseComponent > > compatibleOnFace(const std::vector< std::reference_wrapper< const HouseComponent > > &choices, SocketDirection face, int rotation)
Internal compatibleOnFace stage helper. @cost Component choices times sockets; used for one facade pl...
Definition HouseGenerationAlgorithms.cpp:132
int directionRotation(SocketDirection direction)
Definition HouseGenerationAlgorithms.cpp:68
bool pointInPolygon(float px, float py, const std::vector< HousePolygonPoint > &poly)
Ray-casting point-in-polygon test in corner coordinates.
Definition HouseGenerationAlgorithms.cpp:100
eve::Result< void > partitionFloor(int width, int depth, const std::vector< uint8_t > &mask, const std::vector< std::string > &roomTypes, std::mt19937 &rng, const std::vector< std::reference_wrapper< const HouseComponent > > &innerWall, const std::vector< std::reference_wrapper< const HouseComponent > > &innerDoor, std::vector< HouseInstance > &instances, std::vector< HouseRoom > &rooms, int floorZ)
Partition active cells into exact, rectangular rooms and emit mask-safe boundaries.
Definition HouseGenerationAlgorithms.cpp:197
bool has(const std::vector< std::reference_wrapper< const HouseComponent > > &values)
Definition HouseGenerationAlgorithms.cpp:18
bool isWindowComponent(const HouseComponent *component)
Definition HouseGenerationAlgorithms.cpp:26
std::vector< uint8_t > footprintMask(const std::string &shape, int width, int depth, int inset)
Internal footprintMask stage helper. @cost Linear in plot cells; reuse for one floor emission.
Definition HouseGenerationAlgorithms.cpp:75
bool isRotationAllowed(const HouseComponent &component, int rotation)
Definition HouseGenerationAlgorithms.cpp:20
const HouseComponent * pick(const std::vector< std::reference_wrapper< const HouseComponent > > &choices, std::mt19937 &rng)
Borrow a weighted component from library-backed choices. @ownership Borrowed; the session's library o...
Definition HouseGenerationAlgorithms.cpp:4
std::vector< std::reference_wrapper< const HouseComponent > > facadeVariant(const std::vector< std::reference_wrapper< const HouseComponent > > &choices, bool wantWindow)
Internal facadeVariant stage helper. @cost Linear in component choices; amortized across one facade p...
Definition HouseGenerationAlgorithms.cpp:32
@ NotFound
@ Unsupported