summaryrefslogtreecommitdiff
path: root/src/maths/maths.h
diff options
context:
space:
mode:
authorJoshua Rowe <17525998+omnisci3nce@users.noreply.github.com>2024-04-20 18:33:05 +1000
committerGitHub <noreply@github.com>2024-04-20 18:33:05 +1000
commitb283835c5e6998bda9b986ff49ee4fd57fe68fc7 (patch)
treebe478c168506a669876ff9df8920b7e35539e98f /src/maths/maths.h
parentb240374c23365e33727d78ca74e901bcb383e077 (diff)
parent013e1c111e0717f6dc01a8e8582e13a4095e05bc (diff)
Merge pull request #7 from omnisci3nce/transform-hierarchy
Transform hierarchy
Diffstat (limited to 'src/maths/maths.h')
-rw-r--r--src/maths/maths.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/maths/maths.h b/src/maths/maths.h
index d832739..6834f69 100644
--- a/src/maths/maths.h
+++ b/src/maths/maths.h
@@ -203,12 +203,14 @@ static inline mat4 mat4_look_at(vec3 position, vec3 target, vec3 up) {
.is_dirty = false })
static transform transform_create(vec3 pos, quat rot, f32 scale) {
- return (transform){ .position = pos, .rotation = rot, .scale = scale, .is_dirty = false };
+ return (transform){ .position = pos, .rotation = rot, .scale = scale, .is_dirty = true };
}
static inline mat4 transform_to_mat(transform *tf) {
- // TODO: rotation
- return mat4_mult(mat4_translation(tf->position), mat4_scale(tf->scale));
+ mat4 trans = mat4_translation(tf->position);
+ mat4 rot = mat4_rotation(tf->rotation);
+ mat4 scale = mat4_scale(tf->scale);
+ return mat4_mult(trans, mat4_mult(rot, scale));
}
// --- Sizing asserts