diff options
author | sanine <sanine.not@pm.me> | 2021-10-21 21:33:06 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2021-10-21 21:33:06 -0500 |
commit | 9c238237597de90c73cc65c3fccf2f49bfaa46b4 (patch) | |
tree | bd7bb7846568e64104c63eba57a0adae1300d3ef /src/glm_vec3_bindings.c | |
parent | d356c9bb873092e9d8ed53ee5f15a560accbf5bb (diff) |
move test files to the same directories as the files they test
Diffstat (limited to 'src/glm_vec3_bindings.c')
-rw-r--r-- | src/glm_vec3_bindings.c | 420 |
1 files changed, 0 insertions, 420 deletions
diff --git a/src/glm_vec3_bindings.c b/src/glm_vec3_bindings.c deleted file mode 100644 index e6ea407..0000000 --- a/src/glm_vec3_bindings.c +++ /dev/null @@ -1,420 +0,0 @@ -#include "glm_bindings.h" - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * - * Vec3 Functions - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - */ - - -int honey_glm_vec3_copy(lua_State* L) -{ - honey_glm_array *self, *dest; - honey_lua_parse_arguments - (L, 1, 2, HONEY_USERDATA, &self, HONEY_USERDATA, &dest); - - if (dest->type != VEC3) - honey_lua_throw_error(L, "destination must be VEC3 (%d); got %d instead", - dest->type); - - glm_vec3_copy(self->data, dest->data); - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_zero(lua_State* L) -{ - honey_glm_array *self; - honey_lua_parse_arguments(L, 1, 1, HONEY_USERDATA, &self); - - glm_vec3_zero(self->data); - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_eye(lua_State* L) -{ - honey_glm_array *self; - honey_lua_parse_arguments(L, 1, 1, HONEY_USERDATA, &self); - - glm_vec3_one(self->data); - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_dot(lua_State* L) -{ - honey_glm_array *a, *b; - honey_lua_parse_arguments - (L, 1, 2, - HONEY_USERDATA, &a, - HONEY_USERDATA, &b); - - if (b->type != VEC3) - honey_lua_throw_error(L, "destination must be VEC3 (%d); got %d instead", - VEC3, b->type); - - float result = glm_vec3_dot(a->data, b->data); - - lua_pushnumber(L, result); - return 1; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -static bool get_vec3_arrays(lua_State* L, - honey_glm_array** a, - honey_glm_array** b, - honey_glm_array** dest) -{ - int choice = honey_lua_parse_arguments - (L, 2, - 2, HONEY_USERDATA, a, HONEY_USERDATA, b, - 3, HONEY_USERDATA, a, HONEY_USERDATA, b, HONEY_USERDATA, dest); - - if ((*b)->type != VEC3) - honey_lua_throw_error - (L, "second argument must be VEC3 (%d); got %d instead", - VEC3, (*b)->type); - - if (choice == 1) { - if ((*dest)->type != VEC3) - honey_lua_throw_error - (L, "third argument must be VEC3 (%d); got %d instead", - VEC3, (*dest)->type); - } - else { - lua_pushcfunction(L, honey_glm_new_vec3); - honey_lua_pcall(L, 0, 1); - *dest = lua_touserdata(L, -1); - } - - return choice == 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -static bool get_vec3_scalars(lua_State* L, - honey_glm_array** a, - float* s, - honey_glm_array** dest) -{ - int choice = honey_lua_parse_arguments - (L, 2, - 2, HONEY_USERDATA, a, HONEY_NUMBER, s, - 3, HONEY_USERDATA, a, HONEY_NUMBER, s, HONEY_USERDATA, dest); - - if (choice == 1) { - if ((*dest)->type != VEC3) - honey_lua_throw_error - (L, "third argument must be VEC3 (%d); got %d instead", - VEC3, (*dest)->type); - } - else { - lua_pushcfunction(L, honey_glm_new_vec3); - honey_lua_pcall(L, 0, 1); - *dest = lua_touserdata(L, -1); - } - - return choice == 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_cross(lua_State* L) -{ - honey_glm_array *a, *b, *dest; - bool new_dest = get_vec3_arrays(L, &a, &b, &dest); - - glm_vec3_cross(a->data, b->data, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_crossn(lua_State* L) -{ - honey_glm_array *a, *b, *dest; - bool new_dest = get_vec3_arrays(L, &a, &b, &dest); - - glm_vec3_crossn(a->data, b->data, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_norm2(lua_State* L) -{ - honey_glm_array *self; - honey_lua_parse_arguments(L, 1, 1, HONEY_USERDATA, &self); - float result = glm_vec3_norm2(self->data); - lua_pushnumber(L, result); - return 1; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_norm(lua_State* L) -{ - honey_glm_array *self; - honey_lua_parse_arguments(L, 1, 1, HONEY_USERDATA, &self); - float result = glm_vec3_norm(self->data); - lua_pushnumber(L, result); - return 1; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_add(lua_State* L) -{ - honey_glm_array *a, *b, *dest; - bool new_dest = get_vec3_arrays(L, &a, &b, &dest); - - glm_vec3_add(a->data, b->data, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_adds(lua_State* L) -{ - honey_glm_array *self, *dest; - float s; - bool new_dest = get_vec3_scalars(L, &self, &s, &dest); - - glm_vec3_adds(self->data, s, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_sub(lua_State* L) -{ - honey_glm_array *a, *b, *dest; - bool new_dest = get_vec3_arrays(L, &a, &b, &dest); - - glm_vec3_sub(a->data, b->data, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_subs(lua_State* L) -{ - honey_glm_array *self, *dest; - float s; - bool new_dest = get_vec3_scalars(L, &self, &s, &dest); - - glm_vec3_subs(self->data, s, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_mul(lua_State* L) -{ - honey_glm_array *a, *b, *dest; - bool new_dest = get_vec3_arrays(L, &a, &b, &dest); - - glm_vec3_mul(a->data, b->data, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_muls(lua_State* L) -{ - honey_glm_array *self, *dest; - float s; - int choice = honey_lua_parse_arguments - (L, 2, - 2, HONEY_USERDATA, &self, HONEY_NUMBER, &s, - 3, HONEY_USERDATA, &self, HONEY_NUMBER, &s, HONEY_USERDATA, &dest); - - if (choice == 0) - dest = self; - else { - if (dest->type != VEC3) - honey_lua_throw_error - (L, "destination vector must be of type VEC3 (%d); got %d instead", - VEC3, dest->type); - } - - dest->data[0] = s * self->data[0]; - dest->data[1] = s * self->data[1]; - dest->data[2] = s * self->data[2]; - - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_scale(lua_State* L) -{ - honey_glm_array *self, *dest; - float s; - bool new_dest = get_vec3_scalars(L, &self, &s, &dest); - - glm_vec3_scale(self->data, s, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_scale_as(lua_State* L) -{ - honey_glm_array *self, *dest; - float s; - bool new_dest = get_vec3_scalars(L, &self, &s, &dest); - - glm_vec3_scale_as(self->data, s, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_div(lua_State* L) -{ - honey_glm_array *a, *b, *dest; - bool new_dest = get_vec3_arrays(L, &a, &b, &dest); - - glm_vec3_div(a->data, b->data, dest->data); - - if (new_dest) - return 1; - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_negate(lua_State* L) -{ - honey_glm_array *self, *dest; - int choice = honey_lua_parse_arguments - (L, 2, - 1, HONEY_USERDATA, &self, - 2, HONEY_USERDATA, &self, HONEY_USERDATA, &dest); - - if (choice == 0) - glm_vec3_negate(self->data); - else - glm_vec3_negate_to(self->data, dest->data); - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_normalize(lua_State* L) -{ - honey_glm_array *self, *dest; - int choice = honey_lua_parse_arguments - (L, 2, - 1, HONEY_USERDATA, &self, - 2, HONEY_USERDATA, &self, HONEY_USERDATA, &dest); - - if (choice == 0) - glm_vec3_normalize(self->data); - else - glm_vec3_normalize_to(self->data, dest->data); - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_angle(lua_State* L) -{ - honey_glm_array *a, *b; - honey_lua_parse_arguments - (L, 1, 2, - HONEY_USERDATA, &a, HONEY_USERDATA, &b); - - if (b->type != VEC3) - honey_lua_throw_error - (L, "second argument must be VEC3 (%d); got %d instead", - VEC3, b->type); - - float angle = glm_vec3_angle(a->data, b->data); - lua_pushnumber(L, angle); - return 1; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_clamp(lua_State* L) -{ - honey_glm_array* self; - float min, max; - honey_lua_parse_arguments(L, 1, 3, - HONEY_USERDATA, &self, - HONEY_NUMBER, &min, - HONEY_NUMBER, &max); - - glm_vec3_clamp(self->data, min, max); - return 0; -} - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -int honey_glm_vec3_lerp(lua_State* L) -{ - honey_glm_array *a, *b, *dest; - float s; - int choice = honey_lua_parse_arguments - (L, 2, - 3, HONEY_USERDATA, &a, HONEY_USERDATA, &b, HONEY_NUMBER, &s, - 4, HONEY_USERDATA, &a, HONEY_USERDATA, &b, HONEY_NUMBER, &s, HONEY_USERDATA, &dest); - - if (b->type != VEC3) - honey_lua_throw_error - (L, "second argument must be VEC3 (%d); got %d instead", - VEC3, b->type); - - if (choice == 1) { - if (dest->type != VEC3) - honey_lua_throw_error - (L, "fourth argument must be VEC3 (%d); got %d instead", - VEC3, dest->type); - } - else { - lua_pushcfunction(L, honey_glm_new_vec3); - honey_lua_pcall(L, 0, 1); - dest = lua_touserdata(L, -1); - } - - glm_vec3_lerp(a->data, b->data, s, dest->data); - - if (choice == 0) - return 1; - return 0; -} |