[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21590] branches/blender2.5/blender: 2.5: added panel with IK settings for bone.

Brecht Van Lommel brecht at blender.org
Wed Jul 15 00:11:25 CEST 2009


Revision: 21590
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21590
Author:   blendix
Date:     2009-07-15 00:11:25 +0200 (Wed, 15 Jul 2009)

Log Message:
-----------
2.5: added panel with IK settings for bone.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_data_bone.py
    branches/blender2.5/blender/release/ui/buttons_object_constraint.py
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c

Modified: branches/blender2.5/blender/release/ui/buttons_data_bone.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_data_bone.py	2009-07-14 22:10:47 UTC (rev 21589)
+++ branches/blender2.5/blender/release/ui/buttons_data_bone.py	2009-07-14 22:11:25 UTC (rev 21590)
@@ -106,9 +106,80 @@
 		sub.itemR(bone, "draw_wire", text="Wireframe")
 		sub.itemR(bone, "hidden", text="Hide")
 
+class BONE_PT_inverse_kinematics(BoneButtonsPanel):
+	__idname__ = "BONE_PT_inverse_kinematics"
+	__label__ = "Inverse Kinematics"
+	__default_closed__ = True
+	
+	def poll(self, context):
+		ob = context.object
+		bone = context.bone
+
+		if ob and context.bone:
+			pchan = ob.pose.pose_channels[context.bone.name]
+			return pchan.has_ik
+		
+		return False
+
+	def draw(self, context):
+		layout = self.layout
+		ob = context.object
+		bone = context.bone
+		pchan = ob.pose.pose_channels[context.bone.name]
+
+		split = layout.split(percentage=0.25)
+		split.itemR(pchan, "ik_dof_x", text="X")
+		row = split.row()
+		row.itemR(pchan, "ik_stiffness_x", text="Stiffness")
+		row.active = pchan.ik_dof_x
+
+		split = layout.split(percentage=0.25)
+		row = split.row()
+		row.itemR(pchan, "ik_limit_x", text="Limit")
+		row.active = pchan.ik_dof_x
+		row = split.row(align=True)
+		row.itemR(pchan, "ik_min_x", text="")
+		row.itemR(pchan, "ik_max_x", text="")
+		row.active = pchan.ik_dof_x and pchan.ik_limit_x
+
+		split = layout.split(percentage=0.25)
+		split.itemR(pchan, "ik_dof_y", text="Y")
+		row = split.row()
+		row.itemR(pchan, "ik_stiffness_y", text="Stiffness")
+		row.active = pchan.ik_dof_y
+
+		split = layout.split(percentage=0.25)
+		row = split.row()
+		row.itemR(pchan, "ik_limit_y", text="Limit")
+		row.active = pchan.ik_dof_y
+		row = split.row(align=True)
+		row.itemR(pchan, "ik_min_y", text="")
+		row.itemR(pchan, "ik_max_y", text="")
+		row.active = pchan.ik_dof_y and pchan.ik_limit_y
+
+		split = layout.split(percentage=0.25)
+		split.itemR(pchan, "ik_dof_z", text="Z")
+		row = split.row()
+		row.itemR(pchan, "ik_stiffness_z", text="Stiffness")
+		row.active = pchan.ik_dof_z
+
+		split = layout.split(percentage=0.25)
+		row = split.row()
+		row.itemR(pchan, "ik_limit_z", text="Limit")
+		row.active = pchan.ik_dof_z
+		row = split.row(align=True)
+		row.itemR(pchan, "ik_min_z", text="")
+		row.itemR(pchan, "ik_max_z", text="")
+		row.active = pchan.ik_dof_z and pchan.ik_limit_z
+
+		split = layout.split()
+		split.itemR(pchan, "ik_stretch", text="Stretch")
+		split.itemL()
+
 class BONE_PT_deform(BoneButtonsPanel):
 	__idname__ = "BONE_PT_deform"
 	__label__ = "Deform"
+	__default_closed__ = True
 
 	def draw_header(self, context):
 		layout = self.layout
@@ -154,4 +225,5 @@
 bpy.types.register(BONE_PT_transform)
 bpy.types.register(BONE_PT_bone)
 bpy.types.register(BONE_PT_deform)
+bpy.types.register(BONE_PT_inverse_kinematics)
 

Modified: branches/blender2.5/blender/release/ui/buttons_object_constraint.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_object_constraint.py	2009-07-14 22:10:47 UTC (rev 21589)
+++ branches/blender2.5/blender/release/ui/buttons_object_constraint.py	2009-07-14 22:11:25 UTC (rev 21590)
@@ -131,7 +131,8 @@
 		self.target_template(layout, con)
 		
 		layout.itemR(con, "pole_target")
-		layout.itemR(con, "pole_subtarget")
+		if con.pole_target and con.pole_target.type == "ARMATURE":
+			layout.item_pointerR(con, "pole_subtarget", con.pole_target.data, "bones", text="Bone")
 		
 		col = layout.column_flow()
 		col.itemR(con, "iterations")

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c	2009-07-14 22:10:47 UTC (rev 21589)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_pose.c	2009-07-14 22:11:25 UTC (rev 21590)
@@ -99,6 +99,14 @@
 	ED_armature_bone_rename(ob->data, oldname, newname);
 }
 
+static int rna_PoseChannel_has_ik_get(PointerRNA *ptr)
+{
+	Object *ob= (Object*)ptr->id.data;
+	bPoseChannel *pchan= (bPoseChannel*)ptr->data;
+
+	return ED_pose_channel_in_IK_chain(ob, pchan);
+}
+
 #else
 
 /* users shouldn't be editing pose channel data directly -- better to set ipos and let blender calc pose_channel stuff */
