From 07ef51cdb18fbfd85612c64c772d2cfa79c6775c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 16 Apr 2005 15:06:02 +0000 Subject: [PATCH] More SoftBody stuff: - after grab/duplicate the softbody didn't get a reset signal - added 'copy properties' for softbody settings - duplicate object didn't copy softbody yet --- source/blender/blenkernel/BKE_object.h | 2 ++ source/blender/blenkernel/intern/object.c | 17 +++++++++++++++-- source/blender/blenkernel/intern/softbody.c | 2 +- source/blender/src/editobject.c | 18 +++++++++++------- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index a5384ee2ae2..775b2057551 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -43,10 +43,12 @@ struct Object; struct Camera; struct BoundBox; struct View3D; +struct SoftBody; void clear_workob(void); void copy_baseflags(void); void copy_objectflags(void); +struct SoftBody *copy_softbody(struct SoftBody *sb); void update_base_layer(struct Object *ob); void free_object(struct Object *ob); void unlink_object(struct Object *ob); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 23ec5c5b08d..25dee64a7e8 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -745,6 +745,18 @@ void base_init_from_view3d(Base *base, View3D *v3d) v3d->viewquat[0]= -v3d->viewquat[0]; } +SoftBody *copy_softbody(SoftBody *sb) +{ + SoftBody *sbn; + + sbn= MEM_dupallocN(sb); + sbn->totspring= sbn->totpoint= 0; + sbn->bpoint= NULL; + sbn->bspring= NULL; + sbn->ctime= 0.0f; + + return sbn; +} Object *copy_object(Object *ob) { @@ -785,7 +797,6 @@ Object *copy_object(Object *ob) if (actcon) obn->activecon = actcon; - if(ob->pd) obn->pd= MEM_dupallocN(ob->pd); /* increase user numbers */ id_us_plus((ID *)obn->data); @@ -794,7 +805,9 @@ Object *copy_object(Object *ob) for(a=0; atotcol; a++) id_us_plus((ID *)obn->mat[a]); obn->disp.first= obn->disp.last= NULL; - obn->soft= NULL; + + if(ob->pd) obn->pd= MEM_dupallocN(ob->pd); + obn->soft= copy_softbody(ob->soft); return obn; } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 8409608bb54..e6d6dd7c341 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1269,7 +1269,7 @@ void sbFree(SoftBody *sb) /* makes totally fresh start situation */ void sbObjectToSoftbody(Object *ob) { - + switch(ob->type) { case OB_MESH: mesh_to_softbody(ob); diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 67e3a42a307..098288d49f3 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -2430,6 +2430,8 @@ void copy_attr_menu() if( give_parteff(ob) ) strcat(str, "|Particle Settings%x20"); + if(ob->soft) strcat(str, "|Soft Body Settings%x23"); + event= pupmenu(str); if(event<= 0) return; @@ -2602,7 +2604,7 @@ void copy_attr(short event) makeDispList(base->object); } } - else if(event==22){ + else if(event==22) { /* Clear the constraints on the target */ free_constraints(&base->object->constraints); free_constraint_channels(&base->object->constraintChannels); @@ -2616,6 +2618,12 @@ void copy_attr(short event) base->object->activecon = NULL; } + else if(event==23) { + base->object->softflag= ob->softflag; + if(base->object->soft) sbFree(base->object->soft); + + base->object->soft= copy_softbody(ob->soft); + } } } base= base->next; @@ -4368,7 +4376,6 @@ void special_aftertrans_update(char mode, int flip, short canceled, int keyflags Base *base; MetaBall *mb; Curve *cu; - Ika *ika; int doit,redrawipo=0; @@ -4449,11 +4456,6 @@ void special_aftertrans_update(char mode, int flip, short canceled, int keyflags where_is_object(ob); - if(ob->type==OB_IKA) { - ika= ob->data; - VecMat4MulVecfl(ika->effg, ob->obmat, ika->eff); - itterate_ika(ob); - } if(ob->type==OB_ARMATURE && canceled) { /* Unfortunately, sometimes when you escape * a transform on an object that is the @@ -4504,6 +4506,8 @@ void special_aftertrans_update(char mode, int flip, short canceled, int keyflags makeDispList(ob); } + if(ob->softflag & OB_SB_ENABLE) sbObjectReset(ob); + where_is_object(ob); /* always do, for track etc. */ /* Set autokey if necessary */