From 4eb0614c5b4a7511ee5b344b6a12213ec15c78b7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 20 Mar 2008 10:50:46 +0000 Subject: * Bugfix #8599a: Deleting the first Action Channel in an Action Group acted odd. In some cases it crashed, other times it corrupted stuff (removing all subsequent Action Channels). Was missing a call to remove the Action Channel from group(s). * Fixed whitespace in many places... --- source/blender/src/drawaction.c | 28 +++++++------- source/blender/src/editaction.c | 20 ++++++---- source/blender/src/editarmature.c | 77 ++++++++++++++++++--------------------- source/blender/src/editipo.c | 2 +- 4 files changed, 62 insertions(+), 65 deletions(-) diff --git a/source/blender/src/drawaction.c b/source/blender/src/drawaction.c index 36038901db9..1d3ece58db7 100644 --- a/source/blender/src/drawaction.c +++ b/source/blender/src/drawaction.c @@ -168,7 +168,7 @@ static void meshactionbuts(SpaceAction *saction, Object *ob, Key *key) for (i=1; i < key->totkey; i++) { make_rvk_slider(block, ob, i, x, y, SLIDERWIDTH-2, CHANNELHEIGHT-1, "Slider to control Shape Keys"); - + y-=CHANNELHEIGHT+CHANNELSKIP; /* see sliderval array in editkey.c */ @@ -176,7 +176,6 @@ static void meshactionbuts(SpaceAction *saction, Object *ob, Key *key) } } uiDrawBlock(block); - } static void icu_slider_func(void *voidicu, void *voidignore) @@ -238,7 +237,7 @@ static void make_icu_slider(uiBlock *block, IpoCurve *icu, /* create a slider for the ipo-curve*/ uiBut *but; - if(icu==NULL) return; + if(icu == NULL) return; if (IS_EQ(icu->slide_max, icu->slide_min)) { if (IS_EQ(icu->ymax, icu->ymin)) { @@ -359,7 +358,7 @@ static void action_icu_buts(SpaceAction *saction) // TODO... } break; - } + } } /* adjust y-position for next one */ @@ -905,7 +904,7 @@ void do_actionbuts(unsigned short event) } } - +// currently not used... static void action_panel_properties(short cntrl) // ACTION_HANDLER_PROPERTIES { uiBlock *block; @@ -913,10 +912,10 @@ static void action_panel_properties(short cntrl) // ACTION_HANDLER_PROPERTIES block= uiNewBlock(&curarea->uiblocks, "action_panel_properties", UI_EMBOSS, UI_HELV, curarea->win); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | cntrl); uiSetPanelHandler(ACTION_HANDLER_PROPERTIES); // for close and esc - if(uiNewPanel(curarea, block, "Transform Properties", "Action", 10, 230, 318, 204)==0) return; + if (uiNewPanel(curarea, block, "Transform Properties", "Action", 10, 230, 318, 204)==0) + return; uiDefBut(block, LABEL, 0, "test text", 10,180,300,19, 0, 0, 0, 0, 0, ""); - } static void action_blockhandlers(ScrArea *sa) @@ -924,17 +923,17 @@ static void action_blockhandlers(ScrArea *sa) SpaceAction *sact= sa->spacedata.first; short a; - for(a=0; ablockhandler[a]) { - - case ACTION_HANDLER_PROPERTIES: - action_panel_properties(sact->blockhandler[a+1]); - break; - + case ACTION_HANDLER_PROPERTIES: + action_panel_properties(sact->blockhandler[a+1]); + break; } + /* clear action value for event */ sact->blockhandler[a+1]= 0; } + uiDrawBlocksPanels(sa, 0); } @@ -959,7 +958,6 @@ void drawactionspace(ScrArea *sa, void *spacedata) /* only try to refresh action that's displayed if not pinned */ if (G.saction->pin==0) { - /* TODO: allow more than one active action sometime? */ if (OBACT) G.saction->action = OBACT->action; else @@ -1508,7 +1506,7 @@ void agroup_to_keylist(bActionGroup *agrp, ListBase *keys, ListBase *blocks, Act if (agrp) { /* loop through action channels */ for (achan= agrp->channels.first; achan && achan->grp==agrp; achan= achan->next) { - if(VISIBLE_ACHAN(achan)) { + if (VISIBLE_ACHAN(achan)) { /* firstly, add keys from action channel's ipo block */ if (achan->ipo) ipo_to_keylist(achan->ipo, keys, blocks, aki); diff --git a/source/blender/src/editaction.c b/source/blender/src/editaction.c index d6d748f2213..769a4f7f72f 100644 --- a/source/blender/src/editaction.c +++ b/source/blender/src/editaction.c @@ -1088,7 +1088,7 @@ void verify_pchan2achan_grouping (bAction *act, bPose *pose, char name[]) return; if (name[0] == 0) return; - + /* try to get the channels */ pchan= get_pose_channel(pose, name); if (pchan == NULL) return; @@ -1529,7 +1529,7 @@ void delete_action_channels (void) bConstraintChannel *conchan, *cnext; next= ale->next; - /* release reference to ipo users */ + /* release references to ipo users */ if (achan->ipo) achan->ipo->id.us--; @@ -1540,12 +1540,16 @@ void delete_action_channels (void) conchan->ipo->id.us--; } + /* remove action-channel from group(s) */ + if (achan->grp) + action_groups_removeachan(act, achan); + /* free memory */ BLI_freelistN(&achan->constraintChannels); BLI_freelinkN(&act->chanbase, achan); BLI_freelinkN(&act_data, ale); } - + remake_action_ipos(data); BIF_undo_push("Delete Action Channels"); @@ -1867,7 +1871,7 @@ void paste_actdata () /* check if we have a corresponding action channel */ if ((no_name) || (strcmp(achan->name, achant->name)==0)) { actname= achan->name; - + /* check if this is a constraint channel */ if (ale->type == ACTTYPE_CONCHAN) { bConstraintChannel *conchant= ale->data; @@ -1901,12 +1905,12 @@ void paste_actdata () /* this shouldn't happen, but it might */ if (ELEM(NULL, ipo_src, ipo_dst)) continue; - + /* loop over curves, pasting keyframes */ for (ico= ipo_src->curve.first; ico; ico= ico->next) { icu= verify_ipocurve((ID*)OBACT, ico->blocktype, actname, conname, "", ico->adrcode); - - if(icu) { + + if (icu) { /* just start pasting, with the the first keyframe on the current frame, and so on */ for (i=0, bezt=ico->bezt; i < ico->totvert; i++, bezt++) { /* temporarily apply offset to src beztriple while copying */ @@ -4233,7 +4237,7 @@ void winqreadactionspace(ScrArea *sa, void *spacedata, BWinEvent *evt) */ if (IN_2D_VERT_SCROLL(mval)) selectall_action_keys(mval, 0, select_mode); - + /* Clicking in the horizontal scrollbar selects * all of the keys within 0.5 of the nearest integer * frame diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 10bec0a7e92..a93d81e04af 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -3036,7 +3036,6 @@ void deselectall_posearmature (Object *ob, int test, int doundo) int bone_looper(Object *ob, Bone *bone, void *data, int (*bone_func)(Object *, Bone *, void *)) { - /* We want to apply the function bone_func to every bone * in an armature -- feed bone_looper the first bone and * a pointer to the bone_func and watch it go!. The int count @@ -3046,19 +3045,15 @@ int bone_looper(Object *ob, Bone *bone, void *data, int count = 0; if (bone) { - - /* only do bone_func if the bone is non null - */ + /* only do bone_func if the bone is non null */ count += bone_func(ob, bone, data); - - /* try to execute bone_func for the first child - */ - count += bone_looper(ob, bone->childbase.first, data, - bone_func); - - /* try to execute bone_func for the next bone at this - * depth of the recursion. - */ + + /* try to execute bone_func for the first child */ + count += bone_looper(ob, bone->childbase.first, data, bone_func); + + /* try to execute bone_func for the next bone at this + * depth of the recursion. + */ count += bone_looper(ob, bone->next, data, bone_func); } @@ -3096,15 +3091,15 @@ static int bone_skinnable(Object *ob, Bone *bone, void *datap) if(!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { - if(data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) + if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) segments = bone->segments; else segments = 1; - + if (data->list != NULL) { hbone = (Bone ***) &data->list; - for(a=0; aflag & BONE_NO_DEFORM)) { if (!get_named_vertexgroup(ob,bone->name)) { add_defgroup_name(ob, bone->name); @@ -3159,19 +3154,19 @@ static int dgroup_skinnable(Object *ob, Bone *bone, void *datap) int a, segments; struct { Object *armob; void *list; int heat; } *data= datap; - if(!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) { + if (!(G.f & G_WEIGHTPAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { - if(data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) + if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) segments = bone->segments; else segments = 1; - - if(!(defgroup = get_named_vertexgroup(ob, bone->name))) + + if (!(defgroup = get_named_vertexgroup(ob, bone->name))) defgroup = add_defgroup_name(ob, bone->name); - + if (data->list != NULL) { hgroup = (bDeformGroup ***) &data->list; - + for(a=0; atotvert; i++) { iflip = (dgroupflip)? mesh_get_x_mirror_vert(ob, i): 0; - + /* for each skinnable bone */ for (j=0; j < numbones; ++j) { if(!selected[j]) continue; - + bone = bonelist[j]; dgroup = dgrouplist[j]; - + /* store the distance-factor from the vertex to the bone */ distance = distfactor_to_bone (verts[i], root[j], tip[j], bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); @@ -3221,7 +3216,7 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i add_vert_to_defgroup (ob, dgroup, i, distance, WEIGHT_REPLACE); else remove_vert_defgroup (ob, dgroup, i); - + /* do same for mirror */ if (dgroupflip && dgroupflip[j] && iflip >= 0) { if (distance!=0.0) @@ -3306,7 +3301,7 @@ void add_verts_to_dgroups(Object *ob, Object *par, int heat, int mirror) if(segments == 0) { segments = 1; bbone = NULL; - + if(par->pose && (pchan=get_pose_channel(par->pose, bone->name))) { if(bone->segments > 1) { segments = bone->segments; @@ -3314,10 +3309,10 @@ void add_verts_to_dgroups(Object *ob, Object *par, int heat, int mirror) } } } - + segments--; } - + /* compute root and tip */ if(bbone) { VECCOPY(root[j], bbone[segments].mat[3]); @@ -3333,10 +3328,10 @@ void add_verts_to_dgroups(Object *ob, Object *par, int heat, int mirror) VECCOPY(root[j], bone->arm_head); VECCOPY(tip[j], bone->arm_tail); } - + Mat4MulVecfl(par->obmat, root[j]); Mat4MulVecfl(par->obmat, tip[j]); - + /* set selected */ if(wpmode) { if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED)) @@ -3344,7 +3339,7 @@ void add_verts_to_dgroups(Object *ob, Object *par, int heat, int mirror) } else selected[j] = 1; - + /* find flipped group */ if(mirror) { char name[32]; @@ -3352,11 +3347,11 @@ void add_verts_to_dgroups(Object *ob, Object *par, int heat, int mirror) BLI_strncpy(name, dgroup->name, 32); // 0 = don't strip off number extensions bone_flip_name(name, 0); - + for (curdg = ob->defbase.first; curdg; curdg=curdg->next) if (!strcmp(curdg->name, name)) break; - + dgroupflip[j] = curdg; } } @@ -3368,12 +3363,12 @@ void add_verts_to_dgroups(Object *ob, Object *par, int heat, int mirror) if (wpmode) { /* if in weight paint mode, use final verts from derivedmesh */ DerivedMesh *dm = mesh_get_derived_final(ob, CD_MASK_BAREMESH); - + if(dm->foreachMappedVert) { dm->foreachMappedVert(dm, add_vgroups__mapFunc, (void*)verts); vertsfilled = 1; } - + dm->release(dm); } else if (modifiers_findByType(ob, eModifierType_Subsurf)) { @@ -3439,9 +3434,9 @@ void create_vgroups_from_armature(Object *ob, Object *par) add_defgroup_unique_bone); if (ob->type == OB_MESH) create_dverts(ob->data); - + break; - + case 3: case 4: /* Traverse the bone list, trying to create vertex groups @@ -3477,7 +3472,7 @@ void hide_selected_pose_bones(void) bone_looper(OBACT, arm->bonebase.first, NULL, hide_selected_pose_bone); - + allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWBUTSEDIT, 0); allqueue(REDRAWACTION, 0); diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index ef656281d75..cf59b5829ef 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -1815,7 +1815,7 @@ Ipo *verify_ipo(ID *from, short blocktype, char *actname, char *constname, char if(achan) { /* automatically assign achan to act-group based on pchan's grouping */ if (blocktype == ID_PO) - verify_pchan2achan_grouping(ob->action, ob->pose, actname); + verify_pchan2achan_grouping(ob->action, ob->pose, actname); /* constraint exception */ if(blocktype==ID_CO) { -- cgit v1.2.3