[Bf-blender-cvs] [5dc799b] PSketch: PSculpt: Code Cleanup - Unify all the *data's, and stop passing it around everywhere
Joshua Leung
noreply at git.blender.org
Sun Jan 31 14:29:29 CET 2016
Commit: 5dc799b50b52684ef961a6e6e03b4dc643f0ff15
Author: Joshua Leung
Date: Sat Jan 30 17:31:57 2016 +1300
Branches: PSketch
https://developer.blender.org/rB5dc799b50b52684ef961a6e6e03b4dc643f0ff15
PSculpt: Code Cleanup - Unify all the *data's, and stop passing it around everywhere
===================================================================
M source/blender/editors/armature/pose_sculpt.c
===================================================================
diff --git a/source/blender/editors/armature/pose_sculpt.c b/source/blender/editors/armature/pose_sculpt.c
index 235145b..cbf7896 100644
--- a/source/blender/editors/armature/pose_sculpt.c
+++ b/source/blender/editors/armature/pose_sculpt.c
@@ -229,7 +229,7 @@ typedef struct tPoseSculptingOp {
} tPoseSculptingOp;
/* Callback Function Signature */
-typedef void (*PSculptBrushCallback)(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float sco1[2], float sco2[2]);
+typedef void (*PSculptBrushCallback)(tPoseSculptingOp *pso, bPoseChannel *pchan, float sco1[2], float sco2[2]);
/* Init ------------------------------------------------ */
@@ -254,9 +254,9 @@ static void psculpt_init_view3d_data(bContext *C, tPSculptContext *data)
/* Brush Utilities ---------------------------------------- */
-static float psculpt_brush_calc_influence(tPoseSculptingOp *pso, tPSculptContext *data, bool use_falloff)
+static float psculpt_brush_calc_influence(tPoseSculptingOp *pso, bool use_falloff)
{
- //tPSculptContext *data = &pso->data;
+ tPSculptContext *data = &pso->data;
PSculptBrushData *brush = data->brush;
float fac = brush->strength;
@@ -683,7 +683,7 @@ static void apply_pchan_joints(bPoseChannel *pchan, float dvec[3])
/* ........................................................ */
/* check if a bone has already been affected by the brush, and add an entry if not */
-static tAffectedBone *verify_bone_is_affected(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, bool add)
+static tAffectedBone *verify_bone_is_affected(tPoseSculptingOp *pso, bPoseChannel *pchan, bool add)
{
/* try to find bone */
tAffectedBone *tab = BLI_ghash_lookup(pso->affected_bones, pchan);
@@ -710,8 +710,10 @@ static void free_affected_bone(void *tab_p)
/* Brushes ------------------------------------------------ */
/* change selection status of bones - used to define masks */
-static void psculpt_brush_select_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
+static void psculpt_brush_select_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
{
+ tPSculptContext *data = &pso->data;
+
if (pchan->bone) {
if (data->invert)
pchan->bone->flag &= ~BONE_SELECTED;
@@ -723,7 +725,7 @@ static void psculpt_brush_select_apply(tPoseSculptingOp *pso, tPSculptContext *d
/* .......................... */
/* "Smooth" brush */
-static void psculpt_brush_smooth_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float sco1[2], float sco2[2])
+static void psculpt_brush_smooth_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float sco1[2], float sco2[2])
{
}
@@ -731,19 +733,20 @@ static void psculpt_brush_smooth_apply(tPoseSculptingOp *pso, tPSculptContext *d
/* .......................... */
/* "Grab" brush - Translate bone */
-static void psculpt_brush_grab_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
+static void psculpt_brush_grab_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
{
+ tPSculptContext *data = &pso->data;
PSculptBrushData *brush = data->brush;
float imat[4][4], mat[4][4];
float cvec[3];
float fac;
/* strength of push */
- fac = psculpt_brush_calc_influence(pso, data, true);
+ fac = psculpt_brush_calc_influence(pso, true);
if (data->invert) fac = -fac;
if (brush->flag & PSCULPT_BRUSH_FLAG_GRAB_INITIAL) {
- tAffectedBone *tab = verify_bone_is_affected(pso, data, pchan, data->is_first);
+ tAffectedBone *tab = verify_bone_is_affected(pso, pchan, data->is_first);
/* if one couldn't be found or added, then it didn't exist the first time round,
* so we shouldn't proceed (to avoid clobbering additional bones)
@@ -788,8 +791,9 @@ static void psculpt_brush_grab_apply(tPoseSculptingOp *pso, tPSculptContext *dat
/* .......................... */
/* "Adjust" Brush - Compute transform to apply to all bones inside the brush */
-static void psculpt_brush_calc_trackball(tPoseSculptingOp *pso, tPSculptContext *data)
+static void psculpt_brush_calc_trackball(tPoseSculptingOp *pso)
{
+ tPSculptContext *data = &pso->data;
PSculptBrushData *brush = data->brush;
RegionView3D *rv3d = data->rv3d;
@@ -826,16 +830,18 @@ static void psculpt_brush_calc_trackball(tPoseSculptingOp *pso, tPSculptContext
/* "Adjust" Brush - i.e. a simple trackball transform */
// TODO: on root bones, don't do trackball... do grab instead?
-static void psculpt_brush_adjust_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
+static void psculpt_brush_adjust_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
{
+ tPSculptContext *data = &pso->data;
pchan_do_rotate(data->ob, pchan, data->rmat);
}
/* .......................... */
/* "Curl" brush - Rotate bone around its non-primary axes */
-static void psculpt_brush_curl_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
+static void psculpt_brush_curl_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
{
+ tPSculptContext *data = &pso->data;
PSculptBrushData *brush = data->brush;
short locks = pchan->protectflag;
float eul[3] = {0.0f};
@@ -850,8 +856,8 @@ static void psculpt_brush_curl_apply(tPoseSculptingOp *pso, tPSculptContext *dat
* however is much too strong for controllability. So, leaving it as-is.
* - Rotations are internally represented using radians, which are very sensitive
*/
- angle = psculpt_brush_calc_influence(pso, data, true); //printf("%f ", angle);
- angle = DEG2RAD(angle); //printf("%f \n", angle);
+ angle = psculpt_brush_calc_influence(pso, true); //printf("%f ", angle);
+ angle = DEG2RAD(angle); //printf("%f \n", angle);
if (data->invert) angle = -angle;
@@ -877,8 +883,9 @@ static void psculpt_brush_curl_apply(tPoseSculptingOp *pso, tPSculptContext *dat
/* .......................... */
/* "Twist" brush - Rotate bone around its primary axis */
-static void psculpt_brush_twist_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
+static void psculpt_brush_twist_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
{
+ tPSculptContext *data = &pso->data;
short locks = pchan->protectflag;
float eul[3] = {0.0f};
float angle = 0.0f;
@@ -892,8 +899,8 @@ static void psculpt_brush_twist_apply(tPoseSculptingOp *pso, tPSculptContext *da
* however is much too strong for controllability. So, leaving it as-is.
* - Rotations are internally represented using radians, which are very sensitive
*/
- angle = psculpt_brush_calc_influence(pso, data, true); //printf("%f ", angle);
- angle = DEG2RAD(angle); //printf("%f \n", angle);
+ angle = psculpt_brush_calc_influence(pso, true); //printf("%f ", angle);
+ angle = DEG2RAD(angle); //printf("%f \n", angle);
if (data->invert) angle = -angle;
@@ -909,14 +916,15 @@ static void psculpt_brush_twist_apply(tPoseSculptingOp *pso, tPSculptContext *da
/* .......................... */
/* "Stretch" brush - Scale bone along its primary axis */
-static void psculpt_brush_stretch_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
+static void psculpt_brush_stretch_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
{
+ tPSculptContext *data = &pso->data;
PSculptBrushData *brush = data->brush;
const float DAMP_FAC = 0.1f; /* damping factor - to be configurable? */
float fac;
/* scale factor must be greater than 1 for add, and less for subtract */
- fac = psculpt_brush_calc_influence(pso, data, true) * DAMP_FAC;
+ fac = psculpt_brush_calc_influence(pso, true) * DAMP_FAC;
if (data->invert)
fac = 1.0f - fac;
@@ -952,9 +960,9 @@ static void psculpt_brush_stretch_apply(tPoseSculptingOp *pso, tPSculptContext *
* making it possible to "relax" the pose somewhat (if they are similar)
*/
// TODO: Use mouse pressure here to modulate factor too?
-static void psculpt_brush_reset_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
+static void psculpt_brush_reset_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
{
- const float fac = psculpt_brush_calc_influence(pso, data, true);
+ const float fac = psculpt_brush_calc_influence(pso, true);
const short locks = pchan->protectflag;
float eul[3] = {0.0f};
@@ -991,13 +999,13 @@ static void psculpt_brush_reset_apply(tPoseSculptingOp *pso, tPSculptContext *da
/* .......................... */
/* "radial" brush */
-static void psculpt_brush_radial_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
+static void psculpt_brush_radial_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
{
}
/* "wrap" brush */
-static void psculpt_brush_wrap_apply(tPoseSculptingOp *pso, tPSculptContext *data, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
+static void psculpt_brush_wrap_apply(tPoseSculptingOp *pso, bPoseChannel *pchan, float UNUSED(sco1[2]), float UNUSED(sco2[2]))
{
}
@@ -1036,7 +1044,7 @@ static int psculpt_brush_init(bContext *C, wmOperator *op)
brush = data->brush;
data->invert = (brush && (brush->flag & PSCULPT_BRUSH_FLAG_INV)) ||
(RNA_boolean_get(op->ptr, "invert"));
-
+
data->is_first = true;
/* init data needed for handling autokeying
@@ -1109,9 +1117,10 @@ static void psculpt_brush_do_autokey(bContext *C, tPoseSculptingOp *pso)
/* Apply brush callback on bones which f
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list