mat4_t m4_invert(mat4_t matrix);
vec3_t m4_mul_pos (mat4_t matrix, vec3_t position);
vec3_t m4_mul_dir (mat4_t matrix, vec3_t direction);
- //TODO: implement m4_transform_vec(mat4_t matrix, vec4_t vec);
+ vec4_t m4_transform_vec(mat4_t matrix, vec4_t vec);
//TODO: ref: https://github.com/LWJGL/lwjgl/blob/2df01dd762e20ca0871edb75daf670ccacc89b60/src/java/org/lwjgl/util/vector/Matrix4f.java
void m4_print (mat4_t matrix);
return inv;
}
+vec4_t m4_transform_vec(mat4_t m, vec4_t v)
+{
+ vec4_t ret = {0};
+
+ float x = m.m00 * v.x + m.m10 * v.y + m.m20 * v.z + m.m30 * v.w;
+ float y = m.m01 * v.x + m.m11 * v.y + m.m21 * v.z + m.m31 * v.w;
+ float z = m.m02 * v.x + m.m12 * v.y + m.m22 * v.z + m.m32 * v.w;
+ float w = m.m03 * v.x + m.m13 * v.y + m.m23 * v.z + m.m33 * v.w;
+
+ ret.x = x;
+ ret.y = y;
+ ret.z = z;
+ ret.w = w;
+
+ return ret;
+}
+
#endif // MATH_3D_IMPLEMENTATION