载入中...
搜索中...
未找到
ArchSpaceProjector.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
5#include "common/Result.h"
6
7#include <cstdint>
8#include <string>
9#include <vector>
10
11namespace eve::archspace {
12
13class Document;
14
16enum class GridCellKind : std::uint8_t { Empty = 0, Floor, Wall, Portal, Solid };
17
24 int width = 0;
25 int height = 0;
26 double originX = 0.0;
27 double originZ = 0.0;
28 double cellSize = 1.0;
30 std::string orientation = "orthogonal";
31 std::vector<GridCellKind> cells;
33 std::vector<std::string> regionIds;
34};
35
47public:
49 virtual ~IArchSpaceProjector() = default;
50
56 [[nodiscard]] virtual const char* kind() const noexcept = 0;
57
65 [[nodiscard]] virtual eve::Result<void> sync(const Document& document, std::uint64_t revision) = 0;
66
68 virtual void clear() = 0;
69
74 [[nodiscard]] virtual eve::Result<std::string> pickNode(Vec3 /*rayOrigin*/, Vec3 /*rayDir*/) const {
76 "ArchSpace projector does not support picking",
77 "pick", {}, "archspace.projector"));
78 }
79};
80
87public:
89 MeshSceneProjector() = default;
90
96 [[nodiscard]] const char* kind() const noexcept override { return "scene3d"; }
97
98 [[nodiscard]] eve::Result<void> sync(const Document& document, std::uint64_t revision) override;
99
100 void clear() override;
101
107 [[nodiscard]] const MeshBake& mesh() const noexcept { return mesh_; }
108
110 [[nodiscard]] std::uint64_t revision() const noexcept { return revision_; }
111
112private:
113 MeshBake mesh_{};
114 std::uint64_t revision_ = 0;
115};
116
132 const Document& document, const std::string& levelId, double cellSize,
133 const std::string& orientation = "orthogonal");
134
135} // namespace eve::archspace
std::uint64_t revision
#define EVENGINE_API_WORLD
Definition Export.h:109
Move-only, checked operation results for the common layer.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Authoritative ArchSpace document (Pascal-like node graph).
Presentation adapter contract for ArchSpace documents.
virtual const char * kind() const noexcept=0
Stable projector kind wire name. @ownership Non-owning pointer to a static string literal; do not fre...
virtual void clear()=0
Drop derived presentation state.
virtual eve::Result< std::string > pickNode(Vec3, Vec3) const
Pick a document node under a world-space ray when supported.
virtual eve::Result< void > sync(const Document &document, std::uint64_t revision)=0
Rebuild derived presentation from document at revision.
virtual ~IArchSpaceProjector()=default
Releases IArchSpaceProjector resources.
Mesh bake projector for 3D / scene hosts.
const MeshBake & mesh() const noexcept
Last baked mesh; empty after clear or before the first successful sync. @ownership Borrowed from this...
MeshSceneProjector()=default
Mesh scene projector.
std::uint64_t revision() const noexcept
Revision last successfully synced; 0 before the first sync.
const char * kind() const noexcept override
Stable projector kind wire name. @ownership Non-owning pointer to a static string literal; do not fre...
GridCellKind
Semantic cell kind for grid projections (tilemap / HD2D hosts).
eve::Result< GridProjection > bakeGridProjection(const Document &document, const std::string &levelId, double cellSize, const std::string &orientation)
Rasterize one level into a grid for ortho/iso/HD2D hosts.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
Renderer-neutral occupancy grid rebuilt from an ArchSpace level.
std::string orientation
Wire hint: "orthogonal" or "isometric".
std::vector< GridCellKind > cells
std::vector< std::string > regionIds
Region id per cell (empty when none). Parallel to cells.
Renderer-neutral triangle mesh rebuilt from the document.
Metres in world/level space.