diff options
| author | mat <git@matdoes.dev> | 2025-12-18 15:03:45 -0800 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-12-18 15:03:45 -0800 |
| commit | 82effd29c472cac9ea54fb6d24e88656517f01a0 (patch) | |
| tree | 602dcfa4f1949db9b20632848c828a865058e460 /azalea-core/src/math.rs | |
| parent | 037b473fadd6a0eb980d4240d1fe89f2331ddc39 (diff) | |
| download | azalea-drasl-82effd29c472cac9ea54fb6d24e88656517f01a0.tar.xz | |
fix stack overflow when running on windows in debug mode
Diffstat (limited to 'azalea-core/src/math.rs')
| -rw-r--r-- | azalea-core/src/math.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/azalea-core/src/math.rs b/azalea-core/src/math.rs index 4d3bf84c..1e410cb4 100644 --- a/azalea-core/src/math.rs +++ b/azalea-core/src/math.rs @@ -6,8 +6,14 @@ use std::{ pub const EPSILON: f64 = 1.0e-7; -pub static SIN: LazyLock<[f32; 65536]> = - LazyLock::new(|| std::array::from_fn(|i| f64::sin((i as f64) * PI * 2. / 65536.) as f32)); +// has to be boxed to avoid a stack overflow on windows when run in debug mode +pub static SIN: LazyLock<Box<[f32; 65536]>> = LazyLock::new(|| { + (0..65536) + .map(|i| f64::sin((i as f64) * PI * 2. / 65536.) as f32) + .collect::<Box<[f32]>>() + .try_into() + .unwrap() +}); /// A sine function that uses a lookup table. pub fn sin(x: f32) -> f32 { |
