From 435009e2cd266fb0c29d01b6c8dd3de39e705279 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 24 Jul 2021 11:31:00 +0900 Subject: [PATCH] [entity] Update local rotation and scale caches When setting local rotation/scale/transform, need to cache the rotation and scale, otherwise they can't be fetched easily later on (position is easy as it's just the fourth column of the matrix). --- libs/entity/transform.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/entity/transform.c b/libs/entity/transform.c index 0e274f83a..b2e4b09da 100644 --- a/libs/entity/transform.c +++ b/libs/entity/transform.c @@ -222,6 +222,7 @@ Transform_SetLocalRotation (transform_t *transform, vec4f_t rotation) mat4f_t mat; mat4fquat (mat, rotation); + h->localRotation.a[transform->index] = rotation; h->localMatrix.a[transform->index][0] = mat[0] * scale[0]; h->localMatrix.a[transform->index][1] = mat[1] * scale[1]; h->localMatrix.a[transform->index][2] = mat[2] * scale[2]; @@ -245,6 +246,7 @@ Transform_SetLocalScale (transform_t *transform, vec4f_t scale) mat4f_t mat; mat4fquat (mat, rotation); + h->localScale.a[transform->index] = scale; h->localMatrix.a[transform->index][0] = mat[0] * scale[0]; h->localMatrix.a[transform->index][1] = mat[1] * scale[1]; h->localMatrix.a[transform->index][2] = mat[2] * scale[2]; @@ -304,6 +306,8 @@ Transform_SetLocalTransform (transform_t *transform, vec4f_t scale, mat4fquat (mat, rotation); position[3] = 1; + h->localRotation.a[transform->index] = rotation; + h->localScale.a[transform->index] = scale; h->localMatrix.a[transform->index][0] = mat[0] * scale[0]; h->localMatrix.a[transform->index][1] = mat[1] * scale[1]; h->localMatrix.a[transform->index][2] = mat[2] * scale[2];