From 23ba151d95e4284ddb2d5f1c9810741061c293fd Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 14 May 2020 16:44:28 +0200 Subject: Refactoring to the point before started refactoring, without crash on texture binding --- src/helper.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/helper.c') diff --git a/src/helper.c b/src/helper.c index 34fd560..8fd9dcc 100644 --- a/src/helper.c +++ b/src/helper.c @@ -6,16 +6,45 @@ /* By: charles +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/05/11 14:55:27 by charles #+# #+# */ -/* Updated: 2020/05/11 14:57:29 by charles ### ########.fr */ +/* Updated: 2020/05/14 16:42:13 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "scop.h" -bool has_extension(char *filepath, char *extension) +bool helper_check_extension(char *filepath, char *extension) { char *match; match = ft_strstr(filepath, extension); return (match != NULL && ft_strlen(match) == ft_strlen(extension)); } + +void helper_find_boundary( + float *vertices, + size_t vertices_num, + t_ftmvec3 *max, + t_ftmvec3 *min) +{ + size_t i; + + ftm_vec3init(min, INFINITY, INFINITY, INFINITY); + ftm_vec3init(max, -INFINITY, -INFINITY, -INFINITY); + i = 0; + while (i < vertices_num) + { + if (vertices[i + 0] > max->x) + max->x = vertices[i + 0]; + if (vertices[i + 0] < min->x) + min->x = vertices[i + 0]; + if (vertices[i + 1] > max->y) + max->y = vertices[i + 1]; + if (vertices[i + 1] < min->y) + min->y = vertices[i + 1]; + if (vertices[i + 2] > max->z) + max->z = vertices[i + 2]; + if (vertices[i + 2] < min->z) + min->z = vertices[i + 2]; + i += VERTEX_COUNT; + } +} -- cgit