载入中...
搜索中...
未找到
PlacementMove.cpp
浏览该文件的文档.
20eve::Result<PlacementEditReceipt> PlacementSystem::moveBuildingResult(PlacementWorld *world, int instanceId, int cellX,
37 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "move would invalidate structural dependents",
42 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "cell move cannot target a non-cell instance",
45 const float rot = (rotationDeg < 0.f) ? pb.rotationDeg : normalizeRotation(pb.buildingId, rotationDeg);
47 if (!canPlaceElev(world, pb.buildingId, cellX, cellY, pb.elevation, rot, instanceId, &reason, pb.level)) {
49 eve::DiagnosticCode::Conflict, "move preflight rejected without mutation", reason, {}, "building.edit"));
55 eve::DiagnosticCode::NotFound, "move definition was not found", pb.buildingId, {}, "building.edit"));
94eve::Result<PlacementEditReceipt> PlacementSystem::moveEdgeResult(PlacementWorld *world, int instanceId, int cellX,
104 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "edge move source instance was not found",
110 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "edge move requires an edge instance",
115 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "edge move would invalidate structural dependents",
119 if (!canPlaceEdge(world, pb.buildingId, cellX, cellY, direction, instanceId, &reason, pb.level)) {
121 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "edge move preflight rejected without mutation",
125 if (!addressResult.ok()) return eve::Result<PlacementEditReceipt>::failure(addressResult.status());
130 eve::DiagnosticCode::NotFound, "edge move definition was not found", pb.buildingId, {}, "building.edit"));
160 const size_t required = target.axis == EdgeAxis::Horizontal ? size_t(world->width_) * size_t(world->height_ + 1)
176eve::Result<PlacementEditReceipt> PlacementSystem::moveCornerResult(PlacementWorld *world, int instanceId, int vertexX,
186 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "corner move source instance was not found",
192 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "corner move requires a corner instance",
197 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "corner move would invalidate structural dependents",
201 if (!canPlaceCorner(world, placed.buildingId, vertexX, vertexY, instanceId, &reason, placed.level)) {
203 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "corner move preflight rejected without mutation",
249eve::Result<PlacementEditReceipt> PlacementSystem::moveFreeResult(PlacementWorld *world, int instanceId, float worldX,
259 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "free move source instance was not found",
264 if (!canPlaceFree(world, placed.buildingId, worldX, worldY, instanceId, &reason, placed.level, rotationDeg)) {
266 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "free move preflight rejected without mutation",
275 grid::worldToCell(*world->grid_, worldX, worldY, placed.originCellX, placed.originCellY, world->width_,
295eve::Result<PlacementEditReceipt> PlacementSystem::moveFreeSurfaceResult(PlacementWorld *world, int instanceId,
299 eve::DiagnosticCode::InvalidArgument, "free surface move requires a world and positive instance id",
305 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "free surface move source instance was not found",
312 eve::Diagnostic::error(eve::DiagnosticCode::NotFound, "free surface move definition was not found",
316 const float planeY = world->getGrid().plane == grid::GridPlane::XZ ? patch.anchor.worldZ : patch.anchor.worldY;
317 const float elevation = world->getGrid().plane == grid::GridPlane::XZ ? patch.anchor.worldY : patch.anchor.worldZ;
319 if (!canPlaceFree(world, placed.buildingId, planeX, planeY, instanceId, &reason, placed.level, rotationDeg) ||
323 reason = patch.maxSlopeDegrees > def->maxSurfaceSlopeDegrees ? "surface_slope" : "surface_height_delta";
325 eve::DiagnosticCode::Conflict, "free surface move preflight rejected without mutation", reason, {},
335 grid::worldToCell(*world->grid_, planeX, planeY, placed.originCellX, placed.originCellY, world->width_,
367eve::Result<PlacementEditReceipt> PlacementSystem::replaceBuildingResult(PlacementWorld *world, int instanceId,
393 eve::DiagnosticCode::InvalidArgument, "replacement must use the same placement domain as the source",
399 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "replace would invalidate structural dependents",
406 if (!canPlaceEdge(world, replacementBuildingId, pb.edge.x, pb.edge.y, direction, instanceId, &reason,
409 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "replace preflight rejected without mutation",
413 if (!canPlaceCorner(world, replacementBuildingId, pb.corner.x, pb.corner.y, instanceId, &reason, pb.level)) {
415 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "replace preflight rejected without mutation",
419 if (!canPlaceFree(world, replacementBuildingId, pb.worldX, pb.worldY, instanceId, &reason, pb.level,
422 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "replace preflight rejected without mutation",
425 } else if (!canPlaceElev(world, replacementBuildingId, pb.originCellX, pb.originCellY, pb.elevation, pb.rotationDeg,
428 eve::DiagnosticCode::Conflict, "replace preflight rejected without mutation", reason, {}, "building.edit"));
451 pb.rotationDeg = sourceEdge ? pb.rotationDeg : normalizeRotation(replacementBuildingId, pb.rotationDeg);
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.
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 eve::Result< PlacementEditReceipt > moveFreeSurfaceResult(PlacementWorld *world, int instanceId, const SurfacePatch &patch, float rotationDeg)
Atomically move a free-domain instance and replace its surface attachment.
Definition PlacementMove.cpp:295
static int removeBuildingCascade(PlacementWorld *world, int instanceId)
Compatibility-only count projection; prefer removeBuildingCascadeResult in C++.
Definition PlacementStructure.cpp:138
static void clearBuildings(PlacementWorld *world)
Definition PlacementMove.cpp:495
static eve::Result< PlacementEditReceipt > moveCornerResult(PlacementWorld *world, int instanceId, int vertexX, int vertexY)
Atomically move a corner-domain instance to another grid vertex.
Definition PlacementMove.cpp:176
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< PlacementEditReceipt > moveFreeResult(PlacementWorld *world, int instanceId, float worldX, float worldY, float elevation, float rotationDeg)
Atomically move a free-domain instance to an exact world-plane anchor.
Definition PlacementMove.cpp:249
static eve::Result< PlacementEditReceipt > replaceBuildingResult(PlacementWorld *world, int instanceId, const std::string &replacementBuildingId)
Atomically replace an instance definition at its current cell or edge address.
Definition PlacementMove.cpp:367
static eve::Result< PlacementEditReceipt > moveEdgeResult(PlacementWorld *world, int instanceId, int cellX, int cellY, const std::string &direction)
Atomically move an edge-domain instance to a canonical grid edge.
Definition PlacementMove.cpp:94
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 bool canPlaceElev(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, float elevation, float rotationDeg=0.f, int excludeInstanceId=0, std::string *reason=nullptr, int level=std::numeric_limits< int >::min())
Definition PlacementValidation.cpp:147
static eve::Result< PlacementEditReceipt > moveBuildingResult(PlacementWorld *world, int instanceId, int cellX, int cellY, float rotationDeg=-1.f)
Atomically move a cell-domain instance while preserving its identity and state.
Definition PlacementMove.cpp:20
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
void applyDefinitionFreeFootprint(PlacedBuilding &placed, const BuildingDefinition &definition, const PlacementWorld &world)
Definition PlacementGeometry.cpp:85
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档: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::vector< std::string > tags
Definition BuildingTypes.h:146
Canonical address of one logical grid vertex used by corner objects.
Definition BuildingTypes.h:40
EdgeCurveGroupId edgeCurveGroupId
Optional link to a world-owned curve group; zero means an ordinary edge.
Definition BuildingTypes.h:197
int level
Authoritative discrete floor coordinate used by occupancy and topology.
Definition BuildingTypes.h:211
std::string placementKind
Placement domain snapshot: cell, edge, corner, or free.
Definition BuildingTypes.h:193
std::vector< int > supportInstanceIds
Derived support links rebuilt from authoritative level/address data.
Definition BuildingTypes.h:236
CornerAddress corner
Canonical grid vertex when placementKind is corner.
Definition BuildingTypes.h:199
Owning before/after receipt produced by one committed placement edit.
Definition BuildingTypes.h:304
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