[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21407] branches/soc-2009-aligorith/source /blender: NLA SoC: SVN Maintenance for files added to this branch ( eol-style -> native)

Joshua Leung aligorith at gmail.com
Tue Jul 7 14:23:44 CEST 2009


Revision: 21407
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21407
Author:   aligorith
Date:     2009-07-07 14:23:44 +0200 (Tue, 07 Jul 2009)

Log Message:
-----------
NLA SoC: SVN Maintenance for files added to this branch (eol-style -> native)

Modified Paths:
--------------
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/fmodifier.c
    branches/soc-2009-aligorith/source/blender/blenkernel/nla_private.h
    branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_buttons.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c

Property Changed:
----------------
    branches/soc-2009-aligorith/source/blender/blenkernel/intern/fmodifier.c
    branches/soc-2009-aligorith/source/blender/blenkernel/nla_private.h
    branches/soc-2009-aligorith/source/blender/editors/animation/fmodifier_ui.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_buttons.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_channels.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_draw.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_edit.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c
    branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_select.c
    branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c

Modified: branches/soc-2009-aligorith/source/blender/blenkernel/intern/fmodifier.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/blenkernel/intern/fmodifier.c	2009-07-07 12:17:06 UTC (rev 21406)
+++ branches/soc-2009-aligorith/source/blender/blenkernel/intern/fmodifier.c	2009-07-07 12:23:44 UTC (rev 21407)
@@ -1,1197 +1,1197 @@
-/**
- * $Id: fcurve.c 21299 2009-07-02 02:12:37Z aligorith $
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- *
- * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
- * All rights reserved.
- *
- * Contributor(s): Joshua Leung (full recode)
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-
-#include <math.h>
-#include <stdio.h>
-#include <stddef.h>
-#include <string.h>
-#include <float.h>
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "MEM_guardedalloc.h"
-
-#include "DNA_anim_types.h"
-
-#include "BLI_blenlib.h"
-#include "BLI_arithb.h"
-#include "BLI_noise.h"
-
-#include "BKE_fcurve.h"
-#include "BKE_curve.h" 
-#include "BKE_global.h"
-#include "BKE_idprop.h"
-#include "BKE_utildefines.h"
-
-#include "RNA_access.h"
-#include "RNA_types.h"
-
-#ifndef DISABLE_PYTHON
-#include "BPY_extern.h" /* for BPY_pydriver_eval() */
-#endif
-
-#define SMALL -1.0e-10
-#define SELECT 1
-
-/* ******************************** F-Modifiers ********************************* */
-
-/* Info ------------------------------- */
-
-/* F-Modifiers are modifiers which operate on F-Curves. However, they can also be defined
- * on NLA-Strips to affect all of the F-Curves referenced by the NLA-Strip. 
- */
-
-/* Template --------------------------- */
-
-/* Each modifier defines a set of functions, which will be called at the appropriate
- * times. In addition to this, each modifier should have a type-info struct, where
- * its functions are attached for use. 
- */
- 
-/* Template for type-info data:
- *	- make a copy of this when creating new modifiers, and just change the functions
- *	  pointed to as necessary
- *	- although the naming of functions doesn't matter, it would help for code
- *	  readability, to follow the same naming convention as is presented here
- * 	- any functions that a constraint doesn't need to define, don't define
- *	  for such cases, just use NULL 
- *	- these should be defined after all the functions have been defined, so that
- * 	  forward-definitions/prototypes don't need to be used!
- *	- keep this copy #if-def'd so that future constraints can get based off this
- */
-#if 0
-static FModifierTypeInfo FMI_MODNAME = {
-	FMODIFIER_TYPE_MODNAME, /* type */
-	sizeof(FMod_ModName), /* size */
-	FMI_TYPE_SOME_ACTION, /* action type */
-	FMI_REQUIRES_SOME_REQUIREMENT, /* requirements */
-	"Modifier Name", /* name */
-	"FMod_ModName", /* struct name */
-	fcm_modname_free, /* free data */
-	fcm_modname_relink, /* relink data */
-	fcm_modname_copy, /* copy data */
-	fcm_modname_new_data, /* new data */
-	fcm_modname_verify, /* verify */
-	fcm_modname_time, /* evaluate time */
-	fcm_modname_evaluate /* evaluate */
-};
-#endif
-
-/* Generator F-Curve Modifier --------------------------- */
-
-/* Generators available:
- * 	1) simple polynomial generator:
- *		- Exanded form - (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... + C[n])  
- *		- Factorised form - (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1]))
- */
-
-static void fcm_generator_free (FModifier *fcm)
-{
-	FMod_Generator *data= (FMod_Generator *)fcm->data;
-	
-	/* free polynomial coefficients array */
-	if (data->coefficients)
-		MEM_freeN(data->coefficients);
-}
-
-static void fcm_generator_copy (FModifier *fcm, FModifier *src)
-{
-	FMod_Generator *gen= (FMod_Generator *)fcm->data;
-	FMod_Generator *ogen= (FMod_Generator *)src->data;
-	
-	/* copy coefficients array? */
-	if (ogen->coefficients)
-		gen->coefficients= MEM_dupallocN(ogen->coefficients);
-}
-
-static void fcm_generator_new_data (void *mdata)
-{
-	FMod_Generator *data= (FMod_Generator *)mdata;
-	float *cp;
-	
-	/* set default generator to be linear 0-1 (gradient = 1, y-offset = 0) */
-	data->poly_order= 1;
-	data->arraysize= 2;
-	cp= data->coefficients= MEM_callocN(sizeof(float)*2, "FMod_Generator_Coefs");
-	cp[0] = 0; // y-offset 
-	cp[1] = 1; // gradient
-}
-
-static void fcm_generator_verify (FModifier *fcm)
-{
-	FMod_Generator *data= (FMod_Generator *)fcm->data;
-	
-	/* requirements depend on mode */
-	switch (data->mode) {
-		case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */
-		{
-			/* arraysize needs to be order+1, so resize if not */
-			if (data->arraysize != (data->poly_order+1)) {
-				float *nc;
-				
-				/* make new coefficients array, and copy over as much data as can fit */
-				nc= MEM_callocN(sizeof(float)*(data->poly_order+1), "FMod_Generator_Coefs");
-				
-				if (data->coefficients) {
-					if (data->arraysize > (data->poly_order+1))
-						memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order+1));
-					else
-						memcpy(nc, data->coefficients, sizeof(float)*data->arraysize);
-						
-					/* free the old data */
-					MEM_freeN(data->coefficients);
-				}	
-				
-				/* set the new data */
-				data->coefficients= nc;
-				data->arraysize= data->poly_order+1;
-			}
-		}
-			break;
-		
-		case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* expanded polynomial expression */
-		{
-			/* arraysize needs to be 2*order, so resize if not */
-			if (data->arraysize != (data->poly_order * 2)) {
-				float *nc;
-				
-				/* make new coefficients array, and copy over as much data as can fit */
-				nc= MEM_callocN(sizeof(float)*(data->poly_order*2), "FMod_Generator_Coefs");
-				
-				if (data->coefficients) {
-					if (data->arraysize > (data->poly_order * 2))
-						memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order * 2));
-					else
-						memcpy(nc, data->coefficients, sizeof(float)*data->arraysize);
-						
-					/* free the old data */
-					MEM_freeN(data->coefficients);
-				}	
-				
-				/* set the new data */
-				data->coefficients= nc;
-				data->arraysize= data->poly_order * 2;
-			}
-		}
-			break;	
-	}
-}
-
-static void fcm_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
-{
-	FMod_Generator *data= (FMod_Generator *)fcm->data;
-	
-	/* behaviour depends on mode 
-	 * NOTE: the data in its default state is fine too
-	 */
-	switch (data->mode) {
-		case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */
-		{
-			/* we overwrite cvalue with the sum of the polynomial */
-			float *powers = MEM_callocN(sizeof(float)*data->arraysize, "Poly Powers");
-			float value= 0.0f;
-			unsigned int i;
-			
-			/* for each x^n, precalculate value based on previous one first... this should be 
-			 * faster that calling pow() for each entry
-			 */
-			for (i=0; i < data->arraysize; i++) {
-				/* first entry is x^0 = 1, otherwise, calculate based on previous */
-				if (i)
-					powers[i]= powers[i-1] * evaltime;
-				else
-					powers[0]= 1;
-			}
-			
-			/* for each coefficient, add to value, which we'll write to *cvalue in one go */
-			for (i=0; i < data->arraysize; i++)
-				value += data->coefficients[i] * powers[i];
-			
-			/* only if something changed, write *cvalue in one go */
-			if (data->poly_order) {
-				if (data->flag & FCM_GENERATOR_ADDITIVE)
-					*cvalue += value;
-				else
-					*cvalue= value;
-			}
-				
-			/* cleanup */
-			if (powers) 
-				MEM_freeN(powers);
-		}
-			break;
-			
-		case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* factorised polynomial */
-		{
-			float value= 1.0f, *cp=NULL;
-			unsigned int i;
-			
-			/* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */
-			for (cp=data->coefficients, i=0; (cp) && (i < data->poly_order); cp+=2, i++) 
-				value *= (cp[0]*evaltime + cp[1]);
-				
-			/* only if something changed, write *cvalue in one go */
-			if (data->poly_order) {
-				if (data->flag & FCM_GENERATOR_ADDITIVE)
-					*cvalue += value;
-				else
-					*cvalue= value;
-			}
-		}
-			break;
-	}
-}
-
-static FModifierTypeInfo FMI_GENERATOR = {
-	FMODIFIER_TYPE_GENERATOR, /* type */
-	sizeof(FMod_Generator), /* size */
-	FMI_TYPE_GENERATE_CURVE, /* action type */
-	FMI_REQUIRES_NOTHING, /* requirements */
-	"Generator", /* name */
-	"FMod_Generator", /* struct name */
-	fcm_generator_free, /* free data */
-	fcm_generator_copy, /* copy data */
-	fcm_generator_new_data, /* new data */
-	fcm_generator_verify, /* verify */
-	NULL, /* evaluate time */
-	fcm_generator_evaluate /* evaluate */
-};
-
-/* Built-In Function Generator F-Curve Modifier --------------------------- */
-
-/* This uses the general equation for equations:
- * 		y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset
- *
- * where amplitude, phase_multiplier/offset, y_offset are user-defined coefficients,
- * x is the evaluation 'time', and 'y' is the resultant value
- *
- * Functions available are
- *	sin, cos, tan, sinc (normalised sin), natural log, square root 
- */
-
-static void fcm_fn_generator_new_data (void *mdata)
-{
-	FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)mdata;
-	
-	/* set amplitude and phase multiplier to 1.0f so that something is generated */
-	data->amplitude= 1.0f;
-	data->phase_multiplier= 1.0f;
-}
-
-/* Unary 'normalised sine' function
- * 	y = sin(PI + x) / (PI * x),
- * except for x = 0 when y = 1.
- */
-static double sinc (double x)
-{
-    if (fabs(x) < 0.0001)
-        return 1.0;
-    else
-        return sin(M_PI * x) / (M_PI * x);
-}
-
-static void fcm_fn_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
-{
-	FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)fcm->data;
-	double arg= data->phase_multiplier*evaltime + data->phase_offset;

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list