vec3: add new function glm_vec3_make

Function takes in a float array. Array must be
at least of size 3 and converts it into
a 3D vector.

Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
Vincent Davis Jr
2023-07-02 13:21:41 -05:00
parent 49dd24eaf2
commit aeeeac4c5a
7 changed files with 76 additions and 0 deletions

View File

@@ -1729,3 +1729,24 @@ TEST_IMPL(GLM_PREFIX, vec3_sqrt) {
TEST_SUCCESS
}
TEST_IMPL(GLM_PREFIX, vec3_make) {
float src[9] = {
7.2f, 1.0f, 5.8f,
2.5f, 6.1f, 9.9f,
17.7f, 4.3f, 3.2f
};
vec3 dest[3];
float *srcp = src;
unsigned int i, j;
for (i = 0, j = 0; i < sizeof(src) / sizeof(float); i+=3,j++) {
GLM(vec3_make)(srcp + i, dest[j]);
ASSERT(test_eq(src[ i ], dest[j][0]));
ASSERT(test_eq(src[i+1], dest[j][1]));
ASSERT(test_eq(src[i+2], dest[j][2]));
}
TEST_SUCCESS
}