feat: some shut

This commit is contained in:
2024-04-20 04:08:30 +02:00
parent 78c88e4d66
commit 4c7c4cac2c
21 changed files with 172 additions and 171 deletions

View File

@@ -1,4 +1,4 @@
use crate::encoding;
use crate::{encoding, log};
pub fn math_node(args: &[i32]) -> i32 {
let math_type = args[0];
@@ -16,3 +16,20 @@ pub fn math_node(args: &[i32]) -> i32 {
encoding::encode_float(result)
}
static mut CALL_COUNT: i32 = 0;
pub fn random_node(args: &[i32]) -> i32 {
let min = encoding::decode_float(args[0]);
let max = encoding::decode_float(args[1]);
let seed = (args[2] + unsafe { CALL_COUNT } * 2312312) % 100_000;
let v = seed as f32 / 100_000.0;
log!("Random node: min: {}, max: {}, seed: {}", min, max, seed);
let result = min + v * (max - min);
unsafe {
CALL_COUNT += 1;
}
encoding::encode_float(result)
}