[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19352] branches/blender2.5/blender/source /blender: F-Curve Modifiers - Envelope: Bugfixes

Joshua Leung aligorith at gmail.com
Sun Mar 22 10:54:14 CET 2009


Revision: 19352
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19352
Author:   aligorith
Date:     2009-03-22 10:54:13 +0100 (Sun, 22 Mar 2009)

Log Message:
-----------
F-Curve Modifiers - Envelope: Bugfixes

* Envelope modifier now works correctly. Previously, the mapping was being done in the wrong order.
* Extra controls for modifiers now only draw when the F-Curve is the active one, so the view will be less cluttered in other cases.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
    branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c	2009-03-22 01:58:43 UTC (rev 19351)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/fcurve.c	2009-03-22 09:54:13 UTC (rev 19352)
@@ -1464,10 +1464,11 @@
 	}
 	
 	/* adjust *cvalue 
-	 * NOTE: env->min/max are relative to env->midval, and can be either +ve OR -ve, so we add...
+	 *	- fac is the ratio of how the current y-value corresponds to the reference range
+	 *	- thus, the new value is found by mapping the old range to the new!
 	 */
-	fac= (*cvalue - min) / (max - min);
-	*cvalue= (env->midval + env->min) + (fac * (env->max - env->min)); 
+	fac= (*cvalue - (env->midval + env->min)) / (env->max - env->min);
+	*cvalue= min + fac*(max - min); 
 }
 
 static FModifierTypeInfo FMI_ENVELOPE = {

Modified: branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c	2009-03-22 01:58:43 UTC (rev 19351)
+++ branches/blender2.5/blender/source/blender/editors/space_graph/graph_draw.c	2009-03-22 09:54:13 UTC (rev 19352)
@@ -95,7 +95,7 @@
 
 /* Envelope -------------- */
 
-// TODO: draw a shaded poly showing the region of influence too?
+// TODO: draw a shaded poly showing the region of influence too!!!
 static void draw_fcurve_modifier_controls_envelope (FCurve *fcu, FModifier *fcm, View2D *v2d)
 {
 	FMod_Envelope *env= (FMod_Envelope *)fcm->data;
@@ -104,7 +104,6 @@
 	int i;
 	
 	/* draw two black lines showing the standard reference levels */
-	// TODO: how to make these more distinctive?
 	glColor3f(0.0f, 0.0f, 0.0f);
 	setlinestyle(5);
 	
@@ -117,7 +116,6 @@
 	glEnd(); // GL_LINES
 	setlinestyle(0);
 	
-	
 	/* set size of vertices (non-adjustable for now) */
 	glPointSize(2.0f);
 	
@@ -821,11 +819,14 @@
 		
 		/* 2) draw handles and vertices as appropriate based on active */
 		if ( ((fcm) && (fcm->type != FMODIFIER_TYPE_CYCLES)) || (fcu->modifiers.first && !fcm) ) {
-			/* draw controls for the 'active' modifier (if applicable) 
+			/* draw controls for the 'active' modifier
+			 *	- there may not be an 'active' modifier on this curve to draw
+			 *	- this curve may not be active, so modifier controls shouldn't get drawn either
+			 *
 			 * NOTE: cycles modifier is currently an exception where the original points can still be edited, so
 			 *  	 	this branch is skipped... (TODO: set up the generic system for this so that we don't need special hacks like this)
 			 */
-			if (fcm) {
+			if ((fcu->flag & FCURVE_ACTIVE) && (fcm)) {
 				switch (fcm->type) {
 					case FMODIFIER_TYPE_ENVELOPE: /* envelope */
 						draw_fcurve_modifier_controls_envelope(fcu, fcm, &ar->v2d);





More information about the Bf-blender-cvs mailing list