载入中...
搜索中...
未找到
GraphicsMeshFactoryAdapter.cpp
浏览该文件的文档.
2
4#include "graphics/Mesh.h"
5
6namespace eve::asset_graphics {
8 std::span<const float> bitangents) {
10 return mesh->setTangentFrame(tangents, bitangents);
11}
12namespace {
13
14} // namespace
15
17 const float* posXYZ, const float* nrmXYZ, const float* uvST, int vertexCount,
18 const std::uint32_t* indices, int indexCount) {
19 graphics::Mesh* mesh = factory_.newMeshFromArrays(posXYZ, nrmXYZ, uvST, vertexCount,
21 if (!mesh)
23 "graphics backend rejected canonical mesh upload", {},
24 {}, "asset.graphics.adapter"));
26}
27
29 const float* posXYZ, const float* nrmXYZ, const float* uvST, const float* colorRGBA,
30 int vertexCount, const std::uint32_t* indices, int indexCount) {
32 posXYZ, nrmXYZ, uvST, colorRGBA, vertexCount, indices, indexCount);
33 if (!mesh)
35 Diagnostic::error(DiagnosticCode::Failed, "graphics backend rejected colored canonical mesh upload", {}, {},
36 "asset.graphics.adapter"));
38}
39
41 if (!mesh)
43 DiagnosticCode::InvalidArgument, "cannot release a null graphics mesh", {}, {}, "asset.graphics.adapter"));
44 if (!factory_.releaseMesh(mesh))
45 return Result<void>::failure(Diagnostic::error(DiagnosticCode::Failed, "graphics backend rejected mesh release",
46 {}, {}, "asset.graphics.adapter"));
47 return Result<void>::success();
48}
49
51 std::span<const float> values) {
52 if (!mesh)
54 Diagnostic::error(DiagnosticCode::InvalidArgument, "null mesh", {}, {}, "asset.graphics.adapter"));
55 return mesh->setTexcoordSet(set, values);
56}
57
58} // namespace eve::asset_graphics
std::map< std::string, Var > values
Transactional graphics consumers for canonical runtime assets.
std::uint32_t vertexCount
std::uint32_t indexCount
std::vector< std::uint32_t > indices
Mesh * mesh
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
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Result< void > setMeshTangentFrame(graphics::Mesh *mesh, std::span< const float > tangents, std::span< const float > bitangents) override
Attach authored XYZ tangent and bitangent streams before mesh publication.
Result< void > releaseMesh(graphics::Mesh *mesh) override
Release a mesh previously returned by this factory.
Result< graphics::Mesh * > uploadMesh(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const std::uint32_t *indices, int indexCount) override
Upload validated, tightly packed mesh arrays.
Result< graphics::Mesh * > uploadMeshColored(const float *posXYZ, const float *nrmXYZ, const float *uvST, const float *colorRGBA, int vertexCount, const std::uint32_t *indices, int indexCount) override
Upload a mesh with a tightly packed linear RGBA vertex-color stream.
Result< void > setMeshTexcoords(graphics::Mesh *mesh, std::uint32_t set, std::span< const float > values) override
Attach an owning UV stream to an uploaded mesh before publication. @thread Graphics thread; input is ...
virtual bool releaseMesh(Mesh *mesh)=0
Release mesh.
virtual Mesh * newMeshFromArrays(const float *posXYZ, const float *nrmXYZ, const float *uvST, int vertexCount, const uint32_t *indices, int indexCount)=0
Creates a mesh from arrays. @ownership Caller deletes unless documented otherwise.
virtual Mesh * newMeshFromArraysColored(const float *posXYZ, const float *nrmXYZ, const float *uvST, const float *colorRGBA, int vertexCount, const uint32_t *indices, int indexCount)=0
Create a mesh with a packed linear RGBA vertex-color stream.
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:25