- switch displistmesh_to_mesh to just dupalloc the mface's
- added verteCos argument to sbObjectReset, lack of this was causing softbody objects to not be initialized with deform - made convert-to-mesh option call DAG_scene_sort, prevents crashes due to obsolete object pointer
This commit is contained in:
@@ -65,7 +65,7 @@ extern void sbObjectStep(struct Object *ob, float framnr, float (*vertexCos)[
|
||||
extern void sbObjectToSoftbody(struct Object *ob, float (*vertexCos)[3]);
|
||||
|
||||
/* resets all motion and time */
|
||||
extern void sbObjectReset(struct Object *ob);
|
||||
extern void sbObjectReset(struct Object *ob, float (*vertexCos)[3]);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -139,9 +139,6 @@ DispListMesh *displistmesh_copy(DispListMesh *odlm)
|
||||
|
||||
void displistmesh_to_mesh(DispListMesh *dlm, Mesh *me)
|
||||
{
|
||||
MFace *mfaces;
|
||||
int i;
|
||||
|
||||
if (dlm->totvert>MESH_MAX_VERTS) {
|
||||
error("Too many vertices");
|
||||
} else {
|
||||
@@ -149,27 +146,16 @@ void displistmesh_to_mesh(DispListMesh *dlm, Mesh *me)
|
||||
me->totvert= dlm->totvert;
|
||||
|
||||
me->mvert= MEM_dupallocN(dlm->mvert);
|
||||
me->mface= mfaces= MEM_mallocN(sizeof(*mfaces)*me->totface, "me->mface");
|
||||
me->mface= MEM_dupallocN(dlm->mface);
|
||||
if (dlm->tface)
|
||||
me->tface= MEM_dupallocN(dlm->tface);
|
||||
if (dlm->mcol)
|
||||
me->mcol= MEM_dupallocN(dlm->mcol);
|
||||
|
||||
if(dlm->medge) {
|
||||
me->totedge= dlm->totedge;
|
||||
me->medge= MEM_dupallocN(dlm->medge);
|
||||
}
|
||||
|
||||
for (i=0; i<me->totface; i++) {
|
||||
MFace *mf= &mfaces[i];
|
||||
MFace *oldmf= &dlm->mface[i];
|
||||
|
||||
mf->v1= oldmf->v1;
|
||||
mf->v2= oldmf->v2;
|
||||
mf->v3= oldmf->v3;
|
||||
mf->v4= oldmf->v4;
|
||||
mf->flag= oldmf->flag;
|
||||
mf->mat_nr= oldmf->mat_nr;
|
||||
mf->edcode= ME_V1V2|ME_V2V3|ME_V3V4|ME_V4V1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1188,7 +1188,7 @@ void sbObjectToSoftbody(Object *ob, float (*vertexCos)[3])
|
||||
}
|
||||
|
||||
/* reset all motion */
|
||||
void sbObjectReset(Object *ob)
|
||||
void sbObjectReset(Object *ob, float (*vertexCos)[3])
|
||||
{
|
||||
SoftBody *sb= ob->soft;
|
||||
BodyPoint *bp;
|
||||
@@ -1199,7 +1199,7 @@ void sbObjectReset(Object *ob)
|
||||
|
||||
sb->ctime= bsystem_time(ob, NULL, (float)G.scene->r.cfra, 0.0);
|
||||
|
||||
object_update_softbody(ob, NULL);
|
||||
object_update_softbody(ob, vertexCos);
|
||||
|
||||
for(a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) {
|
||||
// origS is previous timestep
|
||||
@@ -1259,7 +1259,7 @@ void sbObjectStep(Object *ob, float framenr, float (*vertexCos)[3])
|
||||
dtime= ctime - sb->ctime;
|
||||
// bail out for negative or for large steps
|
||||
if(dtime<0.0 || dtime >= 9.9*G.scene->r.framelen) { // G.scene->r.framelen corrects for frame-mapping, so this is actually 10 frames for UI
|
||||
sbObjectReset(ob);
|
||||
sbObjectReset(ob, vertexCos);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2194,10 +2194,9 @@ void convertmenu(void)
|
||||
|
||||
dm= mesh_create_derived_no_deform(ob, NULL);
|
||||
dlm= dm->convertToDispListMesh(dm);
|
||||
dm->release(dm);
|
||||
|
||||
displistmesh_to_mesh(dlm, ob1->data);
|
||||
displistmesh_free(dlm);
|
||||
dm->release(dm);
|
||||
}
|
||||
else if(ob->type==OB_FONT) {
|
||||
if(nr==1) {
|
||||
@@ -2304,7 +2303,7 @@ void convertmenu(void)
|
||||
allqueue(REDRAWBUTSEDIT, 0);
|
||||
BIF_undo_push("Convert Object");
|
||||
|
||||
DAG_scene_flush_update(G.scene);
|
||||
DAG_scene_sort(G.scene);
|
||||
}
|
||||
|
||||
/* Change subdivision properties of mesh object ob, if
|
||||
|
||||
@@ -1412,7 +1412,7 @@ void special_aftertrans_update(short cancelled)
|
||||
|
||||
ob= base->object;
|
||||
/* reset soft body object */
|
||||
if(ob->softflag & OB_SB_ENABLE) sbObjectReset(ob);
|
||||
if(ob->softflag & OB_SB_ENABLE) sbObjectReset(ob, NULL);
|
||||
|
||||
/* Set autokey if necessary */
|
||||
if ((G.flags & G_RECORDKEYS) && (!cancelled) && (base->flag & SELECT)){
|
||||
|
||||
Reference in New Issue
Block a user