FastLED 3.10.8
Loading...
Searching...
No Matches

◆ pnoise2d_raw()

fl::i32 fl::perlin_i16_optimized::pnoise2d_raw ( fl::i32 fx_raw,
fl::i32 fy_raw,
const fl::i32 * fade_lut,
const fl::u8 * perm )
static

Definition at line 35 of file perlin_i16_optimized.cpp.hpp.

37 {
38 int X, Y;
39 fl::i16 x16, y16; // i16 fractional parts!
40 floor_frac_i16(fx_raw, X, x16);
41 floor_frac_i16(fy_raw, Y, y16);
42 X &= 255;
43 Y &= 255;
44
45 // Fade values can be up to 65536, need to stay i32
46 // But we can still optimize grad and internal lerp to use i16
47 fl::i32 u = fade(x16, fade_lut);
48 fl::i32 v = fade(y16, fade_lut);
49
50 int A = perm[X & 255] + Y;
51 int AA = perm[A & 255];
52 int AB = perm[(A + 1) & 255];
53 int B = perm[(X + 1) & 255] + Y;
54 int BA = perm[B & 255];
55 int BB = perm[(B + 1) & 255];
56
57 // grad returns i16 (coordinates are i16), lerp takes i32 fade values
58 fl::i32 g00 = grad_i16(perm[AA & 255], x16, y16);
59 fl::i32 g10 = grad_i16(perm[BA & 255], x16 - HP_ONE_I16, y16);
60 fl::i32 g01 = grad_i16(perm[AB & 255], x16, y16 - HP_ONE_I16);
61 fl::i32 g11 = grad_i16(perm[BB & 255], x16 - HP_ONE_I16, y16 - HP_ONE_I16);
62
63 // Lerp with i32 (grad results fit in i16 range but lerp needs i32 for fade values)
64 fl::i32 lerp0 = lerp(u, g00, g10);
65 fl::i32 lerp1 = lerp(u, g01, g11);
66 fl::i32 result = lerp(v, lerp0, lerp1);
67
68 return result;
69}
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
static FASTLED_FORCE_INLINE fl::i32 lerp(fl::i32 t, fl::i32 a, fl::i32 b) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE void floor_frac_i16(fl::i32 fp16, int &ifloor, fl::i16 &frac16) FL_NO_EXCEPT
static constexpr fl::i32 HP_ONE_I16
static FASTLED_FORCE_INLINE fl::i32 grad_i16(int hash, fl::i16 x, fl::i16 y) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE fl::i32 fade(fl::i16 t, const fl::i32 *table) FL_NO_EXCEPT

References fl::B, fl::fade(), fl::FL_NO_EXCEPT, floor_frac_i16(), grad_i16(), HP_ONE_I16, and fl::lerp().

Referenced by pnoise2d(), and autoresearch::animartrix_check::runPerlinBenchmark().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: