载入中...
搜索中...
未找到
PlacementPatterns.cpp
浏览该文件的文档.
23 PlacementWorld *world, const std::string &buildingId, const std::vector<CornerAddress> &vertices) {
26 eve::DiagnosticCode::InvalidArgument, "edge path preview requires a world and at least two vertices",
32 eve::DiagnosticCode::InvalidArgument, "edge path preview requires an edge building definition", buildingId,
46 eve::DiagnosticCode::InvalidArgument, "each edge path segment must be non-empty and axis-aligned",
80 eve::DiagnosticCode::InvalidArgument, "cubic edge curve requires four controls and 2..4096 subdivisions",
86 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "edge curve controls must be finite", {},
102 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "edge curve exceeds grid coordinate range",
115 if (!targetResult.ok()) return eve::Result<std::vector<CornerAddress>>::failure(targetResult.status());
128 eve::DiagnosticCode::InvalidArgument, "edge curve rasterization exceeds 65536 unit edges", {}, {},
135 eve::DiagnosticCode::InvalidArgument, "edge curve rasterization must cover at least one unit edge", {}, {},
142 PlacementWorld *world, const std::string &buildingId, const std::vector<EdgeCurvePoint> &controlPoints,
150 PlacementWorld *world, const std::string &buildingId, const std::vector<EdgeCurvePoint> &controlPoints,
158 const PlacementWorld &world, const std::string &surfaceName, const std::vector<EdgeCurvePoint> &controlPoints,
163 return eve::Result<EdgeCurveSurface>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument,
184 auto sampled = sampleSurface(world, surfaceName, ox + static_cast<float>(gx) * xx + static_cast<float>(gy) * yx,
191 } else if (hit.surfaceId != result.surfaceId || hit.surfaceRevision != result.surfaceRevision) {
193 eve::DiagnosticCode::Conflict, "curve crosses a surface identity or revision boundary", hit.surfaceId,
202 PlacementWorld *world, const std::string &buildingId, const std::vector<EdgeCurvePoint> &controlPoints,
206 eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument, "curve surface placement requires a world", {},
215eve::Result<PlacementSystem::EdgeLinePlacement> PlacementSystem::placeEdgeLine(PlacementWorld *world,
219 auto path = placeEdgePath(world, buildingId, {{startVertexX, startVertexY}, {endVertexX, endVertexY}});
227 PlacementWorld *world, const std::string &buildingId, const std::vector<CornerAddress> &vertices) {
229 if (!previewResult.ok()) return eve::Result<EdgePathPlacement>::failure(previewResult.status());
234 PlacementWorld *world, EdgePathPreview preview, const std::vector<EdgeCurvePoint> *curveControls,
267 const size_t required = edge.axis == EdgeAxis::Horizontal ? size_t(world->width_) * size_t(world->height_ + 1)
318 return eve::Result<AreaPreview>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument,
324 return eve::Result<AreaPreview>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument,
378 return eve::Result<AreaPreview>::failure(eve::Diagnostic::error(eve::DiagnosticCode::InvalidArgument,
411eve::Result<PlacementSystem::PatternPreview> PlacementSystem::previewPattern(PlacementWorld *world,
423 std::abs(point.x - std::round(point.x)) > 0.0001f || std::abs(point.y - std::round(point.y)) > 0.0001f)
428 result.push_back({static_cast<int>(std::lround(point.x)), static_cast<int>(std::lround(point.y))});
453 if (request.points.size() != 4) return failure("cubic edge pattern requires exactly four control points");
466 if (request.points.size() != 2) return failure("rectangle pattern requires exactly two corner points");
467 if (!request.surfaceName.empty()) return failure("area patterns do not accept a custom surface name");
480 if (request.points.size() != 1) return failure("circle-brush pattern requires exactly one center point");
481 if (!request.surfaceName.empty()) return failure("area patterns do not accept a custom surface name");
484 auto area = previewBrush(world, buildingId, vertices.value()[0].x, vertices.value()[0].y, request.radius,
494eve::Result<PlacementSystem::PatternPlacement> PlacementSystem::placePattern(PlacementWorld *world,
508 return commitEdgePath(world, result.preview.edge, &result.preview.request.points, request.subdivisions);
509 auto surface = sampleEdgeCurveSurface(*world, request.surfaceName, result.preview.request.points,
526eve::Result<PlacementSystem::AreaPlacement> PlacementSystem::commitArea(PlacementWorld *world, AreaPreview preview) {
529 eve::Diagnostic::error(eve::DiagnosticCode::Conflict, "area commit requires a fully accepted preview",
535 eve::DiagnosticCode::NotFound, "area definition was not found", preview.buildingId, {}, "building.area"));
579eve::Result<PlacementSystem::AreaPlacement> PlacementSystem::placeRectangle(PlacementWorld *world,
583 auto preview = previewRectangle(world, buildingId, minCellX, minCellY, maxCellX, maxCellY, rotationDeg);
597eve::Result<PlacementSystem::AreaPlacement> PlacementSystem::placeRectangleOutline(PlacementWorld *world,
602 auto preview = previewRectangleOutline(world, buildingId, minCellX, minCellY, maxCellX, maxCellY, 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< EdgeCurveSurface > sampleEdgeCurveSurface(const PlacementWorld &world, const std::string &surfaceName, const std::vector< EdgeCurvePoint > &controlPoints, int subdivisions)
Sample one same-identity custom surface frame at every analytic curve segment.
Definition PlacementPatterns.cpp:157
static eve::Result< PatternPreview > previewPattern(PlacementWorld *world, const std::string &buildingId, const PatternRequest &request)
Expand any built-in placement pattern without mutating the world.
Definition PlacementPatterns.cpp:411
static eve::Result< AreaPlacement > placeBrush(PlacementWorld *world, const std::string &buildingId, int centerCellX, int centerCellY, int radius, float rotationDeg=0.f)
Atomically commit a circular brush; any rejection aborts all cells.
Definition PlacementPatterns.cpp:588
static eve::Result< EdgeLinePlacement > placeEdgeLine(PlacementWorld *world, const std::string &buildingId, int startVertexX, int startVertexY, int endVertexX, int endVertexY)
Atomically place every unit edge between two logical grid vertices.
Definition PlacementPatterns.cpp:215
static eve::Result< PatternPlacement > placePattern(PlacementWorld *world, const std::string &buildingId, const PatternRequest &request)
Validate and atomically commit any built-in placement pattern.
Definition PlacementPatterns.cpp:494
static eve::Result< std::vector< CornerAddress > > sampleEdgeCubicBezier(const std::vector< EdgeCurvePoint > &controlPoints, int subdivisions)
Deterministically rasterize four cubic Bezier controls to adjacent grid vertices.
Definition PlacementPatterns.cpp:74
static eve::Result< AreaPreview > previewRectangle(PlacementWorld *world, const std::string &buildingId, int minCellX, int minCellY, int maxCellX, int maxCellY, float rotationDeg=0.f)
Preview every anchor in an inclusive rectangular area without mutation.
Definition PlacementPatterns.cpp:361
static eve::Result< EdgePathPreview > previewEdgeCubicBezier(PlacementWorld *world, const std::string &buildingId, const std::vector< EdgeCurvePoint > &controlPoints, int subdivisions)
Sample and validate a cubic Bezier edge curve without mutating the world.
Definition PlacementPatterns.cpp:141
static eve::Result< EdgePathPreview > previewEdgePath(PlacementWorld *world, const std::string &buildingId, const std::vector< CornerAddress > &vertices)
Validate and expand a multi-segment orthogonal path without mutation.
Definition PlacementPatterns.cpp:22
static eve::Result< AreaPreview > previewRectangleOutline(PlacementWorld *world, const std::string &buildingId, int minCellX, int minCellY, int maxCellX, int maxCellY, float rotationDeg=0.f)
Preview only the perimeter anchors of an inclusive rectangle.
Definition PlacementPatterns.cpp:390
static eve::Result< EdgePathPlacement > placeEdgeCubicBezier(PlacementWorld *world, const std::string &buildingId, const std::vector< EdgeCurvePoint > &controlPoints, int subdivisions)
Atomically place the deterministic grid-edge rasterization of a cubic Bezier.
Definition PlacementPatterns.cpp:149
static eve::Result< EdgePathPlacement > placeEdgePath(PlacementWorld *world, const std::string &buildingId, const std::vector< CornerAddress > &vertices)
Atomically place every unit edge along a multi-segment orthogonal vertex path.
Definition PlacementPatterns.cpp:226
static eve::Result< AreaPlacement > placeRectangle(PlacementWorld *world, const std::string &buildingId, int minCellX, int minCellY, int maxCellX, int maxCellY, float rotationDeg=0.f)
Atomically commit a previously shaped rectangle; any rejection aborts all cells.
Definition PlacementPatterns.cpp:579
static const std::vector< BuildingChangeEvent > & events()
Definition PlacementSystem.cpp:405
static eve::Result< EdgePathPlacement > placeEdgeCubicBezierOnSurface(PlacementWorld *world, const std::string &buildingId, const std::vector< EdgeCurvePoint > &controlPoints, int subdivisions, const std::string &surfaceName)
Atomically place a curve whose committed centerline follows a custom surface.
Definition PlacementPatterns.cpp:201
static bool foreachFootprintCell(const BuildingDefinition &def, int originCellX, int originCellY, float rotationDeg, const std::function< bool(int cx, int cy)> &fn)
枚举占地格子(旋转后局部 → 世界格子)。返回 false 若定义未知。
Definition PlacementSystem.cpp:487
static eve::Result< PlacementHit > sampleSurface(const PlacementWorld &world, const std::string &name, float x, float y)
Sample a named placement surface.
Definition PlacementSystem.cpp:161
static float normalizeRotation(const std::string &buildingId, float rotationDeg)
规范化旋转角(cardinal → 0/90/180/270;none → 0)。
Definition PlacementSystem.cpp:457
@ RectangleOutline
@ RectangleFill
@ EdgeCubicBezier
static eve::Result< AreaPreview > previewBrush(PlacementWorld *world, const std::string &buildingId, int centerCellX, int centerCellY, int radius, float rotationDeg=0.f)
Preview anchors inside an inclusive Euclidean cell-radius brush.
Definition PlacementPatterns.cpp:373
static eve::Result< AreaPlacement > placeRectangleOutline(PlacementWorld *world, const std::string &buildingId, int minCellX, int minCellY, int maxCellX, int maxCellY, float rotationDeg=0.f)
Atomically commit only the perimeter anchors of an inclusive rectangle.
Definition PlacementPatterns.cpp:597
static bool canPlace(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f, int excludeInstanceId=0, std::string *reason=nullptr)
Definition PlacementValidation.cpp:309
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
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:10
@ Vertical
@ Horizontal
@ InvalidArgument
@ NotFound
@ Conflict
Definition Container.h:602
std::vector< std::string > tags
Definition BuildingTypes.h:146
Canonical address of one logical grid vertex used by corner objects.
Definition BuildingTypes.h:40
One cubic Bezier control point in logical grid-vertex space.
Definition BuildingTypes.h:59
Strong world-local identity of one authoritative edge-curve group.
Definition BuildingTypes.h:49
Owning same-identity surface frames sampled along an analytic edge curve.
Definition PlacementSystem.h:89
std::string providerName
Definition PlacementSystem.h:90
Atomic result of placing one axis-aligned continuous edge line.
Definition PlacementSystem.h:73
std::vector< int > instanceIds
Definition PlacementSystem.h:74
Owning validated edge addresses for one non-mutating path preview.
Definition PlacementSystem.h:81
std::vector< EdgeAddress > edges
Definition PlacementSystem.h:84
std::string buildingId
Definition PlacementSystem.h:82
Atomic placement receipt shared by every built-in pattern kind.
Definition PlacementSystem.h:149
PatternPreview preview
Definition PlacementSystem.h:150
Owning non-mutating expansion of an edge or area pattern.
Definition PlacementSystem.h:135
PatternRequest request
Definition PlacementSystem.h:136
AreaPreview area
Definition PlacementSystem.h:138
EdgePathPreview edge
Definition PlacementSystem.h:137
Owning, renderer-neutral request for one atomic placement pattern.
Definition PlacementSystem.h:126
One sampled point and orthonormal frame on a placement surface.
Definition PlacementSystem.h:41
std::string surfaceId
Definition PlacementSystem.h:54