@@ -129,29 +137,41 @@
 	RNA_def_property_ui_text(prop, "Name", "");
 	RNA_def_struct_name_property(srna, prop);
 
+	prop= RNA_def_property(srna, "has_ik", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_funcs(prop,  "rna_PoseChannel_has_ik_get", NULL);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Has IK", "Is part of an IK chain.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
+
 	prop= RNA_def_property(srna, "ik_dof_x", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_NO_XDOF);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_XDOF);
 	RNA_def_property_ui_text(prop, "IK X DoF", "Allow movement around the X axis.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
 	prop= RNA_def_property(srna, "ik_dof_y", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_NO_YDOF);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_YDOF);
 	RNA_def_property_ui_text(prop, "IK Y DoF", "Allow movement around the Y axis.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
 	prop= RNA_def_property(srna, "ik_dof_z", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_NO_ZDOF);
+	RNA_def_property_boolean_negative_sdna(prop, NULL, "ikflag", BONE_IK_NO_ZDOF);
 	RNA_def_property_ui_text(prop, "IK Z DoF", "Allow movement around the Z axis.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
 	prop= RNA_def_property(srna, "ik_limit_x", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_XLIMIT);
 	RNA_def_property_ui_text(prop, "IK X Limit", "Limit movement around the X axis.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
 	prop= RNA_def_property(srna, "ik_limit_y", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_YLIMIT);
 	RNA_def_property_ui_text(prop, "IK Y Limit", "Limit movement around the Y axis.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
 	prop= RNA_def_property(srna, "ik_limit_z", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "ikflag", BONE_IK_ZLIMIT);
 	RNA_def_property_ui_text(prop, "IK Z Limit", "Limit movement around the Z axis.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 	
 	prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "selectflag", BONE_SELECTED);
@@ -166,11 +186,13 @@
 	RNA_def_property_int_sdna(prop, NULL, "pathsf");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Bone Paths Calculation Start Frame", "Starting frame of range of frames to use for Bone Path calculations.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
 	prop= RNA_def_property(srna, "path_end_frame", PROP_INT, PROP_NONE);
 	RNA_def_property_int_sdna(prop, NULL, "pathef");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Bone Paths Calculation End Frame", "End frame of range of frames to use for Bone Path calculations.");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
 	prop= RNA_def_property(srna, "bone", PROP_POINTER, PROP_NEVER_NULL);
 	RNA_def_property_struct_type(prop, "Bone");
@@ -239,28 +261,69 @@
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 	RNA_def_property_ui_text(prop, "Pose Tail Position", "Location of tail of the channel's bone.");
 
-	prop= RNA_def_property(srna, "ik_min_limits", PROP_FLOAT, PROP_VECTOR);
-	RNA_def_property_float_sdna(prop, NULL, "limitmin");
+	prop= RNA_def_property(srna, "ik_min_x", PROP_FLOAT, PROP_ROTATION);
+	RNA_def_property_float_sdna(prop, NULL, "limitmin[0]");
 	RNA_def_property_range(prop, -180.0f, 0.0f);
-	RNA_def_property_ui_text(prop, "IK Minimum Limits", "Minimum angles for IK Limit");
+	RNA_def_property_ui_text(prop, "IK X Minimum", "Minimum angles for IK Limit");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
-	prop= RNA_def_property(srna, "ik_max_limits", PROP_FLOAT, PROP_VECTOR);
-	RNA_def_property_float_sdna(prop, NULL, "limitmax");
+	prop= RNA_def_property(srna, "ik_max_x", PROP_FLOAT, PROP_ROTATION);
+	RNA_def_property_float_sdna(prop, NULL, "limitmax[0]");
 	RNA_def_property_range(prop, 0.0f, 180.0f);
-	RNA_def_property_ui_text(prop, "IK Maximum Limits", "Maximum angles for IK Limit");
+	RNA_def_property_ui_text(prop, "IK X Maximum", "Maximum angles for IK Limit");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
-	prop= RNA_def_property(srna, "ik_stiffness", PROP_FLOAT, PROP_VECTOR);
-	RNA_def_property_float_sdna(prop, NULL, "stiffness");
-	RNA_def_property_range(prop, 0.0f,0.99f);
-	RNA_def_property_ui_text(prop, "IK Stiffness", "Stiffness around the different axes.");
+	prop= RNA_def_property(srna, "ik_min_y", PROP_FLOAT, PROP_ROTATION);
+	RNA_def_property_float_sdna(prop, NULL, "limitmin[1]");
+	RNA_def_property_range(prop, -180.0f, 0.0f);
+	RNA_def_property_ui_text(prop, "IK Y Minimum", "Minimum angles for IK Limit");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
 
+	prop= RNA_def_property(srna, "ik_max_y", PROP_FLOAT, PROP_ROTATION);
+	RNA_def_property_float_sdna(prop, NULL, "limitmax[1]");
+	RNA_def_property_range(prop, 0.0f, 180.0f);
+	RNA_def_property_ui_text(prop, "IK Y Maximum", "Maximum angles for IK Limit");
+	RNA_def_property_update(prop, NC_OBJECT|ND_POSE|ND_TRANSFORM, "rna_Pose_update");
+
+	prop= RNA_def_property(srna, "ik_min_z", PROP_FLOAT, PROP_ROTATION);
+	RNA_def_property_float_sdna(prop, NULL, "limitmin[2]");
+	RNA_def_property_range(prop, -180.0f, 0.0f);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list