Fun commit: I put some 3-liner verlet integrator in, to activate it, set clmd->sim_parms.solver_type in cloth_init to 1 - bugs in there

This commit is contained in:
Daniel Genrich
2007-11-05 19:28:38 +00:00
parent 7a6b3a63fa
commit 0a1be3e2ce
3 changed files with 15 additions and 20 deletions

View File

@@ -171,6 +171,11 @@ int implicit_init ( Object *ob, ClothModifierData *clmd );
int implicit_free ( ClothModifierData *clmd );
int implicit_solver ( Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors );
/* explicit verlet simulator */
int verlet_init ( Object *ob, ClothModifierData *clmd );
int verlet_free ( ClothModifierData *clmd );
int verlet_solver ( Object *ob, float frame, ClothModifierData *clmd, ListBase *effectors );
/* used for caching in implicit.c */
typedef struct Frame
{
@@ -227,5 +232,8 @@ typedef struct FaceCollPair
}
FaceCollPair;
// function definitions from implicit.c
DO_INLINE void mul_fvector_S(float to[3], float from[3], float scalar);
#endif

View File

@@ -114,7 +114,7 @@ double tval()
static CM_SOLVER_DEF solvers [] =
{
{ "Implicit", CM_IMPLICIT, implicit_init, implicit_solver, implicit_free },
// { "Implicit", CM_VERLET, verlet_init, verlet_solver, verlet_free },
{ "Verlet", CM_VERLET, verlet_init, verlet_solver, verlet_free },
};
/* ********** cloth engine ******* */
@@ -504,7 +504,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d
// if(!cloth_cache_search_frame(clmd, framenr))
{
verts = cloth->verts;
/*
// Force any pinned verts to their constrained location.
for ( i = 0; i < clmd->clothObject->numverts; i++, verts++ )
{
@@ -515,7 +515,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd,Object *ob, DerivedMesh *d
VECCOPY ( verts->xconst, mvert[i].co );
Mat4MulVecfl ( ob->obmat, verts->xconst );
}
*/
tstart();
/* Call the solver. */

View File

@@ -87,10 +87,6 @@ double itval()
}
#else
#include <sys/time.h>
// intrinsics need better compile flag checking
// #include <xmmintrin.h>
// #include <pmmintrin.h>
// #include <pthread.h>
static struct timeval _itstart, _itend;
static struct timezone itz;
@@ -110,14 +106,7 @@ double itval()
return t2-t1;
}
#endif
/*
#define C99
#ifdef C99
#defineDO_INLINE inline
#else
#defineDO_INLINE static
#endif
*/
struct Cloth;
//////////////////////////////////////////
@@ -1502,11 +1491,9 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
// call collision function
result = cloth_bvh_objcollision(clmd, step + dt, step, dt);
// copy corrected positions back to simulation
// copy corrected positions back to simulation
if(result)
{
printf("result: %d\n", result);
memcpy(cloth->current_xold, cloth->current_x, sizeof(lfVector) * numverts);
memcpy(id->Xnew, cloth->current_x, sizeof(lfVector) * numverts);
@@ -2284,12 +2271,12 @@ int cloth_bvh_objcollision(ClothModifierData * clmd, float step, float prevstep,
{
float correction = mindistance - length;
if(cloth->verts [i].goal >= SOFTGOALSNAP)
if((clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (cloth->verts [i].goal >= SOFTGOALSNAP))
{
VecMulf(temp, -correction);
VECADD(current_x[j], current_x[j], temp);
}
else if(cloth->verts [j].goal >= SOFTGOALSNAP)
else if((clmd->sim_parms.flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (cloth->verts [j].goal >= SOFTGOALSNAP))
{
VecMulf(temp, correction);
VECADD(current_x[i], current_x[i], temp);