[Bf-blender-cvs] [335eeb48151] PSketch-279: PSculpt: Start of support for sculpting Bendy Bones too

Joshua Leung noreply at git.blender.org
Tue May 8 18:02:50 CEST 2018


Commit: 335eeb48151786e03660e245a085f9462c3e50f8
Author: Joshua Leung
Date:   Sun Dec 24 15:49:20 2017 +1300
Branches: PSketch-279
https://developer.blender.org/rB335eeb48151786e03660e245a085f9462c3e50f8

PSculpt: Start of support for sculpting Bendy Bones too

===================================================================

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/armature/pose_sculpt.c
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_sculpt_paint.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..394a91aa8be 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -924,6 +924,7 @@ class VIEW3D_PT_tools_posemode_sculpt(View3DPanel, Panel):
             layout.row().prop(brush, "direction", expand=True)
 
         if tool in ('GRAB', 'DRAW', 'ADJUST'):
+            layout.row().prop(brush, "transform_mode", expand=True)
             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 e154bc01f02..f2939192811 100644
--- a/source/blender/editors/armature/pose_sculpt.c
+++ b/source/blender/editors/armature/pose_sculpt.c
@@ -150,6 +150,12 @@ typedef struct tAffectedBone {
 	float oldquat[4];
 	float oldangle;
 	float oldaxis[3];
+	
+	float bbcurvein[2];         /* original bendy bone vals - x/y components are grouped together here */
+	float bbcurveout[2];
+	float bbroll[2];            /* original bendy bone vals - we group the head/tail or 1/2 versions together */
+	float bbease[2];
+	float bbscale[2];
 } tAffectedBone;
 
 /* ******************************************************** */
@@ -806,6 +812,17 @@ static tAffectedBone *verify_bone_is_affected(tPoseSculptingOp *pso, bPoseChanne
 		copy_v3_v3(tab->oldaxis, pchan->rotAxis);
 		tab->oldangle = pchan->rotAngle;
 		
+		tab->bbcurvein[0] = pchan->curveInX;
+		tab->bbcurvein[1] = pchan->curveInY;
+		tab->bbcurveout[0] = pchan->curveOutX;
+		tab->bbcurveout[1] = pchan->curveOutY;
+		tab->bbroll[0] = pchan->roll1;
+		tab->bbroll[1] = pchan->roll2;
+		tab->bbease[0] = pchan->ease1;
+		tab->bbease[1] = pchan->ease2;
+		tab->bbscale[0] = pchan->scaleIn;
+		tab->bbscale[1] = pchan->scaleOut;
+		
 		// TODO: custom props?
 	}
 	
@@ -947,21 +964,29 @@ static void psculpt_brush_grab_apply(tPoseSculptingOp *pso, bPoseChannel *pchan,
 	mul_m4_m4m4(mat, pso->ob->obmat, pchan->bone->arm_mat);
 	invert_m4_m4(imat, mat);
 	
-	/* apply deforms to bone locations only based on amount mouse moves */
+	/* apply deforms to based on amount mouse moves */
 	copy_v3_v3(cvec, pso->dvec);
 	mul_mat3_m4_v3(imat, cvec);
 	mul_v3_fl(cvec, fac);
 	
-	/* knock out invalid transforms */
-	if (pchan->protectflag & OB_LOCK_LOCX)
-		cvec[0] = 0.0f;
-	if (pchan->protectflag & OB_LOCK_LOCY)
-		cvec[1] = 0.0f;
-	if (pchan->protectflag & OB_LOCK_LOCZ)
-		cvec[2] = 0.0f;
+	/* apply to bone location? */
+	if ((brush->tfmMode & PSCULPT_BRUSH_NO_TFM) == 0) {
+		/* knock out invalid transforms */
+		if (pchan->protectflag & OB_LOCK_LOCX)
+			cvec[0] = 0.0f;
+		if (pchan->protectflag & OB_LOCK_LOCY)
+			cvec[1] = 0.0f;
+		if (pchan->protectflag & OB_LOCK_LOCZ)
+			cvec[2] = 0.0f;
+		
+		/* apply to bone */
+		add_v3_v3(pchan->loc, cvec);
+	}
 	
-	/* apply to bone */
-	add_v3_v3(pchan->loc, cvec);
+	/* apply to bendy bone points? */
+	if ((brush->tfmMode & PSCULPT_BRUSH_NO_BBONE) == 0) {
+		// TODO: How to figure out which point to affect?
+	}
 }
 
 /* Adjust ---------------------------------------------- */
