[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21719] branches/blender2.5/blender/source /blender: 2.5 - Constraints Editing + Keyframe Drawing Tweaks

Joshua Leung aligorith at gmail.com
Mon Jul 20 14:42:31 CEST 2009


Revision: 21719
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21719
Author:   aligorith
Date:     2009-07-20 14:42:31 +0200 (Mon, 20 Jul 2009)

Log Message:
-----------
2.5 - Constraints Editing + Keyframe Drawing Tweaks

Constraints:
* Adding constraints with targets should now work. 
-- (When no target is provided, the code to create a new target is not yet in place again yet)
* Constraints can be added in Object and PoseModes again using the Ctrl-Shift-C hotkey. 
* All constraints can now be cleared from the active Object or selected Bones using the Ctrl-Alt-C hotkey.
* Added warnings when adding constraints invalid for the current context, and removed the old add_constraint() function.
* Buttons window updates correctly after adding keyframes now

Keyframes Drawing:
* Removed un-necessary extra function-call for RB-Tree implementation, by inlining a special one-off case.
* Keyframe diamonds which are not within the viewable area are now not drawn (but filtering will still need to find them).

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenlib/intern/DLRB_tree.c
    branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c
    branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
    branches/blender2.5/blender/source/blender/editors/object/editconstraint.c
    branches/blender2.5/blender/source/blender/editors/object/object_intern.h
    branches/blender2.5/blender/source/blender/editors/object/object_ops.c
    branches/blender2.5/blender/source/blender/editors/space_buttons/space_buttons.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c

Modified: branches/blender2.5/blender/source/blender/blenlib/intern/DLRB_tree.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/DLRB_tree.c	2009-07-20 12:05:18 UTC (rev 21718)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/DLRB_tree.c	2009-07-20 12:42:31 UTC (rev 21719)
@@ -161,7 +161,6 @@
 /* *********************************************** */
 /* Tree Rotation Utilities */
 
-/* Left Rotation is only done for Right-Right Case, and Left-Right Case */
 static void rotate_left (DLRBT_Tree *tree, DLRBT_Node *root)
 {
 	DLRBT_Node **root_slot, *pivot;
@@ -235,7 +234,6 @@
 static void insert_check_1(DLRBT_Tree *tree, DLRBT_Node *node);
 static void insert_check_2(DLRBT_Tree *tree, DLRBT_Node *node);
 static void insert_check_3(DLRBT_Tree *tree, DLRBT_Node *node);
-static void insert_check_4(DLRBT_Tree *tree, DLRBT_Node *node);
 
 /* ----- */
 
@@ -286,7 +284,7 @@
 	}
 }
 
-/* W. 4) Perform rotation on sub-tree containing the 'new' node */
+/* W. 4+5) Perform rotation on sub-tree containing the 'new' node, then do any  */
 static void insert_check_3 (DLRBT_Tree *tree, DLRBT_Node *node)
 {
 	DLRBT_Node *gp= get_grandparent(node);
@@ -305,34 +303,30 @@
 			rotate_right(tree, node); 
 			node= node->right;
 		}
-		// TODO: what about other cases?
 		
-		/* fix old parent's color-tagging */
-		insert_check_4(tree, node);
+		/* fix old parent's color-tagging, and perform rotation on the old parent in the 
+		 * opposite direction if needed for the current situation
+		 * NOTE: in the code above, node pointer is changed to point to the old parent 
+		 */
+		if (node) {
+			/* get 'new' grandparent (i.e. grandparent for old-parent (node)) */
+			gp= get_grandparent(node);
+			
+			/* modify the coloring of the grandparent and parent so that they still satisfy the constraints */
+			node->parent->tree_col= DLRBT_BLACK;
+			gp->tree_col= DLRBT_RED;
+			
+			/* if there are several nodes that all form a left chain, do a right rotation to correct this
+			 * (or a rotation in the opposite direction if they all form a right chain)
+			 */
+			if ((node == node->parent->left) && (node->parent == gp->left))
+				rotate_right(tree, gp);
+			else //if ((node == node->parent->right) && (node->parent == gp->right))
+				rotate_left(tree, gp);
+		}
 	}
 }
 
-/* W. 5) Perform rotation in the opposite direction on the parent of the given node */
-static void insert_check_4 (DLRBT_Tree *tree, DLRBT_Node *node)
-{
-	DLRBT_Node *gp= get_grandparent(node);
-	
-	if (node == NULL)
-		return;
-	
-	/* modify the coloring of the grandparent and parent so that they still satisfy the constraints */
-	node->parent->tree_col= DLRBT_BLACK;
-	gp->tree_col= DLRBT_RED;
-	
-	/* if there are several nodes that all form a left chain, do a right rotation to correct this
-	 * (or a rotation in the opposite direction if they all form a right chain)
-	 */
-	if ((node == node->parent->left) && (node->parent == gp->left))
-		rotate_right(tree, gp);
-	else /* ((node == node->parent->right) && (node->parent == gp->right)) */
-		rotate_left(tree, gp);
-}
-
 /* ----- */
 
 /* Balance the tree after the given element has been added to it 

Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c	2009-07-20 12:05:18 UTC (rev 21718)
+++ branches/blender2.5/blender/source/blender/editors/animation/keyframes_draw.c	2009-07-20 12:42:31 UTC (rev 21719)
@@ -445,28 +445,16 @@
 	/* draw keys */
 	if (keys) {
 		for (ak= keys->first; ak; ak= ak->next) {
+			/* optimisation: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw 
+			 *	- this might give some improvements, since we current have to flip between view/region matrices
+			 */
+			if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax) == 0)
+				continue;
+			
 			/* draw using OpenGL - uglier but faster */
