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:43:02 +0300
committerJoshua Leung <aligorith@gmail.com>2009-03-16 14:43:02 +0300
commit133e8827b7e9b76e61e405c6eeac88126a106b09 (patch)
tree3bc5962e774edbb2db5318cf710fc3f3a5210088 /source/blender/blenkernel
parentae0f349346941983727a5af7dd503efeb9361154 (diff)
F-Curve Modifiers - Generator: Finishing off most of UI
* Finished code for Expanded Polynomial and Factorised Polynomial UI's. * Started UI code for 'Builtin Function' mode. There are still 4 controls to add there to use something other than simple mapping * Finished/fixed up verification code for these so that values get initialised ok.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/fcurve.c52
1 files changed, 47 insertions, 5 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index e977310ecc8..570af95f267 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1184,23 +1184,65 @@ static void fcm_generator_verify (FModifier *fcm)
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);
}
- /* free the old data, and set the new */
- if (data->coefficients) MEM_freeN(data->coefficients);
-
+ /* set the new data */
data->coefficients= nc;
data->arraysize= data->poly_order+1;
}
}
break;
- // FIXME: add checks for all others
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;
+
+ case FCM_GENERATOR_FUNCTION: /* builtin function */
+ {
+ /* arraysize needs to be 4*/
+ if (data->arraysize != 4) {
+ float *nc;
+
+ /* free the old data */
+ if (data->coefficients)
+ MEM_freeN(data->coefficients);
+
+ /* make new coefficients array, and init using default values */
+ nc= data->coefficients= MEM_callocN(sizeof(float)*4, "FMod_Generator_Coefs");
+ data->arraysize= 4;
+
+ nc[0]= 1.0f;
+ nc[1]= 1.0f;
+ nc[2]= 0.0f;
+ nc[3]= 0.0f;
+ }
+ }
+ break;
}
}