From 86e8d54dcb7c46f876816dd0ddc87e893e958201 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Mon, 3 Nov 2008 17:54:12 +0000 Subject: [PATCH] Sketch Retargetting: Rolling bone perpendicular to stroke's normal is now optional. Normal pointer added to reeb nodes (the last bone in a chain needs it and can't get it from the embedding). --- source/blender/include/reeb.h | 2 ++ source/blender/makesdna/DNA_scene_types.h | 7 ++++++- source/blender/src/drawview.c | 9 +++++---- source/blender/src/editarmature_retarget.c | 7 ++++--- source/blender/src/editarmature_sketch.c | 10 +++++++++- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/source/blender/include/reeb.h b/source/blender/include/reeb.h index 5dcbad7e80b..6496eb34836 100644 --- a/source/blender/include/reeb.h +++ b/source/blender/include/reeb.h @@ -80,6 +80,8 @@ typedef struct ReebNode { int symmetry_flag; float symmetry_axis[3]; /*********************************/ + + float *no; int index; float weight; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 6f33ece2ee9..3899600af30 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -446,10 +446,11 @@ typedef struct ToolSettings { char bone_sketching; char bone_sketching_convert; char skgen_subdivision_number; + char skgen_retarget_options; /* Alt+RMB option */ char edge_mode; - char pad3[4]; + char pad3[3]; } ToolSettings; /* Used by all brushes to store their properties, which can be directly set @@ -883,6 +884,10 @@ typedef struct Scene { #define SK_CONVERT_CUT_CORRELATION 3 #define SK_CONVERT_RETARGET 4 +/* toolsettings->skgen_retarget_options */ +#define SK_RETARGET_ROLL 1 + + #ifdef __cplusplus } #endif diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 7f1e8122da6..d799d31c742 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -2321,18 +2321,19 @@ static void view3d_panel_bonesketch_spaces(short cntrl) uiBlockBeginAlign(block); uiDefButC(block, ROW, B_REDR, "Length", 10, yco, 60, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_CUT_LENGTH, 0, 0, "Subdivide arcs in bones of equal length"); - uiDefButF(block, NUM, B_REDR, "L:", 70, yco, 90, 19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0, "Maximum length of the bones when subdividing"); + uiDefButF(block, NUM, B_REDR, "L:", 70, yco, 90, 19, &G.scene->toolsettings->skgen_length_limit,0.1,50.0, 10, 0, "Maximum length of the subdivided bones"); yco -= 20; uiDefButC(block, ROW, B_REDR, "Correlation", 10, yco, 60, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_CUT_CORRELATION, 0, 0, "Subdivide arcs based on correlation"); - uiDefButF(block, NUM, B_REDR, "T:", 70, yco, 90, 19, &G.scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0, "Specify the threshold correlation for subdivision"); + uiDefButF(block, NUM, B_REDR, "T:", 70, yco, 90, 19, &G.scene->toolsettings->skgen_correlation_limit,0.0, 1.0, 0.01, 0, "Correlation threshold for subdivision"); yco -= 20; uiDefButC(block, ROW, B_REDR, "Fixed", 10, yco, 60, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_CUT_FIXED, 0, 0, "Subdivide arcs based on a fixed number of bones"); - uiDefButC(block, NUM, B_REDR, "N:", 70, yco, 90, 19, &G.scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5, "Specify the bones to subdivide into"); + uiDefButC(block, NUM, B_REDR, "N:", 70, yco, 90, 19, &G.scene->toolsettings->skgen_subdivision_number,1, 100, 1, 5, "Number of subdivided bones"); yco -= 20; - uiDefButC(block, ROW, B_REDR, "Retarget", 10, yco,150, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_RETARGET, 0, 0, "Subdivide arcs based on a fixed number of bones"); + uiDefButC(block, ROW, B_REDR, "Retarget", 10, yco,80, 19, &G.scene->toolsettings->bone_sketching_convert, 0, SK_CONVERT_RETARGET, 0, 0, "Retarget selected bones to stroke"); + uiDefButBitC(block, TOG, SK_RETARGET_ROLL, B_DIFF, "Roll", 90, yco, 70,19, &G.scene->toolsettings->skgen_retarget_options, 0, 0, 0, 0, "Roll bones perpendicular to view"); /* button here to select what to do (copy or not), template, ...*/ yco -= 20; diff --git a/source/blender/src/editarmature_retarget.c b/source/blender/src/editarmature_retarget.c index 34c5064e5f3..d54389e7d80 100644 --- a/source/blender/src/editarmature_retarget.c +++ b/source/blender/src/editarmature_retarget.c @@ -2264,6 +2264,7 @@ static void retargetArctoArcAggresive(RigGraph *rigg, RigArc *iarc, RigNode *ino else { vec1 = node_end->p; + no = node_end->no; } if (edge->bone) @@ -2349,7 +2350,7 @@ static void retargetArctoArcLength(RigGraph *rigg, RigArc *iarc, RigNode *inode_ if (bucket == NULL) { vec1 = node_end->p; - no = NULL; + no = node_end->no; } /* no need to move virtual edges (space between unconnected bones) */ @@ -2398,11 +2399,11 @@ void *exec_retargetArctoArc(void *param) if (testFlipArc(iarc, inode_start)) { - repositionBone(rigg, edge, earc->tail->p, earc->head->p, NULL); + repositionBone(rigg, edge, earc->tail->p, earc->head->p, earc->head->no); } else { - repositionBone(rigg, edge, earc->head->p, earc->tail->p, NULL); + repositionBone(rigg, edge, earc->head->p, earc->tail->p, earc->tail->no); } } else diff --git a/source/blender/src/editarmature_sketch.c b/source/blender/src/editarmature_sketch.c index f1ca1bd0387..aeff63ce4d7 100644 --- a/source/blender/src/editarmature_sketch.c +++ b/source/blender/src/editarmature_sketch.c @@ -362,6 +362,11 @@ ReebNode *pointToNode(SK_Point *pt) node = MEM_callocN(sizeof(ReebNode), "reeb node"); VECCOPY(node->p, pt->p); + if (G.scene->toolsettings->skgen_retarget_options & SK_RETARGET_ROLL) + { + node->no = pt->no; + } + return node; } @@ -380,7 +385,10 @@ ReebArc *strokeToArc(SK_Stroke *stk) for (i = 0; i < arc->bcount; i++) { VECCOPY(arc->buckets[i].p, stk->points[i + 1].p); - arc->buckets[i].no = stk->points[i + 1].no; + if (G.scene->toolsettings->skgen_retarget_options & SK_RETARGET_ROLL) + { + arc->buckets[i].no = stk->points[i + 1].no; + } } return arc;