载入中...
搜索中...
未找到
HouseGenerationFinish.cpp
浏览该文件的文档.
2
5 // Expand the canonical footprint to every cell occupied by rotated multi-cell components.
6 int occupiedWidth = r.width, occupiedDepth = r.depth;
7 for (const HouseInstance& instance : generated.instances) {
8 const auto component = library_.find(instance.componentId);
9 if (!component) continue;
10 const int rotation = (instance.rotationDeg % 360 + 360) % 360;
11 const bool quarter = (rotation / 90) % 2 != 0;
12 occupiedWidth =
13 std::max(occupiedWidth, instance.x + (quarter ? component->get().depth : component->get().width));
14 occupiedDepth =
15 std::max(occupiedDepth, instance.y + (quarter ? component->get().width : component->get().depth));
16 }
17 std::vector<uint8_t> occupiedMask(size_t(occupiedWidth * occupiedDepth), 0);
18 for (int y = 0; y < r.depth; ++y)
19 for (int x = 0; x < r.width; ++x)
20 occupiedMask[size_t(y * occupiedWidth + x)] = baseMask[size_t(y * r.width + x)];
21 for (const HouseInstance& instance : generated.instances) {
22 const auto component = library_.find(instance.componentId);
23 if (!component) continue;
24 const int rotation = (instance.rotationDeg % 360 + 360) % 360;
25 const bool quarter = (rotation / 90) % 2 != 0;
26 const int cellWidth = quarter ? component->get().depth : component->get().width;
27 const int cellDepth = quarter ? component->get().width : component->get().depth;
28 for (int y = 0; y < cellDepth; ++y)
29 for (int x = 0; x < cellWidth; ++x)
30 occupiedMask[size_t((instance.y + y) * occupiedWidth + instance.x + x)] = 1;
31 }
32 generated.footprintWidth = occupiedWidth;
33 generated.footprintDepth = occupiedDepth;
34 generated.footprintMask = std::move(occupiedMask);
35 auto validated = generated.validate(library_);
36 if (!validated.ok()) return validated;
37
39}
40} // namespace eve::housegen::house_detail
double y
double x
std::array< float, 4 > rotation
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
eve::OptionalRef< const HouseComponent > find(std::string_view id) const
按 id 查询组件;缺失是正常查询结果。
eve::Result< void > validate(const HouseComponentLibrary &library) const
校验布局是否满足组件库规则。
std::vector< uint8_t > footprintMask
Definition HouseLayout.h:36
int footprintWidth
Canonical base-floor occupancy mask owned by this layout.
Definition HouseLayout.h:34
std::vector< HouseInstance > instances
组件实例 / 房间 / 诊断信息。
Definition HouseLayout.h:38
布局中的单个组件实例(位置 + 旋转)。
int width
占地尺寸(格)与层数。