[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27048] trunk/blender/source/blender: Bugfix #21245: "Track to" (Ctrl + T) operator was missing notifier updates

Joshua Leung aligorith at gmail.com
Sun Feb 21 12:05:53 CET 2010


Revision: 27048
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27048
Author:   aligorith
Date:     2010-02-21 12:05:52 +0100 (Sun, 21 Feb 2010)

Log Message:
-----------
Bugfix #21245: "Track to" (Ctrl + T) operator was missing notifier updates

Bugfix #21255: Clear track operator did not remove TrackTo constraints too. This could still be made to do Locked Track and other tracking constraints later too, but for now this will do.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_constraint.h
    trunk/blender/source/blender/blenkernel/intern/constraint.c
    trunk/blender/source/blender/editors/object/object_relations.c

Modified: trunk/blender/source/blender/blenkernel/BKE_constraint.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_constraint.h	2010-02-21 10:56:14 UTC (rev 27047)
+++ trunk/blender/source/blender/blenkernel/BKE_constraint.h	2010-02-21 11:05:52 UTC (rev 27048)
@@ -136,6 +136,7 @@
 
 int remove_constraint(ListBase *list, struct bConstraint *con);
 int remove_constraint_index(ListBase *list, int index);
+void remove_constraints_type(ListBase *list, short type, short last_only);
 
 /* Constraints + Proxies function prototypes */
 void extract_proxylocal_constraints(struct ListBase *dst, struct ListBase *src);

Modified: trunk/blender/source/blender/blenkernel/intern/constraint.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-02-21 10:56:14 UTC (rev 27047)
+++ trunk/blender/source/blender/blenkernel/intern/constraint.c	2010-02-21 11:05:52 UTC (rev 27048)
@@ -3903,6 +3903,26 @@
 		return 0;
 }
 
+/* Remove all the constraints of the specified type from the given constraint stack */
+void remove_constraints_type (ListBase *list, short type, short last_only)
+{
+	bConstraint *con, *conp;
+	
+	if (list == NULL)
+		return;
+	
+	/* remove from the end of the list to make it faster to find the last instance */
+	for (con= list->last; con; con= conp) {
+		conp= con->prev;
+		
+		if (con->type == type) {
+			remove_constraint(list, con);
+			if (last_only) 
+				return;
+		}
+	}
+}
+
 /* ......... */
 
 /* Creates a new constraint, initialises its data, and returns it */
@@ -4062,9 +4082,6 @@
 		/* make a new copy of the constraint's data */
 		con->data = MEM_dupallocN(con->data);
 		
-		// NOTE: depreceated... old animation system
-		id_us_plus((ID *)con->ipo);
-		
 		/* only do specific constraints if required */
 		if (cti) {
 			/* perform custom copying operations if needed */

Modified: trunk/blender/source/blender/editors/object/object_relations.c
===================================================================
--- trunk/blender/source/blender/editors/object/object_relations.c	2010-02-21 10:56:14 UTC (rev 27047)
+++ trunk/blender/source/blender/editors/object/object_relations.c	2010-02-21 11:05:52 UTC (rev 27048)
@@ -873,9 +873,17 @@
 		return OPERATOR_CANCELLED;
 	}
 	CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) {
+		/* remove track-object for old track */
 		ob->track= NULL;
 		ob->recalc |= OB_RECALC;
 		
+		/* also remove all Track To constraints 
+		 * TODO: 
+		 *	- do we only want to do the last instance (use 1 as last arg instead)
+		 *	- also, what about other forms of tracking?
+		 */
+		remove_constraints_type(&ob->constraints, CONSTRAINT_TYPE_TRACKTO, 0);
+		
 		if(type == 1)
 			ED_object_apply_obmat(ob);
 	}
@@ -883,6 +891,7 @@
 
 	DAG_ids_flush_update(0);
 	DAG_scene_sort(CTX_data_scene(C));
+	WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 
 	return OPERATOR_FINISHED;
 }
@@ -973,8 +982,10 @@
 		}
 		CTX_DATA_END;
 	}
+	
 	DAG_scene_sort(scene);
 	DAG_ids_flush_update(0);
+	WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL);
 	
 	return OPERATOR_FINISHED;
 }





More information about the Bf-blender-cvs mailing list