forked from bartvdbraak/blender
cloth was using edgehash not quite correctly:
- was ordering vertex args unnecessarily. - was adding the same edges multiple times into the edgehash.
This commit is contained in:
parent
1ba29c3a4a
commit
585272fbcf
@ -80,7 +80,7 @@ typedef struct Cloth {
|
||||
struct MFace *mfaces;
|
||||
struct Implicit_Data *implicit; /* our implicit solver connects to this pointer */
|
||||
struct Implicit_Data *implicitEM; /* our implicit solver connects to this pointer */
|
||||
struct EdgeHash *edgehash; /* used for selfcollisions */
|
||||
struct EdgeHash *edgehash; /* used for selfcollisions (currently used as a 'set', value is ignored) */
|
||||
int last_frame, pad4;
|
||||
} Cloth;
|
||||
|
||||
|
@ -1223,7 +1223,7 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
// check for existing spring
|
||||
// check also if startpoint is equal to endpoint
|
||||
if ((index2 != tspring2->ij) &&
|
||||
!BLI_edgehash_haskey(edgehash, MIN2(tspring2->ij, index2), MAX2(tspring2->ij, index2)))
|
||||
!BLI_edgehash_haskey(edgehash, tspring2->ij, index2))
|
||||
{
|
||||
spring = (ClothSpring *)MEM_callocN ( sizeof ( ClothSpring ), "cloth spring" );
|
||||
|
||||
@ -1283,16 +1283,18 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm )
|
||||
}
|
||||
}
|
||||
|
||||
/* note: the edges may already exist so run reinsert */
|
||||
|
||||
/* insert other near springs in edgehash AFTER bending springs are calculated (for selfcolls) */
|
||||
for (i = 0; i < numedges; i++) { /* struct springs */
|
||||
BLI_edgehash_insert(edgehash, MIN2(medge[i].v1, medge[i].v2), MAX2(medge[i].v2, medge[i].v1), NULL);
|
||||
BLI_edgehash_reinsert(edgehash, medge[i].v1, medge[i].v2, NULL);
|
||||
}
|
||||
|
||||
for (i = 0; i < numfaces; i++) { /* edge springs */
|
||||
if (mface[i].v4) {
|
||||
BLI_edgehash_insert(edgehash, MIN2(mface[i].v1, mface[i].v3), MAX2(mface[i].v3, mface[i].v1), NULL);
|
||||
BLI_edgehash_reinsert(edgehash, mface[i].v1, mface[i].v3, NULL);
|
||||
|
||||
BLI_edgehash_insert(edgehash, MIN2(mface[i].v2, mface[i].v4), MAX2(mface[i].v2, mface[i].v4), NULL);
|
||||
BLI_edgehash_reinsert(edgehash, mface[i].v2, mface[i].v4, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -865,8 +865,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData *clmd, float step, floa
|
||||
|
||||
if ( ( ABS ( temp[0] ) > mindistance ) || ( ABS ( temp[1] ) > mindistance ) || ( ABS ( temp[2] ) > mindistance ) ) continue;
|
||||
|
||||
// check for adjacent points (i must be smaller j)
|
||||
if ( BLI_edgehash_haskey ( cloth->edgehash, MIN2(i, j), MAX2(i, j) ) ) {
|
||||
if (BLI_edgehash_haskey(cloth->edgehash, i, j)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ EdgeHash *BLI_edgehash_new_ex(const char *info,
|
||||
EdgeHash *BLI_edgehash_new(const char *info);
|
||||
void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp);
|
||||
void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
|
||||
void BLI_edgehash_assign(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
|
||||
void BLI_edgehash_reinsert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
|
||||
void *BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1);
|
||||
void **BLI_edgehash_lookup_p(EdgeHash *eh, unsigned int v0, unsigned int v1);
|
||||
bool BLI_edgehash_haskey(EdgeHash *eh, unsigned int v0, unsigned int v1);
|
||||
|
@ -205,7 +205,7 @@ void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *v
|
||||
/**
|
||||
* Assign a new value to a key that may already be in edgehash.
|
||||
*/
|
||||
void BLI_edgehash_assign(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val)
|
||||
void BLI_edgehash_reinsert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val)
|
||||
{
|
||||
unsigned int hash;
|
||||
EdgeEntry *e;
|
||||
|
Loading…
Reference in New Issue
Block a user