载入中...
搜索中...
未找到
VegetationAsset.cpp
浏览该文件的文档.
22uint32_t VegetationAsset::vertexCount() const noexcept { return uint32_t(impl_->vertices.size()); }
23Result<std::unique_ptr<VegetationAsset>> VegetationAsset::fromCanonical(const asset::CanonicalMeshData& mesh) {
26 if (!count || count > 4'000'000 || mesh.positions.size() % 3 || mesh.normals.size() != count * 3 ||
29 DiagnosticCode::InvalidArgument, "invalid vegetation mesh geometry", {}, {}, "asset.graphics.vegetation"));
63 DiagnosticCode::InvalidArgument, "vegetation index out of range", {}, {}, "asset.graphics.vegetation"));
66 auto four = [](const auto& a, size_t at) { return glm::vec4(a[at], a[at + 1], a[at + 2], a[at + 3]); };
74 DiagnosticCode::InvalidArgument, "invalid vegetation normal", {}, {}, "asset.graphics.vegetation"));
104 return Result<Output>::failure(Diagnostic::error(DiagnosticCode::Failed, "vegetation asset allocation failed",
108Result<std::unique_ptr<VegetationAsset>> VegetationAsset::load(const asset::EvpackResourceReader& reader,
125 return Result<Output>::failure(Diagnostic::error(DiagnosticCode::NotFound, "vegetation mesh bulk is missing",
141 graphics.newMeshFromArrays(geometry.value().positions.data(), geometry.value().normals.data(), impl_->uv.data(),
145 DiagnosticCode::Failed, "vegetation backend mesh creation failed", {}, {}, "asset.graphics.vegetation"));
147 mesh->adoptTangentFrame(std::move(geometry.value().tangents), std::move(geometry.value().bitangents));
151 DiagnosticCode::Failed, "vegetation mesh rollback failed", {}, {}, "asset.graphics.vegetation"));
158 DiagnosticCode::Failed, "vegetation highlight rollback failed", {}, {}, "asset.graphics.vegetation"));
165 DiagnosticCode::Failed, "vegetation factor rollback failed", {}, {}, "asset.graphics.vegetation"));
170Result<graphics::Mesh*> VegetationAsset::createGpuFieldMesh(graphics::Graphics& graphics) const {
185 shading.insert(shading.end(), {vertex.variation, vertex.occlusion, vertex.detail, vertex.detailCoord.x,
204 DiagnosticCode::Failed, "vegetation rest mesh upload failed", {}, {}, "asset.graphics.vegetation"));
221 DiagnosticCode::Failed, "vegetation rest mesh allocation failed", {}, {}, "asset.graphics.vegetation"));
227 return graphics::updateVegetationMesh(graphics, mesh, field, impl_->vertices, motion, impl_->uv, impl_->indices);
Typed capability-aware runtime access to admitted packs.
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
Immutable reader retaining an admitted pack by shared ownership.
Definition EvpackResourceReader.h:29
Result< RuntimeAssetPayload > read(const AssetRef &asset, std::string_view expectedType, const EvpackCapabilities &capabilities, std::uint64_t maximumDecodedBytes) const
Resolve, type-check, variant-select and decode a canonical runtime asset.
Definition EvpackResourceReader.cpp:10
Owning decoded TVE rest geometry, independent of archive and GPU resource lifetimes....
Definition VegetationAsset.h:27
Result< graphics::VegetationGeometry > evaluate(const graphics::VegetationField &field, const graphics::VegetationMotion &motion) const
Evaluate owning world-space geometry with explicit field/time/transform inputs. Worker-safe with immu...
Definition VegetationAsset.cpp:131
std::uint32_t vertexCount() const noexcept
Return the immutable rest vertex count.
Definition VegetationAsset.cpp:22
Result< graphics::Mesh * > createMesh(graphics::Graphics &graphics, const graphics::VegetationField &field, const graphics::VegetationMotion &motion) const
Create a backend-owned animated mesh; caller must release it through graphics. Graphics-thread only....
Definition VegetationAsset.cpp:135
VegetationAsset(const VegetationAsset &)=delete
Result< graphics::Mesh * > createGpuFieldMesh(graphics::Graphics &graphics) const
Create an object-space rest mesh with owning GPU-deformation factors. Graphics-thread only....
Definition VegetationAsset.cpp:170
Result< void > updateMesh(graphics::Graphics &graphics, graphics::Mesh &mesh, const graphics::VegetationField &field, const graphics::VegetationMotion &motion) const
Update an existing mesh from immutable rest data, without accumulating deformation....
Definition VegetationAsset.cpp:224
static Result< std::unique_ptr< VegetationAsset > > load(const asset::EvpackResourceReader &reader, const AssetRef &ref, const asset::EvpackCapabilities &capabilities, const asset::CanonicalMeshLimits &limits)
Read one canonical runtime mesh and decode its TVE authoring streams. Reader, identity,...
Definition VegetationAsset.cpp:108
static Result< std::unique_ptr< VegetationAsset > > fromCanonical(const asset::CanonicalMeshData &mesh)
Admit explicit TVE-packed Unity canonical streams as native rest geometry.
Definition VegetationAsset.cpp:23
Definition Graphics.h:125
virtual bool releaseMesh(Mesh *mesh)
Eagerly releases a mesh created by this Graphics.
Definition Graphics.h:927
virtual Mesh * newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
Upload a triangle mesh from packed CPU arrays. Owned by Graphics. posXYZ required (vertexCount*3)....
Backend-independent, owning vegetation influence field. Single writer; concurrent const evaluation is...
Definition VegetationField.h:86
Definition CookedMaterial.cpp:5
Result< CanonicalMeshData > decodeCanonicalMesh(std::span< const std::uint8_t > bytes, const CanonicalMeshLimits &limits)
Decode canonical EVMESH binary v1, v2 or v3 into independently owned arrays.
Definition CanonicalMesh.cpp:22
Result< VegetationGeometry > deformVegetation(const VegetationField &field, std::span< const VegetationVertex > vertices, const VegetationMotion &motion)
Evaluate plant bending, squash, rolling, flutter, interaction and perspective. Worker-safe with immut...
Definition VegetationMotion.cpp:185
Result< void > updateVegetationMesh(Graphics &graphics, Mesh &mesh, const VegetationField &field, std::span< const VegetationVertex > vertices, const VegetationMotion &motion, std::span< const float > texcoords, std::span< const uint32_t > indices)
Deform rest geometry then update an existing mesh through the active Graphics backend....
Definition VegetationRender.cpp:22
Result< std::vector< VegetationVertex > > decodeTveVegetationVertices(std::span< const TvePackedVertex > vertices)
Decode TVE 12.x color/motion/bounds/detail/pivot packing to native rest vertices. Borrows input only ...
Definition VegetationPacking.cpp:15
@ InvalidArgument
@ NotFound
@ Unsupported
@ Failed
@ ParseError
Definition Container.h:602
Owning float vertex attribute; one to four components per vertex.
Definition CanonicalMesh.h:11
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
Actual runtime device capabilities used for variant selection.
Definition Evpack.h:92
One decoded runtime chunk with its admitted semantic metadata.
Definition EvpackResourceReader.h:13
std::vector< std::uint8_t > bytes
Definition EvpackResourceReader.h:16
std::vector< graphics::VegetationVertex > vertices
Definition VegetationAsset.cpp:15
std::vector< uint32_t > indices
Definition VegetationAsset.cpp:17
std::vector< float > uv
Definition VegetationAsset.cpp:16
Source-equivalent plant motion parameters with explicit time and texture inputs. All data is owned....
Definition VegetationMotion.h:38