载入中...
搜索中...
未找到
GeometryCollectionRenderer.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4#include "common/Result.h"
5
6#include <array>
7#include <cstdint>
8#include <map>
9#include <memory>
10#include <vector>
11
12namespace eve::graphics {
13class Graphics;
14class Mesh;
15} // namespace eve::graphics
16
17namespace eve::physics {
18
19class GeometryCollectionInstance;
20class CollapseAnimation;
21class CollapsePlayback;
22struct FractureGeometry;
23struct BonePresentation;
24
42public:
49 explicit GeometryCollectionRenderer(GeometryCollectionInstance* instance) noexcept;
50
55
61 void setInstance(GeometryCollectionInstance* instance);
67 [[nodiscard]] GeometryCollectionInstance* getInstance() const noexcept { return instance_; }
68
70 void setExteriorColor(float r, float g, float b, float a);
72 void setInteriorColor(float r, float g, float b, float a);
84 [[nodiscard]] eve::Result<void> setGroupExteriorColor(int groupId, float r, float g, float b, float a);
86 void setSleepColor(float r, float g, float b, float a);
87
95 [[nodiscard("check geometry-collection draw")]] eve::Result<void> draw(graphics::Graphics* graphics);
96
98 [[nodiscard]] int lastActiveDrawCount() const noexcept { return lastActiveDrawCount_; }
100 [[nodiscard]] int lastSleepBatchCount() const noexcept { return lastSleepBatchCount_; }
101
111 [[nodiscard]] eve::Result<void> drawAnimation(const CollapseAnimation& animation, graphics::Graphics* graphics,
112 float seconds, float offsetX, float offsetY, float offsetZ);
113
121 [[nodiscard]] eve::Result<void> prepareAnimation(const CollapseAnimation& animation, graphics::Graphics* graphics);
126 [[nodiscard]] eve::Result<void> prepareInstance(graphics::Graphics* graphics);
127
134 [[nodiscard]] eve::Result<void> submitAnimation(const CollapseAnimation& animation, float seconds, float offsetX,
135 float offsetY, float offsetZ);
136
143 [[nodiscard]] eve::Result<void> preparePlayback(const CollapsePlayback& player, graphics::Graphics* graphics);
150 [[nodiscard]] eve::Result<void> submitPlayback(const CollapsePlayback& player);
151
152private:
153 [[nodiscard]] eve::Result<void> beginAnimationSubmission(const CollapseAnimation& animation);
154 [[nodiscard]] eve::Result<void> finishAnimationSubmission();
155 struct DepthRegistration;
156 std::shared_ptr<DepthRegistration> depthRegistration_;
157 [[nodiscard]] eve::Result<void> registerDepthContribution();
158 std::uint64_t forwardToken_ = 0;
159 std::uint64_t shadowToken_ = 0;
160 bool submitted_ = false;
161 [[nodiscard]] eve::Result<void> prepareGeometry(std::shared_ptr<const FractureGeometry> geometry,
162 graphics::Graphics* graphics, const std::vector<int>& groups);
163 [[nodiscard]] eve::Result<void> updateGeometry(graphics::Graphics& graphics);
164 [[nodiscard]] eve::Result<void> drawGeometry(graphics::Graphics& graphics);
165 struct FragmentBatch {
166 graphics::Mesh* mesh = nullptr;
167 int groupId = 0;
168 bool interior = false;
169 std::vector<float> restPositions, restNormals, positions, normals, uv;
170 std::vector<std::uint32_t> indices, bones;
171 };
172 void releaseFragmentMeshes(graphics::Graphics* graphics);
173 std::shared_ptr<const FractureGeometry> preparedGeometry_;
174 std::vector<FragmentBatch> fragmentBatches_;
175 std::map<int, std::array<float, 4>> groupColors_;
176 std::vector<BonePresentation> poseScratch_;
177 std::vector<std::array<float, 16>> boneMatrices_;
178 void ensureUnitBox(graphics::Graphics& graphics);
179 void releaseOwnedMeshes(graphics::Graphics* graphics);
180 void invalidateSleepBatch(graphics::Graphics* graphics = nullptr);
181 [[nodiscard]] eve::Result<void> rebuildSleepBatch(graphics::Graphics& graphics);
182
183 GeometryCollectionInstance* instance_ = nullptr;
185 graphics::Graphics* meshOwner_ = nullptr;
186 graphics::Mesh* unitBox_ = nullptr;
187 graphics::Mesh* sleepBatch_ = nullptr;
188 std::uint64_t sleepBatchRevision_ = 0;
189 int sleepBatchBoneCount_ = 0;
190 int lastActiveDrawCount_ = 0;
191 int lastSleepBatchCount_ = 0;
192 float exteriorR_ = 0.62f, exteriorG_ = 0.58f, exteriorB_ = 0.52f, exteriorA_ = 1.f;
193 float interiorR_ = 0.78f, interiorG_ = 0.42f, interiorB_ = 0.28f, interiorA_ = 1.f;
194 float sleepR_ = 0.45f, sleepG_ = 0.45f, sleepB_ = 0.48f, sleepA_ = 1.f;
195};
196
197} // namespace eve::physics
float uv
#define EVENGINE_API_DOMAINS
Definition Export.h:110
tensor::Graph g
Definition GpuGraph.cpp:7
double r
std::vector< std::uint32_t > indices
std::vector< float > normals
std::vector< float > positions
std::vector< Bone > bones
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
MeshVfxBatchedDraw draw
OceanMeshSettings mesh
uint32_t groups
Definition OnnxGpgpu.cpp:39
Move-only, checked operation results for the common layer.
std::string geometry
Graphics * graphics
float offsetX
float offsetY
Move-only operation result carrying either a value or Status.
Definition Result.h:176
GPU mesh handle (+ optional CPU morph targets).
Definition Mesh.h:26
Owning, solver-independent baked rigid-fragment animation within Physics. @ownership Owns all samples...
Independent clock over a frozen, shared collapse animation. @ownership Owns a shared immutable snapsh...
Runtime owner of bone state, connection strain, and PhysicsLink bindings.
Presentation bridge for a borrowed geometry-collection instance.
int lastSleepBatchCount() const noexcept
Number of bones included in the sleeping batch on the last draw.
GeometryCollectionInstance * getInstance() const noexcept
Return the currently borrowed instance. @ownership Borrowed; caller must not delete through this poin...
GeometryCollectionRenderer & operator=(const GeometryCollectionRenderer &)=delete
GeometryCollectionRenderer(const GeometryCollectionRenderer &)=delete
int lastActiveDrawCount() const noexcept
Number of bones drawn individually on the last successful draw.
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
Optional physics backend for vehicle mobility and body attach.
Definition Climbing.h:36