Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-03-16 14:11:44 +0300
committerJoshua Leung <aligorith@gmail.com>2009-03-16 14:11:44 +0300
commitae0f349346941983727a5af7dd503efeb9361154 (patch)
treeb09c770a339428fcc100d105431084dae2083d45 /source/blender/blenkernel
parent89459e4a51bda16985459d2c34a2df77ef11907c (diff)
F-Curve Modifiers: Basic GUI for Generator Modifier working
* Currently, this only works for the 'Expanded polynomial' mode, but this will be expanded to include the other modes too. Now you can modify the values and interactively see the graph in the view change. * Disabled the backdrops (modifier 'panels') temporarily, as ROUNDBOX UI elements currently swallow all events, which is not good. Note: the code here still uses the old-style UI definition code since the new stuff is still under heavy construction.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_fcurve.h2
-rw-r--r--source/blender/blenkernel/intern/fcurve.c48
2 files changed, 49 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h
index 23c4579de14..a53785adf17 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -56,6 +56,8 @@ typedef struct FModifierTypeInfo {
void (*copy_data)(struct FModifier *fcm, struct FModifier *src);
/* set settings for data that will be used for FCuModifier.data (memory already allocated using MEM_callocN) */
void (*new_data)(void *mdata);
+ /* verifies that the modifier settings are valid */
+ void (*verify_data)(struct FModifier *fcm);
/* evaluation */
/* evaluate the modifier for the given time and 'accumulated' value */
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 3b60be396e7..e977310ecc8 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1114,6 +1114,7 @@ static FModifierTypeInfo FMI_MODNAME = {
fcm_modname_relink, /* relink data */
fcm_modname_copy, /* copy data */
fcm_modname_new_data, /* new data */
+ fcm_modname_verify, /* verify */
fcm_modname_evaluate /* evaluate */
};
#endif
@@ -1163,6 +1164,45 @@ static void fcm_generator_new_data (void *mdata)
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, and set the new */
+ if (data->coefficients) MEM_freeN(data->coefficients);
+
+ data->coefficients= nc;
+ data->arraysize= data->poly_order+1;
+ }
+ }
+ break;
+
+ // FIXME: add checks for all others
+ case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* expanded polynomial expression */
+ {
+
+ }
+ break;
+ }
+}
static void fcm_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime)
{
@@ -1294,6 +1334,7 @@ static FModifierTypeInfo FMI_GENERATOR = {
fcm_generator_free, /* free data */
fcm_generator_copy, /* copy data */
fcm_generator_new_data, /* new data */
+ fcm_generator_verify, /* verify */
fcm_generator_evaluate /* evaluate */
};
@@ -1378,6 +1419,7 @@ static FModifierTypeInfo FMI_ENVELOPE = {
fcm_envelope_free, /* free data */
fcm_envelope_copy, /* copy data */
NULL, /* new data */
+ NULL /*fcm_envelope_verify*/, /* verify */
fcm_envelope_evaluate /* evaluate */
};
@@ -1513,6 +1555,7 @@ static FModifierTypeInfo FMI_CYCLES = {
NULL, /* free data */
NULL, /* copy data */
NULL, /* new data */
+ NULL /*fcm_cycles_verify*/, /* verify */
fcm_cycles_evaluate /* evaluate */
};
@@ -1529,6 +1572,7 @@ static FModifierTypeInfo FMI_NOISE = {
NULL, /* free data */
NULL, /* copy data */
fcm_noise_new_data, /* new data */
+ NULL /*fcm_noise_verify*/, /* verify */
fcm_noise_evaluate /* evaluate */
};
#endif // XXX not yet implemented
@@ -1546,6 +1590,7 @@ static FModifierTypeInfo FMI_FILTER = {
NULL, /* free data */
NULL, /* copy data */
NULL, /* new data */
+ NULL /*fcm_filter_verify*/, /* verify */
fcm_filter_evaluate /* evaluate */
};
#endif // XXX not yet implemented
@@ -1600,6 +1645,7 @@ static FModifierTypeInfo FMI_PYTHON = {
fcm_python_free, /* free data */
fcm_python_copy, /* copy data */
fcm_python_new_data, /* new data */
+ NULL /*fcm_python_verify*/, /* verify */
fcm_python_evaluate /* evaluate */
};
@@ -1689,7 +1735,7 @@ FModifier *fcurve_add_modifier (FCurve *fcu, int type)
BLI_addtail(&fcu->modifiers, fcm);
/* add modifier's data */
- fcm->data= MEM_callocN(fmi->size, "F-Curve Modifier Data");
+ fcm->data= MEM_callocN(fmi->size, fmi->structName);
/* init custom settings if necessary */
if (fmi->new_data)