diff --git a/source/blender/src/drawgpencil.c b/source/blender/src/drawgpencil.c index 4b6b5ab26c8..15f65bfe3cf 100644 --- a/source/blender/src/drawgpencil.c +++ b/source/blender/src/drawgpencil.c @@ -145,6 +145,13 @@ void gp_ui_delframe_cb (void *gpd, void *gpl) allqueue(REDRAWACTION, 0); } +/* convert the active layer to geometry */ +void gp_ui_convertlayer_cb (void *gpd, void *gpl) +{ + gpencil_layer_setactive(gpd, gpl); + gpencil_convert_menu(); +} + /* ------- Drawing Code ------- */ /* draw the controls for a given layer */ @@ -166,7 +173,7 @@ static void gp_drawui_layer (uiBlock *block, bGPdata *gpd, bGPDlayer *gpl, short /* rounded header */ if (active) uiBlockSetCol(block, TH_BUT_ACTION); rb_col= (active)?-20:20; - uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-8, *yco-2, width, 24, NULL, 5.0, 0.0, 15 , rb_col-20, ""); + uiDefBut(block, ROUNDBOX, B_REDR, "", *xco-8, *yco-2, width, 24, NULL, 5.0, 0.0, 15 , rb_col-20, ""); if (active) uiBlockSetCol(block, TH_AUTO); /* lock toggle */ @@ -249,8 +256,14 @@ static void gp_drawui_layer (uiBlock *block, bGPdata *gpd, bGPDlayer *gpl, short /* options */ uiBlockBeginAlign(block); - but= uiDefBut(block, BUT, B_REDR, "Del Active Frame", *xco+160, *yco-75, 140, 20, NULL, 0, 0, 0, 0, "Erases the the active frame for this layer (Hotkey = Alt-XKEY/DEL)"); - uiButSetFunc(but, gp_ui_delframe_cb, gpd, gpl); + if (curarea->spacetype == SPACE_VIEW3D) { + but= uiDefBut(block, BUT, B_REDR, "Convert to...", *xco+160, *yco-75, 140, 20, NULL, 0, 0, 0, 0, "Converts this layer's strokes to geometry (Hotkey = Alt-Shift-C)"); + uiButSetFunc(but, gp_ui_convertlayer_cb, gpd, gpl); + } + else { + but= uiDefBut(block, BUT, B_REDR, "Del Active Frame", *xco+160, *yco-75, 140, 20, NULL, 0, 0, 0, 0, "Erases the the active frame for this layer (Hotkey = Alt-XKEY/DEL)"); + uiButSetFunc(but, gp_ui_delframe_cb, gpd, gpl); + } but= uiDefBut(block, BUT, B_REDR, "Del Last Stroke", *xco+160, *yco-95, 140, 20, NULL, 0, 0, 0, 0, "Erases the last stroke from the active frame (Hotkey = Alt-XKEY/DEL)"); uiButSetFunc(but, gp_ui_delstroke_cb, gpd, gpl); diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 12face8f1ba..5e50c8117cc 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -440,9 +440,23 @@ void docenter_armature (Object *ob, int centermode) } /* helper for apply_armature_pose2bones - fixes parenting of objects that are bone-parented to armature */ -static void applyarmature_fix_boneparents (Object *ob) +static void applyarmature_fix_boneparents (Object *armob) { + Object *ob; + /* go through all objects in database */ + for (ob= G.main->object.first; ob; ob= ob->id.next) { + /* if parent is bone in this armature, apply corrections */ + if ((ob->parent == armob) && (ob->partype == PARBONE)) { + /* apply current transform from parent (not yet destroyed), + * then calculate new parent inverse matrix + */ + apply_obmat(ob); + + what_does_parent(ob); + Mat4Invert(ob->parentinv, workob.obmat); + } + } } /* set the current pose as the restpose */ @@ -463,6 +477,9 @@ void apply_armature_pose2bones(void) } arm= get_armature(ob); + /* helpful warnings... */ + // TODO: add warnings to be careful about actions, applying deforms first, etc. + /* Get editbones of active armature to alter */ if (G.edbo.first) BLI_freelistN(&G.edbo); make_boneList(&G.edbo, &arm->bonebase, NULL); @@ -504,7 +521,10 @@ void apply_armature_pose2bones(void) /* clear transform values for pchan */ pchan->loc[0]= pchan->loc[1]= pchan->loc[2]= 0; pchan->quat[1]= pchan->quat[2]= pchan->quat[3]= 0; - pchan->quat[0]= pchan->size[1]= 1; + pchan->quat[0]= pchan->size[0]= pchan->size[1]= pchan->size[2]= 1; + + /* set anim lock */ + curbone->flag |= BONE_UNKEYED; } /* convert editbones back to bones */ diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index fcf4caf4522..e57a3480b52 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -4370,6 +4370,9 @@ static void do_view3d_pose_armaturemenu(void *arg, int event) case 18: pose_autoside_names(event-16); break; + case 19: /* assign pose as restpose */ + apply_armature_pose2bones(); + break; } allqueue(REDRAWVIEW3D, 0); @@ -4395,6 +4398,7 @@ static uiBlock *view3d_pose_armaturemenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Relax Pose|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 15, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Pose as Restpose|Ctrl A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 19, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");