[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28873] trunk/blender/source/blender/ editors: Bugfix #22204: curve modifier onto lamp energy with more than one user of lamp settings creates two modifiers

Joshua Leung aligorith at gmail.com
Thu May 20 07:18:29 CEST 2010


Revision: 28873
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28873
Author:   aligorith
Date:     2010-05-20 07:18:27 +0200 (Thu, 20 May 2010)

Log Message:
-----------
Bugfix #22204: curve modifier onto lamp energy with more than one user of lamp settings creates two modifiers

This was caused by the multi-user data appearing multiple times in the channel list. Now most editing functions filter out duplicates before doing anything to prevent these problems. 

Hopefully the additional cost of filtering the entire list an extra time won't be too much of a speed/mem hit...

Modified Paths:
--------------
    trunk/blender/source/blender/editors/animation/anim_channels_edit.c
    trunk/blender/source/blender/editors/animation/anim_filter.c
    trunk/blender/source/blender/editors/include/ED_anim_api.h
    trunk/blender/source/blender/editors/space_action/action_edit.c
    trunk/blender/source/blender/editors/space_action/action_select.c
    trunk/blender/source/blender/editors/space_graph/graph_edit.c
    trunk/blender/source/blender/editors/space_graph/graph_select.c
    trunk/blender/source/blender/editors/space_graph/space_graph.c

Modified: trunk/blender/source/blender/editors/animation/anim_channels_edit.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_channels_edit.c	2010-05-20 04:44:10 UTC (rev 28872)
+++ trunk/blender/source/blender/editors/animation/anim_channels_edit.c	2010-05-20 05:18:27 UTC (rev 28873)
@@ -939,7 +939,7 @@
 	/* do groups only first (unless in Drivers mode, where there are none) */
 	if (ac.datatype != ANIMCONT_DRIVERS) {
 		/* filter data */
-		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CHANNELS | ANIMFILTER_FOREDIT);
+		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
 		ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
 		
 		/* delete selected groups and their associated channels */
@@ -978,7 +978,7 @@
 	/* now do F-Curves */
 	if (ac.datatype != ANIMCONT_GPENCIL) {
 		/* filter data */
-		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT);
+		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
 		ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
 		
 		/* delete selected F-Curves */
@@ -1038,7 +1038,7 @@
 	ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype);
 	
 	/* hide all channels not selected */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_UNSEL);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
 	
 	for (ale= anim_data.first; ale; ale= ale->next) {
@@ -1054,7 +1054,7 @@
 	BLI_freelistN(&anim_data);
 	
 	/* make all the selected channels visible */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
 	
 	for (ale= anim_data.first; ale; ale= ale->next) {
@@ -1113,11 +1113,11 @@
 		return OPERATOR_CANCELLED;
 		
 	/* get list of all channels that selection may need to be flushed to */
-	filter= ANIMFILTER_CHANNELS;
+	filter= (ANIMFILTER_CHANNELS | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype);
 		
 	/* filter data */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
 	
 	/* See if we should be making showing all selected or hiding */
@@ -1215,7 +1215,8 @@
 	}
 	
 	/* filter data that we're working on */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS);
+	// XXX: noduplis enabled so that results don't cancel, but will be problematic for some channels where only type differs
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CHANNELS | ANIMFILTER_NODUPLIS);
 	if (onlysel) filter |= ANIMFILTER_SEL;
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 	

Modified: trunk/blender/source/blender/editors/animation/anim_filter.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_filter.c	2010-05-20 04:44:10 UTC (rev 28872)
+++ trunk/blender/source/blender/editors/animation/anim_filter.c	2010-05-20 05:18:27 UTC (rev 28873)
@@ -68,6 +68,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "BLI_blenlib.h"
+#include "BLI_ghash.h"
 
 #include "BKE_animsys.h"
 #include "BKE_action.h"
@@ -2512,6 +2513,65 @@
 	return 1;
 }  
 
