载入中...
搜索中...
未找到
TextureCellBomb.h
浏览该文件的文档.
1#pragma once
2
3#include <cmath>
4#include <cstdint>
5
6namespace eve::graphics {
7
13 float cellScale = 4.f; // cells per UV unit
14 float strength = 0.f; // 0 = off (plain UV)
15 float rotAmount = 1.f; // 0..1 rotation scale
16};
17
18inline void texBombHash22(float x, float y, float &ox, float &oy) {
19 float px = x * 0.1031f;
20 float py = y * 0.1030f;
21 float pz = x * 0.0973f;
22 px -= std::floor(px);
23 py -= std::floor(py);
24 pz -= std::floor(pz);
25 float d = px * (py + 33.33f) + py * (pz + 33.33f) + pz * (px + 33.33f);
26 px += d;
27 py += d;
28 pz += d;
29 ox = (px + py) * pz;
30 oy = (px + pz) * py;
31 ox -= std::floor(ox);
32 oy -= std::floor(oy);
33}
34
36inline void texCellBombSampleUV(float u, float v, const TexCellBombParams &p, float &ou,
37 float &ov) {
38 if (p.strength < 1e-4f) {
39 ou = u;
40 ov = v;
41 return;
42 }
43 const float scale = p.cellScale < 1e-3f ? 1e-3f : p.cellScale;
44 const float cx = std::floor(u * scale);
45 const float cy = std::floor(v * scale);
46 float rndx = 0.f, rndy = 0.f;
47 texBombHash22(cx, cy, rndx, rndy);
48 float rndBx = 0.f, rndBy = 0.f;
49 texBombHash22(cx + 19.f, cy + 47.f, rndBx, rndBy);
50 const float ox = (rndx * 2.f - 1.f) * (p.strength / scale);
51 const float oy = (rndy * 2.f - 1.f) * (p.strength / scale);
52 float rot = p.rotAmount;
53 if (rot < 0.f) rot = 0.f;
54 if (rot > 1.f) rot = 1.f;
55 const float ang = (rndBx * 2.f - 1.f) * 3.14159265f * rot * p.strength;
56 const float s = std::sin(ang);
57 const float c = std::cos(ang);
58 const float cellCenterU = (cx + 0.5f) / scale;
59 const float cellCenterV = (cy + 0.5f) / scale;
60 const float lu = u - cellCenterU;
61 const float lv = v - cellCenterV;
62 ou = cellCenterU + (c * lu - s * lv) + ox;
63 ov = cellCenterV + (s * lu + c * lv) + oy;
64}
65
66} // namespace eve::graphics
float cx
Definition CardTypes.cpp:31
float cy
Definition CardTypes.cpp:32
int y
Definition Grass.cpp:135
float u
Definition Grass.cpp:234
int x
Definition Grass.cpp:135
std::vector< Colorf > px
uint32_t c
glm::vec4 p[6]
int d
int v
float scale
Definition TreeMesh.cpp:122
uint32_t s
Definition Weather.cpp:28
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6
void texBombHash22(float x, float y, float &ox, float &oy)
void texCellBombSampleUV(float u, float v, const TexCellBombParams &p, float &ou, float &ov)
Map UV → bombed sample UV for the dominant (floor) cell; strength≤0 → identity.
CPU reference for texture cell-bombing math (matches tex_cell_bomb.glsl). Used by unit tests; the GPU...