aboutsummaryrefslogtreecommitdiff
path: root/src/helper.c
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-05-14 16:44:28 +0200
committerCharles <sircharlesaze@gmail.com>2020-05-14 16:44:28 +0200
commit23ba151d95e4284ddb2d5f1c9810741061c293fd (patch)
tree98d9aa1322dc108e1adf2a695fc642266e05c2b3 /src/helper.c
parent29ea8338efb0b5450611b73463c9d7d469db2d75 (diff)
downloadscop-23ba151d95e4284ddb2d5f1c9810741061c293fd.tar.gz
scop-23ba151d95e4284ddb2d5f1c9810741061c293fd.tar.bz2
scop-23ba151d95e4284ddb2d5f1c9810741061c293fd.zip
Refactoring to the point before started refactoring, without crash on texture binding
Diffstat (limited to 'src/helper.c')
-rw-r--r--src/helper.c33
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;
+ }
+}