载入中...
搜索中...
未找到
PlacementSystem.cpp
浏览该文件的文档.
85void PlacementSystem::unregisterChangeHook(const std::string &name) { changeHooks().erase(name); }
471void PlacementSystem::effectiveFootprint(const BuildingDefinition &def, float rotationDeg, int *outW,
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 Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
static Status failure(StatusCode code, Diagnostic diagnostic)
Construct a failed status with one diagnostic.
Definition Status.cpp:28
std::function< bool(const PlacementWorld &world, const PlacementQuery &q, std::string *reason)> ValidateFn
Definition PlacementSystem.h:34
static SnapResult snap(const PlacementWorld &world, const std::string &buildingId, float worldX, float worldY)
Definition PlacementSystem.cpp:432
static void effectiveFootprint(const BuildingDefinition &def, float rotationDeg, int *outW, int *outH)
旋转后的占地宽高(cardinal 90/270 交换)。
Definition PlacementSystem.cpp:471
std::function< bool(const PlacementWorld &world, float x, float y, PlacementHit *hit)> SurfaceFn
Definition PlacementSystem.h:160
static std::vector< std::string > surfaceNames()
Definition PlacementSystem.cpp:283
static void registerSurfaceProvider(const std::string &name, SurfaceProviderFn fn)
Register or replace a structured surface provider.
Definition PlacementSystem.cpp:106
static void registerSurface(const std::string &name, SurfaceFn fn)
Definition PlacementSystem.cpp:91
static SnapResult snap3D(const PlacementWorld &world, const std::string &buildingId, float worldX, float worldY, float worldZ)
Definition PlacementSystem.cpp:442
static eve::Result< void > registerHeightfieldSurface(const std::string &name, std::shared_ptr< const HeightfieldSurface > surface)
Register an immutable built-in heightfield and retain it until unregistration.
Definition PlacementSystem.cpp:111
static PlacementSystem & inst()
Process singleton holding all PlacementSystem state.
Definition PlacementSystem.cpp:20
static const std::vector< BuildingChangeEvent > & events()
Definition PlacementSystem.cpp:405
static bool surfaceHit(const PlacementWorld &world, const std::string &name, float x, float y, PlacementHit *hit)
Definition PlacementSystem.cpp:151
std::function< SnapResult(const PlacementWorld &world, float worldX, float worldY)> SnapFn
Definition PlacementSystem.h:37
static float getPlaneSurfaceHeight()
Definition PlacementSystem.cpp:293
static void unregisterChangeHook(const std::string &name)
Definition PlacementSystem.cpp:85
static void setPlaneSurfaceHeight(float h)
Definition PlacementSystem.cpp:291
std::function< eve::Result< PlacementHit >(const PlacementWorld &world, float x, float y)> SurfaceProviderFn
Canonical surface provider contract.
Definition PlacementSystem.h:167
static bool hasSurface(const std::string &name)
Definition PlacementSystem.cpp:146
std::function< void(const BuildingChangeEvent &ev)> ChangeHook
Definition PlacementSystem.h:38
static void pushEvent(BuildingChangeEvent ev)
Definition PlacementSystem.cpp:396
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
static eve::Result< SurfacePatch > sampleSurfacePatch(const PlacementWorld &world, const std::string &buildingId, const std::string &surfaceName, float x, float y, float rotationDegrees=0.f)
Sample the occupied cells of a rotated footprint relative to an exact anchor hit.
Definition PlacementSystem.cpp:185
static bool hasSnapRule(const std::string &name)
Definition PlacementSystem.cpp:75
static void clearEvents()
Definition PlacementSystem.cpp:403
static void unregisterSurface(const std::string &name)
Definition PlacementSystem.cpp:141
static bool hasChangeHook(const std::string &name)
Definition PlacementSystem.cpp:87
static void registerSnapRule(const std::string &name, SnapFn fn)
Definition PlacementSystem.cpp:68
static bool hasValidateRule(const std::string &name)
Definition PlacementSystem.cpp:63
static eve::Result< void > registerStaticMeshSurface(const std::string &name, std::shared_ptr< const StaticMeshSurface > surface)
Register an immutable BVH-accelerated triangle mesh and retain its snapshot.
Definition PlacementSystem.cpp:126
static void pollEvents(std::vector< BuildingChangeEvent > &out)
Definition PlacementSystem.cpp:398
static void unregisterValidateRule(const std::string &name)
Definition PlacementSystem.cpp:59
static void unregisterSnapRule(const std::string &name)
Definition PlacementSystem.cpp:73
static void registerChangeHook(const std::string &name, ChangeHook fn)
Definition PlacementSystem.cpp:80
static SnapResult snapWithMode(const PlacementWorld &world, const std::string &mode, float worldX, float worldY)
Definition PlacementSystem.cpp:415
static void registerValidateRule(const std::string &name, ValidateFn fn)
Definition PlacementSystem.cpp:54
SurfaceFrameStatus normalizeSurfaceFrame(PlacementSystem::PlacementHit &hit)
Definition PlacementGeometry.cpp:216
FreeFootprint definitionFreeFootprint(const BuildingDefinition &definition, const PlacementWorld &world, float x, float y, float rotationDeg)
Definition PlacementGeometry.cpp:60
std::vector< FreeFootprint::Point > worldVertices(const FreeFootprint &footprint)
Transform footprint vertices. @cost Copies vertex count per overlap query.
Definition PlacementGeometry.cpp:119
int cardinalQuarter(float rotationDeg)
Definition PlacementGeometry.cpp:50
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:10
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
void rotatedFootprintSize(int w, int h, const std::vector< uint8_t > &mask, int steps, bool hexMode, int &outW, int &outH)
Axis-aligned size of a footprint after rotation.
Definition GridProjection.cpp:187
void foreachRotatedFootprint(int w, int h, const std::vector< uint8_t > &mask, int steps, bool hexMode, const std::function< void(int lx, int ly)> &fn)
Enumerates local cells of a rotated footprint.
Definition GridProjection.cpp:121
@ InvalidArgument
@ NotFound
@ Conflict
@ Applied
std::string placementKind
Placement domain: cell (default), edge, corner, or free.
Definition BuildingTypes.h:111
std::vector< float > freeFootprintVertices
Optional convex local polygon as x/y pairs in grid-cell units, centered on the free anchor.
Definition BuildingTypes.h:119
float freeFootprintHeightCells
Optional oriented-box height in grid-cell units; positive width and height select OBB collision.
Definition BuildingTypes.h:117
std::vector< uint8_t > footprintMask
可选占地掩码,长度 footprintW*footprintH;空表示实心矩形。行主序、原点在最小 x/y。
Definition BuildingTypes.h:135
float freeFootprintWidthCells
Optional oriented-box width in grid-cell units; positive width and height select OBB collision.
Definition BuildingTypes.h:115
One sampled point and orthonormal frame on a placement surface.
Definition PlacementSystem.h:41
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