-			// NOTE: a previous version of this didn't work nice for some intel cards
+			// NOTE1: a previous version of this didn't work nice for some intel cards
+			// NOTE2: if we wanted to go back to icons, these are  icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3;
 			draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), KEYFRAME_SHAPE_BOTH);
-			
-#if 0 // OLD CODE
-			//int sc_x, sc_y;
-			
-			/* get co-ordinate to draw at */
-			//gla2DDrawTranslatePt(di, ak->cfra, ypos, &sc_x, &sc_y);
-			
-			/* draw using icons - old way which is slower but more proven */
-			//if (ak->sel & SELECT) UI_icon_draw_aspect((float)sc_x-7, (float)sc_y-6, ICON_SPACE2, 1.0f);
-			//else UI_icon_draw_aspect((float)sc_x-7, (float)sc_y-6, ICON_SPACE3, 1.0f);
-#endif // OLD CODE
-#if 0 // NEW NON-WORKING CODE 
-			/* draw icon */
-			// FIXME: this draws slightly wrong, as we need to apply some offset for icon, but that depends on scaling
-			// so for now disabled
-			//int icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3;
-			//UI_icon_draw_aspect(ak->cfra, ypos-6, icon, 1.0f);
-#endif // NEW NON-WORKING CODE
-			
 		}	
 	}
 	

Modified: branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c	2009-07-20 12:05:18 UTC (rev 21718)
+++ branches/blender2.5/blender/source/blender/editors/armature/armature_ops.c	2009-07-20 12:42:31 UTC (rev 21719)
@@ -251,6 +251,11 @@
 
 	WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0);
 	
+	WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+	WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+	//WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
+	//WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+	
 	// XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
 	WM_keymap_verify_item(keymap, "ANIM_OT_insert_keyframe_menu", IKEY, KM_PRESS, 0, 0);
 	WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe_old", IKEY, KM_PRESS, KM_ALT, 0);

Modified: branches/blender2.5/blender/source/blender/editors/object/editconstraint.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/object/editconstraint.c	2009-07-20 12:05:18 UTC (rev 21718)
+++ branches/blender2.5/blender/source/blender/editors/object/editconstraint.c	2009-07-20 12:42:31 UTC (rev 21719)
@@ -77,9 +77,6 @@
 #include "object_intern.h"
 
 /* XXX */
-static void BIF_undo_push() {}
-static void error() {}
-static int okee() {return 0;}
 static int pupmenu() {return 0;}
 
 /* -------------- Get Active Constraint Data ---------------------- */
@@ -273,255 +270,6 @@
 	}
 }
 
-/* context: active object in posemode, active channel, optional selected channel */
-void add_constraint (Scene *scene, View3D *v3d, short only_IK)
-{
-	Object *ob= OBACT, *obsel=NULL;
-	bPoseChannel *pchanact=NULL, *pchansel=NULL;
-	bConstraint *con=NULL;
-	Base *base;
-	short nr;
-	
-	/* paranoia checks */
-	if ((ob==NULL) || (ob==scene->obedit)) 
-		return;
-
-	if ((ob->pose) && (ob->flag & OB_POSEMODE)) {
-		bArmature *arm= ob->data;
-		
-		/* find active channel */
-		pchanact= get_active_posechannel(ob);
-		if (pchanact==NULL) 
-			return;
-		
-		/* find selected bone */
-		for (pchansel=ob->pose->chanbase.first; pchansel; pchansel=pchansel->next) {
-			if (pchansel != pchanact) {
-				if (pchansel->bone->flag & BONE_SELECTED)  {
-					if (pchansel->bone->layer & arm->layer)
-						break;
-				}
-			}
-		}
-	}
-	
-	/* find selected object */
-	for (base= FIRSTBASE; base; base= base->next) {
-		if ((TESTBASE(v3d, base)) && (base->object!=ob)) 
-			obsel= base->object;
-	}
-	
-	/* the only_IK caller has checked for posemode! */
-	if (only_IK) {
-		for (con= pchanact->constraints.first; con; con= con->next) {
-			if (con->type==CONSTRAINT_TYPE_KINEMATIC) break;
-		}
-		if (con) {
-			error("Pose Channel already has IK");
-			return;
-		}
-		
-		if (pchansel)
-			nr= pupmenu("Add IK Constraint%t|To Active Bone%x10");
-		else if (obsel)
-			nr= pupmenu("Add IK Constraint%t|To Active Object%x10");
-		else 
-			nr= pupmenu("Add IK Constraint%t|To New Empty Object%x10|Without Target%x11");
-	}
-	else {
-		if (pchanact) {
-			if (pchansel)
-				nr= pupmenu("Add Constraint to Active Bone%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Stretch To%x7|%l|Action%x16|Script%x18");
-			else if ((obsel) && (obsel->type==OB_CURVE))
-				nr= pupmenu("Add Constraint to Active Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Follow Path%x6|Clamp To%x17|Stretch To%x7|%l|Action%x16|Script%x18");
-			else if ((obsel) && (obsel->type==OB_MESH))
-				nr= pupmenu("Add Constraint to Active Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Shrinkwrap%x22|Stretch To%x7|%l|Action%x16|Script%x18");
-			else if (obsel)
-				nr= pupmenu("Add Constraint to Active Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Stretch To%x7|%l|Action%x16|Script%x18");
-			else
-				nr= pupmenu("Add Constraint to New Empty Object%t|Child Of%x19|Transformation%x20|%l|Copy Location%x1|Copy Rotation%x2|Copy Scale%x8|%l|Limit Location%x13|Limit Rotation%x14|Limit Scale%x15|Limit Distance%x21|%l|Track To%x3|Floor%x4|Locked Track%x5|Stretch To%x7|%l|Action%x16|Script%x18");
-		}
-		else {
-			if ((obsel) && (obsel->type==OB_CURVE))

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list