载入中...
搜索中...
未找到
DrawItem2D.h
浏览该文件的文档.
1#pragma once
2
4#include "graphics/Color.h"
5
6#include <algorithm>
7#include <cstdint>
8#include <vector>
9
10namespace eve::graphics {
11
12class Camera2D;
13class Canvas;
14class Quad;
15class Shader;
16class Texture;
17
19struct DrawItem2D {
20 float x = 0.f;
21 float y = 0.f;
22 float w = 0.f;
23 float h = 0.f;
24 float depthY = 0.f;
26 float rotation = 0.f;
28 float anchorX = 0.5f, anchorY = 0.5f;
29 bool flipX = false, flipY = false;
32 int order = 0;
33 bool hasOrder = false;
34 Color color{1.f, 1.f, 1.f, 1.f};
35 int layer = 0;
38 Texture *texture = nullptr;
39 Texture *normal = nullptr;
40 Quad *quad = nullptr;
41 Shader *shader = nullptr;
42 Canvas *canvas = nullptr;
43 Camera2D *camera = nullptr;
44 bool receiveLight = true;
45 bool litPath = false;
49 float distortionStrength = 0.f;
50 bool hasUV = false;
52 bool rotatedUV = false;
53 float u0 = 0.f, v0 = 0.f, u1 = 1.f, v1 = 1.f;
55 float camX = 0.f, camY = 0.f, camZoom = 1.f;
56 bool camValid = false;
57 Color camClear{0.1f, 0.1f, 0.12f, 1.f};
58 float camAmbientR = 0.15f, camAmbientG = 0.15f, camAmbientB = 0.18f;
59};
60
62inline void sortDrawItems2D(std::vector<DrawItem2D> &items) {
64 std::stable_sort(items.begin(), items.end(), [](const DrawItem2D &a, const DrawItem2D &b) {
65 const bool aOff = a.canvas != nullptr;
66 const bool bOff = b.canvas != nullptr;
67 if (aOff != bOff) return aOff && !bOff;
68 if (a.canvas != b.canvas) return a.canvas < b.canvas;
69 if (a.layer != b.layer) return a.layer < b.layer;
70 if (a.hasOrder && b.hasOrder && a.order != b.order) return a.order < b.order;
71 if (a.depthY != b.depthY) return a.depthY < b.depthY;
72 // Do not use pipeline/texture state as a tie-breaker: alpha compositing is
73 // order-dependent. stable_sort preserves submission order for equal visual keys,
74 // while the backend still batches adjacent compatible items.
75 return false;
76 });
77}
78
79} // namespace eve::graphics
MeleePoint3 b
Definition MeleeHit.cpp:41
MeleePoint3 a
Definition MeleeHit.cpp:40
Declarative 2D camera (viewport center + zoom).
Canvas public API.
Definition Canvas.h:17
Pixel-space sub-rectangle of a Texture (atlas cell / sprite frame). UV conversion uses the texture's ...
Definition Quad.h:11
Custom GPU program.
Definition Shader.h:41
GPU texture created via Graphics::newTexture. Owns GPU resources through an opaque backend handle.
Definition Texture.h:15
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
eve::Color Color
RGBA color used by every graphics draw call. Lives inside eve::graphics so including a graphics heade...
Definition Color.h:13
void sortDrawItems2D(std::vector< DrawItem2D > &items)
Sort draw items 2 d.
Definition DrawItem2D.h:62
BlendMode
Render-neutral 2D blend mode shared by graphics-facing modules.
Definition RenderTypes.h:11
Shared 2D draw queue item (sprites + tiles).
Definition DrawItem2D.h:19
BlendMode blend
2D quad blending (alpha / additive / opaque).
Definition DrawItem2D.h:37
bool rotatedUV
Atlas-packed rotated region: corner UVs are remapped (rotated 90°).
Definition DrawItem2D.h:52
bool sceneColorDistortion
Sample and perturb the resolved 3D scene instead of drawing the texture color.
Definition DrawItem2D.h:47
float camX
Screen-space camera already resolved; if cameraEntity set, RenderSystem resolves.
Definition DrawItem2D.h:55
float distortionStrength
Maximum displacement in screen pixels for sceneColorDistortion.
Definition DrawItem2D.h:49
float anchorX
Normalized transform pivot; (0,0) top-left, (0.5,0.5) center.
Definition DrawItem2D.h:28
float rotation
Degrees, clockwise, around the rectangle center (screen Y-down).
Definition DrawItem2D.h:26