载入中...
搜索中...
未找到
CanonicalMeshEncode.cpp
浏览该文件的文档.
23 if (!count || mesh.positions.size() % 3 || count > limits.maximumVertices || mesh.indices.empty() ||
32 3 + (mesh.normals.empty() ? 0 : 3) + uint64_t(mesh.texcoords.size()) * 2 + (mesh.colors.empty() ? 0 : 4);
36 if (!validValues(mesh.positions) || !validValues(mesh.normals) || !validValues(mesh.colors)) return invalid();
51 (extended ? 28ull : 24ull) + uint64_t(mesh.texcoords.size()) * 4 + uint64_t(mesh.attributes.size()) * 72;
61 bytes.insert(bytes.end(), {'E', 'V', 'M', 'E', 'S', 'H', 0, uint8_t(extended || !mesh.colors.empty() ? 3 : 2)});
78 for (size_t j = 0; j < components; ++j) put(std::bit_cast<uint32_t>(values[vertex * components + j]));
84 for (const auto& [name, attribute] : mesh.attributes) stream(attribute.values, v, attribute.components);
91 Diagnostic::error(DiagnosticCode::Failed, "canonical mesh allocation failed", {}, {}, "asset.mesh"));
112 out << "NODE " << std::quoted(std::string(id)) << ' ' << std::quoted(std::string(operation)) << '\n';
116 out << "EDGE " << std::quoted(std::string(from)) << ' ' << std::quoted(std::string(to)) << " 0\n";
124 Value::fromJson(std::string_view(reinterpret_cast<const char*>(definition.data()), definition.size()));
132 if (!schema || !schema->isString() || schema->asString() != "eve.pcg-graph" || !version || !version->isInt64() ||
136 DiagnosticCode::Unsupported, "unsupported eve.pcg-graph/1 definition", {}, {}, "asset.cook.pcg"));
139 DiagnosticCode::InvalidArgument, "PCG rule count exceeds Cook limits", "$.rules", {}, "asset.cook.pcg"));
155 seed->asInt() < 0 || !number(rule ? field(*rule, "densityPerSquareMeter") : nullptr, density) ||
157 !number(rule ? field(*rule, "maximumSlopeRadians") : nullptr, maximumSlope) || minimumSlope < 0 ||
169 plan << "FLOAT " << std::quoted(sample) << " \"spacing\" " << (density > 0 ? std::sqrt(1.0 / density) : 1.0)
176 plan << "FLOAT " << std::quoted(slope) << " \"minDegrees\" " << minimumSlope * radiansToDegrees << '\n';
177 plan << "FLOAT " << std::quoted(slope) << " \"maxDegrees\" " << maximumSlope * radiansToDegrees << '\n';
189 << "STRING " << std::quoted(taggedPrototype) << " \"value\" " << std::quoted(prototype->asString())
194 << "STRING " << std::quoted(taggedLayer) << " \"value\" " << std::quoted(layer->asString()) << '\n';
211 DiagnosticCode::InvalidArgument, "compiled PCG plan exceeds Cook budget", {}, {}, "asset.cook.pcg"));
212 Value::Object runtime{{"schema", Value("eve.pcg-graph")}, {"schemaVersion", Value(std::int64_t(1))},
216 if (!encodedDefinition) return Result<CookedCanonicalPcgGraph>::failure(encodedDefinition.status());
237 if (!value || !value->isInt64() || value->asInt() <= 0 || uint64_t(value->asInt()) > UINT32_MAX) return false;
246Result<CookedCanonicalVolumeTexture> cookCanonicalVolumeTextureRgba8(std::span<const uint8_t> definition,
250 Value::fromJson(std::string_view(reinterpret_cast<const char*>(definition.data()), definition.size()));
257 !blob->isString() || !blob->asString().ends_with("/source.r8") || !positive32(*object, "width", width) ||
260 Diagnostic::error(DiagnosticCode::ParseError, "volume definition shape or members are invalid", {}, {},
267 DiagnosticCode::InvalidArgument, "volume dimensions, version, source bytes or budget are invalid", {}, {},
273 DiagnosticCode::InvalidArgument, "volume dimensions, version, source bytes or budget are invalid", {}, {},
Canonical PCG graph compilation to runtime execution plans.
Bounded R8 volume conversion to runtime EVVOL.
Owning, renderer-independent dynamic values.
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
Result< std::string > toJson() const
Serialize this value as deterministic compact JSON.
Definition Value.cpp:187
const std::string & asString() const
Return the string payload; the caller must have checked the kind.
Definition Value.cpp:207
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:177
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:209
bool isInt64() const
True when the JSON number was an integer literal that fits Int64.
Definition Json.cpp:329
Definition AssetCooker.cpp:19
Result< CookedCanonicalVolumeTexture > cookCanonicalVolumeTextureRgba8(std::span< const uint8_t > definition, std::span< const uint8_t > sourceR8, uint64_t maximumDecodedBytes)
Definition CanonicalMeshEncode.cpp:246
EVENGINE_API_FOUNDATION Result< std::vector< std::uint8_t > > encodeCanonicalMesh(const CanonicalMeshData &mesh, const CanonicalMeshLimits &limits={})
Encode an owning snapshot to EVMESH v3, or v2 when no named attributes exist. Borrows input synchrono...
Definition CanonicalMeshEncode.cpp:15
Result< CookedCanonicalPcgGraph > cookCanonicalPcgGraph(std::span< const std::uint8_t > definition, std::uint32_t maximumRules, std::uint64_t maximumPlanBytes)
Compile eve.pcg-graph/1 terrain scatter rules to a bounded PointGraph plan.
Definition CanonicalMeshEncode.cpp:121
const Value * field(const Value &value, const char *key)
Borrow an optional object field.
Definition BuildingSnapshot.cpp:96
@ InvalidArgument
@ Unsupported
@ Failed
@ ParseError
Owning CPU mesh snapshot; UV arrays are packed ST pairs indexed by source set number....
Definition CanonicalMesh.h:18
Allocation limits checked before decoding any vertex arrays. UV count is byte-budget bounded.
Definition CanonicalMesh.h:27
Runtime definition and RGBA8 bulk generated from one canonical volume.
Definition CanonicalVolumeTextureCook.h:15
std::vector< std::uint8_t > definition
Definition CanonicalVolumeTextureCook.h:16