Bug: uniqueness of vertices with big mesh.
This commit is contained in:
parent
5359a3e861
commit
582bc2d5e0
@ -98,7 +98,8 @@ face_free (struct face_item * root)
|
||||
struct item
|
||||
{
|
||||
struct item * next;
|
||||
unsigned int hash;
|
||||
unsigned int a;
|
||||
unsigned int b;
|
||||
unsigned int id;
|
||||
};
|
||||
|
||||
@ -139,25 +140,26 @@ map_free (struct map * map)
|
||||
}
|
||||
|
||||
static struct item *
|
||||
map_get_item (struct map * map, unsigned int hash)
|
||||
map_get_item (struct map * map, unsigned int hash, unsigned int a, unsigned int b)
|
||||
{
|
||||
struct item * item = map->items[hash % MAP_SIZE];
|
||||
while (item != NULL && item->hash != hash) { item = item->next; }
|
||||
while (item != NULL && item->a != a && item->b != b) { item = item->next; }
|
||||
return item;
|
||||
}
|
||||
|
||||
static int
|
||||
map_add_item (struct map * map, unsigned int hash, int id)
|
||||
map_add_item (struct map * map, unsigned int hash, unsigned int a, unsigned int b, int id)
|
||||
{
|
||||
struct item * next;
|
||||
struct item * item;
|
||||
if (map_get_item (map, hash) != NULL) { return 0; }
|
||||
if (map_get_item (map, hash, a, b) != NULL) { return 0; }
|
||||
|
||||
next = map->items[hash % MAP_SIZE];
|
||||
item = malloc (sizeof (struct item));
|
||||
if (item == NULL) { return -1; }
|
||||
|
||||
item->hash = hash;
|
||||
item->a = a;
|
||||
item->b = b;
|
||||
item->next = next;
|
||||
item->id = id;
|
||||
|
||||
@ -202,12 +204,12 @@ middle_point_v (struct map * map, int * state,
|
||||
vec3 middle;
|
||||
|
||||
hash = hash_2_int (a, b);
|
||||
item = map_get_item (map, hash);
|
||||
item = map_get_item (map, hash, a, b);
|
||||
id = v->nb_vertices;
|
||||
|
||||
if (item != NULL) { *state = 0; return item->id; }
|
||||
|
||||
if (map_add_item (map, hash, id) == -1) { *state = -1; return 0; }
|
||||
if (map_add_item (map, hash, a, b, id) == -1) { *state = -1; return 0; }
|
||||
|
||||
*state = 1;
|
||||
middle = sweet_vector_middle3 (v->vertices[a], v->vertices[b]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user