Temporary fix for loading crash of .blends with cached frames. Also fixed some goal behavior/init problem to match SB behaviour
This commit is contained in:
@@ -913,13 +913,10 @@ static void cloth_apply_vgroup(ClothModifierData *clmd, DerivedMesh *dm, short v
|
||||
verts = clothObj->verts;
|
||||
|
||||
for (i = 0; i < numverts; i++, verts++)
|
||||
{
|
||||
/* so this will definily be below SOFTGOALSNAP */
|
||||
verts->goal= 0.0f;
|
||||
|
||||
{
|
||||
// LATER ON, support also mass painting here
|
||||
if(clmd->sim_parms.flags & CSIMSETT_FLAG_GOAL)
|
||||
{
|
||||
{
|
||||
dvert = dm->getVertData(dm, i, CD_MDEFORMVERT);
|
||||
if(dvert)
|
||||
{
|
||||
@@ -1211,7 +1208,12 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d
|
||||
Mat4MulVecfl(ob->obmat, verts->x);
|
||||
|
||||
verts->mass = clmd->sim_parms.mass;
|
||||
verts->goal= clmd->sim_parms.defgoal;
|
||||
|
||||
if(clmd->sim_parms.flags & CSIMSETT_FLAG_GOAL)
|
||||
verts->goal= clmd->sim_parms.defgoal;
|
||||
else
|
||||
verts->goal= 0.0f;
|
||||
|
||||
verts->flags = 0;
|
||||
VECCOPY(verts->xold, verts->x);
|
||||
VECCOPY(verts->xconst, verts->x);
|
||||
|
||||
@@ -570,7 +570,7 @@ DO_INLINE void mul_bfmatrix_S(fmatrix3x3 *matrix, float scalar)
|
||||
/* STATUS: verified */
|
||||
DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, float (*fLongVector)[3])
|
||||
{
|
||||
int i = 0,j=0;
|
||||
unsigned int i = 0,j=0;
|
||||
zero_lfvector(to, from[0].vcount);
|
||||
/* process diagonal elements */
|
||||
for(i = 0; i < from[0].vcount; i++)
|
||||
|
||||
@@ -4873,6 +4873,7 @@ static void clothModifier_deformVerts(
|
||||
DerivedMesh *dm = NULL;
|
||||
|
||||
// if possible use/create DerivedMesh
|
||||
|
||||
if(derivedData) dm = CDDM_copy(derivedData);
|
||||
else if(ob->type==OB_MESH) dm = CDDM_from_mesh(ob->data, ob);
|
||||
|
||||
|
||||
@@ -2878,11 +2878,13 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
|
||||
ClothModifierData *clmd = (ClothModifierData*) md;
|
||||
|
||||
clmd->clothObject = NULL;
|
||||
/*
|
||||
if (clmd->sim_parms.flags & CSIMSETT_FLAG_BAKED) {
|
||||
clmd->baked_data = newdataadr (fd, clmd->baked_data);
|
||||
clmd->sim_parms.cache = NULL;
|
||||
|
||||
if (clmd->sim_parms.cache) {
|
||||
// TODO
|
||||
// clmd->cache = newdataadr (fd, clmd->cache);
|
||||
printf ("direct_link_modifiers: read cloth baked_data.\n");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
else if (md->type==eModifierType_Hook) {
|
||||
HookModifierData *hmd = (HookModifierData*) md;
|
||||
|
||||
@@ -813,6 +813,23 @@ static void write_constraint_channels(WriteData *wd, ListBase *chanbase)
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
// TODO: finish this
|
||||
static void write_cloth_cache(WriteData *wd, LinkNode *ln)
|
||||
{
|
||||
|
||||
while(ln) {
|
||||
writestruct(wd, DATA, "cloth_cache", 1, ln);
|
||||
writestruct(wd, DATA, "cloth_cache_frame", 1, ln->link);
|
||||
writestruct(wd, DATA, "cloth_cache_frame_verts", 1, ln->link);
|
||||
writestruct(wd, DATA, "cloth_cache_frame_springs", 1, ln->link);
|
||||
}
|
||||
|
||||
ln = ln->next;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
static void write_modifiers(WriteData *wd, ListBase *modbase)
|
||||
{
|
||||
ModifierData *md;
|
||||
@@ -832,16 +849,20 @@ static void write_modifiers(WriteData *wd, ListBase *modbase)
|
||||
else if (md->type==eModifierType_Cloth) {
|
||||
int n;
|
||||
ClothModifierData *clmd = (ClothModifierData *) md;
|
||||
/*
|
||||
if ((clmd->sim_parms.flags & CSIMSETT_FLAG_BAKED) && clmd->baked_data) {
|
||||
|
||||
if (clmd->sim_parms.cache) {
|
||||
// Compute the number of vertices we're saving.
|
||||
|
||||
// TODO
|
||||
// write_cloth_cache();
|
||||
/*
|
||||
// old code
|
||||
n = (clmd->sim_parms.bake_end_frame - clmd->sim_parms.bake_start_frame + 1) *
|
||||
clmd->sim_parms.bake_num_verts;
|
||||
writedata (wd, DATA, n * sizeof (clmd->baked_data [0]), clmd->baked_data);
|
||||
printf ("write_modifiers: wrote %d elements of size %d for cloth baked data.\n",
|
||||
n, sizeof (clmd->baked_data [0]));
|
||||
}*/
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user