polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit a386037a32d1d36ee9582c75dd1935f0cb973d4f
parent cd968f4dd9f69a1f415884914863c541e6995981
Author: William Casarin <jb55@jb55.com>
Date:   Mon, 29 Jul 2019 08:03:19 -0700

split vec3_forward out to vec3_forward_amt

sometimes you don't need the vec3_add at the end

Diffstat:
Msrc/mat_util.c | 12++++++++----
Msrc/mat_util.h | 1+
2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/mat_util.c b/src/mat_util.c @@ -25,12 +25,16 @@ mat4 *mat4_create_transform(float *pos, float *scale, float *rot, mat4 *dest) { return dest; } +vec3 *vec3_forward_amt(quat *orientation, float *dir, float *dest) +{ + float q[4] = {0}; + quat_inverse(orientation, q); + quat_multiply_vec3(q, dir, dest); + return dest; +} vec3 *vec3_forward(vec3 *v, quat *orientation, float *dir, float *dest) { - float q[4] = {0}; float movement[3] = {0}; - quat_inverse(orientation, q); - quat_multiply_vec3(q, dir, movement); - vec3_add(v, movement, dest); + vec3_add(v, vec3_forward_amt(orientation, dir, movement), dest); return dest; } diff --git a/src/mat_util.h b/src/mat_util.h @@ -9,5 +9,6 @@ void look_at(vec3 *eye, vec3 *target, vec3 *up, mat4 *dest); mat4 *mat4_create_transform(float *pos, float *scale, quat *orientation, mat4 *dest); vec3 *vec3_forward(vec3 *p, quat *orientation, vec3 *dir, float *dest); +vec3 *vec3_forward_amt(quat *orientation, float *dir, float *dest); #endif /* POLYADVENT_MAT_UTIL_H */