载入中...
搜索中...
未找到
OceanRenderer.cpp
浏览该文件的文档.
74 auto configured = graphics_.configureMeshShaderSurface(*state.shader, graphics::BlendMode::Opaque, true, true);
88 graphics_.newMeshFromArrays(positions.data(), normals.data(), uv.data(), static_cast<int>(count),
94 return Result<std::unique_ptr<OceanRenderer>>::failure(failure(DiagnosticCode::Unsupported, error.what()));
101 return Result<void>::failure(failure(DiagnosticCode::Conflict, "Renderer expects a resident GPU projection"));
106 if (frame.positions.size() != count * 3 || frame.normals.size() != count * 3 || frame.surface.size() != count * 2 ||
107 !std::isfinite(frame.time) || !std::isfinite(frame.origin.x) || !std::isfinite(frame.origin.y) ||
108 !std::isfinite(frame.origin.z) || !std::all_of(frame.positions.begin(), frame.positions.end(), finite) ||
111 return Result<void>::failure(failure(DiagnosticCode::InvalidArgument, "Invalid ocean vertex frame"));
113 const glm::vec3 normal(frame.normals[i * 3], frame.normals[i * 3 + 1], frame.normals[i * 3 + 2]);
115 if (length < 0.99F || length > 1.01F || frame.surface[i * 2] < 0.0F || frame.surface[i * 2] > 1.0F)
116 return Result<void>::failure(failure(DiagnosticCode::InvalidArgument, "Ocean normals or foam invalid"));
118 if (!state.graphics->updateMeshVertices(state.mesh, frame.positions.data(), frame.normals.data(),
120 return Result<void>::failure(failure(DiagnosticCode::Unsupported, "Ocean mesh upload rejected"));
129 if (!state.published) return Result<void>::failure(failure(DiagnosticCode::Conflict, "Ocean frame not published"));
131 return Result<void>::failure(failure(DiagnosticCode::Conflict, "Hull mask and ocean render origins differ"));
132 state.graphics->setMesh3DNormalTexture(state.hullPublished ? state.hullMask[state.hullFront] : nullptr);
133 auto* atlas = state.backend == OceanRenderBackend::GpuResident ? state.atlas[state.front] : nullptr;
136 state.graphics->drawMeshShader(state.mesh, glm::mat4(1.0F), atlas, glm::vec4(1.0F), state.shader);
137 if (state.backend == OceanRenderBackend::GpuResident) state.graphics->setMesh3DHeightTexture(nullptr);
A structured explanation of a failed, degraded, or noteworthy result.
Definition Diagnostic.h:94
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
Owning topology preparation; settings are copied at build, with no retained references.
Definition OceanMesh.h:36
EVENGINE_API_DOMAINS Result< OceanMeshData > build() const
Build positively oriented triangles on XZ, graded geometrically from near water to horizon.
Definition OceanMesh.cpp:6
Prepare CPU reference vertices from the same water view used by rigid bodies. Borrows mesh and water ...
Definition OceanMesh.h:64
EVENGINE_API_DOMAINS Result< std::unique_ptr< OceanRenderer > > build() const
Allocate shader and fixed topology, publishing only a complete renderer.
Definition OceanRenderer.cpp:38
Graphics projection of an ocean; never owns or advances simulation state. Render-thread only,...
Definition OceanRenderer.h:27
EVENGINE_API_DOMAINS OceanMeshFrameBuilder frameBuilder(const OceanWaterView &water) const
Prepare a cheap borrowed CPU projection builder; set center/origin before building.
Definition OceanRenderer.cpp:35
EVENGINE_API_DOMAINS Result< void > draw()
Draw the published frame in the current 3D pass; camera/scene must use its render origin.
Definition OceanRenderer.cpp:125
EVENGINE_API_DOMAINS ~OceanRenderer()
EVENGINE_API_DOMAINS Result< void > publish(const OceanMeshFrame &frame)
Publish a prepared owning vertex frame; input is borrowed only for this call.
Definition OceanRenderer.cpp:98
Synchronous borrowed composition of the spectral sea and an optional local wake. Both owners must out...
Definition OceanWaterView.h:17
virtual bool releaseMesh(Mesh *mesh)
Eagerly releases a mesh created by this Graphics.
Definition Graphics.h:935
virtual bool releaseTexture(Texture *texture)
Eagerly releases a texture created by this Graphics.
Definition Graphics.h:732
virtual bool releaseShader(Shader *shader)
Eagerly releases a shader created by this Graphics.
Definition Graphics.h:1976
@ CpuReference
@ GpuResident
@ InvalidArgument
@ Unsupported
@ StaleHandle
@ Conflict
Definition Container.h:602
Owning CPU reference projection, ready for a mesh upload; simulation time and origin identify the fra...
Definition OceanMesh.h:49
graphics::Shader * shader
Definition OceanRendererInternal.h:14
std::weak_ptr< const void > lifetime
Definition OceanRendererInternal.h:12
std::array< graphics::Texture *, 2 > wake
Definition OceanRendererInternal.h:17
std::array< graphics::Texture *, 2 > hullMask
Definition OceanRendererInternal.h:17
std::array< graphics::Texture *, 2 > atlas
Definition OceanRendererInternal.h:17
graphics::Graphics * graphics
Definition OceanRendererInternal.h:11