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
|
||||||
{
|
{
|
||||||
struct item * next;
|
struct item * next;
|
||||||
unsigned int hash;
|
unsigned int a;
|
||||||
|
unsigned int b;
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -139,25 +140,26 @@ map_free (struct map * map)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct item *
|
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];
|
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;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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 * next;
|
||||||
struct item * item;
|
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];
|
next = map->items[hash % MAP_SIZE];
|
||||||
item = malloc (sizeof (struct item));
|
item = malloc (sizeof (struct item));
|
||||||
if (item == NULL) { return -1; }
|
if (item == NULL) { return -1; }
|
||||||
|
|
||||||
item->hash = hash;
|
item->a = a;
|
||||||
|
item->b = b;
|
||||||
item->next = next;
|
item->next = next;
|
||||||
item->id = id;
|
item->id = id;
|
||||||
|
|
||||||
@ -202,12 +204,12 @@ middle_point_v (struct map * map, int * state,
|
|||||||
vec3 middle;
|
vec3 middle;
|
||||||
|
|
||||||
hash = hash_2_int (a, b);
|
hash = hash_2_int (a, b);
|
||||||
item = map_get_item (map, hash);
|
item = map_get_item (map, hash, a, b);
|
||||||
id = v->nb_vertices;
|
id = v->nb_vertices;
|
||||||
|
|
||||||
if (item != NULL) { *state = 0; return item->id; }
|
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;
|
*state = 1;
|
||||||
middle = sweet_vector_middle3 (v->vertices[a], v->vertices[b]);
|
middle = sweet_vector_middle3 (v->vertices[a], v->vertices[b]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user