载入中...
搜索中...
未找到
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
19inline void texBombHash22(float x, float y, float &ox, float &oy) {
20 float px = x * 0.1031f;
21 float py = y * 0.1030f;
22 float pz = x * 0.0973f;
23 px -= std::floor(px);
24 py -= std::floor(py);
25 pz -= std::floor(pz);
26 float d = px * (py + 33.33f) + py * (pz + 33.33f) + pz * (px + 33.33f);
27 px += d;
28 py += d;
29 pz += d;
30 ox = (px + py) * pz;
31 oy = (px + pz) * py;
32 ox -= std::floor(ox);
33 oy -= std::floor(oy);
34}
35
37inline void texCellBombSampleUV(float u, float v, const TexCellBombParams &p, float &ou,
38 float &ov) {
39 if (p.strength < 1e-4f) {
40 ou = u;
41 ov = v;
42 return;
43 }
44 const float scale = p.cellScale < 1e-3f ? 1e-3f : p.cellScale;
45 const float cx = std::floor(u * scale);
46 const float cy = std::floor(v * scale);
47 float rndx = 0.f, rndy = 0.f;
49 texBombHash22(cx, cy, rndx, rndy);
50 float rndBx = 0.f, rndBy = 0.f;
52 texBombHash22(cx + 19.f, cy + 47.f, rndBx, rndBy);
53 const float ox = (rndx * 2.f - 1.f) * (p.strength / scale);
54 const float oy = (rndy * 2.f - 1.f) * (p.strength / scale);
55 float rot = p.rotAmount;
56 if (rot < 0.f) rot = 0.f;
57 if (rot > 1.f) rot = 1.f;
58 const float ang = (rndBx * 2.f - 1.f) * 3.14159265f * rot * p.strength;
59 const float s = std::sin(ang);
60 const float c = std::cos(ang);
61 const float cellCenterU = (cx + 0.5f) / scale;
62 const float cellCenterV = (cy + 0.5f) / scale;
63 const float lu = u - cellCenterU;
64 const float lv = v - cellCenterV;
65 ou = cellCenterU + (c * lu - s * lv) + ox;
66 ov = cellCenterV + (s * lu + c * lv) + oy;
67}
68
69} // namespace eve::graphics
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
const std::string & s
float ang
float cx
Definition CardTypes.cpp:33
float cy
Definition CardTypes.cpp:34
float py
float pz
glm::vec4 p[6]
float u
Definition Grass.cpp:233
float v
std::int32_t c
std::vector< Colorf > px
std::array< float, 3 > scale
float d
double oy
double ox
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition Animation.h:25
void texBombHash22(float x, float y, float &ox, float &oy)
Tex bomb hash 22.
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...