+/* ----------- Cleanup API --------------- */
+
+/* Remove entries with invalid types in animation channel list */
+static int animdata_filter_remove_invalid (ListBase *anim_data)
+{
+	bAnimListElem *ale, *next;
+	int items = 0;
+	
+	/* only keep entries with valid types */
+	for (ale= anim_data->first; ale; ale= next) {
+		next= ale->next;
+		
+		if (ale->type == ANIMTYPE_NONE)
+			BLI_freelinkN(anim_data, ale);
+		else
+			items++;
+	}
+	
+	return items;
+}
+
+/* Remove duplicate entries in animation channel list */
+static int animdata_filter_remove_duplis (ListBase *anim_data)
+{
+	bAnimListElem *ale, *next;
+	GHash *gh;
+	int items = 0;
+	
+	/* build new hashtable to efficiently store and retrieve which entries have been 
+	 * encountered already while searching
+	 */
+	gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "animdata_filter_duplis_remove gh");
+	
+	/* loop through items, removing them from the list if a similar item occurs already */
+	for (ale = anim_data->first; ale; ale = next) {
+		next = ale->next;
+		
+		/* check if hash has any record of an entry like this 
+		 *	- just use ale->data for now, though it would be nicer to involve 
+		 *	  ale->type in combination too to capture corner cases (where same data performs differently)
+		 */
+		if (BLI_ghash_haskey(gh, ale->data) == 0) {
+			/* this entry is 'unique' and can be kept */
+			BLI_ghash_insert(gh, ale->data, NULL);
+			items++;
+		}
+		else {
+			/* this entry isn't needed anymore */
+			BLI_freelinkN(anim_data, ale);
+		}
+	}
+	
+	/* free the hash... */
+	BLI_ghash_free(gh, NULL, NULL);
+	
+	/* return the number of items still in the list */
+	return items;
+}
+
 /* ----------- Public API --------------- */
 
 /* This function filters the active data source to leave only animation channels suitable for
@@ -2527,7 +2587,6 @@
 	
 	/* only filter data if there's somewhere to put it */
 	if (data && anim_data) {
-		bAnimListElem *ale, *next;
 		Object *obact= (ac) ? ac->obact : NULL;
 		
 		/* firstly filter the data */
@@ -2572,16 +2631,12 @@
 				break;
 		}
 			
-		/* remove any weedy entries */
-		// XXX this is weedy code!
-		for (ale= anim_data->first; ale; ale= next) {
-			next= ale->next;
-			
-			if (ale->type == ANIMTYPE_NONE) {
-				items--;
-				BLI_freelinkN(anim_data, ale);
-			}
-		}
+		/* remove any 'weedy' entries */
+		items = animdata_filter_remove_invalid(anim_data);
+		
+		/* remove duplicates (if required) */
+		if (filter_mode & ANIMFILTER_NODUPLIS)
+			items = animdata_filter_remove_duplis(anim_data);
 	}
 	
 	/* return the number of items in the list */

Modified: trunk/blender/source/blender/editors/include/ED_anim_api.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_anim_api.h	2010-05-20 04:44:10 UTC (rev 28872)
+++ trunk/blender/source/blender/editors/include/ED_anim_api.h	2010-05-20 05:18:27 UTC (rev 28873)
@@ -192,6 +192,7 @@
 	ANIMFILTER_ANIMDATA		= (1<<9),	/* only return the underlying AnimData blocks (not the tracks, etc.) data comes from */
 	ANIMFILTER_NLATRACKS	= (1<<10),	/* only include NLA-tracks */
 	ANIMFILTER_SELEDIT		= (1<<11),	/* link editability with selected status */
+	ANIMFILTER_NODUPLIS		= (1<<12),	/* duplicate entries for animation data attached to multi-user blocks must not occur */
 	
 	/* all filters - the power inside the bracket must be the last power for left-shifts + 1 */
 	ANIMFILTER_ALLFILTERS	= ((1<<12) - 1)

Modified: trunk/blender/source/blender/editors/space_action/action_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_edit.c	2010-05-20 04:44:10 UTC (rev 28872)
+++ trunk/blender/source/blender/editors/space_action/action_edit.c	2010-05-20 05:18:27 UTC (rev 28873)
@@ -133,7 +133,7 @@
 	int filter;
 	
 	/* get data to filter, from Action or Dopesheet */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 	
 	/* set large values to try to override */
@@ -284,7 +284,7 @@
 	free_anim_copybuf();
 	
 	/* filter data */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 	
 	/* copy keyframes */
@@ -303,7 +303,7 @@
 	int filter, ok=0;
 	
 	/* filter data */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 	
 	/* paste keyframes */
@@ -421,7 +421,7 @@
 	short flag = 0;
 	
 	/* filter data */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 	if (mode == 2) 			filter |= ANIMFILTER_SEL;
 	else if (mode == 3) 	filter |= ANIMFILTER_ACTGROUPED;
 	
@@ -508,9 +508,9 @@
 	
 	/* filter data */
 	if (ac->datatype == ANIMCONT_GPENCIL)
-		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
+		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
 	else
-		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 	
 	/* loop through filtered data and delete selected keys */
@@ -586,9 +586,9 @@
 	
 	/* filter data */
 	if (ac->datatype == ANIMCONT_GPENCIL)
-		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
+		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
 	else
-		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+		filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 	
 	/* loop through filtered data and delete selected keys */
@@ -659,7 +659,7 @@
 	int filter;
 	
 	/* filter data */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);
 	ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
 	
 	/* loop through filtered data and clean curves */
@@ -727,7 +727,7 @@
 	int filter;
 	
 	/* filter data */
-	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY);
+	filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVESONLY | ANIMFILTER_NODUPLIS);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list