diff --git a/sweet.h b/sweet.h index 876f767..021930e 100644 --- a/sweet.h +++ b/sweet.h @@ -25,6 +25,7 @@ #include "sweet_math.h" #include "sweet_matrix.h" #include "sweet_matrix_stack.h" +#include "sweet_geometry.h" #endif diff --git a/sweet_geometry.c b/sweet_geometry.c index 4363c49..15b7eee 100644 --- a/sweet_geometry.c +++ b/sweet_geometry.c @@ -226,7 +226,7 @@ middle_point (struct map * map, v2 = v->vertices[b]; middle = sweet_vector_middle3 (v1, v2); - if (v->buffer < (v->nb_vertices * sizeof (vec3))) + if (v->buffer <= (v->nb_vertices * sizeof (vec3))) { vec3 * p; v->buffer = v->buffer * 2; @@ -302,9 +302,9 @@ sweet_geometry_icosphere (unsigned int nb_iterations, float scale, unsigned int j; map_init (&map); - *mesh_vertices = NULL; *mesh_indices = NULL; + nb_faces = 20; v.nb_vertices = 12; v.buffer = v.nb_vertices * sizeof (vec3); @@ -348,7 +348,7 @@ sweet_geometry_icosphere (unsigned int nb_iterations, float scale, (*mesh_indices) = malloc (nb_faces * sizeof (unsigned int) * 3); (*mesh_vertices) = malloc (v.nb_vertices * sizeof (float) * 3); - if (*mesh_indices == NULL || *mesh_vertices == NULL) + if ((*mesh_indices) == NULL || (*mesh_vertices) == NULL) { free_all (&map, &v, root, *mesh_vertices, *mesh_indices); *count_vertices = 0;