载入中...
搜索中...
未找到
Ghost.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5// 鬼影预览:候选建筑姿态 + 最近一次校验结果,供 UI 着色与确认放置。
6
8
9#include <string>
10
11namespace eve::building {
12
13class PlacementWorld;
14
17public:
19 Ghost() = default;
21 ~Ghost() = default;
22
24 void destroy();
25
27 std::string getBuildingId() const { return buildingId_; }
29 void setBuildingId(const std::string &id);
30
32 int getCellX() const { return cellX_; }
34 int getCellY() const { return cellY_; }
36 void setCell(int cellX, int cellY);
37
39 float getWorldX() const { return worldX_; }
41 float getWorldY() const { return worldY_; }
43 void setWorld(float worldX, float worldY);
45 float getElevation() const { return elevation_; }
47 void setElevation(float elevation);
48
50 float getRotationDeg() const { return rotationDeg_; }
52 void setRotationDeg(float deg);
54 void rotateBy(float deltaDeg);
56 std::string getPlacementKind() const { return placementKind_; }
58 std::string getEdgeAxis() const;
60 void setEdge(PlacementWorld *world, int cellX, int cellY, const std::string &direction);
62 void setCorner(PlacementWorld *world, int vertexX, int vertexY);
64 void setFree(PlacementWorld *world, float worldX, float worldY, float elevation = 0.f);
65
67 bool isValid() const { return valid_; }
69 std::string getReason() const { return reason_; }
71 std::string getSurfaceId() const { return surfaceId_; }
73 int64_t getSurfaceRevision() const { return static_cast<int64_t>(surfaceRevision_); }
75 float getSurfaceNormalX() const { return surfaceNormalX_; }
77 float getSurfaceNormalY() const { return surfaceNormalY_; }
79 float getSurfaceNormalZ() const { return surfaceNormalZ_; }
81 float getSurfaceTangentX() const { return surfaceTangentX_; }
83 float getSurfaceTangentY() const { return surfaceTangentY_; }
85 float getSurfaceTangentZ() const { return surfaceTangentZ_; }
87 int getSurfaceSampleCount() const { return surfaceSampleCount_; }
89 float getSurfaceMaxSlopeDegrees() const { return surfaceMaxSlopeDegrees_; }
91 float getSurfaceHeightDelta() const { return surfaceHeightDelta_; }
92
94 void setFromWorld(PlacementWorld *world, float worldX, float worldY);
97 void setFromWorld3D(PlacementWorld *world, float worldX, float worldY, float worldZ);
100 void setFromSurface(PlacementWorld *world, const std::string &surface, float x, float y);
102 bool validate(PlacementWorld *world);
103
104private:
105 friend class PlacementSystem;
106
107 std::string buildingId_;
108 int cellX_ = 0;
109 int cellY_ = 0;
110 float worldX_ = 0.f;
111 float worldY_ = 0.f;
112 float elevation_ = 0.f;
113 std::string surfaceId_;
114 uint64_t surfaceRevision_ = 0;
115 float surfaceNormalX_ = 0.f;
116 float surfaceNormalY_ = 1.f;
117 float surfaceNormalZ_ = 0.f;
118 float surfaceTangentX_ = 1.f;
119 float surfaceTangentY_ = 0.f;
120 float surfaceTangentZ_ = 0.f;
121 int surfaceSampleCount_ = 0;
122 float surfaceMaxSlopeDegrees_ = 0.f;
123 float surfaceHeightDelta_ = 0.f;
124 std::string surfaceProviderName_;
125 float surfaceInputX_ = 0.f;
126 float surfaceInputY_ = 0.f;
127 bool surfacePatchStale_ = false;
128 bool surfaceHitMissing_ = false;
129 float rotationDeg_ = 0.f;
130 std::string placementKind_ = "cell";
131 EdgeAddress edge_;
132 CornerAddress corner_;
133 bool valid_ = false;
134 std::string reason_;
135};
136
137} // namespace eve::building
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
#define EVENGINE_API_WORLD
Definition Export.h:109
float elevation
void(* destroy)(void *)
World3D * world
RoadLaneDirection direction
EVENGINE_API_WORLD public API.
Definition Ghost.h:16
float getElevation() const
Returns the elevation.
Definition Ghost.h:45
int getCellY() const
Returns the cell y.
Definition Ghost.h:34
float getWorldY() const
Returns the world y.
Definition Ghost.h:41
float getSurfaceHeightDelta() const
Sampled elevation range across the complete footprint.
Definition Ghost.h:91
int getCellX() const
Returns the cell x.
Definition Ghost.h:32
float getSurfaceTangentX() const
X component of the captured unit surface tangent.
Definition Ghost.h:81
std::string getSurfaceId() const
Surface identity captured by the last successful setFromSurface call.
Definition Ghost.h:71
Ghost()=default
Ghost.
std::string getReason() const
Returns the reason.
Definition Ghost.h:69
bool isValid() const
True when valid.
Definition Ghost.h:67
std::string getPlacementKind() const
Current placement domain (cell, edge, corner, or free).
Definition Ghost.h:56
float getSurfaceTangentZ() const
Z component of the captured unit surface tangent.
Definition Ghost.h:85
float getWorldX() const
Returns the world x.
Definition Ghost.h:39
float getRotationDeg() const
Returns the rotation deg.
Definition Ghost.h:50
float getSurfaceTangentY() const
Y component of the captured unit surface tangent.
Definition Ghost.h:83
std::string getBuildingId() const
Returns the building id.
Definition Ghost.h:27
~Ghost()=default
Ghost.
int getSurfaceSampleCount() const
Number of occupied footprint cells sampled in the current patch.
Definition Ghost.h:87
int64_t getSurfaceRevision() const
Surface revision captured by the last successful setFromSurface call.
Definition Ghost.h:73
float getSurfaceNormalY() const
Y component of the captured unit surface normal.
Definition Ghost.h:77
float getSurfaceMaxSlopeDegrees() const
Maximum sampled slope relative to the grid-plane up axis.
Definition Ghost.h:89
float getSurfaceNormalZ() const
Z component of the captured unit surface normal.
Definition Ghost.h:79
float getSurfaceNormalX() const
X component of the captured unit surface normal.
Definition Ghost.h:75
EVENGINE_API_WORLD public API.
格子型建筑放置世界(脚本可直接操作)。
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:7
Canonical address of one logical grid vertex used by corner objects.
Canonical address of one grid edge.