@@ -1461,6 +1486,18 @@ static void psculpt_brush_restore_apply(tPoseSculptingOp *pso, bPoseChannel *pch
 		pchan->size[1] = interpf(tab->oldscale[1], pchan->size[1], fac);
 	if ((locks & OB_LOCK_SCALEZ) == 0)
 		pchan->size[2] = interpf(tab->oldscale[2], pchan->size[2], fac);
+	
+	/* bendy bones */
+	pchan->curveInX = tab->bbcurvein[0];
+	pchan->curveInY = tab->bbcurvein[1];
+	pchan->curveOutX = tab->bbcurveout[0];
+	pchan->curveOutY = tab->bbcurveout[1];
+	pchan->roll1 = tab->bbroll[0];
+	pchan->roll2 = tab->bbroll[1];
+	pchan->ease1 = tab->bbease[0];
+	pchan->ease2 = tab->bbease[1];
+	pchan->scaleIn = tab->bbscale[0];
+	pchan->scaleOut = tab->bbscale[1];
 }
 
 
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index e86bd136f72..df8cc4c6612 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1132,8 +1132,8 @@ typedef struct PSculptBrushData {
 	short flag;		/* ePSculptBrush_Flag */
 	
 	/* Brush Specific Settings */
-	short xzMode;	/* ePSculptBrush_XZMode */
-	short pad;
+	short xzMode;	  /* ePSculptBrush_XZMode */
+	short tfmMode;    /* ePSculptBrush_TransformMode */
 	
 	/* Volume Preserve Settings */
 	float bulge;
@@ -2368,6 +2368,15 @@ typedef enum ePSculptBrush_XZMode {
 	PSCULPT_BRUSH_DO_Z  = 2
 } ePSculptBrush_XZMode;
 
+/* PSculptBrushData.tfmMode - which set of transforms (normal/bbone) do we affect */
+typedef enum ePSculptBrush_TransformMode {
+	PSCULPT_BRUSH_NO_BBONE = (1 << 0),
+	PSCULPT_BRUSH_NO_TFM   = (1 << 1),
+	
+	PSCULPT_BRUSH_TFM_BOTH = 0,
+} ePSculptBrush_TransformMode;
+
+
 /* toolsettings->skgen_options */
 #define SKGEN_FILTER_INTERNAL	(1 << 0)
 #define SKGEN_FILTER_EXTERNAL	(1 << 1)
diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c
index 87ea094d83d..971b08b433f 100644
--- a/source/blender/makesrna/intern/rna_sculpt_paint.c
+++ b/source/blender/makesrna/intern/rna_sculpt_paint.c
@@ -1173,6 +1173,12 @@ static void rna_def_pose_sculpt(BlenderRNA *brna)
 		{PSCULPT_BRUSH_DO_X, "X", 0, "X", "Affect X axis only"},
 		{PSCULPT_BRUSH_DO_Z, "Z", 0, "Z", "Affect Z axis only"},
 		{0, NULL, 0, NULL, NULL}};
+		
+	static EnumPropertyItem prop_tfm_mode_items[]= {
+		{0, "BOTH", 0, "Both", "Affect both normal transforms and Bendy Bones"},
+		{PSCULPT_BRUSH_NO_BBONE, "TRANSFORMS", 0, "Transform", "Affect normal transforms only"},
+		{PSCULPT_BRUSH_NO_TFM,   "BBONES", 0, "BBones", "Affect Bendy Bone properties only"},
+		{0, NULL, 0, NULL, NULL}};
 	
 	StructRNA *srna;
 	PropertyRNA *prop;
@@ -1249,6 +1255,13 @@ static void rna_def_pose_sculpt(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "XZ Axis Behaviour", "Which axes (X and Z) get affected by brush");
 	RNA_def_property_update(prop, 0, "rna_PSculptBrush_update");
 	
+	/* which transforms should get affected */
+	prop = RNA_def_property(srna, "transform_mode", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "tfmMode");
+	RNA_def_property_enum_items(prop, prop_tfm_mode_items);
+	RNA_def_property_ui_text(prop, "Transform Mode", "Which transforms (normal, Bendy Bones) get affected");
+	RNA_def_property_update(prop, 0, "rna_PSculptBrush_update");
+	
 	/* only include initial bones */
 	prop = RNA_def_property(srna, "use_initial_only", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", PSCULPT_BRUSH_FLAG_GRAB_INITIAL);



More information about the Bf-blender-cvs mailing list