diff options
Diffstat (limited to 'src/helper.c')
| -rw-r--r-- | src/helper.c | 33 |
1 files changed, 31 insertions, 2 deletions
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 <charles.cabergs@gmail.com> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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; + } +} |
