4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * Contributor(s): Blender Foundation (2009), Joshua Leung
22 * ***** END GPL LICENSE BLOCK *****
25 /** \file blender/makesrna/intern/rna_fcurve.c
32 #include "RNA_access.h"
33 #include "RNA_define.h"
34 #include "RNA_enum_types.h"
36 #include "rna_internal.h"
38 #include "DNA_anim_types.h"
39 #include "DNA_object_types.h"
40 #include "DNA_scene_types.h"
42 #include "MEM_guardedalloc.h"
46 #include "BKE_action.h"
50 #include "ED_keyframing.h"
51 #include "ED_keyframes_edit.h"
53 EnumPropertyItem fmodifier_type_items[] = {
54 {FMODIFIER_TYPE_NULL, "NULL", 0, "Invalid", ""},
55 {FMODIFIER_TYPE_GENERATOR, "GENERATOR", 0, "Generator", ""},
56 {FMODIFIER_TYPE_FN_GENERATOR, "FNGENERATOR", 0, "Built-In Function", ""},
57 {FMODIFIER_TYPE_ENVELOPE, "ENVELOPE", 0, "Envelope", ""},
58 {FMODIFIER_TYPE_CYCLES, "CYCLES", 0, "Cycles", ""},
59 {FMODIFIER_TYPE_NOISE, "NOISE", 0, "Noise", ""},
60 {FMODIFIER_TYPE_FILTER, "FILTER", 0, "Filter", ""},
61 //{FMODIFIER_TYPE_PYTHON, "PYTHON", 0, "Python", ""}, // FIXME: not implemented yet!
62 {FMODIFIER_TYPE_LIMITS, "LIMITS", 0, "Limits", ""},
63 {FMODIFIER_TYPE_STEPPED, "STEPPED", 0, "Stepped Interpolation", ""},
64 {0, NULL, 0, NULL, NULL}};
66 EnumPropertyItem beztriple_keyframe_type_items[] = {
67 {BEZT_KEYTYPE_KEYFRAME, "KEYFRAME", 0, "Keyframe", ""},
68 {BEZT_KEYTYPE_BREAKDOWN, "BREAKDOWN", 0, "Breakdown", ""},
69 {BEZT_KEYTYPE_EXTREME, "EXTREME", 0, "Extreme", ""},
70 {BEZT_KEYTYPE_JITTER, "JITTER", 0, "Jitter", ""},
71 {0, NULL, 0, NULL, NULL}};
77 static StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr)
79 FModifier *fcm= (FModifier *)ptr->data;
82 case FMODIFIER_TYPE_GENERATOR:
83 return &RNA_FModifierGenerator;
84 case FMODIFIER_TYPE_FN_GENERATOR:
85 return &RNA_FModifierFunctionGenerator;
86 case FMODIFIER_TYPE_ENVELOPE:
87 return &RNA_FModifierEnvelope;
88 case FMODIFIER_TYPE_CYCLES:
89 return &RNA_FModifierCycles;
90 case FMODIFIER_TYPE_NOISE:
91 return &RNA_FModifierNoise;
92 //case FMODIFIER_TYPE_FILTER:
93 // return &RNA_FModifierFilter;
94 case FMODIFIER_TYPE_PYTHON:
95 return &RNA_FModifierPython;
96 case FMODIFIER_TYPE_LIMITS:
97 return &RNA_FModifierLimits;
98 case FMODIFIER_TYPE_STEPPED:
99 return &RNA_FModifierStepped;
101 return &RNA_UnknownType;
105 /* ****************************** */
107 #include "BKE_fcurve.h"
108 #include "BKE_depsgraph.h"
109 #include "BKE_animsys.h"
111 static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
113 ID *id= ptr->id.data;
114 ChannelDriver *driver= ptr->data;
116 driver->flag &= ~DRIVER_FLAG_INVALID;
118 // TODO: this really needs an update guard...
119 DAG_scene_sort(bmain, scene);
120 DAG_id_tag_update(id, OB_RECALC_OB|OB_RECALC_DATA);
122 WM_main_add_notifier(NC_SCENE|ND_FRAME, scene);
125 static void rna_ChannelDriver_update_expr(Main *bmain, Scene *scene, PointerRNA *ptr)
127 ChannelDriver *driver= ptr->data;
128 driver->flag |= DRIVER_FLAG_RECOMPILE;
129 rna_ChannelDriver_update_data(bmain, scene, ptr);
132 static void rna_DriverTarget_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
134 PointerRNA driverptr;
135 ChannelDriver *driver;
137 AnimData *adt= BKE_animdata_from_id(ptr->id.data);
139 /* find the driver this belongs to and update it */
140 for (fcu=adt->drivers.first; fcu; fcu=fcu->next) {
144 // FIXME: need to be able to search targets for required one...
145 //BLI_findindex(&driver->targets, ptr->data) != -1)
146 RNA_pointer_create(ptr->id.data, &RNA_Driver, driver, &driverptr);
147 rna_ChannelDriver_update_data(bmain, scene, &driverptr);
153 static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA *ptr)
155 ChannelDriver *driver= ptr->data;
156 rna_DriverTarget_update_data(bmain, scene, ptr);
158 driver->flag |= DRIVER_FLAG_RENAMEVAR;
164 /* note: this function exists only to avoid id refcounting */
165 static void rna_DriverTarget_id_set(PointerRNA *ptr, PointerRNA value)
167 DriverTarget *dtar= (DriverTarget*)ptr->data;
168 dtar->id= value.data;
171 static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr)
173 DriverTarget *dtar= (DriverTarget*)ptr->data;
174 return ID_code_to_RNA_type(dtar->idtype);
177 static int rna_DriverTarget_id_editable(PointerRNA *ptr)
179 DriverTarget *dtar= (DriverTarget*)ptr->data;
180 return (dtar->idtype)? PROP_EDITABLE : 0;
183 static int rna_DriverTarget_id_type_editable(PointerRNA *ptr)
185 DriverTarget *dtar= (DriverTarget*)ptr->data;
187 /* when the id-type can only be object, don't allow editing
188 * otherwise, there may be strange crashes
190 return ((dtar->flag & DTAR_FLAG_ID_OB_ONLY) == 0);
193 static void rna_DriverTarget_id_type_set(PointerRNA *ptr, int value)
195 DriverTarget *data= (DriverTarget*)(ptr->data);
197 /* check if ID-type is settable */
198 if ((data->flag & DTAR_FLAG_ID_OB_ONLY) == 0) {
199 /* change ID-type to the new type */
203 /* make sure ID-type is Object */
207 /* clear the id-block if the type is invalid */
208 if ((data->id) && (GS(data->id->name) != data->idtype))
212 static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value)
214 DriverTarget *dtar= (DriverTarget *)ptr->data;
217 strcpy(value, dtar->rna_path);
222 static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr)
224 DriverTarget *dtar= (DriverTarget *)ptr->data;
227 return strlen(dtar->rna_path);
232 static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value)
234 DriverTarget *dtar= (DriverTarget *)ptr->data;
236 // XXX in this case we need to be very careful, as this will require some new dependencies to be added!
238 MEM_freeN(dtar->rna_path);
241 dtar->rna_path= BLI_strdup(value);
243 dtar->rna_path= NULL;
246 static void rna_DriverVariable_type_set(PointerRNA *ptr, int value)
248 DriverVar *dvar= (DriverVar *)ptr->data;
250 /* call the API function for this */
251 driver_change_variable_type(dvar, value);
254 /* ****************************** */
256 static void rna_FKeyframe_handle1_get(PointerRNA *ptr, float *values)
258 BezTriple *bezt= (BezTriple*)ptr->data;
260 values[0]= bezt->vec[0][0];
261 values[1]= bezt->vec[0][1];
264 static void rna_FKeyframe_handle1_set(PointerRNA *ptr, const float *values)
266 BezTriple *bezt= (BezTriple*)ptr->data;
268 bezt->vec[0][0]= values[0];
269 bezt->vec[0][1]= values[1];
272 static void rna_FKeyframe_handle2_get(PointerRNA *ptr, float *values)
274 BezTriple *bezt= (BezTriple*)ptr->data;
276 values[0]= bezt->vec[2][0];
277 values[1]= bezt->vec[2][1];
280 static void rna_FKeyframe_handle2_set(PointerRNA *ptr, const float *values)
282 BezTriple *bezt= (BezTriple*)ptr->data;
284 bezt->vec[2][0]= values[0];
285 bezt->vec[2][1]= values[1];
288 static void rna_FKeyframe_ctrlpoint_get(PointerRNA *ptr, float *values)
290 BezTriple *bezt= (BezTriple*)ptr->data;
292 values[0]= bezt->vec[1][0];
293 values[1]= bezt->vec[1][1];
296 static void rna_FKeyframe_ctrlpoint_set(PointerRNA *ptr, const float *values)
298 BezTriple *bezt= (BezTriple*)ptr->data;
300 bezt->vec[1][0]= values[0];
301 bezt->vec[1][1]= values[1];
304 /* ****************************** */
306 static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value)
308 FCurve *fcu= (FCurve *)ptr->data;
311 strcpy(value, fcu->rna_path);
316 static int rna_FCurve_RnaPath_length(PointerRNA *ptr)
318 FCurve *fcu= (FCurve *)ptr->data;
321 return strlen(fcu->rna_path);
326 static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
328 FCurve *fcu= (FCurve *)ptr->data;
331 MEM_freeN(fcu->rna_path);
334 fcu->rna_path= BLI_strdup(value);
335 fcu->flag &= ~FCURVE_DISABLED;
341 static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
343 ID *pid = (ID *)ptr->id.data;
344 ID *vid = (ID *)value.id.data;
345 FCurve *fcu= ptr->data;
349 if (ELEM(NULL, pid, vid)) {
350 printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n", pid, vid);
353 else if (value.data && (pid != vid)) {
354 /* id's differ, cant do this, should raise an error */
355 printf("ERROR: ID's differ - ptr=%p vs value=%p \n", pid, vid);
359 if (GS(pid->name)==ID_AC && GS(vid->name)==ID_AC) {
360 /* the ID given is the action already - usually when F-Curve is obtained from an action's pointer */
361 act = (bAction *)pid;
364 /* the ID given is the owner of the F-Curve (for drivers) */
365 AnimData *adt = BKE_animdata_from_id(ptr->id.data);
366 act = (adt)? adt->action : NULL;
369 /* already belongs to group? */
370 if (fcu->grp == value.data) {
372 printf("ERROR: F-Curve already belongs to this group\n");
376 /* can only change group if we have info about the action the F-Curve is in
377 * (i.e. for drivers or random F-Curves, this cannot be done)
380 /* can't change the grouping of F-Curve when it doesn't belong to an action */
381 printf("ERROR: cannot assign F-Curve to group, since F-Curve is not attached to any ID\n");
384 /* make sure F-Curve exists in this action first, otherwise we could still have been tricked */
385 else if (BLI_findindex(&act->curves, fcu) == -1) {
386 printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name);
390 /* try to remove F-Curve from action (including from any existing groups) */
391 action_groups_remove_channel(act, fcu);
393 /* add the F-Curve back to the action now in the right place */
394 // TODO: make the api function handle the case where there isn't any group to assign to
396 /* add to its group using API function, which makes sure everything goes ok */
397 action_groups_add_channel(act, value.data, fcu);
400 /* need to add this back, but it can only go at the end of the list (or else will corrupt groups) */
401 BLI_addtail(&act->curves, fcu);
405 DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
407 /* call the API function for this */
408 return driver_add_new_variable(driver);
411 void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar)
413 if(BLI_findindex(&driver->variables, dvar) == -1) {
414 BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver.");
418 driver_free_variable(driver, dvar);
422 static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
424 FCurve *fcu= (FCurve*)ptr->data;
425 FModifier *fcm= find_active_fmodifier(&fcu->modifiers);
426 return rna_pointer_inherit_refine(ptr, &RNA_FModifier, fcm);
429 static void rna_FCurve_active_modifier_set(PointerRNA *ptr, PointerRNA value)
431 FCurve *fcu= (FCurve*)ptr->data;
432 set_active_fmodifier(&fcu->modifiers, (FModifier *)value.data);
435 static FModifier *rna_FCurve_modifiers_new(FCurve *fcu, int type)
437 return add_fmodifier(&fcu->modifiers, type);
440 static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, FModifier *fcm)
442 if(BLI_findindex(&fcu->modifiers, fcm) == -1) {
443 BKE_reportf(reports, RPT_ERROR, "FCurveModifier '%s' not found in fcurve.", fcm->name);
446 remove_fmodifier(&fcu->modifiers, fcm);
449 static void rna_FModifier_active_set(PointerRNA *ptr, int value)
451 FModifier *fm= (FModifier*)ptr->data;
453 /* don't toggle, always switch on */
454 fm->flag |= FMODIFIER_FLAG_ACTIVE;
457 static void rna_FModifier_active_update(Main *bmain, Scene *scene, PointerRNA *ptr)
459 FModifier *fm, *fmo= (FModifier*)ptr->data;
461 /* clear active state of other FModifiers in this list */
462 for (fm=fmo->prev; fm; fm=fm->prev)
464 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
466 for (fm=fmo->next; fm; fm=fm->next)
468 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
473 static int rna_FModifierGenerator_coefficients_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
475 FModifier *fcm= (FModifier*)ptr->data;
476 FMod_Generator *gen= fcm->data;
479 length[0]= gen->arraysize;
481 length[0]= 100; /* for raw_access, untested */
486 static void rna_FModifierGenerator_coefficients_get(PointerRNA *ptr, float *values)
488 FModifier *fcm= (FModifier*)ptr->data;
489 FMod_Generator *gen= fcm->data;
490 memcpy(values, gen->coefficients, gen->arraysize * sizeof(float));
493 static void rna_FModifierGenerator_coefficients_set(PointerRNA *ptr, const float *values)
495 FModifier *fcm= (FModifier*)ptr->data;
496 FMod_Generator *gen= fcm->data;
497 memcpy(gen->coefficients, values, gen->arraysize * sizeof(float));
500 static void rna_FModifierLimits_minx_range(PointerRNA *ptr, float *min, float *max)
502 FModifier *fcm= (FModifier*)ptr->data;
503 FMod_Limits *data= fcm->data;
506 *max= (data->flag & FCM_LIMIT_XMAX)? data->rect.xmax : MAXFRAMEF;
509 static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *max)
511 FModifier *fcm= (FModifier*)ptr->data;
512 FMod_Limits *data= fcm->data;
514 *min= (data->flag & FCM_LIMIT_XMIN)? data->rect.xmin : MINAFRAMEF;
518 static void rna_FModifierLimits_miny_range(PointerRNA *ptr, float *min, float *max)
520 FModifier *fcm= (FModifier*)ptr->data;
521 FMod_Limits *data= fcm->data;
524 *max= (data->flag & FCM_LIMIT_YMAX)? data->rect.ymax : FLT_MAX;
527 static void rna_FModifierLimits_maxy_range(PointerRNA *ptr, float *min, float *max)
529 FModifier *fcm= (FModifier*)ptr->data;
530 FMod_Limits *data= fcm->data;
532 *min= (data->flag & FCM_LIMIT_YMIN)? data->rect.ymin : -FLT_MAX;
537 static void rna_FModifierStepped_start_frame_range(PointerRNA *ptr, float *min, float *max)
539 FModifier *fcm= (FModifier*)ptr->data;
540 FMod_Stepped *data= fcm->data;
543 *max= (data->flag & FCM_STEPPED_NO_AFTER)? data->end_frame : MAXFRAMEF;
546 static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, float *max)
548 FModifier *fcm= (FModifier*)ptr->data;
549 FMod_Stepped *data= fcm->data;
551 *min= (data->flag & FCM_STEPPED_NO_BEFORE)? data->start_frame : MINAFRAMEF;
555 static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
557 int index= insert_vert_fcurve(fcu, frame, value, flag);
558 return ((fcu->bezt) && (index >= 0))? (fcu->bezt + index) : NULL;
561 static void rna_FKeyframe_points_add(FCurve *fcu, int tot)
565 BezTriple *nbezt= MEM_callocN(sizeof(BezTriple) * (fcu->totvert + tot), "rna_FKeyframe_points_add");
566 memcpy(nbezt, fcu->bezt, sizeof(BezTriple) * fcu->totvert);
567 MEM_freeN(fcu->bezt);
571 fcu->bezt= MEM_callocN(sizeof(BezTriple) * tot, "rna_FKeyframe_points_add");
578 static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast)
580 int index= (int)(bezt - fcu->bezt);
581 if (index < 0 || index >= fcu->totvert) {
582 BKE_report(reports, RPT_ERROR, "Keyframe not in F-Curve.");
586 delete_fcurve_key(fcu, index, !do_fast);
589 static void rna_fcurve_range(FCurve *fcu, float range[2])
591 calc_fcurve_range(fcu, range, range+1);
596 static void rna_def_fmodifier_generator(BlenderRNA *brna)
601 static EnumPropertyItem generator_mode_items[] = {
602 {FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""},
603 {FCM_GENERATOR_POLYNOMIAL_FACTORISED, "POLYNOMIAL_FACTORISED", 0, "Factorised Polynomial", ""},
604 {0, NULL, 0, NULL, NULL}};
606 srna= RNA_def_struct(brna, "FModifierGenerator", "FModifier");
607 RNA_def_struct_ui_text(srna, "Generator F-Curve Modifier", "Deterministically generates values for the modified F-Curve");
608 RNA_def_struct_sdna_from(srna, "FMod_Generator", "data");
610 /* define common props */
611 prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
612 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
613 RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
614 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
616 // XXX this has a special validation func
617 prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
618 RNA_def_property_enum_items(prop, generator_mode_items);
619 RNA_def_property_ui_text(prop, "Mode", "Type of generator to use");
620 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
623 /* order of the polynomial */
624 // XXX this has a special validation func
625 prop= RNA_def_property(srna, "poly_order", PROP_INT, PROP_NONE);
626 RNA_def_property_ui_text(prop, "Polynomial Order", "The highest power of 'x' for this polynomial. (number of coefficients - 1)");
627 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
629 /* coefficients array */
630 prop= RNA_def_property(srna, "coefficients", PROP_FLOAT, PROP_NONE);
631 RNA_def_property_array(prop, 32);
632 RNA_def_property_flag(prop, PROP_DYNAMIC);
633 RNA_def_property_dynamic_array_funcs(prop, "rna_FModifierGenerator_coefficients_get_length");
634 RNA_def_property_float_funcs(prop, "rna_FModifierGenerator_coefficients_get", "rna_FModifierGenerator_coefficients_set", NULL);
635 RNA_def_property_ui_text(prop, "Coefficients", "Coefficients for 'x' (starting from lowest power of x^0)");
640 static void rna_def_fmodifier_function_generator(BlenderRNA *brna)
645 static EnumPropertyItem prop_type_items[] = {
646 {0, "SIN", 0, "Sine", ""},
647 {1, "COS", 0, "Cosine", ""},
648 {2, "TAN", 0, "Tangent", ""},
649 {3, "SQRT", 0, "Square Root", ""},
650 {4, "LN", 0, "Natural Logarithm", ""},
651 {5, "SINC", 0, "Normalised Sine", "sin(x) / x"},
652 {0, NULL, 0, NULL, NULL}};
654 srna= RNA_def_struct(brna, "FModifierFunctionGenerator", "FModifier");
655 RNA_def_struct_ui_text(srna, "Built-In Function F-Modifier", "Generates values using a Built-In Function");
656 RNA_def_struct_sdna_from(srna, "FMod_FunctionGenerator", "data");
659 prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
660 RNA_def_property_ui_text(prop, "Amplitude", "Scale factor determining the maximum/minimum values");
661 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
663 prop= RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE);
664 RNA_def_property_ui_text(prop, "Phase Multiplier", "Scale factor determining the 'speed' of the function");
665 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
667 prop= RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE);
668 RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function");
669 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
671 prop= RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE);
672 RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by");
673 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
676 prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
677 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
678 RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
679 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
681 prop= RNA_def_property(srna, "function_type", PROP_ENUM, PROP_NONE);
682 RNA_def_property_enum_sdna(prop, NULL, "type");
683 RNA_def_property_enum_items(prop, prop_type_items);
684 RNA_def_property_ui_text(prop, "Type", "Type of built-in function to use");
685 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
690 static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna)
695 srna= RNA_def_struct(brna, "FModifierEnvelopeControlPoint", NULL);
696 RNA_def_struct_ui_text(srna, "Envelope Control Point", "Control point for envelope F-Modifier");
697 RNA_def_struct_sdna(srna, "FCM_EnvelopeData");
700 * - for now, these are allowed to go past each other, so that we can have inverted action
701 * - technically, the range is limited by the settings in the envelope-modifier data, not here...
703 prop= RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
704 RNA_def_property_float_sdna(prop, NULL, "min");
705 RNA_def_property_ui_text(prop, "Minimum Value", "Lower bound of envelope at this control-point");
706 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
708 prop= RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
709 RNA_def_property_float_sdna(prop, NULL, "max");
710 RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point");
711 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
714 prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
715 RNA_def_property_float_sdna(prop, NULL, "time");
716 RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on");
717 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
720 // - selection flags (not implemented in UI yet though)
723 static void rna_def_fmodifier_envelope(BlenderRNA *brna)
728 srna= RNA_def_struct(brna, "FModifierEnvelope", "FModifier");
729 RNA_def_struct_ui_text(srna, "Envelope F-Modifier", "Scales the values of the modified F-Curve");
730 RNA_def_struct_sdna_from(srna, "FMod_Envelope", "data");
733 prop= RNA_def_property(srna, "control_points", PROP_COLLECTION, PROP_NONE);
734 RNA_def_property_collection_sdna(prop, NULL, "data", "totvert");
735 RNA_def_property_struct_type(prop, "FModifierEnvelopeControlPoint");
736 RNA_def_property_ui_text(prop, "Control Points", "Control points defining the shape of the envelope");
739 prop= RNA_def_property(srna, "reference_value", PROP_FLOAT, PROP_NONE);
740 RNA_def_property_float_sdna(prop, NULL, "midval");
741 RNA_def_property_ui_text(prop, "Reference Value", "Value that envelope's influence is centered around / based on");
742 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
744 prop= RNA_def_property(srna, "default_min", PROP_FLOAT, PROP_NONE);
745 RNA_def_property_float_sdna(prop, NULL, "min");
746 RNA_def_property_ui_text(prop, "Default Minimum", "Lower distance from Reference Value for 1:1 default influence");
747 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
749 prop= RNA_def_property(srna, "default_max", PROP_FLOAT, PROP_NONE);
750 RNA_def_property_float_sdna(prop, NULL, "max");
751 RNA_def_property_ui_text(prop, "Default Maximum", "Upper distance from Reference Value for 1:1 default influence");
752 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
757 static void rna_def_fmodifier_cycles(BlenderRNA *brna)
762 static EnumPropertyItem prop_type_items[] = {
763 {FCM_EXTRAPOLATE_NONE, "NONE", 0, "No Cycles", "Don't do anything"},
764 {FCM_EXTRAPOLATE_CYCLIC, "REPEAT", 0, "Repeat Motion", "Repeat keyframe range as-is"},
765 {FCM_EXTRAPOLATE_CYCLIC_OFFSET, "REPEAT_OFFSET", 0, "Repeat with Offset", "Repeat keyframe range, but with offset based on gradient between values"},
766 {FCM_EXTRAPOLATE_MIRROR, "MIRROR", 0, "Repeat Mirrored", "Alternate between forward and reverse playback of keyframe range"},
767 {0, NULL, 0, NULL, NULL}};
769 srna= RNA_def_struct(brna, "FModifierCycles", "FModifier");
770 RNA_def_struct_ui_text(srna, "Cycles F-Modifier", "Repeats the values of the modified F-Curve");
771 RNA_def_struct_sdna_from(srna, "FMod_Cycles", "data");
774 prop= RNA_def_property(srna, "mode_before", PROP_ENUM, PROP_NONE);
775 RNA_def_property_enum_sdna(prop, NULL, "before_mode");
776 RNA_def_property_enum_items(prop, prop_type_items);
777 RNA_def_property_ui_text(prop, "Before Mode", "Cycling mode to use before first keyframe");
778 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
780 prop= RNA_def_property(srna, "cycles_before", PROP_INT, PROP_NONE);
781 RNA_def_property_int_sdna(prop, NULL, "before_cycles");
782 RNA_def_property_ui_text(prop, "Before Cycles", "Maximum number of cycles to allow before first keyframe. (0 = infinite)");
783 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
786 prop= RNA_def_property(srna, "mode_after", PROP_ENUM, PROP_NONE);
787 RNA_def_property_enum_sdna(prop, NULL, "after_mode");
788 RNA_def_property_enum_items(prop, prop_type_items);
789 RNA_def_property_ui_text(prop, "After Mode", "Cycling mode to use after last keyframe");
790 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
792 prop= RNA_def_property(srna, "cycles_after", PROP_INT, PROP_NONE);
793 RNA_def_property_int_sdna(prop, NULL, "after_cycles");
794 RNA_def_property_ui_text(prop, "After Cycles", "Maximum number of cycles to allow after last keyframe. (0 = infinite)");
795 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
800 static void rna_def_fmodifier_python(BlenderRNA *brna)
805 srna= RNA_def_struct(brna, "FModifierPython", "FModifier");
806 RNA_def_struct_ui_text(srna, "Python F-Modifier", "Performs user-defined operation on the modified F-Curve");
807 RNA_def_struct_sdna_from(srna, "FMod_Python", "data");
812 static void rna_def_fmodifier_limits(BlenderRNA *brna)
817 srna= RNA_def_struct(brna, "FModifierLimits", "FModifier");
818 RNA_def_struct_ui_text(srna, "Limits F-Modifier", "Limits the time/value ranges of the modified F-Curve");
819 RNA_def_struct_sdna_from(srna, "FMod_Limits", "data");
821 prop= RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
822 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMIN);
823 RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value");
824 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
826 prop= RNA_def_property(srna, "use_min_y", PROP_BOOLEAN, PROP_NONE);
827 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMIN);
828 RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
829 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
831 prop= RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
832 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMAX);
833 RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
834 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
836 prop= RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
837 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMAX);
838 RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
839 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
841 prop= RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
842 RNA_def_property_float_sdna(prop, NULL, "rect.xmin");
843 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_minx_range");
844 RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
845 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
847 prop= RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
848 RNA_def_property_float_sdna(prop, NULL, "rect.ymin");
849 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_miny_range");
850 RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
851 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
853 prop= RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
854 RNA_def_property_float_sdna(prop, NULL, "rect.xmax");
855 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxx_range");
856 RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
857 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
859 prop= RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
860 RNA_def_property_float_sdna(prop, NULL, "rect.ymax");
861 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxy_range");
862 RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
863 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
868 static void rna_def_fmodifier_noise(BlenderRNA *brna)
873 static EnumPropertyItem prop_modification_items[] = {
874 {FCM_NOISE_MODIF_REPLACE, "REPLACE", 0, "Replace", ""},
875 {FCM_NOISE_MODIF_ADD, "ADD", 0, "Add", ""},
876 {FCM_NOISE_MODIF_SUBTRACT, "SUBTRACT", 0, "Subtract", ""},
877 {FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", 0, "Multiply", ""},
878 {0, NULL, 0, NULL, NULL}};
880 srna= RNA_def_struct(brna, "FModifierNoise", "FModifier");
881 RNA_def_struct_ui_text(srna, "Noise F-Modifier", "Gives randomness to the modified F-Curve");
882 RNA_def_struct_sdna_from(srna, "FMod_Noise", "data");
884 prop= RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
885 RNA_def_property_enum_sdna(prop, NULL, "modification");
886 RNA_def_property_enum_items(prop, prop_modification_items);
887 RNA_def_property_ui_text(prop, "Blend Type", "Method of modifying the existing F-Curve");
888 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
890 prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
891 RNA_def_property_float_sdna(prop, NULL, "size");
892 RNA_def_property_ui_text(prop, "Scale", "Scaling (in time) of the noise");
893 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
895 prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
896 RNA_def_property_float_sdna(prop, NULL, "strength");
897 RNA_def_property_ui_text(prop, "Strength", "Amplitude of the noise - the amount that it modifies the underlying curve");
898 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
900 prop= RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
901 RNA_def_property_float_sdna(prop, NULL, "phase");
902 RNA_def_property_ui_text(prop, "Phase", "A random seed for the noise effect");
903 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
905 prop= RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
906 RNA_def_property_int_sdna(prop, NULL, "depth");
907 RNA_def_property_ui_text(prop, "Depth", "Amount of fine level detail present in the noise");
908 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
914 static void rna_def_fmodifier_stepped(BlenderRNA *brna)
919 srna= RNA_def_struct(brna, "FModifierStepped", "FModifier");
920 RNA_def_struct_ui_text(srna, "Stepped Interpolation F-Modifier", "Holds each interpolated value from the F-Curve for several frames without changing the timing");
921 RNA_def_struct_sdna_from(srna, "FMod_Stepped", "data");
924 prop= RNA_def_property(srna, "frame_step", PROP_FLOAT, PROP_NONE);
925 RNA_def_property_float_sdna(prop, NULL, "step_size");
926 RNA_def_property_ui_text(prop, "Step Size", "Number of frames to hold each value");
927 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
929 prop= RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
930 RNA_def_property_float_sdna(prop, NULL, "offset");
931 RNA_def_property_ui_text(prop, "Offset", "Reference number of frames before frames get held. Use to get hold for '1-3' vs '5-7' holding patterns");
932 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
934 prop= RNA_def_property(srna, "use_frame_start", PROP_BOOLEAN, PROP_NONE);
935 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_BEFORE);
936 RNA_def_property_ui_text(prop, "Use Start Frame", "Restrict modifier to only act after its 'start' frame");
937 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
939 prop= RNA_def_property(srna, "use_frame_end", PROP_BOOLEAN, PROP_NONE);
940 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_AFTER);
941 RNA_def_property_ui_text(prop, "Use End Frame", "Restrict modifier to only act before its 'end' frame");
942 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
944 prop= RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
945 RNA_def_property_float_sdna(prop, NULL, "start_frame");
946 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_start_frame_range");
947 RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
948 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
950 prop= RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
951 RNA_def_property_float_sdna(prop, NULL, "end_frame");
952 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_end_frame_range");
953 RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if applicable)");
954 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
960 static void rna_def_fmodifier(BlenderRNA *brna)
965 /* base struct definition */
966 srna= RNA_def_struct(brna, "FModifier", NULL);
967 RNA_def_struct_refine_func(srna, "rna_FModifierType_refine");
968 RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve");
970 #if 0 // XXX not used yet
972 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
973 RNA_def_struct_name_property(srna, prop);
974 RNA_def_property_ui_text(prop, "Name", "Short description of F-Curve Modifier");
975 #endif // XXX not used yet
978 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
979 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
980 RNA_def_property_enum_items(prop, fmodifier_type_items);
981 RNA_def_property_ui_text(prop, "Type", "F-Curve Modifier Type");
984 prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
985 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_EXPANDED);
986 RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI");
987 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
989 prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
990 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_MUTED);
991 RNA_def_property_ui_text(prop, "Muted", "F-Curve Modifier will not be evaluated");
992 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
993 RNA_def_property_ui_icon(prop, ICON_MUTE_IPO_OFF, 1);
995 prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
996 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
997 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FMODIFIER_FLAG_DISABLED);
998 RNA_def_property_ui_text(prop, "Disabled", "F-Curve Modifier has invalid settings and will not be evaluated");
999 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1001 // TODO: setting this to true must ensure that all others in stack are turned off too...
1002 prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1003 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_ACTIVE);
1004 RNA_def_property_ui_text(prop, "Active", "F-Curve Modifier is the one being edited ");
1005 RNA_def_property_boolean_funcs(prop, NULL, "rna_FModifier_active_set");
1006 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, "rna_FModifier_active_update");
1007 RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
1010 /* *********************** */
1012 static void rna_def_drivertarget(BlenderRNA *brna)
1017 static EnumPropertyItem prop_trans_chan_items[] = {
1018 {DTAR_TRANSCHAN_LOCX, "LOC_X", 0, "X Location", ""},
1019 {DTAR_TRANSCHAN_LOCY, "LOC_Y", 0, "Y Location", ""},
1020 {DTAR_TRANSCHAN_LOCZ, "LOC_Z", 0, "Z Location", ""},
1021 {DTAR_TRANSCHAN_ROTX, "ROT_X", 0, "X Rotation", ""},
1022 {DTAR_TRANSCHAN_ROTY, "ROT_Y", 0, "Y Rotation", ""},
1023 {DTAR_TRANSCHAN_ROTZ, "ROT_Z", 0, "Z Rotation", ""},
1024 {DTAR_TRANSCHAN_SCALEX, "SCALE_X", 0, "X Scale", ""},
1025 {DTAR_TRANSCHAN_SCALEY, "SCALE_Y", 0, "Y Scale", ""},
1026 {DTAR_TRANSCHAN_SCALEZ, "SCALE_Z", 0, "Z Scale", ""},
1027 {0, NULL, 0, NULL, NULL}};
1029 srna= RNA_def_struct(brna, "DriverTarget", NULL);
1030 RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables");
1032 /* Target Properties - ID-block to Drive */
1033 prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1034 RNA_def_property_struct_type(prop, "ID");
1035 RNA_def_property_flag(prop, PROP_EDITABLE);
1036 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
1037 /* note: custom set function is ONLY to avoid rna setting a user for this. */
1038 RNA_def_property_pointer_funcs(prop, NULL, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", NULL);
1039 RNA_def_property_ui_text(prop, "ID", "ID-block that the specific property used can be found from (id_type property must be set first)");
1040 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1042 prop= RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
1043 RNA_def_property_enum_sdna(prop, NULL, "idtype");
1044 RNA_def_property_enum_items(prop, id_type_items);
1045 RNA_def_property_enum_default(prop, ID_OB);
1046 RNA_def_property_enum_funcs(prop, NULL, "rna_DriverTarget_id_type_set", NULL);
1047 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_type_editable");
1048 RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
1049 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1051 /* Target Properties - Property to Drive */
1052 prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
1053 RNA_def_property_string_funcs(prop, "rna_DriverTarget_RnaPath_get", "rna_DriverTarget_RnaPath_length", "rna_DriverTarget_RnaPath_set");
1054 RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from ID-block) to property used");
1055 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1057 prop= RNA_def_property(srna, "bone_target", PROP_STRING, PROP_NONE);
1058 RNA_def_property_string_sdna(prop, NULL, "pchan_name");
1059 RNA_def_property_ui_text(prop, "Bone Name", "Name of PoseBone to use as target");
1060 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1062 prop= RNA_def_property(srna, "transform_type", PROP_ENUM, PROP_NONE);
1063 RNA_def_property_enum_sdna(prop, NULL, "transChan");
1064 RNA_def_property_enum_items(prop, prop_trans_chan_items);
1065 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
1066 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1068 prop= RNA_def_property(srna, "use_local_space_transform", PROP_BOOLEAN, PROP_NONE);
1069 RNA_def_property_boolean_sdna(prop, NULL, "flag", DTAR_FLAG_LOCALSPACE);
1070 RNA_def_property_ui_text(prop, "Local Space", "Use transforms in Local Space (as opposed to the worldspace default)");
1071 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1074 static void rna_def_drivervar(BlenderRNA *brna)
1079 static EnumPropertyItem prop_type_items[] = {
1080 {DVAR_TYPE_SINGLE_PROP, "SINGLE_PROP", 0, "Single Property", "Use the value from some RNA property (Default)"},
1081 {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", 0, "Transform Channel", "Final transformation value of object or bone"},
1082 {DVAR_TYPE_ROT_DIFF, "ROTATION_DIFF", 0, "Rotational Difference", "Use the angle between two bones"},
1083 {DVAR_TYPE_LOC_DIFF, "LOC_DIFF", 0, "Distance", "Distance between two bones or objects"},
1084 {0, NULL, 0, NULL, NULL}};
1087 srna= RNA_def_struct(brna, "DriverVariable", NULL);
1088 RNA_def_struct_sdna(srna, "DriverVar");
1089 RNA_def_struct_ui_text(srna, "Driver Variable", "Variable from some source/target for driver relationship");
1092 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1093 RNA_def_struct_name_property(srna, prop);
1094 RNA_def_property_ui_text(prop, "Name", "Name to use in scripted expressions/functions. (No spaces or dots are allowed. Also, must not start with a symbol or digit)");
1095 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_name"); // XXX
1098 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1099 RNA_def_property_enum_items(prop, prop_type_items);
1100 RNA_def_property_enum_funcs(prop, NULL, "rna_DriverVariable_type_set", NULL);
1101 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
1102 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); // XXX
1105 // TODO: for nicer api, only expose the relevant props via subclassing, instead of exposing the collection of targets
1106 prop= RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
1107 RNA_def_property_collection_sdna(prop, NULL, "targets", "num_targets");
1108 RNA_def_property_struct_type(prop, "DriverTarget");
1109 RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable");
1113 /* channeldriver.variables.* */
1114 static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop)
1117 // PropertyRNA *prop;
1122 RNA_def_property_srna(cprop, "ChannelDriverVariables");
1123 srna= RNA_def_struct(brna, "ChannelDriverVariables", NULL);
1124 RNA_def_struct_sdna(srna, "ChannelDriver");
1125 RNA_def_struct_ui_text(srna, "ChannelDriver Variables", "Collection of channel driver Variables");
1129 func= RNA_def_function(srna, "new", "rna_Driver_new_variable");
1130 RNA_def_function_ui_description(func, "Add a new variable for the driver.");
1132 parm= RNA_def_pointer(func, "var", "DriverVariable", "", "Newly created Driver Variable.");
1133 RNA_def_function_return(func, parm);
1135 /* remove variable */
1136 func= RNA_def_function(srna, "remove", "rna_Driver_remove_variable");
1137 RNA_def_function_ui_description(func, "Remove an existing variable from the driver.");
1138 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1139 /* target to remove */
1140 parm= RNA_def_pointer(func, "variable", "DriverVariable", "", "Variable to remove from the driver.");
1141 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1144 static void rna_def_channeldriver(BlenderRNA *brna)
1149 static EnumPropertyItem prop_type_items[] = {
1150 {DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""},
1151 {DRIVER_TYPE_SUM, "SUM", 0, "Sum Values", ""},
1152 {DRIVER_TYPE_PYTHON, "SCRIPTED", 0, "Scripted Expression", ""},
1153 {DRIVER_TYPE_MIN, "MIN", 0, "Minimum Value", ""},
1154 {DRIVER_TYPE_MAX, "MAX", 0, "Maximum Value", ""},
1155 {0, NULL, 0, NULL, NULL}};
1157 srna= RNA_def_struct(brna, "Driver", NULL);
1158 RNA_def_struct_sdna(srna, "ChannelDriver");
1159 RNA_def_struct_ui_text(srna, "Driver", "Driver for the value of a setting based on an external value");
1162 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1163 RNA_def_property_enum_items(prop, prop_type_items);
1164 RNA_def_property_ui_text(prop, "Type", "Driver type");
1165 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data");
1168 prop= RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE);
1169 RNA_def_property_ui_text(prop, "Expression", "Expression to use for Scripted Expression");
1170 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_expr");
1173 prop= RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE);
1174 RNA_def_property_collection_sdna(prop, NULL, "variables", NULL);
1175 RNA_def_property_struct_type(prop, "DriverVariable");
1176 RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver");
1177 rna_def_channeldriver_variables(brna, prop);
1180 prop= RNA_def_property(srna, "show_debug_info", PROP_BOOLEAN, PROP_NONE);
1181 RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_SHOWDEBUG);
1182 RNA_def_property_ui_text(prop, "Show Debug Info", "Show intermediate values for the driver calculations to allow debugging of drivers");
1184 /* State Info (for Debugging) */
1185 prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1186 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", DRIVER_FLAG_INVALID);
1187 RNA_def_property_ui_text(prop, "Invalid", "Driver could not be evaluated in past, so should be skipped");
1191 RNA_api_drivers(srna);
1194 /* *********************** */
1196 static void rna_def_fpoint(BlenderRNA *brna)
1201 srna= RNA_def_struct(brna, "FCurveSample", NULL);
1202 RNA_def_struct_sdna(srna, "FPoint");
1203 RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve");
1205 /* Boolean values */
1206 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1207 RNA_def_property_boolean_sdna(prop, NULL, "flag", 1);
1208 RNA_def_property_ui_text(prop, "Select", "Selection status");
1209 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1212 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_NONE); /* keyframes are dimensionless */
1213 RNA_def_property_float_sdna(prop, NULL, "vec");
1214 RNA_def_property_array(prop, 2);
1215 RNA_def_property_ui_text(prop, "Point", "Point coordinates");
1216 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1220 /* duplicate of BezTriple in rna_curve.c
1221 * but with F-Curve specific options updates/functionality
1223 static void rna_def_fkeyframe(BlenderRNA *brna)
1228 srna= RNA_def_struct(brna, "Keyframe", NULL);
1229 RNA_def_struct_sdna(srna, "BezTriple");
1230 RNA_def_struct_ui_text(srna, "Keyframe", "Bezier curve point with two handles defining a Keyframe on an F-Curve");
1232 /* Boolean values */
1233 prop= RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
1234 RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
1235 RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status");
1236 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1238 prop= RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
1239 RNA_def_property_boolean_sdna(prop, NULL, "f3", 0);
1240 RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status");
1241 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1243 prop= RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
1244 RNA_def_property_boolean_sdna(prop, NULL, "f2", 0);
1245 RNA_def_property_ui_text(prop, "Select", "Control point selection status");
1246 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1249 prop= RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
1250 RNA_def_property_enum_sdna(prop, NULL, "h1");
1251 RNA_def_property_enum_items(prop, beztriple_handle_type_items);
1252 RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types");
1253 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1255 prop= RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
1256 RNA_def_property_enum_sdna(prop, NULL, "h2");
1257 RNA_def_property_enum_items(prop, beztriple_handle_type_items);
1258 RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types");
1259 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1261 prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
1262 RNA_def_property_enum_sdna(prop, NULL, "ipo");
1263 RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items);
1264 RNA_def_property_ui_text(prop, "Interpolation", "Interpolation method to use for segment of the curve from this Keyframe until the next Keyframe");
1265 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1267 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1268 RNA_def_property_enum_sdna(prop, NULL, "hide");
1269 RNA_def_property_enum_items(prop, beztriple_keyframe_type_items);
1270 RNA_def_property_ui_text(prop, "Type", "The type of keyframe");
1271 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1274 prop= RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_NONE); /* keyframes are dimensionless */
1275 RNA_def_property_array(prop, 2);
1276 RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle1_get", "rna_FKeyframe_handle1_set", NULL);
1277 RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
1278 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1280 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_NONE); /* keyframes are dimensionless */
1281 RNA_def_property_array(prop, 2);
1282 RNA_def_property_float_funcs(prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_set", NULL);
1283 RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
1284 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1286 prop= RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_NONE); /* keyframes are dimensionless */
1287 RNA_def_property_array(prop, 2);
1288 RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle2_get", "rna_FKeyframe_handle2_set", NULL);
1289 RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
1290 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1293 static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1302 RNA_def_property_srna(cprop, "FCurveModifiers");
1303 srna= RNA_def_struct(brna, "FCurveModifiers", NULL);
1304 RNA_def_struct_sdna(srna, "FCurve");
1305 RNA_def_struct_ui_text(srna, "F-Curve Modifiers", "Collection of F-Curve Modifiers");
1308 /* Collection active property */
1309 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1310 RNA_def_property_struct_type(prop, "FModifier");
1311 RNA_def_property_pointer_funcs(prop, "rna_FCurve_active_modifier_get", "rna_FCurve_active_modifier_set", NULL, NULL);
1312 RNA_def_property_flag(prop, PROP_EDITABLE);
1313 RNA_def_property_ui_text(prop, "Active F-Curve Modifier", "Active F-Curve Modifier");
1315 /* Constraint collection */
1316 func= RNA_def_function(srna, "new", "rna_FCurve_modifiers_new");
1317 RNA_def_function_ui_description(func, "Add a constraint to this object");
1319 parm= RNA_def_pointer(func, "fmodifier", "FModifier", "", "New fmodifier.");
1320 RNA_def_function_return(func, parm);
1322 parm= RNA_def_enum(func, "type", fmodifier_type_items, 1, "", "Constraint type to add.");
1323 RNA_def_property_flag(parm, PROP_REQUIRED);
1325 func= RNA_def_function(srna, "remove", "rna_FCurve_modifiers_remove");
1326 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1327 RNA_def_function_ui_description(func, "Remove a modifier from this fcurve.");
1328 /* modifier to remove */
1329 parm= RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier.");
1330 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1333 /* fcurve.keyframe_points */
1334 static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
1341 static EnumPropertyItem keyframe_flag_items[] = {
1342 {INSERTKEY_REPLACE, "REPLACE", 0, "Replace", "Don't add any new keyframes, but just replace existing ones"},
1343 {INSERTKEY_NEEDED, "NEEDED", 0, "Needed", "Only adds keyframes that are needed"},
1344 {INSERTKEY_FAST, "FAST", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time"},
1345 {0, NULL, 0, NULL, NULL}};
1347 RNA_def_property_srna(cprop, "FCurveKeyframePoints");
1348 srna= RNA_def_struct(brna, "FCurveKeyframePoints", NULL);
1349 RNA_def_struct_sdna(srna, "FCurve");
1350 RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points");
1352 func= RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert");
1353 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
1354 parm= RNA_def_float(func, "frame", 0.0f, -FLT_MAX, FLT_MAX, "", "X Value of this keyframe point", -FLT_MAX, FLT_MAX);
1355 RNA_def_property_flag(parm, PROP_REQUIRED);
1356 parm= RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "", "Y Value of this keyframe point", -FLT_MAX, FLT_MAX);
1357 RNA_def_property_flag(parm, PROP_REQUIRED);
1359 RNA_def_enum_flag(func, "options", keyframe_flag_items, 0, "", "Keyframe options.");
1361 parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
1362 RNA_def_function_return(func, parm);
1364 func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
1365 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
1366 RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
1368 func= RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
1369 RNA_def_function_ui_description(func, "Remove keyframe from an fcurve.");
1370 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1371 parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove.");
1372 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1374 RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating the curve each time");
1377 static void rna_def_fcurve(BlenderRNA *brna)
1384 static EnumPropertyItem prop_mode_extend_items[] = {
1385 {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant", ""},
1386 {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear", ""},
1387 {0, NULL, 0, NULL, NULL}};
1388 static EnumPropertyItem prop_mode_color_items[] = {
1389 {FCURVE_COLOR_AUTO_RAINBOW, "AUTO_RAINBOW", 0, "Auto Rainbow", ""},
1390 {FCURVE_COLOR_AUTO_RGB, "AUTO_RGB", 0, "Auto XYZ to RGB", ""},
1391 {FCURVE_COLOR_CUSTOM, "CUSTOM", 0, "User Defined", ""},
1392 {0, NULL, 0, NULL, NULL}};
1394 srna= RNA_def_struct(brna, "FCurve", NULL);
1395 RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time");
1396 RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
1399 prop= RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
1400 RNA_def_property_enum_sdna(prop, NULL, "extend");
1401 RNA_def_property_enum_items(prop, prop_mode_extend_items);
1402 RNA_def_property_ui_text(prop, "Extrapolation", "");
1403 RNA_def_property_update(prop, NC_ANIMATION, NULL); // XXX need an update callback for this so that animation gets evaluated
1406 prop= RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE);
1407 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1408 RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)");
1410 prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1411 RNA_def_property_pointer_sdna(prop, NULL, "grp");
1412 RNA_def_property_flag(prop, PROP_EDITABLE);
1413 RNA_def_property_ui_text(prop, "Group", "Action Group that this F-Curve belongs to");
1414 RNA_def_property_pointer_funcs(prop, NULL, "rna_FCurve_group_set", NULL, NULL);
1415 RNA_def_property_update(prop, NC_ANIMATION, NULL);
1417 /* Path + Array Index */
1418 prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
1419 RNA_def_property_string_funcs(prop, "rna_FCurve_RnaPath_get", "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set");
1420 RNA_def_property_ui_text(prop, "Data Path", "RNA Path to property affected by F-Curve");
1421 RNA_def_property_update(prop, NC_ANIMATION, NULL); // XXX need an update callback for this to that animation gets evaluated
1423 /* called 'index' when given as function arg */
1424 prop= RNA_def_property(srna, "array_index", PROP_INT, PROP_NONE);
1425 RNA_def_property_ui_text(prop, "RNA Array Index", "Index to the specific property affected by F-Curve if applicable");
1426 RNA_def_property_update(prop, NC_ANIMATION, NULL); // XXX need an update callback for this so that animation gets evaluated
1429 prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
1430 RNA_def_property_enum_items(prop, prop_mode_color_items);
1431 RNA_def_property_ui_text(prop, "Color Mode", "Method used to determine color of F-Curve in Graph Editor");
1432 RNA_def_property_update(prop, NC_ANIMATION, NULL);
1434 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1435 RNA_def_property_array(prop, 3);
1436 RNA_def_property_range(prop, 0.0f, 1.0f);
1437 RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor");
1438 RNA_def_property_update(prop, NC_ANIMATION, NULL);
1441 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1442 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_SELECTED);
1443 RNA_def_property_ui_text(prop, "Select", "F-Curve is selected for editing");
1444 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1446 prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
1447 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_PROTECTED);
1448 RNA_def_property_ui_text(prop, "Lock", "F-Curve's settings cannot be edited");
1449 RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
1451 prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1452 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_MUTED);
1453 RNA_def_property_ui_text(prop, "Muted", "F-Curve is not evaluated");
1454 RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
1456 prop= RNA_def_property(srna, "use_auto_handle_clamp", PROP_BOOLEAN, PROP_NONE);
1457 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_AUTO_HANDLES);
1458 RNA_def_property_ui_text(prop, "Auto Clamped Handles", "All auto-handles for F-Curve are clamped");
1459 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1461 prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1462 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_VISIBLE);
1463 RNA_def_property_ui_text(prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs");
1464 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
1466 /* State Info (for Debugging) */
1467 prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1468 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_DISABLED);
1469 RNA_def_property_ui_text(prop, "Valid", "False when F-Curve could not be evaluated in past, so should be skipped when evaluating");
1470 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1473 prop= RNA_def_property(srna, "sampled_points", PROP_COLLECTION, PROP_NONE);
1474 RNA_def_property_collection_sdna(prop, NULL, "fpt", "totvert");
1475 RNA_def_property_struct_type(prop, "FCurveSample");
1476 RNA_def_property_ui_text(prop, "Sampled Points", "Sampled animation data");
1478 prop= RNA_def_property(srna, "keyframe_points", PROP_COLLECTION, PROP_NONE);
1479 RNA_def_property_collection_sdna(prop, NULL, "bezt", "totvert");
1480 RNA_def_property_struct_type(prop, "Keyframe");
1481 RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes");
1482 rna_def_fcurve_keyframe_points(brna, prop);
1484 prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
1485 RNA_def_property_struct_type(prop, "FModifier");
1486 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the shape of the F-Curve");
1487 rna_def_fcurve_modifiers(brna, prop);
1490 func= RNA_def_function(srna, "evaluate", "evaluate_fcurve"); /* calls the C/API direct */
1491 RNA_def_function_ui_description(func, "Evaluate fcurve.");
1492 parm= RNA_def_float(func, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame", "Evaluate fcurve at given frame", -FLT_MAX, FLT_MAX);
1493 RNA_def_property_flag(parm, PROP_REQUIRED);
1495 parm= RNA_def_float(func, "position", 0, -FLT_MAX, FLT_MAX, "Position", "FCurve position", -FLT_MAX, FLT_MAX);
1496 RNA_def_function_return(func, parm);
1498 func= RNA_def_function(srna, "range", "rna_fcurve_range");
1499 RNA_def_function_ui_description(func, "Get the time extents for F-Curve.");
1501 parm= RNA_def_float_vector(func, "range", 2, NULL, -FLT_MAX, FLT_MAX, "Range", "Min/Max values", -FLT_MAX, FLT_MAX);
1502 RNA_def_property_flag(parm, PROP_THICK_WRAP);
1503 RNA_def_function_output(func, parm);
1506 /* *********************** */
1508 void RNA_def_fcurve(BlenderRNA *brna)
1510 rna_def_fcurve(brna);
1511 rna_def_fkeyframe(brna);
1512 rna_def_fpoint(brna);
1514 rna_def_drivertarget(brna);
1515 rna_def_drivervar(brna);
1516 rna_def_channeldriver(brna);
1518 rna_def_fmodifier(brna);
1520 rna_def_fmodifier_generator(brna);
1521 rna_def_fmodifier_function_generator(brna);
1522 rna_def_fmodifier_envelope(brna);
1523 rna_def_fmodifier_envelope_ctrl(brna);
1524 rna_def_fmodifier_cycles(brna);
1525 rna_def_fmodifier_python(brna);
1526 rna_def_fmodifier_limits(brna);
1527 rna_def_fmodifier_noise(brna);
1528 rna_def_fmodifier_stepped(brna);