| 12 | } |
| 13 | |
| 14 | Tile2x2_u8 splat(vec2f xy) { |
| 15 | // 1) collect values. |
| 16 | float x = xy.x; |
| 17 | float y = xy.y; |
| 18 | |
| 19 | // 2) integer cell indices |
| 20 | i16 cx = static_cast<i16>(floorf(x)); |
| 21 | i16 cy = static_cast<i16>(floorf(y)); |
| 22 | |
| 23 | // 3) fractional offsets in [0..1) |
| 24 | float fx = x - cx; |
| 25 | float fy = y - cy; |
| 26 | |
| 27 | // 4) bilinear weights |
| 28 | float w_ll = (1 - fx) * (1 - fy); // lower‑left |
| 29 | float w_lr = fx * (1 - fy); // lower‑right |
| 30 | float w_ul = (1 - fx) * fy; // upper‑left |
| 31 | float w_ur = fx * fy; // upper‑right |
| 32 | |
| 33 | // 5) build Tile2x2_u8 anchored at (cx,cy) |
| 34 | Tile2x2_u8 out(vec2<u16>(cx, cy)); |
| 35 | out.lower_left() = to_uint8(w_ll); |
| 36 | out.lower_right() = to_uint8(w_lr); |
| 37 | out.upper_left() = to_uint8(w_ul); |
| 38 | out.upper_right() = to_uint8(w_ur); |
| 39 | |
| 40 | return out; |
| 41 | } |
| 42 | |
| 43 | } // namespace |
no test coverage detected