[Bf-blender-cvs] [de3fecf6a98] PSketch-279: Push Brush: Second attempt to get the brush more responsive
Joshua Leung
noreply at git.blender.org
Tue May 8 18:03:16 CEST 2018
Commit: de3fecf6a983bd8c277b38e5080455ec7caaace7
Author: Joshua Leung
Date: Sun Dec 31 17:33:48 2017 +1300
Branches: PSketch-279
https://developer.blender.org/rBde3fecf6a983bd8c277b38e5080455ec7caaace7
Push Brush: Second attempt to get the brush more responsive
* Make the "Initial Grab" option work (instead of having variable strength
that will drop off).
* Don't perform this operation on non bendy bones
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/editors/armature/pose_sculpt.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 1feb40a5346..1178267452e 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -923,7 +923,7 @@ class VIEW3D_PT_tools_posemode_sculpt(View3DPanel, Panel):
elif tool not in ('NONE', 'GRAB', 'SMOOTH'):
layout.row().prop(brush, "direction", expand=True)
- if tool in ('GRAB', 'DRAW', 'ADJUST'):
+ if tool in ('GRAB', 'PUSH', 'DRAW', 'ADJUST'):
layout.prop(brush, "use_initial_only")
if tool in ('CURL', 'STRETCH'):
layout.row().prop(brush, "xz_mode", expand=True)
diff --git a/source/blender/editors/armature/pose_sculpt.c b/source/blender/editors/armature/pose_sculpt.c
index 6f988f86a8b..cffda94fe19 100644
--- a/source/blender/editors/armature/pose_sculpt.c
+++ b/source/blender/editors/armature/pose_sculpt.c
@@ -1517,8 +1517,16 @@ static void psculpt_brush_push_apply(tPoseSculptingOp *pso, bPoseChannel *pchan,
float d1, d2, dm;
float mid[2];
+
+ bool do_head = false, do_tail = false;
float fac;
+ /* skip if bone is not a bendy bone */
+ if ((pchan->bone == NULL) || (pchan->bone->segments <= 1)) {
+ //printf("Skipping non bendy bone '%s'\n", pchan->name);
+ return;
+ }
+
/* when invert is true, we don't restrict ourselves to the initial set only (i.e. "push") */
if ((brush->flag & PSCULPT_BRUSH_FLAG_GRAB_INITIAL) && (pso->invert == false)) {
tab = verify_bone_is_affected(pso, pchan, pso->is_first);
@@ -1530,15 +1538,7 @@ static void psculpt_brush_push_apply(tPoseSculptingOp *pso, bPoseChannel *pchan,
return;
}
#if 0 // XXX: Save values below!
- else if (pso->is_first) {
- /* store factor for later */
- tab->fac = fac;
- }
- else {
- /* use stored falloff */
- // XXX: it was better for chains if we didn't use the stored falloff...
- fac = tab->fac;
- }
+
#endif
}
@@ -1557,36 +1557,51 @@ static void psculpt_brush_push_apply(tPoseSculptingOp *pso, bPoseChannel *pchan,
mid_v2_v2v2(mid, sco1, sco2);
dm = len_v2v2(pso->mval, mid);
- /* apply the components directly (since it should be in bone space):
- * - vec.x = bone.x
- * - vec.z = bone.y
- *
- * - vec.y = ease in/out (proportional to bone length?)
- */
if (d1 < d2) {
/* Head (In) */
fac = psculpt_brush_calc_influence(pso, d1);
- mul_v3_v3fl(vec, delta, fac);
-
- pchan->curveInX += vec[0];
- pchan->curveInY += vec[2];
+ do_head = true;
}
else if (d2 < d1) {
/* Tail (Out) */
fac = psculpt_brush_calc_influence(pso, d2);
- mul_v3_v3fl(vec, delta, fac);
-
- pchan->curveOutX += vec[0];
- pchan->curveOutY += vec[2];
+ do_tail = true;
}
else {
/* Affect both by the same amount */
- fac = psculpt_brush_calc_influence(pso, dist);
- mul_v3_v3fl(vec, delta, fac);
-
+ fac = psculpt_brush_calc_influence(pso, dist);
+ do_head = do_tail = true;
+ }
+
+ /* compute effect to apply */
+ if (tab) {
+ /* If "grab initial" is in use, use the stored fac instead of
+ * recalculating each time. This means that the force doesn't
+ * drop off as we try to make it do more.
+ */
+ if (pso->is_first) {
+ /* store factor for later */
+ tab->fac = fac;
+ }
+ else {
+ /* use stored falloff */
+ fac = tab->fac;
+ }
+ }
+ mul_v3_v3fl(vec, delta, fac);
+
+
+ /* apply the components directly (since it should be in bone space):
+ * - vec.x = bone.x
+ * - vec.z = bone.y
+ *
+ * - vec.y = ease in/out (proportional to bone length?)
+ */
+ if (do_head) {
pchan->curveInX += vec[0];
- pchan->curveInY += vec[2];
-
+ pchan->curveInY += vec[2];
+ }
+ if (do_tail) {
pchan->curveOutX += vec[0];
pchan->curveOutY += vec[2];
}
More information about the Bf-blender-cvs
mailing list