diff options
author | omnisci3nce <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-07 21:46:51 +1000 |
---|---|---|
committer | omnisci3nce <17525998+omnisci3nce@users.noreply.github.com> | 2024-04-07 21:46:51 +1000 |
commit | 61d96cf09e2e125f36a94a4c64ed5682fda0df1c (patch) | |
tree | aa79fe48e1a0800bec0157460a4adf7d19d88077 /src/maths/maths.h | |
parent | 42924fe7b32e93bf55ce034467ceb52e0436c303 (diff) |
its bending but not deforming as expected, looks like rotating around model origin
Diffstat (limited to 'src/maths/maths.h')
-rw-r--r-- | src/maths/maths.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/maths/maths.h b/src/maths/maths.h index 76531f2..911b9b7 100644 --- a/src/maths/maths.h +++ b/src/maths/maths.h @@ -302,7 +302,7 @@ static inline mat4 mat4_look_at(vec3 position, vec3 target, vec3 up) { #define TRANSFORM_DEFAULT \ ((transform){ .position = VEC3_ZERO, \ - .rotation = (quat){ .x = 0., .y = 0., .z = 0., .w = 0. }, \ + .rotation = (quat){ .x = 0., .y = 0., .z = 0., .w = 1. }, \ .scale = 1.0, \ .is_dirty = false }) @@ -311,8 +311,10 @@ static transform transform_create(vec3 pos, quat rot, f32 scale) { } static inline mat4 transform_to_mat(transform *tf) { - // TODO: rotation - return mat4_mult(mat4_translation(tf->position), mat4_scale(tf->scale)); + mat4 scale = mat4_scale(tf->scale); + mat4 rotation = mat4_rotation(tf->rotation); + mat4 translation = mat4_translation(tf->position); + return mat4_mult(translation, mat4_mult(rotation, scale)); } // --- Sizing asserts |