From 3265cb676c5c87fd624f59aaf3ca89d947df8cda Mon Sep 17 00:00:00 2001 From: pommicket Date: Wed, 14 Dec 2022 12:45:48 -0500 Subject: GenRandom --- src/main.rs | 9 ++++++++- src/sdf.rs | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 2594fdd..60e2499 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,9 +7,11 @@ - mouse sensitivity - AA quality - # iterations, distance cutoff +- documentation */ extern crate nalgebra; +extern crate gen_random; pub mod sdf; mod sdl; @@ -17,6 +19,8 @@ pub mod win; use nalgebra::{Matrix3, Matrix4, Rotation3, Vector3}; use std::time::Instant; +use gen_random::GenRandom; + type Vec3 = Vector3; type Mat3 = Matrix3; @@ -62,6 +66,9 @@ impl View { fn try_main() -> Result<(), String> { use sdf::{Constant, R3ToR, R3ToR3, RToR}; + let _test = Constant::gen_thread_random(); + println!("{_test:?}"); + let funciton = R3ToR::compose( R3ToR3::InfiniteMirrors(Constant::from(2.0)), R3ToR::sphere_f32(0.2), @@ -150,7 +157,7 @@ void main() { }", ); - println!("{fshader_source}"); + //println!("{fshader_source}"); let program = window .create_program( diff --git a/src/sdf.rs b/src/sdf.rs index f79dc3a..61b070f 100644 --- a/src/sdf.rs +++ b/src/sdf.rs @@ -1,6 +1,10 @@ #![allow(dead_code)] // @TODO @TEMPORARY +extern crate rand; +extern crate gen_random_proc_macro; use std::fmt::{self, Display, Formatter, Write}; +use gen_random_proc_macro::GenRandom; +use gen_random::GenRandom; // we're only writing numbers and strings so write! should never fail. macro_rules! write_str { @@ -8,10 +12,12 @@ macro_rules! write_str { } /// these are constant across 3D space, not across time/user input/etc. +#[derive(GenRandom, Debug)] pub enum Constant { + #[prob = 0.5] F32(f32), + #[prob = 0.5] Time(f32, f32), - // @TODO: sin, sqrt, mod } impl From for Constant { -- cgit v1.2.3