载入中...
搜索中...
未找到
PlacementDomains.cpp
浏览该文件的文档.
20eve::Result<EdgeAddress> PlacementSystem::canonicalEdge(int cellX, int cellY, const std::string &direction) {
42bool PlacementSystem::canPlaceEdge(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY,
71 const int resolvedLevel = level == std::numeric_limits<int>::min() ? world->getActiveLevel() : level;
95int PlacementSystem::placeEdge(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY,
123 const size_t required = edge.axis == EdgeAxis::Horizontal ? size_t(world->width_) * size_t(world->height_ + 1)
148bool PlacementSystem::canPlaceCorner(PlacementWorld *world, const std::string &buildingId, int vertexX, int vertexY,
167 const int resolvedLevel = level == std::numeric_limits<int>::min() ? world->getActiveLevel() : level;
168 const int occupant = world->getCornerOccupantAtLevel(def->channel, vertexX, vertexY, resolvedLevel);
182eve::Result<PlacedBuilding> PlacementSystem::placeCornerResult(PlacementWorld *world, const std::string &buildingId,
186 return eve::Result<PlacedBuilding>::failure(eve::Diagnostic::error(eve::DiagnosticCode::Conflict,
193 eve::DiagnosticCode::NotFound, "corner definition was not found", buildingId, {}, "building.corner"));
235int PlacementSystem::placeCorner(PlacementWorld *world, const std::string &buildingId, int vertexX, int vertexY) {
240bool PlacementSystem::canPlaceFree(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY,
266 const int resolvedLevel = level == std::numeric_limits<int>::min() ? world->getActiveLevel() : level;
268 definitionFreeFootprint(*def, *world, worldX, worldY, normalizeRotation(buildingId, rotationDeg));
270 if (id == excludeInstanceId || placed.placementKind != "edge" || placed.level != resolvedLevel) continue;
297bool PlacementSystem::containsFreePoint(const PlacedBuilding &placed, float worldX, float worldY) {
298 return placed.placementKind == "free" && containsFreeFootprintPoint(placedFreeFootprint(placed), worldX, worldY);
301eve::Result<PlacedBuilding> PlacementSystem::placeFreeResult(PlacementWorld *world, const std::string &buildingId,
305 if (!canPlaceFree(world, buildingId, worldX, worldY, 0, &reason, std::numeric_limits<int>::min(), rotationDeg)) {
307 eve::DiagnosticCode::Conflict, "free placement rejected without mutation", reason, {}, "building.free"));
320 grid::worldToCell(*world->grid_, worldX, worldY, placed.originCellX, placed.originCellY, world->width_,
349 eve::DiagnosticCode::InvalidArgument, "free surface placement requires a world", {}, {}, "building.free"));
354 eve::DiagnosticCode::InvalidArgument, "free surface placement requires a free definition", buildingId, {},
358 const float planeY = world->getGrid().plane == grid::GridPlane::XZ ? patch.anchor.worldZ : patch.anchor.worldY;
359 const float elevation = world->getGrid().plane == grid::GridPlane::XZ ? patch.anchor.worldY : patch.anchor.worldZ;
361 if (!canPlaceFree(world, buildingId, planeX, planeY, 0, &reason, std::numeric_limits<int>::min(), rotationDeg) ||
365 reason = patch.maxSlopeDegrees > def->maxSurfaceSlopeDegrees ? "surface_slope" : "surface_height_delta";
367 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "free surface placement rejected without mutation",
381 grid::worldToCell(*world->grid_, planeX, planeY, placed.originCellX, placed.originCellY, world->width_,
416int PlacementSystem::placeFree(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY,
450 const std::string otherGroup = otherDef->connectionGroup.empty() ? otherDef->id : otherDef->connectionGroup;
std::map< std::string, std::vector< Key >, std::less<> > channels
Definition AnimCurveLibrary.cpp:21
Stable, structured diagnostics shared by engine modules.
Pure cell/world projection helpers for GridConfig.
std::map< std::array< int, 4 >, std::vector< const Subject * > > candidates
Definition Sensing.cpp:32
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
static int placeFree(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, float elevation=0.f, float rotationDeg=0.f)
Compatibility-only id projection; prefer placeFreeResult in C++.
Definition PlacementDomains.cpp:416
static int placeCorner(PlacementWorld *world, const std::string &buildingId, int vertexX, int vertexY)
Compatibility-only id projection; prefer placeCornerResult in C++.
Definition PlacementDomains.cpp:235
static eve::Result< PlacedBuilding > placeFreeSurfaceResult(PlacementWorld *world, const std::string &buildingId, const SurfacePatch &patch, float rotationDeg=0.f)
Atomically place a free object from an owning validated surface patch snapshot.
Definition PlacementDomains.cpp:344
static bool containsFreePoint(const PlacedBuilding &placed, float worldX, float worldY)
Test a world-plane point against a committed circular or oriented-box footprint.
Definition PlacementDomains.cpp:297
static std::string edgeVariant(const PlacementWorld &world, int instanceId)
Stable visual topology class: isolated/end/straight/corner/tee/cross.
Definition PlacementDomains.cpp:477
static bool canPlaceFree(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, int excludeInstanceId=0, std::string *reason=nullptr, int level=std::numeric_limits< int >::min(), float rotationDeg=0.f)
Validate an exact free-domain world-plane anchor and circular or oriented-box footprint.
Definition PlacementDomains.cpp:240
static float normalizeRotation(const std::string &buildingId, float rotationDeg)
规范化旋转角(cardinal → 0/90/180/270;none → 0)。
Definition PlacementSystem.cpp:457
static eve::Result< PlacedBuilding > placeFreeResult(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, float elevation=0.f, float rotationDeg=0.f)
Atomically place a free-domain definition at an unsnapped world-plane anchor.
Definition PlacementDomains.cpp:301
static bool canPlaceCorner(PlacementWorld *world, const std::string &buildingId, int vertexX, int vertexY, int excludeInstanceId=0, std::string *reason=nullptr, int level=std::numeric_limits< int >::min())
Validate a corner-domain placement at one canonical grid vertex.
Definition PlacementDomains.cpp:148
static uint8_t edgeConnectionMask(const PlacementWorld &world, int instanceId)
Compute compatible neighbouring edge topology.
Definition PlacementDomains.cpp:422
static eve::Result< PlacedBuilding > placeCornerResult(PlacementWorld *world, const std::string &buildingId, int vertexX, int vertexY)
Atomically place a corner-domain definition.
Definition PlacementDomains.cpp:182
static int placeEdge(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, const std::string &direction)
Place an edge-domain definition, returning the new instance id or zero.
Definition PlacementDomains.cpp:95
static eve::Result< EdgeAddress > canonicalEdge(int cellX, int cellY, const std::string &direction)
Normalize a cell-relative cardinal direction to a unique edge address.
Definition PlacementDomains.cpp:20
static bool canPlaceEdge(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, const std::string &direction, int excludeInstanceId=0, std::string *reason=nullptr, int level=std::numeric_limits< int >::min())
Validate an edge-domain placement without mutating the world.
Definition PlacementDomains.cpp:42
bool containsFreeFootprintPoint(const FreeFootprint &footprint, float x, float y)
Definition PlacementGeometry.cpp:203
FreeFootprint definitionFreeFootprint(const BuildingDefinition &definition, const PlacementWorld &world, float x, float y, float rotationDeg)
Definition PlacementGeometry.cpp:60
bool hasFreeEdgeOverlap(const PlacementWorld &world, const BuildingDefinition &freeDefinition, const FreeFootprint &footprint, const BuildingDefinition &edgeDefinition, EdgeAddress edge)
Definition PlacementGeometry.cpp:20
void applyDefinitionFreeFootprint(PlacedBuilding &placed, const BuildingDefinition &definition, const PlacementWorld &world)
Definition PlacementGeometry.cpp:85
FreeFootprint placedFreeFootprint(const PlacedBuilding &placed)
Definition PlacementGeometry.cpp:101
bool hasFreeFootprintOverlap(const FreeFootprint &a, const FreeFootprint &b)
Definition PlacementGeometry.cpp:145
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:10
@ Vertical
@ Horizontal
void worldToCell(const GridConfig &cfg, float px, float py, int &cx, int &cy, int mapW, int mapH)
Maps planar coordinates to the nearest cell. Staggered/hex layouts use a bounded nearest-neighbor sea...
Definition GridProjection.cpp:69
@ InvalidArgument
@ NotFound
@ Conflict
std::string placementKind
Placement domain: cell (default), edge, corner, or free.
Definition BuildingTypes.h:111
float maxSurfaceHeightDelta
Maximum elevation range across a sampled footprint; negative disables it.
Definition BuildingTypes.h:145
float maxSurfaceSlopeDegrees
Maximum angle between a footprint normal and the grid-plane up axis.
Definition BuildingTypes.h:143
std::string connectionGroup
Edge topology compatibility group; empty falls back to building id.
Definition BuildingTypes.h:121
std::vector< std::string > tags
Definition BuildingTypes.h:146
Canonical address of one logical grid vertex used by corner objects.
Definition BuildingTypes.h:40
uint64_t surfaceRevision
Definition PlacementSystem.h:55
std::string surfaceId
Definition PlacementSystem.h:54
Surface samples and continuity metrics for one rotated building footprint.
Definition PlacementSystem.h:66
float maxSlopeDegrees
Definition PlacementSystem.h:69
PlacementHit anchor
Definition PlacementSystem.h:67
float heightDelta
Definition PlacementSystem.h:70
std::vector< SurfacePatchSample > samples
Definition PlacementSystem.h:68