Bug in geometry, complete header

This commit is contained in:
Luc Girod 2014-04-30 07:23:56 +02:00
parent 1da4e82e8d
commit 5617ac7ecb
2 changed files with 4 additions and 3 deletions

View File

@ -25,6 +25,7 @@
#include "sweet_math.h"
#include "sweet_matrix.h"
#include "sweet_matrix_stack.h"
#include "sweet_geometry.h"
#endif

View File

@ -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;