Working on math libraries

This commit is contained in:
Krzosa Karol
2022-10-13 12:33:16 +02:00
parent 6e8acf7dc8
commit 022f874c32
8 changed files with 58 additions and 42 deletions

View File

@@ -1,4 +1,4 @@
#import "Math.core"
#import "MathF32.core"
Vec3 :: struct ;; x: F32; y: F32; z: F32
Length :: (a: Vec3): F32 ;; return sqrtf(a.x*a.x + a.y*a.y + a.z*a.z)
@@ -36,9 +36,9 @@ Reflect :: (a: Vec3, normal: Vec3): Vec3
return result
ConvertToARGB :: (a: Vec3): U32
a.x = F32_Clamp(0, a.x, 1)
a.y = F32_Clamp(0, a.y, 1)
a.z = F32_Clamp(0, a.z, 1)
a.x = Clamp(0, a.x, 1)
a.y = Clamp(0, a.y, 1)
a.z = Clamp(0, a.z, 1)
r := (a.x * 255)->U32 << 16
g := (a.y * 255)->U32 << 8
b := (a.z * 255)->U32 << 0