diff options
author | pommicket <pommicket@gmail.com> | 2022-12-16 22:50:43 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-16 22:50:43 -0500 |
commit | b0c8e4cef46c752bdf4ed83361197eb592d269e3 (patch) | |
tree | 35e1dcbac1eca112a341c6c05a7f06b6d2bac8a9 /src | |
parent | 2d569091a912568257bb73f1501ac6d9af6c2c6c (diff) |
change input/output_type to constants
Diffstat (limited to 'src')
-rw-r--r-- | src/sdf.rs | 32 |
1 files changed, 10 insertions, 22 deletions
@@ -257,9 +257,9 @@ trait Function: Sized + GenRandom { fn to_glsl(&self, input: Variable, code: &mut String, var: &mut VarCounter) -> Variable; /// GLSL type which is the input to this function - fn input_type() -> GLSLType; + const INPUT_TYPE: GLSLType; /// GLSL type which is the output of this function - fn output_type() -> GLSLType; + const OUTPUT_TYPE: GLSLType; /// adds GLSL code for function to `code`. fn to_glsl_function(&self, name: &str, code: &mut String) { @@ -268,8 +268,8 @@ trait Function: Sized + GenRandom { write_str!( code, "{} {name}({} {input}) {{\n", - Self::output_type(), - Self::input_type() + Self::OUTPUT_TYPE, + Self::INPUT_TYPE ); let output = self.to_glsl(input, code, &mut var); write_str!(code, "return {output};\n}}\n\n"); @@ -298,12 +298,8 @@ trait Function: Sized + GenRandom { } impl Function for RToR { - fn input_type() -> GLSLType { - GLSLType::Float - } - fn output_type() -> GLSLType { - GLSLType::Float - } + const INPUT_TYPE: GLSLType = GLSLType::Float; + const OUTPUT_TYPE: GLSLType = GLSLType::Float; fn to_glsl(&self, input: Variable, code: &mut String, var: &mut VarCounter) -> Variable { use RToR::*; @@ -324,12 +320,8 @@ impl Function for RToR { } impl Function for R3ToR3 { - fn input_type() -> GLSLType { - GLSLType::Vec3 - } - fn output_type() -> GLSLType { - GLSLType::Vec3 - } + const INPUT_TYPE: GLSLType = GLSLType::Vec3; + const OUTPUT_TYPE: GLSLType = GLSLType::Vec3; fn to_glsl(&self, input: Variable, code: &mut String, var: &mut VarCounter) -> Variable { use R3ToR3::*; @@ -418,12 +410,8 @@ impl Function for R3ToR3 { } impl Function for R3ToR { - fn input_type() -> GLSLType { - GLSLType::Vec3 - } - fn output_type() -> GLSLType { - GLSLType::Float - } + const INPUT_TYPE: GLSLType = GLSLType::Vec3; + const OUTPUT_TYPE: GLSLType = GLSLType::Float; fn to_glsl(&self, input: Variable, code: &mut String, var: &mut VarCounter) -> Variable { use R3ToR::*; |