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) {
142 fcu->flag &= ~FCURVE_DISABLED;
145 // FIXME: need to be able to search targets for required one...
146 //BLI_findindex(&driver->targets, ptr->data) != -1)
147 RNA_pointer_create(ptr->id.data, &RNA_Driver, driver, &driverptr);
148 rna_ChannelDriver_update_data(bmain, scene, &driverptr);
154 static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA *ptr)
156 ChannelDriver *driver= ptr->data;
157 rna_DriverTarget_update_data(bmain, scene, ptr);
159 driver->flag |= DRIVER_FLAG_RENAMEVAR;
165 /* note: this function exists only to avoid id refcounting */
166 static void rna_DriverTarget_id_set(PointerRNA *ptr, PointerRNA value)
168 DriverTarget *dtar= (DriverTarget*)ptr->data;
169 dtar->id= value.data;
172 static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr)
174 DriverTarget *dtar= (DriverTarget*)ptr->data;
175 return ID_code_to_RNA_type(dtar->idtype);
178 static int rna_DriverTarget_id_editable(PointerRNA *ptr)
180 DriverTarget *dtar= (DriverTarget*)ptr->data;
181 return (dtar->idtype)? PROP_EDITABLE : 0;
184 static int rna_DriverTarget_id_type_editable(PointerRNA *ptr)
186 DriverTarget *dtar= (DriverTarget*)ptr->data;
188 /* when the id-type can only be object, don't allow editing
189 * otherwise, there may be strange crashes
191 return ((dtar->flag & DTAR_FLAG_ID_OB_ONLY) == 0);
194 static void rna_DriverTarget_id_type_set(PointerRNA *ptr, int value)
196 DriverTarget *data= (DriverTarget*)(ptr->data);
198 /* check if ID-type is settable */
199 if ((data->flag & DTAR_FLAG_ID_OB_ONLY) == 0) {
200 /* change ID-type to the new type */
204 /* make sure ID-type is Object */
208 /* clear the id-block if the type is invalid */
209 if ((data->id) && (GS(data->id->name) != data->idtype))
213 static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value)
215 DriverTarget *dtar= (DriverTarget *)ptr->data;
218 strcpy(value, dtar->rna_path);
223 static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr)
225 DriverTarget *dtar= (DriverTarget *)ptr->data;
228 return strlen(dtar->rna_path);
233 static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value)
235 DriverTarget *dtar= (DriverTarget *)ptr->data;
237 // XXX in this case we need to be very careful, as this will require some new dependencies to be added!
239 MEM_freeN(dtar->rna_path);
242 dtar->rna_path= BLI_strdup(value);
244 dtar->rna_path= NULL;
247 static void rna_DriverVariable_type_set(PointerRNA *ptr, int value)
249 DriverVar *dvar= (DriverVar *)ptr->data;
251 /* call the API function for this */
252 driver_change_variable_type(dvar, value);
255 /* ****************************** */
257 static void rna_FKeyframe_handle1_get(PointerRNA *ptr, float *values)
259 BezTriple *bezt= (BezTriple*)ptr->data;
261 values[0]= bezt->vec[0][0];
262 values[1]= bezt->vec[0][1];
265 static void rna_FKeyframe_handle1_set(PointerRNA *ptr, const float *values)
267 BezTriple *bezt= (BezTriple*)ptr->data;
269 bezt->vec[0][0]= values[0];
270 bezt->vec[0][1]= values[1];
273 static void rna_FKeyframe_handle2_get(PointerRNA *ptr, float *values)
275 BezTriple *bezt= (BezTriple*)ptr->data;
277 values[0]= bezt->vec[2][0];
278 values[1]= bezt->vec[2][1];
281 static void rna_FKeyframe_handle2_set(PointerRNA *ptr, const float *values)
283 BezTriple *bezt= (BezTriple*)ptr->data;
285 bezt->vec[2][0]= values[0];
286 bezt->vec[2][1]= values[1];
289 static void rna_FKeyframe_ctrlpoint_get(PointerRNA *ptr, float *values)
291 BezTriple *bezt= (BezTriple*)ptr->data;
293 values[0]= bezt->vec[1][0];
294 values[1]= bezt->vec[1][1];
297 static void rna_FKeyframe_ctrlpoint_set(PointerRNA *ptr, const float *values)
299 BezTriple *bezt= (BezTriple*)ptr->data;
301 bezt->vec[1][0]= values[0];
302 bezt->vec[1][1]= values[1];
305 /* ****************************** */
307 static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value)
309 FCurve *fcu= (FCurve *)ptr->data;
312 strcpy(value, fcu->rna_path);
317 static int rna_FCurve_RnaPath_length(PointerRNA *ptr)
319 FCurve *fcu= (FCurve *)ptr->data;
322 return strlen(fcu->rna_path);
327 static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
329 FCurve *fcu= (FCurve *)ptr->data;
332 MEM_freeN(fcu->rna_path);
335 fcu->rna_path= BLI_strdup(value);
336 fcu->flag &= ~FCURVE_DISABLED;
342 static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
344 ID *pid = (ID *)ptr->id.data;
345 ID *vid = (ID *)value.id.data;
346 FCurve *fcu= ptr->data;
350 if (ELEM(NULL, pid, vid)) {
351 printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n", pid, vid);
354 else if (value.data && (pid != vid)) {
355 /* id's differ, cant do this, should raise an error */
356 printf("ERROR: ID's differ - ptr=%p vs value=%p \n", pid, vid);
360 if (GS(pid->name)==ID_AC && GS(vid->name)==ID_AC) {
361 /* the ID given is the action already - usually when F-Curve is obtained from an action's pointer */
362 act = (bAction *)pid;
365 /* the ID given is the owner of the F-Curve (for drivers) */
366 AnimData *adt = BKE_animdata_from_id(ptr->id.data);
367 act = (adt)? adt->action : NULL;
370 /* already belongs to group? */
371 if (fcu->grp == value.data) {
373 printf("ERROR: F-Curve already belongs to this group\n");
377 /* can only change group if we have info about the action the F-Curve is in
378 * (i.e. for drivers or random F-Curves, this cannot be done)
381 /* can't change the grouping of F-Curve when it doesn't belong to an action */
382 printf("ERROR: cannot assign F-Curve to group, since F-Curve is not attached to any ID\n");
385 /* make sure F-Curve exists in this action first, otherwise we could still have been tricked */
386 else if (BLI_findindex(&act->curves, fcu) == -1) {
387 printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name);
391 /* try to remove F-Curve from action (including from any existing groups) */
392 action_groups_remove_channel(act, fcu);
394 /* add the F-Curve back to the action now in the right place */
395 // TODO: make the api function handle the case where there isn't any group to assign to
397 /* add to its group using API function, which makes sure everything goes ok */
398 action_groups_add_channel(act, value.data, fcu);
401 /* need to add this back, but it can only go at the end of the list (or else will corrupt groups) */
402 BLI_addtail(&act->curves, fcu);
406 DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
408 /* call the API function for this */
409 return driver_add_new_variable(driver);
412 void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar)
414 if(BLI_findindex(&driver->variables, dvar) == -1) {
415 BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver.");
419 driver_free_variable(driver, dvar);
423 static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
425 FCurve *fcu= (FCurve*)ptr->data;
426 FModifier *fcm= find_active_fmodifier(&fcu->modifiers);
427 return rna_pointer_inherit_refine(ptr, &RNA_FModifier, fcm);
430 static void rna_FCurve_active_modifier_set(PointerRNA *ptr, PointerRNA value)
432 FCurve *fcu= (FCurve*)ptr->data;
433 set_active_fmodifier(&fcu->modifiers, (FModifier *)value.data);
436 static FModifier *rna_FCurve_modifiers_new(FCurve *fcu, int type)
438 return add_fmodifier(&fcu->modifiers, type);
441 static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, FModifier *fcm)
443 if(BLI_findindex(&fcu->modifiers, fcm) == -1) {
444 BKE_reportf(reports, RPT_ERROR, "FCurveModifier '%s' not found in fcurve.", fcm->name);
447 remove_fmodifier(&fcu->modifiers, fcm);
450 static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value))
452 FModifier *fm= (FModifier*)ptr->data;
454 /* don't toggle, always switch on */
455 fm->flag |= FMODIFIER_FLAG_ACTIVE;
458 static void rna_FModifier_start_frame_range(PointerRNA *ptr, float *min, float *max)
460 FModifier *fcm= (FModifier*)ptr->data;
463 *max= (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)? fcm->efra : MAXFRAMEF;
466 static void rna_FModifier_end_frame_range(PointerRNA *ptr, float *min, float *max)
468 FModifier *fcm= (FModifier*)ptr->data;
470 *min= (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)? fcm->sfra : MINAFRAMEF;
474 static void rna_FModifier_blending_range(PointerRNA *ptr, float *min, float *max)
476 FModifier *fcm= (FModifier*)ptr->data;
479 *max= fcm->efra - fcm->sfra;
482 static void rna_FModifier_active_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
484 FModifier *fm, *fmo= (FModifier*)ptr->data;
486 /* clear active state of other FModifiers in this list */
487 for (fm=fmo->prev; fm; fm=fm->prev)
489 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
491 for (fm=fmo->next; fm; fm=fm->next)
493 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
498 static int rna_FModifierGenerator_coefficients_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
500 FModifier *fcm= (FModifier*)ptr->data;
501 FMod_Generator *gen= fcm->data;
504 length[0]= gen->arraysize;
506 length[0]= 100; /* for raw_access, untested */
511 static void rna_FModifierGenerator_coefficients_get(PointerRNA *ptr, float *values)
513 FModifier *fcm= (FModifier*)ptr->data;
514 FMod_Generator *gen= fcm->data;
515 memcpy(values, gen->coefficients, gen->arraysize * sizeof(float));
518 static void rna_FModifierGenerator_coefficients_set(PointerRNA *ptr, const float *values)
520 FModifier *fcm= (FModifier*)ptr->data;
521 FMod_Generator *gen= fcm->data;
522 memcpy(gen->coefficients, values, gen->arraysize * sizeof(float));
525 static void rna_FModifierLimits_minx_range(PointerRNA *ptr, float *min, float *max)
527 FModifier *fcm= (FModifier*)ptr->data;
528 FMod_Limits *data= fcm->data;
531 *max= (data->flag & FCM_LIMIT_XMAX)? data->rect.xmax : MAXFRAMEF;
534 static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *max)
536 FModifier *fcm= (FModifier*)ptr->data;
537 FMod_Limits *data= fcm->data;
539 *min= (data->flag & FCM_LIMIT_XMIN)? data->rect.xmin : MINAFRAMEF;
543 static void rna_FModifierLimits_miny_range(PointerRNA *ptr, float *min, float *max)
545 FModifier *fcm= (FModifier*)ptr->data;
546 FMod_Limits *data= fcm->data;
549 *max= (data->flag & FCM_LIMIT_YMAX)? data->rect.ymax : FLT_MAX;
552 static void rna_FModifierLimits_maxy_range(PointerRNA *ptr, float *min, float *max)
554 FModifier *fcm= (FModifier*)ptr->data;
555 FMod_Limits *data= fcm->data;
557 *min= (data->flag & FCM_LIMIT_YMIN)? data->rect.ymin : -FLT_MAX;
562 static void rna_FModifierStepped_start_frame_range(PointerRNA *ptr, float *min, float *max)
564 FModifier *fcm= (FModifier*)ptr->data;
565 FMod_Stepped *data= fcm->data;
568 *max= (data->flag & FCM_STEPPED_NO_AFTER)? data->end_frame : MAXFRAMEF;
571 static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, float *max)
573 FModifier *fcm= (FModifier*)ptr->data;
574 FMod_Stepped *data= fcm->data;
576 *min= (data->flag & FCM_STEPPED_NO_BEFORE)? data->start_frame : MINAFRAMEF;
580 static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
582 int index= insert_vert_fcurve(fcu, frame, value, flag);
583 return ((fcu->bezt) && (index >= 0))? (fcu->bezt + index) : NULL;
586 static void rna_FKeyframe_points_add(FCurve *fcu, int tot)
591 BezTriple *nbezt= MEM_callocN(sizeof(BezTriple) * (fcu->totvert + tot), "rna_FKeyframe_points_add");
592 memcpy(nbezt, fcu->bezt, sizeof(BezTriple) * fcu->totvert);
593 MEM_freeN(fcu->bezt);
597 fcu->bezt= MEM_callocN(sizeof(BezTriple) * tot, "rna_FKeyframe_points_add");
600 bezt= fcu->bezt + fcu->totvert;
604 /* defaults, no userprefs gives pradictable results for API */
605 bezt->f1= bezt->f2= bezt->f3= SELECT;
606 bezt->ipo= BEZT_IPO_BEZ;
607 bezt->h1= bezt->h2= HD_AUTO;
613 static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast)
615 int index= (int)(bezt - fcu->bezt);
616 if (index < 0 || index >= fcu->totvert) {
617 BKE_report(reports, RPT_ERROR, "Keyframe not in F-Curve.");
621 delete_fcurve_key(fcu, index, !do_fast);
624 static void rna_fcurve_range(FCurve *fcu, float range[2])
626 calc_fcurve_range(fcu, range, range+1, FALSE);
631 static void rna_def_fmodifier_generator(BlenderRNA *brna)
636 static EnumPropertyItem generator_mode_items[] = {
637 {FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""},
638 {FCM_GENERATOR_POLYNOMIAL_FACTORISED, "POLYNOMIAL_FACTORISED", 0, "Factorised Polynomial", ""},
639 {0, NULL, 0, NULL, NULL}};
641 srna= RNA_def_struct(brna, "FModifierGenerator", "FModifier");
642 RNA_def_struct_ui_text(srna, "Generator F-Curve Modifier", "Deterministically generates values for the modified F-Curve");
643 RNA_def_struct_sdna_from(srna, "FMod_Generator", "data");
645 /* define common props */
646 prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
647 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
648 RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
649 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
651 // XXX this has a special validation func
652 prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
653 RNA_def_property_enum_items(prop, generator_mode_items);
654 RNA_def_property_ui_text(prop, "Mode", "Type of generator to use");
655 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
658 /* order of the polynomial */
659 // XXX this has a special validation func
660 prop= RNA_def_property(srna, "poly_order", PROP_INT, PROP_NONE);
661 RNA_def_property_ui_text(prop, "Polynomial Order", "The highest power of 'x' for this polynomial. (number of coefficients - 1)");
662 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
664 /* coefficients array */
665 prop= RNA_def_property(srna, "coefficients", PROP_FLOAT, PROP_NONE);
666 RNA_def_property_array(prop, 32);
667 RNA_def_property_flag(prop, PROP_DYNAMIC);
668 RNA_def_property_dynamic_array_funcs(prop, "rna_FModifierGenerator_coefficients_get_length");
669 RNA_def_property_float_funcs(prop, "rna_FModifierGenerator_coefficients_get", "rna_FModifierGenerator_coefficients_set", NULL);
670 RNA_def_property_ui_text(prop, "Coefficients", "Coefficients for 'x' (starting from lowest power of x^0)");
675 static void rna_def_fmodifier_function_generator(BlenderRNA *brna)
680 static EnumPropertyItem prop_type_items[] = {
681 {0, "SIN", 0, "Sine", ""},
682 {1, "COS", 0, "Cosine", ""},
683 {2, "TAN", 0, "Tangent", ""},
684 {3, "SQRT", 0, "Square Root", ""},
685 {4, "LN", 0, "Natural Logarithm", ""},
686 {5, "SINC", 0, "Normalised Sine", "sin(x) / x"},
687 {0, NULL, 0, NULL, NULL}};
689 srna= RNA_def_struct(brna, "FModifierFunctionGenerator", "FModifier");
690 RNA_def_struct_ui_text(srna, "Built-In Function F-Modifier", "Generates values using a Built-In Function");
691 RNA_def_struct_sdna_from(srna, "FMod_FunctionGenerator", "data");
694 prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
695 RNA_def_property_ui_text(prop, "Amplitude", "Scale factor determining the maximum/minimum values");
696 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
698 prop= RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE);
699 RNA_def_property_ui_text(prop, "Phase Multiplier", "Scale factor determining the 'speed' of the function");
700 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
702 prop= RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE);
703 RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function");
704 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
706 prop= RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE);
707 RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by");
708 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
711 prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
712 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
713 RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
714 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
716 prop= RNA_def_property(srna, "function_type", PROP_ENUM, PROP_NONE);
717 RNA_def_property_enum_sdna(prop, NULL, "type");
718 RNA_def_property_enum_items(prop, prop_type_items);
719 RNA_def_property_ui_text(prop, "Type", "Type of built-in function to use");
720 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
725 static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna)
730 srna= RNA_def_struct(brna, "FModifierEnvelopeControlPoint", NULL);
731 RNA_def_struct_ui_text(srna, "Envelope Control Point", "Control point for envelope F-Modifier");
732 RNA_def_struct_sdna(srna, "FCM_EnvelopeData");
735 * - for now, these are allowed to go past each other, so that we can have inverted action
736 * - technically, the range is limited by the settings in the envelope-modifier data, not here...
738 prop= RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
739 RNA_def_property_float_sdna(prop, NULL, "min");
740 RNA_def_property_ui_text(prop, "Minimum Value", "Lower bound of envelope at this control-point");
741 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
743 prop= RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
744 RNA_def_property_float_sdna(prop, NULL, "max");
745 RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point");
746 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
749 prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
750 RNA_def_property_float_sdna(prop, NULL, "time");
751 RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on");
752 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
755 // - selection flags (not implemented in UI yet though)
758 static void rna_def_fmodifier_envelope(BlenderRNA *brna)
763 srna= RNA_def_struct(brna, "FModifierEnvelope", "FModifier");
764 RNA_def_struct_ui_text(srna, "Envelope F-Modifier", "Scales the values of the modified F-Curve");
765 RNA_def_struct_sdna_from(srna, "FMod_Envelope", "data");
768 prop= RNA_def_property(srna, "control_points", PROP_COLLECTION, PROP_NONE);
769 RNA_def_property_collection_sdna(prop, NULL, "data", "totvert");
770 RNA_def_property_struct_type(prop, "FModifierEnvelopeControlPoint");
771 RNA_def_property_ui_text(prop, "Control Points", "Control points defining the shape of the envelope");
774 prop= RNA_def_property(srna, "reference_value", PROP_FLOAT, PROP_NONE);
775 RNA_def_property_float_sdna(prop, NULL, "midval");
776 RNA_def_property_ui_text(prop, "Reference Value", "Value that envelope's influence is centered around / based on");
777 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
779 prop= RNA_def_property(srna, "default_min", PROP_FLOAT, PROP_NONE);
780 RNA_def_property_float_sdna(prop, NULL, "min");
781 RNA_def_property_ui_text(prop, "Default Minimum", "Lower distance from Reference Value for 1:1 default influence");
782 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
784 prop= RNA_def_property(srna, "default_max", PROP_FLOAT, PROP_NONE);
785 RNA_def_property_float_sdna(prop, NULL, "max");
786 RNA_def_property_ui_text(prop, "Default Maximum", "Upper distance from Reference Value for 1:1 default influence");
787 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
792 static void rna_def_fmodifier_cycles(BlenderRNA *brna)
797 static EnumPropertyItem prop_type_items[] = {
798 {FCM_EXTRAPOLATE_NONE, "NONE", 0, "No Cycles", "Don't do anything"},
799 {FCM_EXTRAPOLATE_CYCLIC, "REPEAT", 0, "Repeat Motion", "Repeat keyframe range as-is"},
800 {FCM_EXTRAPOLATE_CYCLIC_OFFSET, "REPEAT_OFFSET", 0, "Repeat with Offset", "Repeat keyframe range, but with offset based on gradient between values"},
801 {FCM_EXTRAPOLATE_MIRROR, "MIRROR", 0, "Repeat Mirrored", "Alternate between forward and reverse playback of keyframe range"},
802 {0, NULL, 0, NULL, NULL}};
804 srna= RNA_def_struct(brna, "FModifierCycles", "FModifier");
805 RNA_def_struct_ui_text(srna, "Cycles F-Modifier", "Repeats the values of the modified F-Curve");
806 RNA_def_struct_sdna_from(srna, "FMod_Cycles", "data");
809 prop= RNA_def_property(srna, "mode_before", PROP_ENUM, PROP_NONE);
810 RNA_def_property_enum_sdna(prop, NULL, "before_mode");
811 RNA_def_property_enum_items(prop, prop_type_items);
812 RNA_def_property_ui_text(prop, "Before Mode", "Cycling mode to use before first keyframe");
813 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
815 prop= RNA_def_property(srna, "cycles_before", PROP_INT, PROP_NONE);
816 RNA_def_property_int_sdna(prop, NULL, "before_cycles");
817 RNA_def_property_ui_text(prop, "Before Cycles", "Maximum number of cycles to allow before first keyframe. (0 = infinite)");
818 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
821 prop= RNA_def_property(srna, "mode_after", PROP_ENUM, PROP_NONE);
822 RNA_def_property_enum_sdna(prop, NULL, "after_mode");
823 RNA_def_property_enum_items(prop, prop_type_items);
824 RNA_def_property_ui_text(prop, "After Mode", "Cycling mode to use after last keyframe");
825 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
827 prop= RNA_def_property(srna, "cycles_after", PROP_INT, PROP_NONE);
828 RNA_def_property_int_sdna(prop, NULL, "after_cycles");
829 RNA_def_property_ui_text(prop, "After Cycles", "Maximum number of cycles to allow after last keyframe. (0 = infinite)");
830 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
835 static void rna_def_fmodifier_python(BlenderRNA *brna)
840 srna= RNA_def_struct(brna, "FModifierPython", "FModifier");
841 RNA_def_struct_ui_text(srna, "Python F-Modifier", "Performs user-defined operation on the modified F-Curve");
842 RNA_def_struct_sdna_from(srna, "FMod_Python", "data");
847 static void rna_def_fmodifier_limits(BlenderRNA *brna)
852 srna= RNA_def_struct(brna, "FModifierLimits", "FModifier");
853 RNA_def_struct_ui_text(srna, "Limits F-Modifier", "Limits the time/value ranges of the modified F-Curve");
854 RNA_def_struct_sdna_from(srna, "FMod_Limits", "data");
856 prop= RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
857 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMIN);
858 RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value");
859 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
861 prop= RNA_def_property(srna, "use_min_y", PROP_BOOLEAN, PROP_NONE);
862 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMIN);
863 RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
864 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
866 prop= RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
867 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMAX);
868 RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
869 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
871 prop= RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
872 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMAX);
873 RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
874 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
876 prop= RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
877 RNA_def_property_float_sdna(prop, NULL, "rect.xmin");
878 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_minx_range");
879 RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
880 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
882 prop= RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
883 RNA_def_property_float_sdna(prop, NULL, "rect.ymin");
884 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_miny_range");
885 RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
886 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
888 prop= RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
889 RNA_def_property_float_sdna(prop, NULL, "rect.xmax");
890 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxx_range");
891 RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
892 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
894 prop= RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
895 RNA_def_property_float_sdna(prop, NULL, "rect.ymax");
896 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxy_range");
897 RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
898 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
903 static void rna_def_fmodifier_noise(BlenderRNA *brna)
908 static EnumPropertyItem prop_modification_items[] = {
909 {FCM_NOISE_MODIF_REPLACE, "REPLACE", 0, "Replace", ""},
910 {FCM_NOISE_MODIF_ADD, "ADD", 0, "Add", ""},
911 {FCM_NOISE_MODIF_SUBTRACT, "SUBTRACT", 0, "Subtract", ""},
912 {FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", 0, "Multiply", ""},
913 {0, NULL, 0, NULL, NULL}};
915 srna= RNA_def_struct(brna, "FModifierNoise", "FModifier");
916 RNA_def_struct_ui_text(srna, "Noise F-Modifier", "Gives randomness to the modified F-Curve");
917 RNA_def_struct_sdna_from(srna, "FMod_Noise", "data");
919 prop= RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
920 RNA_def_property_enum_sdna(prop, NULL, "modification");
921 RNA_def_property_enum_items(prop, prop_modification_items);
922 RNA_def_property_ui_text(prop, "Blend Type", "Method of modifying the existing F-Curve");
923 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
925 prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
926 RNA_def_property_float_sdna(prop, NULL, "size");
927 RNA_def_property_ui_text(prop, "Scale", "Scaling (in time) of the noise");
928 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
930 prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
931 RNA_def_property_float_sdna(prop, NULL, "strength");
932 RNA_def_property_ui_text(prop, "Strength", "Amplitude of the noise - the amount that it modifies the underlying curve");
933 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
935 prop= RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
936 RNA_def_property_float_sdna(prop, NULL, "phase");
937 RNA_def_property_ui_text(prop, "Phase", "A random seed for the noise effect");
938 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
940 prop= RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
941 RNA_def_property_int_sdna(prop, NULL, "depth");
942 RNA_def_property_ui_text(prop, "Depth", "Amount of fine level detail present in the noise");
943 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
949 static void rna_def_fmodifier_stepped(BlenderRNA *brna)
954 srna= RNA_def_struct(brna, "FModifierStepped", "FModifier");
955 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");
956 RNA_def_struct_sdna_from(srna, "FMod_Stepped", "data");
959 prop= RNA_def_property(srna, "frame_step", PROP_FLOAT, PROP_NONE);
960 RNA_def_property_float_sdna(prop, NULL, "step_size");
961 RNA_def_property_ui_text(prop, "Step Size", "Number of frames to hold each value");
962 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
964 prop= RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
965 RNA_def_property_float_sdna(prop, NULL, "offset");
966 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");
967 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
969 prop= RNA_def_property(srna, "use_frame_start", PROP_BOOLEAN, PROP_NONE);
970 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_BEFORE);
971 RNA_def_property_ui_text(prop, "Use Start Frame", "Restrict modifier to only act after its 'start' frame");
972 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
974 prop= RNA_def_property(srna, "use_frame_end", PROP_BOOLEAN, PROP_NONE);
975 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_AFTER);
976 RNA_def_property_ui_text(prop, "Use End Frame", "Restrict modifier to only act before its 'end' frame");
977 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
979 prop= RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
980 RNA_def_property_float_sdna(prop, NULL, "start_frame");
981 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_start_frame_range");
982 RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
983 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
985 prop= RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
986 RNA_def_property_float_sdna(prop, NULL, "end_frame");
987 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_end_frame_range");
988 RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if applicable)");
989 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
995 static void rna_def_fmodifier(BlenderRNA *brna)
1000 /* base struct definition */
1001 srna= RNA_def_struct(brna, "FModifier", NULL);
1002 RNA_def_struct_refine_func(srna, "rna_FModifierType_refine");
1003 RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve");
1005 #if 0 // XXX not used yet
1007 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1008 RNA_def_struct_name_property(srna, prop);
1009 RNA_def_property_ui_text(prop, "Name", "Short description of F-Curve Modifier");
1010 #endif // XXX not used yet
1013 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1014 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1015 RNA_def_property_enum_items(prop, fmodifier_type_items);
1016 RNA_def_property_ui_text(prop, "Type", "F-Curve Modifier Type");
1019 prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
1020 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_EXPANDED);
1021 RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI");
1022 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1024 prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1025 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_MUTED);
1026 RNA_def_property_ui_text(prop, "Muted", "F-Curve Modifier will not be evaluated");
1027 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1028 RNA_def_property_ui_icon(prop, ICON_MUTE_IPO_OFF, 1);
1030 prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1031 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1032 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FMODIFIER_FLAG_DISABLED);
1033 RNA_def_property_ui_text(prop, "Disabled", "F-Curve Modifier has invalid settings and will not be evaluated");
1034 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1036 // TODO: setting this to true must ensure that all others in stack are turned off too...
1037 prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1038 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_ACTIVE);
1039 RNA_def_property_ui_text(prop, "Active", "F-Curve Modifier is the one being edited ");
1040 RNA_def_property_boolean_funcs(prop, NULL, "rna_FModifier_active_set");
1041 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, "rna_FModifier_active_update");
1042 RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
1044 /* restricted range */
1045 prop= RNA_def_property(srna, "use_restricted_range", PROP_BOOLEAN, PROP_NONE);
1046 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_RANGERESTRICT);
1047 RNA_def_property_ui_text(prop, "Restrict Frame Range", "F-Curve Modifier is only applied for the specified frame range to help mask off effects in order to chain them");
1048 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1049 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); // XXX: depends on UI implementation
1051 prop= RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
1052 RNA_def_property_float_sdna(prop, NULL, "sfra");
1053 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_start_frame_range");
1054 RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if Restrict Frame Range is in use)");
1055 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1057 prop= RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
1058 RNA_def_property_float_sdna(prop, NULL, "efra");
1059 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_end_frame_range");
1060 RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if Restrict Frame Range is in use)");
1061 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1063 prop= RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE);
1064 RNA_def_property_float_sdna(prop, NULL, "blendin");
1065 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_blending_range");
1066 RNA_def_property_ui_text(prop, "Blend In", "Number of frames from start frame for influence to take effect");
1067 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1069 prop= RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE);
1070 RNA_def_property_float_sdna(prop, NULL, "blendout");
1071 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_blending_range");
1072 RNA_def_property_ui_text(prop, "Blend Out", "Number of frames from start frame for influence to fade out");
1073 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1076 prop= RNA_def_property(srna, "use_influence", PROP_BOOLEAN, PROP_NONE);
1077 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_USEINFLUENCE);
1078 RNA_def_property_ui_text(prop, "Use Influence", "F-Curve Modifier's effects will be tempered by a default factor");
1079 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1080 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); // XXX: depends on UI implementation
1082 prop= RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
1083 RNA_def_property_float_sdna(prop, NULL, "influence");
1084 RNA_def_property_range(prop, 0.0f, 1.0f);
1085 RNA_def_property_float_default(prop, 1.0f);
1086 RNA_def_property_ui_text(prop, "Influence", "Amount of influence F-Curve Modifier will have when not fading in/out");
1087 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1090 /* *********************** */
1092 static void rna_def_drivertarget(BlenderRNA *brna)
1097 static EnumPropertyItem prop_trans_chan_items[] = {
1098 {DTAR_TRANSCHAN_LOCX, "LOC_X", 0, "X Location", ""},
1099 {DTAR_TRANSCHAN_LOCY, "LOC_Y", 0, "Y Location", ""},
1100 {DTAR_TRANSCHAN_LOCZ, "LOC_Z", 0, "Z Location", ""},
1101 {DTAR_TRANSCHAN_ROTX, "ROT_X", 0, "X Rotation", ""},
1102 {DTAR_TRANSCHAN_ROTY, "ROT_Y", 0, "Y Rotation", ""},
1103 {DTAR_TRANSCHAN_ROTZ, "ROT_Z", 0, "Z Rotation", ""},
1104 {DTAR_TRANSCHAN_SCALEX, "SCALE_X", 0, "X Scale", ""},
1105 {DTAR_TRANSCHAN_SCALEY, "SCALE_Y", 0, "Y Scale", ""},
1106 {DTAR_TRANSCHAN_SCALEZ, "SCALE_Z", 0, "Z Scale", ""},
1107 {0, NULL, 0, NULL, NULL}};
1109 static EnumPropertyItem prop_local_space_items[] = {
1110 {0, "WORLD_SPACE", 0, "World Space", "Transforms include effects of parenting/restpose and constraints"},
1111 {DTAR_FLAG_LOCALSPACE, "TRANSFORM_SPACE", 0, "Transform Space", "Transforms don't include parenting/restpose or constraints"},
1112 {DTAR_FLAG_LOCALSPACE|DTAR_FLAG_LOCAL_CONSTS, "LOCAL_SPACE", 0, "Local Space", "Transforms include effects of constraints but not parenting/restpose"},
1113 {0, NULL, 0, NULL, NULL}};
1115 srna= RNA_def_struct(brna, "DriverTarget", NULL);
1116 RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables");
1118 /* Target Properties - ID-block to Drive */
1119 prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1120 RNA_def_property_struct_type(prop, "ID");
1121 RNA_def_property_flag(prop, PROP_EDITABLE);
1122 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
1123 /* note: custom set function is ONLY to avoid rna setting a user for this. */
1124 RNA_def_property_pointer_funcs(prop, NULL, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", NULL);
1125 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)");
1126 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1128 prop= RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
1129 RNA_def_property_enum_sdna(prop, NULL, "idtype");
1130 RNA_def_property_enum_items(prop, id_type_items);
1131 RNA_def_property_enum_default(prop, ID_OB);
1132 RNA_def_property_enum_funcs(prop, NULL, "rna_DriverTarget_id_type_set", NULL);
1133 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_type_editable");
1134 RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
1135 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1137 /* Target Properties - Property to Drive */
1138 prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
1139 RNA_def_property_string_funcs(prop, "rna_DriverTarget_RnaPath_get", "rna_DriverTarget_RnaPath_length", "rna_DriverTarget_RnaPath_set");
1140 RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from ID-block) to property used");
1141 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1143 prop= RNA_def_property(srna, "bone_target", PROP_STRING, PROP_NONE);
1144 RNA_def_property_string_sdna(prop, NULL, "pchan_name");
1145 RNA_def_property_ui_text(prop, "Bone Name", "Name of PoseBone to use as target");
1146 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1148 prop= RNA_def_property(srna, "transform_type", PROP_ENUM, PROP_NONE);
1149 RNA_def_property_enum_sdna(prop, NULL, "transChan");
1150 RNA_def_property_enum_items(prop, prop_trans_chan_items);
1151 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
1152 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1154 prop= RNA_def_property(srna, "transform_space", PROP_ENUM, PROP_NONE);
1155 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
1156 RNA_def_property_enum_items(prop, prop_local_space_items);
1157 RNA_def_property_ui_text(prop, "Transform Space", "Space in which transforms are used");
1158 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1161 static void rna_def_drivervar(BlenderRNA *brna)
1166 static EnumPropertyItem prop_type_items[] = {
1167 {DVAR_TYPE_SINGLE_PROP, "SINGLE_PROP", 0, "Single Property", "Use the value from some RNA property (Default)"},
1168 {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", 0, "Transform Channel", "Final transformation value of object or bone"},
1169 {DVAR_TYPE_ROT_DIFF, "ROTATION_DIFF", 0, "Rotational Difference", "Use the angle between two bones"},
1170 {DVAR_TYPE_LOC_DIFF, "LOC_DIFF", 0, "Distance", "Distance between two bones or objects"},
1171 {0, NULL, 0, NULL, NULL}};
1174 srna= RNA_def_struct(brna, "DriverVariable", NULL);
1175 RNA_def_struct_sdna(srna, "DriverVar");
1176 RNA_def_struct_ui_text(srna, "Driver Variable", "Variable from some source/target for driver relationship");
1179 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1180 RNA_def_struct_name_property(srna, prop);
1181 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)");
1182 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_name"); // XXX
1185 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1186 RNA_def_property_enum_items(prop, prop_type_items);
1187 RNA_def_property_enum_funcs(prop, NULL, "rna_DriverVariable_type_set", NULL);
1188 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
1189 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); // XXX
1192 // TODO: for nicer api, only expose the relevant props via subclassing, instead of exposing the collection of targets
1193 prop= RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
1194 RNA_def_property_collection_sdna(prop, NULL, "targets", "num_targets");
1195 RNA_def_property_struct_type(prop, "DriverTarget");
1196 RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable");
1200 /* channeldriver.variables.* */
1201 static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop)
1204 // PropertyRNA *prop;
1209 RNA_def_property_srna(cprop, "ChannelDriverVariables");
1210 srna= RNA_def_struct(brna, "ChannelDriverVariables", NULL);
1211 RNA_def_struct_sdna(srna, "ChannelDriver");
1212 RNA_def_struct_ui_text(srna, "ChannelDriver Variables", "Collection of channel driver Variables");
1216 func= RNA_def_function(srna, "new", "rna_Driver_new_variable");
1217 RNA_def_function_ui_description(func, "Add a new variable for the driver.");
1219 parm= RNA_def_pointer(func, "var", "DriverVariable", "", "Newly created Driver Variable.");
1220 RNA_def_function_return(func, parm);
1222 /* remove variable */
1223 func= RNA_def_function(srna, "remove", "rna_Driver_remove_variable");
1224 RNA_def_function_ui_description(func, "Remove an existing variable from the driver.");
1225 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1226 /* target to remove */
1227 parm= RNA_def_pointer(func, "variable", "DriverVariable", "", "Variable to remove from the driver.");
1228 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1231 static void rna_def_channeldriver(BlenderRNA *brna)
1236 static EnumPropertyItem prop_type_items[] = {
1237 {DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""},
1238 {DRIVER_TYPE_SUM, "SUM", 0, "Sum Values", ""},
1239 {DRIVER_TYPE_PYTHON, "SCRIPTED", 0, "Scripted Expression", ""},
1240 {DRIVER_TYPE_MIN, "MIN", 0, "Minimum Value", ""},
1241 {DRIVER_TYPE_MAX, "MAX", 0, "Maximum Value", ""},
1242 {0, NULL, 0, NULL, NULL}};
1244 srna= RNA_def_struct(brna, "Driver", NULL);
1245 RNA_def_struct_sdna(srna, "ChannelDriver");
1246 RNA_def_struct_ui_text(srna, "Driver", "Driver for the value of a setting based on an external value");
1247 RNA_def_struct_ui_icon(srna, ICON_DRIVER);
1250 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1251 RNA_def_property_enum_items(prop, prop_type_items);
1252 RNA_def_property_ui_text(prop, "Type", "Driver type");
1253 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data");
1256 prop= RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE);
1257 RNA_def_property_ui_text(prop, "Expression", "Expression to use for Scripted Expression");
1258 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_expr");
1261 prop= RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE);
1262 RNA_def_property_collection_sdna(prop, NULL, "variables", NULL);
1263 RNA_def_property_struct_type(prop, "DriverVariable");
1264 RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver");
1265 rna_def_channeldriver_variables(brna, prop);
1268 prop= RNA_def_property(srna, "show_debug_info", PROP_BOOLEAN, PROP_NONE);
1269 RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_SHOWDEBUG);
1270 RNA_def_property_ui_text(prop, "Show Debug Info", "Show intermediate values for the driver calculations to allow debugging of drivers");
1272 /* State Info (for Debugging) */
1273 prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1274 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", DRIVER_FLAG_INVALID);
1275 RNA_def_property_ui_text(prop, "Invalid", "Driver could not be evaluated in past, so should be skipped");
1279 RNA_api_drivers(srna);
1282 /* *********************** */
1284 static void rna_def_fpoint(BlenderRNA *brna)
1289 srna= RNA_def_struct(brna, "FCurveSample", NULL);
1290 RNA_def_struct_sdna(srna, "FPoint");
1291 RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve");
1293 /* Boolean values */
1294 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1295 RNA_def_property_boolean_sdna(prop, NULL, "flag", 1);
1296 RNA_def_property_ui_text(prop, "Select", "Selection status");
1297 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1300 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
1301 RNA_def_property_float_sdna(prop, NULL, "vec");
1302 RNA_def_property_array(prop, 2);
1303 RNA_def_property_ui_text(prop, "Point", "Point coordinates");
1304 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1308 /* duplicate of BezTriple in rna_curve.c
1309 * but with F-Curve specific options updates/functionality
1311 static void rna_def_fkeyframe(BlenderRNA *brna)
1316 srna= RNA_def_struct(brna, "Keyframe", NULL);
1317 RNA_def_struct_sdna(srna, "BezTriple");
1318 RNA_def_struct_ui_text(srna, "Keyframe", "Bezier curve point with two handles defining a Keyframe on an F-Curve");
1320 /* Boolean values */
1321 prop= RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
1322 RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
1323 RNA_def_property_ui_text(prop, "Handle 1 selected", "Left handle selection status");
1324 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1326 prop= RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
1327 RNA_def_property_boolean_sdna(prop, NULL, "f3", 0);
1328 RNA_def_property_ui_text(prop, "Handle 2 selected", "Right handle selection status");
1329 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1331 prop= RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
1332 RNA_def_property_boolean_sdna(prop, NULL, "f2", 0);
1333 RNA_def_property_ui_text(prop, "Select", "Control point selection status");
1334 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1337 prop= RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
1338 RNA_def_property_enum_sdna(prop, NULL, "h1");
1339 RNA_def_property_enum_items(prop, keyframe_handle_type_items);
1340 RNA_def_property_ui_text(prop, "Left Handle Type", "Handle types");
1341 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1343 prop= RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
1344 RNA_def_property_enum_sdna(prop, NULL, "h2");
1345 RNA_def_property_enum_items(prop, keyframe_handle_type_items);
1346 RNA_def_property_ui_text(prop, "Right Handle Type", "Handle types");
1347 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1349 prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
1350 RNA_def_property_enum_sdna(prop, NULL, "ipo");
1351 RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items);
1352 RNA_def_property_ui_text(prop, "Interpolation", "Interpolation method to use for segment of the curve from this Keyframe until the next Keyframe");
1353 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1355 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1356 RNA_def_property_enum_sdna(prop, NULL, "hide");
1357 RNA_def_property_enum_items(prop, beztriple_keyframe_type_items);
1358 RNA_def_property_ui_text(prop, "Type", "The type of keyframe (for visual purposes only");
1359 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1362 prop= RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
1363 RNA_def_property_array(prop, 2);
1364 RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle1_get", "rna_FKeyframe_handle1_set", NULL);
1365 RNA_def_property_ui_text(prop, "Left Handle", "Coordinates of the left handle (before the control point)");
1366 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1368 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
1369 RNA_def_property_array(prop, 2);
1370 RNA_def_property_float_funcs(prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_set", NULL);
1371 RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
1372 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1374 prop= RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
1375 RNA_def_property_array(prop, 2);
1376 RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle2_get", "rna_FKeyframe_handle2_set", NULL);
1377 RNA_def_property_ui_text(prop, "Right Handle", "Coordinates of the right handle (after the control point)");
1378 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1381 static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1390 RNA_def_property_srna(cprop, "FCurveModifiers");
1391 srna= RNA_def_struct(brna, "FCurveModifiers", NULL);
1392 RNA_def_struct_sdna(srna, "FCurve");
1393 RNA_def_struct_ui_text(srna, "F-Curve Modifiers", "Collection of F-Curve Modifiers");
1396 /* Collection active property */
1397 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1398 RNA_def_property_struct_type(prop, "FModifier");
1399 RNA_def_property_pointer_funcs(prop, "rna_FCurve_active_modifier_get", "rna_FCurve_active_modifier_set", NULL, NULL);
1400 RNA_def_property_flag(prop, PROP_EDITABLE);
1401 RNA_def_property_ui_text(prop, "Active F-Curve Modifier", "Active F-Curve Modifier");
1403 /* Constraint collection */
1404 func= RNA_def_function(srna, "new", "rna_FCurve_modifiers_new");
1405 RNA_def_function_ui_description(func, "Add a constraint to this object");
1407 parm= RNA_def_pointer(func, "fmodifier", "FModifier", "", "New fmodifier.");
1408 RNA_def_function_return(func, parm);
1410 parm= RNA_def_enum(func, "type", fmodifier_type_items, 1, "", "Constraint type to add.");
1411 RNA_def_property_flag(parm, PROP_REQUIRED);
1413 func= RNA_def_function(srna, "remove", "rna_FCurve_modifiers_remove");
1414 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1415 RNA_def_function_ui_description(func, "Remove a modifier from this fcurve.");
1416 /* modifier to remove */
1417 parm= RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier.");
1418 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1421 /* fcurve.keyframe_points */
1422 static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
1429 static EnumPropertyItem keyframe_flag_items[] = {
1430 {INSERTKEY_REPLACE, "REPLACE", 0, "Replace", "Don't add any new keyframes, but just replace existing ones"},
1431 {INSERTKEY_NEEDED, "NEEDED", 0, "Needed", "Only adds keyframes that are needed"},
1432 {INSERTKEY_FAST, "FAST", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time"},
1433 {0, NULL, 0, NULL, NULL}};
1435 RNA_def_property_srna(cprop, "FCurveKeyframePoints");
1436 srna= RNA_def_struct(brna, "FCurveKeyframePoints", NULL);
1437 RNA_def_struct_sdna(srna, "FCurve");
1438 RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points");
1440 func= RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert");
1441 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
1442 parm= RNA_def_float(func, "frame", 0.0f, -FLT_MAX, FLT_MAX, "", "X Value of this keyframe point", -FLT_MAX, FLT_MAX);
1443 RNA_def_property_flag(parm, PROP_REQUIRED);
1444 parm= RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "", "Y Value of this keyframe point", -FLT_MAX, FLT_MAX);
1445 RNA_def_property_flag(parm, PROP_REQUIRED);
1447 RNA_def_enum_flag(func, "options", keyframe_flag_items, 0, "", "Keyframe options.");
1449 parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
1450 RNA_def_function_return(func, parm);
1452 func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
1453 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve.");
1454 RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
1456 func= RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
1457 RNA_def_function_ui_description(func, "Remove keyframe from an fcurve.");
1458 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1459 parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove.");
1460 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1462 RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating the curve each time");
1465 static void rna_def_fcurve(BlenderRNA *brna)
1472 static EnumPropertyItem prop_mode_extend_items[] = {
1473 {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant", ""},
1474 {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear", ""},
1475 {0, NULL, 0, NULL, NULL}};
1476 static EnumPropertyItem prop_mode_color_items[] = {
1477 {FCURVE_COLOR_AUTO_RAINBOW, "AUTO_RAINBOW", 0, "Auto Rainbow", ""},
1478 {FCURVE_COLOR_AUTO_RGB, "AUTO_RGB", 0, "Auto XYZ to RGB", ""},
1479 {FCURVE_COLOR_CUSTOM, "CUSTOM", 0, "User Defined", ""},
1480 {0, NULL, 0, NULL, NULL}};
1482 srna= RNA_def_struct(brna, "FCurve", NULL);
1483 RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time");
1484 RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
1487 prop= RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
1488 RNA_def_property_enum_sdna(prop, NULL, "extend");
1489 RNA_def_property_enum_items(prop, prop_mode_extend_items);
1490 RNA_def_property_ui_text(prop, "Extrapolation", "");
1491 RNA_def_property_update(prop, NC_ANIMATION, NULL); // XXX need an update callback for this so that animation gets evaluated
1494 prop= RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE);
1495 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1496 RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)");
1498 prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1499 RNA_def_property_pointer_sdna(prop, NULL, "grp");
1500 RNA_def_property_flag(prop, PROP_EDITABLE);
1501 RNA_def_property_ui_text(prop, "Group", "Action Group that this F-Curve belongs to");
1502 RNA_def_property_pointer_funcs(prop, NULL, "rna_FCurve_group_set", NULL, NULL);
1503 RNA_def_property_update(prop, NC_ANIMATION, NULL);
1505 /* Path + Array Index */
1506 prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
1507 RNA_def_property_string_funcs(prop, "rna_FCurve_RnaPath_get", "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set");
1508 RNA_def_property_ui_text(prop, "Data Path", "RNA Path to property affected by F-Curve");
1509 RNA_def_property_update(prop, NC_ANIMATION, NULL); // XXX need an update callback for this to that animation gets evaluated
1511 /* called 'index' when given as function arg */
1512 prop= RNA_def_property(srna, "array_index", PROP_INT, PROP_NONE);
1513 RNA_def_property_ui_text(prop, "RNA Array Index", "Index to the specific property affected by F-Curve if applicable");
1514 RNA_def_property_update(prop, NC_ANIMATION, NULL); // XXX need an update callback for this so that animation gets evaluated
1517 prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
1518 RNA_def_property_enum_items(prop, prop_mode_color_items);
1519 RNA_def_property_ui_text(prop, "Color Mode", "Method used to determine color of F-Curve in Graph Editor");
1520 RNA_def_property_update(prop, NC_ANIMATION, NULL);
1522 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1523 RNA_def_property_array(prop, 3);
1524 RNA_def_property_range(prop, 0.0f, 1.0f);
1525 RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor");
1526 RNA_def_property_update(prop, NC_ANIMATION, NULL);
1529 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1530 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_SELECTED);
1531 RNA_def_property_ui_text(prop, "Select", "F-Curve is selected for editing");
1532 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1534 prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
1535 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_PROTECTED);
1536 RNA_def_property_ui_text(prop, "Lock", "F-Curve's settings cannot be edited");
1537 RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
1539 prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1540 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_MUTED);
1541 RNA_def_property_ui_text(prop, "Muted", "F-Curve is not evaluated");
1542 RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
1544 prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1545 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_VISIBLE);
1546 RNA_def_property_ui_text(prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs");
1547 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
1549 /* State Info (for Debugging) */
1550 prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1551 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_DISABLED);
1552 RNA_def_property_ui_text(prop, "Valid", "False when F-Curve could not be evaluated in past, so should be skipped when evaluating");
1553 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1556 prop= RNA_def_property(srna, "sampled_points", PROP_COLLECTION, PROP_NONE);
1557 RNA_def_property_collection_sdna(prop, NULL, "fpt", "totvert");
1558 RNA_def_property_struct_type(prop, "FCurveSample");
1559 RNA_def_property_ui_text(prop, "Sampled Points", "Sampled animation data");
1561 prop= RNA_def_property(srna, "keyframe_points", PROP_COLLECTION, PROP_NONE);
1562 RNA_def_property_collection_sdna(prop, NULL, "bezt", "totvert");
1563 RNA_def_property_struct_type(prop, "Keyframe");
1564 RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes");
1565 rna_def_fcurve_keyframe_points(brna, prop);
1567 prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
1568 RNA_def_property_struct_type(prop, "FModifier");
1569 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the shape of the F-Curve");
1570 rna_def_fcurve_modifiers(brna, prop);
1573 func= RNA_def_function(srna, "evaluate", "evaluate_fcurve"); /* calls the C/API direct */
1574 RNA_def_function_ui_description(func, "Evaluate fcurve.");
1575 parm= RNA_def_float(func, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame", "Evaluate fcurve at given frame", -FLT_MAX, FLT_MAX);
1576 RNA_def_property_flag(parm, PROP_REQUIRED);
1578 parm= RNA_def_float(func, "position", 0, -FLT_MAX, FLT_MAX, "Position", "FCurve position", -FLT_MAX, FLT_MAX);
1579 RNA_def_function_return(func, parm);
1581 func= RNA_def_function(srna, "range", "rna_fcurve_range");
1582 RNA_def_function_ui_description(func, "Get the time extents for F-Curve.");
1584 parm= RNA_def_float_vector(func, "range", 2, NULL, -FLT_MAX, FLT_MAX, "Range", "Min/Max values", -FLT_MAX, FLT_MAX);
1585 RNA_def_property_flag(parm, PROP_THICK_WRAP);
1586 RNA_def_function_output(func, parm);
1589 /* *********************** */
1591 void RNA_def_fcurve(BlenderRNA *brna)
1593 rna_def_fcurve(brna);
1594 rna_def_fkeyframe(brna);
1595 rna_def_fpoint(brna);
1597 rna_def_drivertarget(brna);
1598 rna_def_drivervar(brna);
1599 rna_def_channeldriver(brna);
1601 rna_def_fmodifier(brna);
1603 rna_def_fmodifier_generator(brna);
1604 rna_def_fmodifier_function_generator(brna);
1605 rna_def_fmodifier_envelope(brna);
1606 rna_def_fmodifier_envelope_ctrl(brna);
1607 rna_def_fmodifier_cycles(brna);
1608 rna_def_fmodifier_python(brna);
1609 rna_def_fmodifier_limits(brna);
1610 rna_def_fmodifier_noise(brna);
1611 rna_def_fmodifier_stepped(brna);