diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-27 14:01:16 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-07-27 14:01:16 +1000 |
commit | aa0fe8457cfff9c47c0c9fa4a1c86a79c7cbf9c5 (patch) | |
tree | a7fa374cb59c6c59e386086dcdae8a7efc372b5f /src/maths | |
parent | 2e2c57a8c04575eec164279a49947cfdba250853 (diff) |
add a pool insert function. move RenderEnt to use handles
Diffstat (limited to 'src/maths')
-rw-r--r-- | src/maths/maths.h | 20 | ||||
-rw-r--r-- | src/maths/maths_types.h | 4 |
2 files changed, 11 insertions, 13 deletions
diff --git a/src/maths/maths.h b/src/maths/maths.h index a6f8d80..5055637 100644 --- a/src/maths/maths.h +++ b/src/maths/maths.h @@ -48,14 +48,14 @@ static const Vec3 VEC3_NEG_Z = vec3(0.0, 0.0, -1.0); static const Vec3 VEC3_ZERO = vec3(0.0, 0.0, 0.0); static const Vec3 VEC3_ONES = vec3(1.0, 1.0, 1.0); -c_static_inline void print_vec3(Vec3 v) { +static void print_vec3(Vec3 v) { printf("{ x: %f, y: %f, z: %f )\n", (f64)v.x, (f64)v.y, (f64)v.z); } // TODO: Dimension 2 -c_static_inline Vec2 vec2_create(f32 x, f32 y) { return (Vec2){ x, y }; } +static Vec2 vec2_create(f32 x, f32 y) { return (Vec2){ x, y }; } #define vec2(x, y) ((Vec2){ x, y }) -c_static_inline Vec2 vec2_div(Vec2 a, f32 s) { return (Vec2){ a.x / s, a.y / s }; } +static Vec2 vec2_div(Vec2 a, f32 s) { return (Vec2){ a.x / s, a.y / s }; } // TODO: Dimension 4 static Vec4 vec4_create(f32 x, f32 y, f32 z, f32 w) { return (Vec4){ x, y, z, w }; } @@ -64,17 +64,15 @@ static Vec4 vec4_create(f32 x, f32 y, f32 z, f32 w) { return (Vec4){ x, y, z, w // --- Quaternion Implementations -c_static_inline f32 quat_dot(Quat a, Quat b) { - return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; -} +static f32 quat_dot(Quat a, Quat b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } -c_static_inline Quat quat_normalise(Quat a) { +static Quat quat_normalise(Quat a) { f32 length = sqrtf(quat_dot(a, a)); // same as len squared return (Quat){ a.x / length, a.y / length, a.z / length, a.w / length }; } -c_static_inline Quat quat_ident() { return (Quat){ .x = 0.0, .y = 0.0, .z = 0.0, .w = 1.0 }; } +static Quat quat_ident() { return (Quat){ .x = 0.0, .y = 0.0, .z = 0.0, .w = 1.0 }; } static Quat quat_from_axis_angle(Vec3 axis, f32 angle, bool normalize) { const f32 half_angle = 0.5f * angle; @@ -89,7 +87,7 @@ static Quat quat_from_axis_angle(Vec3 axis, f32 angle, bool normalize) { } // TODO: grok this. -c_static_inline Quat quat_slerp(Quat a, Quat b, f32 percentage) { +static Quat quat_slerp(Quat a, Quat b, f32 percentage) { Quat out_quaternion; Quat q0 = quat_normalise(a); @@ -158,7 +156,7 @@ static Mat4 mat4_scale(f32 scale) { } // TODO: double check this -c_static_inline Mat4 mat4_rotation(Quat rotation) { +static Mat4 mat4_rotation(Quat rotation) { Mat4 out_matrix = mat4_ident(); Quat n = quat_normalise(rotation); @@ -313,7 +311,7 @@ static Transform transform_create(Vec3 pos, Quat rot, f32 scale) { return (Transform){ .position = pos, .rotation = rot, .scale = scale, .is_dirty = true }; } -c_static_inline Mat4 transform_to_mat(Transform *tf) { +static Mat4 transform_to_mat(Transform *tf) { Mat4 scale = mat4_scale(tf->scale); Mat4 rotation = mat4_rotation(tf->rotation); Mat4 translation = mat4_translation(tf->position); diff --git a/src/maths/maths_types.h b/src/maths/maths_types.h index 3fa3dac..2f84774 100644 --- a/src/maths/maths_types.h +++ b/src/maths/maths_types.h @@ -44,10 +44,10 @@ typedef struct Mat4 { typedef struct Bbox_3D { Vec3 min; // minimum point of the box Vec3 max; // maximum point of the box -} Bbox_3d; +} Bbox_3D; /** @brief 3D Axis-aligned bounding box */ -typedef Bbox_3d Aabb_3D; +typedef Bbox_3D Aabb_3D; /** @brief 3D affine transformation */ typedef struct Transform { |