载入中...
搜索中...
未找到
MeshGraph.cpp
浏览该文件的文档.
38 std::find_if(std::begin(specs), std::end(specs), [id](const Spec& spec) { return id == spec.id; });
50 return key == "cellSize" || key == "height" || key == "minX" || key == "minY" || key == "maxX" ||
54 return key == "x" || key == "y" || key == "z" || key == "yaw" || key == "sx" || key == "sy" || key == "sz";
62void addQuad(MeshBuild& mesh, float ax, float ay, float az, float bx, float by, float bz, float cx, float cy, float cz,
73MeshBuild buildTiles(const Grid2D& grid, float cellSize, float height, std::string_view group, int minX, int minY,
85 (group.empty() ? std::string("tiles") : std::string(group)) + "/" + std::to_string(grid.getCell(x, y)) +
86 "/" + std::string(tilePresetKindName(preset.kind)) + "/r" + std::to_string(preset.rotationDegrees) +
111 if (id.empty()) return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "node id is empty", {}, {}, "procgen.meshGraph"));
112 if (!specFor(operation)) return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "unknown operation: " + operation, id, {}, "procgen.meshGraph"));
113 if (nodes_.contains(id)) return Result<void>::failure(Diagnostic::error(DiagnosticCode::Conflict, "duplicate node id", id, {}, "procgen.meshGraph"));
123Result<void> MeshGraph::connect(std::string_view fromId, std::string_view toId, int inputIndex) {
127 return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "connection references an unknown node", std::string(toId), {}, "procgen.meshGraph"));
131 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "input slot is outside the operation contract", std::string(toId), {}, "procgen.meshGraph"));
133 return Result<void>::failure(Diagnostic::error(DiagnosticCode::TypeMismatch, "typed graph ports are incompatible", std::string(toId), {}, "procgen.meshGraph"));
143 return Result<void>::failure(Diagnostic::error(DiagnosticCode::TypeMismatch, "node is not grid.input", std::string(id), {}, "procgen.meshGraph"));
154 return Result<void>::failure(Diagnostic::error(DiagnosticCode::TypeMismatch, "node is not point.input", std::string(id), {}, "procgen.meshGraph"));
165 return Result<void>::failure(Diagnostic::error(DiagnosticCode::TypeMismatch, "node is not mesh.input", std::string(id), {}, "procgen.meshGraph"));
175 if (found == nodes_.end()) return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "unknown node", std::string(id), {}, "procgen.meshGraph"));
177 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "parameter is not declared by this operation: " + key, std::string(id), {}, "procgen.meshGraph"));
179 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "mesh parameter must be finite", std::string(id), {}, "procgen.meshGraph"));
188 if (found == nodes_.end()) return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "unknown node", std::string(id), {}, "procgen.meshGraph"));
190 return Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument, "parameter is not declared by this operation: " + key, std::string(id), {}, "procgen.meshGraph"));
197Result<MeshGraphValue> MeshGraph::evaluate(std::string_view id, std::unordered_map<std::string, int>& states) {
201 Diagnostic::error(DiagnosticCode::NotFound, "unknown node", std::string(id), {}, "procgen.meshGraph"));
206 Diagnostic::error(DiagnosticCode::Conflict, "graph contains a cycle", node.id, {}, "procgen.meshGraph"));
241 Diagnostic::error(DiagnosticCode::Failed, "mesh merge failed", node.id, {}, "procgen.meshGraph"));
246 if (!result.appendTransformed(&source, node.floats["x"], node.floats["y"], node.floats["z"], node.floats["yaw"],
259 if (!result.appendTransformed(&source, points.getX(index), points.getY(index), points.getZ(index), 0.f,
276 return Result<MeshBuild>::failure(Diagnostic::error(DiagnosticCode::TypeMismatch, "output node is not a mesh",
317 out << "FLOAT " << std::quoted(id) << ' ' << std::quoted(key) << ' ' << node.floats.at(key) << '\n';
322 out << "STRING " << std::quoted(id) << ' ' << std::quoted(key) << ' ' << std::quoted(node.strings.at(key))
341 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "invalid mesh graph header", {}, {}, "procgen.meshGraph"));
359 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "invalid NODE record", {}, {}, "procgen.meshGraph"));
366 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "invalid EDGE record", {}, {}, "procgen.meshGraph"));
373 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "invalid FLOAT record", {}, {}, "procgen.meshGraph"));
380 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "invalid STRING record", {}, {}, "procgen.meshGraph"));
383 return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "unknown mesh graph record: " + kind, {}, {}, "procgen.meshGraph"));
387 if (!record.eof()) return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "trailing mesh graph record data", {}, {}, "procgen.meshGraph"));
389 if (!ended) return Result<void>::failure(Diagnostic::error(DiagnosticCode::ParseError, "mesh graph END record is missing", {}, {}, "procgen.meshGraph"));
394 if (states[id] == 1) return Result<void>::failure(Diagnostic::error(DiagnosticCode::Conflict, "cycle in serialized graph", id, {}, "procgen.meshGraph"));
397 if (found == replacement.nodes_.end()) return Result<void>::failure(Diagnostic::error(DiagnosticCode::NotFound, "unknown node", id, {}, "procgen.meshGraph"));
Stable, structured diagnostics shared by engine modules.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Intermediate 2D generation result. cells store semantic ids (see Semantic.h), not tile GIDs — convert...
Definition Grid2D.h:36
CPU triangle mesh from procedural mesh recipes (e.g. marching cubes). Positions/normals are xyz-packe...
Definition MeshBuild.h:19
Typed procedural mesh graph composing grid, point and topology domains.
Definition MeshGraph.h:21
Result< void > setNodeGrid(std::string_view id, const Grid2D &value)
Sets the node grid.
Definition MeshGraph.cpp:140
Result< void > setNodePoints(std::string_view id, const PointSet &value)
Sets the node points.
Definition MeshGraph.cpp:151
Result< void > setNodeFloat(std::string_view id, std::string key, float value)
Sets the node float.
Definition MeshGraph.cpp:173
Result< void > deserializeDefinition(std::string_view definition)
Atomically replace this graph from a versioned definition. Runtime input values are not persisted.
Definition MeshGraph.cpp:335
Result< void > setNodeString(std::string_view id, std::string key, std::string value)
Sets the node string.
Definition MeshGraph.cpp:186
Result< void > connect(std::string_view fromId, std::string_view toId, int inputIndex=0)
Connect.
Definition MeshGraph.cpp:123
std::string serializeDefinition() const
Serialize topology and scalar parameters using the versioned EVPCG mesh schema.
Definition MeshGraph.cpp:307
Result< void > setNodeMesh(std::string_view id, const MeshBuild &value)
Sets the node mesh.
Definition MeshGraph.cpp:162
@ PointSet
Definition EvpackPointGraphLoader.h:12
std::string_view tilePresetKindName(TilePresetKind kind) noexcept
Stable lowercase identifier used in mesh build-layer group names.
Definition TilePreset.cpp:105
TilePresetVariant resolveTilePreset(std::uint8_t mask) noexcept
Resolve the exact TileWorldCreator 4.3.5 standard-grid category and transform tables.
Definition TilePreset.cpp:91
std::variant< Grid2D, PointSet, MeshBuild > MeshGraphValue
Strong values accepted by MeshGraph ports.
Definition MeshGraph.h:18
WidgetDesc grid(int columns, std::vector< WidgetDesc > children, std::string id)
Fixed-column grid; children are placed in source order.
Definition Widget.cpp:687
@ InvalidArgument
@ TypeMismatch
A stable reference resolved to a different canonical domain type.
@ NotFound
@ Failed
@ ParseError
@ Conflict
Definition Container.h:602