2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation (2009), Joshua Leung
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/intern/rna_fcurve.c
30 #include "RNA_access.h"
31 #include "RNA_define.h"
32 #include "RNA_enum_types.h"
34 #include "rna_internal.h"
36 #include "DNA_anim_types.h"
37 #include "DNA_object_types.h"
38 #include "DNA_scene_types.h"
40 #include "MEM_guardedalloc.h"
44 #include "BKE_action.h"
48 #include "ED_keyframing.h"
49 #include "ED_keyframes_edit.h"
51 EnumPropertyItem fmodifier_type_items[] = {
52 {FMODIFIER_TYPE_NULL, "NULL", 0, "Invalid", ""},
53 {FMODIFIER_TYPE_GENERATOR, "GENERATOR", 0, "Generator", ""},
54 {FMODIFIER_TYPE_FN_GENERATOR, "FNGENERATOR", 0, "Built-In Function", ""},
55 {FMODIFIER_TYPE_ENVELOPE, "ENVELOPE", 0, "Envelope", ""},
56 {FMODIFIER_TYPE_CYCLES, "CYCLES", 0, "Cycles", ""},
57 {FMODIFIER_TYPE_NOISE, "NOISE", 0, "Noise", ""},
58 {FMODIFIER_TYPE_FILTER, "FILTER", 0, "Filter", ""},
59 //{FMODIFIER_TYPE_PYTHON, "PYTHON", 0, "Python", ""}, // FIXME: not implemented yet!
60 {FMODIFIER_TYPE_LIMITS, "LIMITS", 0, "Limits", ""},
61 {FMODIFIER_TYPE_STEPPED, "STEPPED", 0, "Stepped Interpolation", ""},
62 {0, NULL, 0, NULL, NULL}};
64 EnumPropertyItem beztriple_keyframe_type_items[] = {
65 {BEZT_KEYTYPE_KEYFRAME, "KEYFRAME", 0, "Keyframe", ""},
66 {BEZT_KEYTYPE_BREAKDOWN, "BREAKDOWN", 0, "Breakdown", ""},
67 {BEZT_KEYTYPE_EXTREME, "EXTREME", 0, "Extreme", ""},
68 {BEZT_KEYTYPE_JITTER, "JITTER", 0, "Jitter", ""},
69 {0, NULL, 0, NULL, NULL}};
75 static StructRNA *rna_FModifierType_refine(struct PointerRNA *ptr)
77 FModifier *fcm= (FModifier *)ptr->data;
80 case FMODIFIER_TYPE_GENERATOR:
81 return &RNA_FModifierGenerator;
82 case FMODIFIER_TYPE_FN_GENERATOR:
83 return &RNA_FModifierFunctionGenerator;
84 case FMODIFIER_TYPE_ENVELOPE:
85 return &RNA_FModifierEnvelope;
86 case FMODIFIER_TYPE_CYCLES:
87 return &RNA_FModifierCycles;
88 case FMODIFIER_TYPE_NOISE:
89 return &RNA_FModifierNoise;
90 //case FMODIFIER_TYPE_FILTER:
91 // return &RNA_FModifierFilter;
92 case FMODIFIER_TYPE_PYTHON:
93 return &RNA_FModifierPython;
94 case FMODIFIER_TYPE_LIMITS:
95 return &RNA_FModifierLimits;
96 case FMODIFIER_TYPE_STEPPED:
97 return &RNA_FModifierStepped;
99 return &RNA_UnknownType;
103 /* ****************************** */
105 #include "BKE_fcurve.h"
106 #include "BKE_depsgraph.h"
107 #include "BKE_animsys.h"
109 static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
111 ID *id= ptr->id.data;
112 ChannelDriver *driver= ptr->data;
114 driver->flag &= ~DRIVER_FLAG_INVALID;
116 // TODO: this really needs an update guard...
117 DAG_scene_sort(bmain, scene);
118 DAG_id_tag_update(id, OB_RECALC_OB|OB_RECALC_DATA);
120 WM_main_add_notifier(NC_SCENE|ND_FRAME, scene);
123 static void rna_ChannelDriver_update_expr(Main *bmain, Scene *scene, PointerRNA *ptr)
125 ChannelDriver *driver= ptr->data;
126 driver->flag |= DRIVER_FLAG_RECOMPILE;
127 rna_ChannelDriver_update_data(bmain, scene, ptr);
130 static void rna_DriverTarget_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
132 PointerRNA driverptr;
133 ChannelDriver *driver;
135 AnimData *adt= BKE_animdata_from_id(ptr->id.data);
137 /* find the driver this belongs to and update it */
138 for (fcu=adt->drivers.first; fcu; fcu=fcu->next) {
140 fcu->flag &= ~FCURVE_DISABLED;
143 // FIXME: need to be able to search targets for required one...
144 //BLI_findindex(&driver->targets, ptr->data) != -1)
145 RNA_pointer_create(ptr->id.data, &RNA_Driver, driver, &driverptr);
146 rna_ChannelDriver_update_data(bmain, scene, &driverptr);
152 static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA *ptr)
154 ChannelDriver *driver= ptr->data;
155 rna_DriverTarget_update_data(bmain, scene, ptr);
157 driver->flag |= DRIVER_FLAG_RENAMEVAR;
163 /* note: this function exists only to avoid id refcounting */
164 static void rna_DriverTarget_id_set(PointerRNA *ptr, PointerRNA value)
166 DriverTarget *dtar= (DriverTarget*)ptr->data;
167 dtar->id= value.data;
170 static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr)
172 DriverTarget *dtar= (DriverTarget*)ptr->data;
173 return ID_code_to_RNA_type(dtar->idtype);
176 static int rna_DriverTarget_id_editable(PointerRNA *ptr)
178 DriverTarget *dtar= (DriverTarget*)ptr->data;
179 return (dtar->idtype)? PROP_EDITABLE : 0;
182 static int rna_DriverTarget_id_type_editable(PointerRNA *ptr)
184 DriverTarget *dtar= (DriverTarget*)ptr->data;
186 /* when the id-type can only be object, don't allow editing
187 * otherwise, there may be strange crashes
189 return ((dtar->flag & DTAR_FLAG_ID_OB_ONLY) == 0);
192 static void rna_DriverTarget_id_type_set(PointerRNA *ptr, int value)
194 DriverTarget *data= (DriverTarget*)(ptr->data);
196 /* check if ID-type is settable */
197 if ((data->flag & DTAR_FLAG_ID_OB_ONLY) == 0) {
198 /* change ID-type to the new type */
202 /* make sure ID-type is Object */
206 /* clear the id-block if the type is invalid */
207 if ((data->id) && (GS(data->id->name) != data->idtype))
211 static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value)
213 DriverTarget *dtar= (DriverTarget *)ptr->data;
216 strcpy(value, dtar->rna_path);
221 static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr)
223 DriverTarget *dtar= (DriverTarget *)ptr->data;
226 return strlen(dtar->rna_path);
231 static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value)
233 DriverTarget *dtar= (DriverTarget *)ptr->data;
235 // XXX in this case we need to be very careful, as this will require some new dependencies to be added!
237 MEM_freeN(dtar->rna_path);
240 dtar->rna_path= BLI_strdup(value);
242 dtar->rna_path= NULL;
245 static void rna_DriverVariable_type_set(PointerRNA *ptr, int value)
247 DriverVar *dvar= (DriverVar *)ptr->data;
249 /* call the API function for this */
250 driver_change_variable_type(dvar, value);
253 /* ****************************** */
255 static void rna_FKeyframe_handle1_get(PointerRNA *ptr, float *values)
257 BezTriple *bezt= (BezTriple*)ptr->data;
259 values[0]= bezt->vec[0][0];
260 values[1]= bezt->vec[0][1];
263 static void rna_FKeyframe_handle1_set(PointerRNA *ptr, const float *values)
265 BezTriple *bezt= (BezTriple*)ptr->data;
267 bezt->vec[0][0]= values[0];
268 bezt->vec[0][1]= values[1];
271 static void rna_FKeyframe_handle2_get(PointerRNA *ptr, float *values)
273 BezTriple *bezt= (BezTriple*)ptr->data;
275 values[0]= bezt->vec[2][0];
276 values[1]= bezt->vec[2][1];
279 static void rna_FKeyframe_handle2_set(PointerRNA *ptr, const float *values)
281 BezTriple *bezt= (BezTriple*)ptr->data;
283 bezt->vec[2][0]= values[0];
284 bezt->vec[2][1]= values[1];
287 static void rna_FKeyframe_ctrlpoint_get(PointerRNA *ptr, float *values)
289 BezTriple *bezt= (BezTriple*)ptr->data;
291 values[0]= bezt->vec[1][0];
292 values[1]= bezt->vec[1][1];
295 static void rna_FKeyframe_ctrlpoint_set(PointerRNA *ptr, const float *values)
297 BezTriple *bezt= (BezTriple*)ptr->data;
299 bezt->vec[1][0]= values[0];
300 bezt->vec[1][1]= values[1];
303 /* ****************************** */
305 static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value)
307 FCurve *fcu= (FCurve *)ptr->data;
310 strcpy(value, fcu->rna_path);
315 static int rna_FCurve_RnaPath_length(PointerRNA *ptr)
317 FCurve *fcu= (FCurve *)ptr->data;
320 return strlen(fcu->rna_path);
325 static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
327 FCurve *fcu= (FCurve *)ptr->data;
330 MEM_freeN(fcu->rna_path);
333 fcu->rna_path= BLI_strdup(value);
334 fcu->flag &= ~FCURVE_DISABLED;
340 static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value)
342 ID *pid = (ID *)ptr->id.data;
343 ID *vid = (ID *)value.id.data;
344 FCurve *fcu= ptr->data;
348 if (ELEM(NULL, pid, vid)) {
349 printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n", pid, vid);
352 else if (value.data && (pid != vid)) {
353 /* id's differ, cant do this, should raise an error */
354 printf("ERROR: ID's differ - ptr=%p vs value=%p \n", pid, vid);
358 if (GS(pid->name)==ID_AC && GS(vid->name)==ID_AC) {
359 /* the ID given is the action already - usually when F-Curve is obtained from an action's pointer */
360 act = (bAction *)pid;
363 /* the ID given is the owner of the F-Curve (for drivers) */
364 AnimData *adt = BKE_animdata_from_id(ptr->id.data);
365 act = (adt)? adt->action : NULL;
368 /* already belongs to group? */
369 if (fcu->grp == value.data) {
371 printf("ERROR: F-Curve already belongs to this group\n");
375 /* can only change group if we have info about the action the F-Curve is in
376 * (i.e. for drivers or random F-Curves, this cannot be done)
379 /* can't change the grouping of F-Curve when it doesn't belong to an action */
380 printf("ERROR: cannot assign F-Curve to group, since F-Curve is not attached to any ID\n");
383 /* make sure F-Curve exists in this action first, otherwise we could still have been tricked */
384 else if (BLI_findindex(&act->curves, fcu) == -1) {
385 printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name);
389 /* try to remove F-Curve from action (including from any existing groups) */
390 action_groups_remove_channel(act, fcu);
392 /* add the F-Curve back to the action now in the right place */
393 // TODO: make the api function handle the case where there isn't any group to assign to
395 /* add to its group using API function, which makes sure everything goes ok */
396 action_groups_add_channel(act, value.data, fcu);
399 /* need to add this back, but it can only go at the end of the list (or else will corrupt groups) */
400 BLI_addtail(&act->curves, fcu);
404 DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
406 /* call the API function for this */
407 return driver_add_new_variable(driver);
410 void rna_Driver_remove_variable(ChannelDriver *driver, ReportList *reports, DriverVar *dvar)
412 if(BLI_findindex(&driver->variables, dvar) == -1) {
413 BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver");
417 driver_free_variable(driver, dvar);
421 static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
423 FCurve *fcu= (FCurve*)ptr->data;
424 FModifier *fcm= find_active_fmodifier(&fcu->modifiers);
425 return rna_pointer_inherit_refine(ptr, &RNA_FModifier, fcm);
428 static void rna_FCurve_active_modifier_set(PointerRNA *ptr, PointerRNA value)
430 FCurve *fcu= (FCurve*)ptr->data;
431 set_active_fmodifier(&fcu->modifiers, (FModifier *)value.data);
434 static FModifier *rna_FCurve_modifiers_new(FCurve *fcu, int type)
436 return add_fmodifier(&fcu->modifiers, type);
439 static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, FModifier *fcm)
441 if(BLI_findindex(&fcu->modifiers, fcm) == -1) {
442 BKE_reportf(reports, RPT_ERROR, "F-Curve modifier '%s' not found in F-Curve", fcm->name);
445 remove_fmodifier(&fcu->modifiers, fcm);
448 static void rna_FModifier_active_set(PointerRNA *ptr, int UNUSED(value))
450 FModifier *fm= (FModifier*)ptr->data;
452 /* don't toggle, always switch on */
453 fm->flag |= FMODIFIER_FLAG_ACTIVE;
456 static void rna_FModifier_start_frame_range(PointerRNA *ptr, float *min, float *max)
458 FModifier *fcm= (FModifier*)ptr->data;
461 *max= (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)? fcm->efra : MAXFRAMEF;
464 static void rna_FModifier_end_frame_range(PointerRNA *ptr, float *min, float *max)
466 FModifier *fcm= (FModifier*)ptr->data;
468 *min= (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)? fcm->sfra : MINAFRAMEF;
472 static void rna_FModifier_blending_range(PointerRNA *ptr, float *min, float *max)
474 FModifier *fcm= (FModifier*)ptr->data;
477 *max= fcm->efra - fcm->sfra;
480 static void rna_FModifier_active_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
482 FModifier *fm, *fmo= (FModifier*)ptr->data;
484 /* clear active state of other FModifiers in this list */
485 for (fm=fmo->prev; fm; fm=fm->prev)
487 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
489 for (fm=fmo->next; fm; fm=fm->next)
491 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
496 static int rna_FModifierGenerator_coefficients_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
498 FModifier *fcm= (FModifier*)ptr->data;
499 FMod_Generator *gen= fcm->data;
502 length[0]= gen->arraysize;
504 length[0]= 100; /* for raw_access, untested */
509 static void rna_FModifierGenerator_coefficients_get(PointerRNA *ptr, float *values)
511 FModifier *fcm= (FModifier*)ptr->data;
512 FMod_Generator *gen= fcm->data;
513 memcpy(values, gen->coefficients, gen->arraysize * sizeof(float));
516 static void rna_FModifierGenerator_coefficients_set(PointerRNA *ptr, const float *values)
518 FModifier *fcm= (FModifier*)ptr->data;
519 FMod_Generator *gen= fcm->data;
520 memcpy(gen->coefficients, values, gen->arraysize * sizeof(float));
523 static void rna_FModifierLimits_minx_range(PointerRNA *ptr, float *min, float *max)
525 FModifier *fcm= (FModifier*)ptr->data;
526 FMod_Limits *data= fcm->data;
529 *max= (data->flag & FCM_LIMIT_XMAX)? data->rect.xmax : MAXFRAMEF;
532 static void rna_FModifierLimits_maxx_range(PointerRNA *ptr, float *min, float *max)
534 FModifier *fcm= (FModifier*)ptr->data;
535 FMod_Limits *data= fcm->data;
537 *min= (data->flag & FCM_LIMIT_XMIN)? data->rect.xmin : MINAFRAMEF;
541 static void rna_FModifierLimits_miny_range(PointerRNA *ptr, float *min, float *max)
543 FModifier *fcm= (FModifier*)ptr->data;
544 FMod_Limits *data= fcm->data;
547 *max= (data->flag & FCM_LIMIT_YMAX)? data->rect.ymax : FLT_MAX;
550 static void rna_FModifierLimits_maxy_range(PointerRNA *ptr, float *min, float *max)
552 FModifier *fcm= (FModifier*)ptr->data;
553 FMod_Limits *data= fcm->data;
555 *min= (data->flag & FCM_LIMIT_YMIN)? data->rect.ymin : -FLT_MAX;
560 static void rna_FModifierStepped_start_frame_range(PointerRNA *ptr, float *min, float *max)
562 FModifier *fcm= (FModifier*)ptr->data;
563 FMod_Stepped *data= fcm->data;
566 *max= (data->flag & FCM_STEPPED_NO_AFTER)? data->end_frame : MAXFRAMEF;
569 static void rna_FModifierStepped_end_frame_range(PointerRNA *ptr, float *min, float *max)
571 FModifier *fcm= (FModifier*)ptr->data;
572 FMod_Stepped *data= fcm->data;
574 *min= (data->flag & FCM_STEPPED_NO_BEFORE)? data->start_frame : MINAFRAMEF;
578 static BezTriple *rna_FKeyframe_points_insert(FCurve *fcu, float frame, float value, int flag)
580 int index= insert_vert_fcurve(fcu, frame, value, flag);
581 return ((fcu->bezt) && (index >= 0))? (fcu->bezt + index) : NULL;
584 static void rna_FKeyframe_points_add(FCurve *fcu, int tot)
589 BezTriple *nbezt= MEM_callocN(sizeof(BezTriple) * (fcu->totvert + tot), "rna_FKeyframe_points_add");
590 memcpy(nbezt, fcu->bezt, sizeof(BezTriple) * fcu->totvert);
591 MEM_freeN(fcu->bezt);
595 fcu->bezt= MEM_callocN(sizeof(BezTriple) * tot, "rna_FKeyframe_points_add");
598 bezt= fcu->bezt + fcu->totvert;
602 /* defaults, no userprefs gives pradictable results for API */
603 bezt->f1= bezt->f2= bezt->f3= SELECT;
604 bezt->ipo= BEZT_IPO_BEZ;
605 bezt->h1= bezt->h2= HD_AUTO_ANIM;
611 static void rna_FKeyframe_points_remove(FCurve *fcu, ReportList *reports, BezTriple *bezt, int do_fast)
613 int index= (int)(bezt - fcu->bezt);
614 if (index < 0 || index >= fcu->totvert) {
615 BKE_report(reports, RPT_ERROR, "Keyframe not in F-Curve");
619 delete_fcurve_key(fcu, index, !do_fast);
622 static void rna_fcurve_range(FCurve *fcu, float range[2])
624 calc_fcurve_range(fcu, range, range+1, FALSE);
629 static void rna_def_fmodifier_generator(BlenderRNA *brna)
634 static EnumPropertyItem generator_mode_items[] = {
635 {FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""},
636 {FCM_GENERATOR_POLYNOMIAL_FACTORISED, "POLYNOMIAL_FACTORISED", 0, "Factorised Polynomial", ""},
637 {0, NULL, 0, NULL, NULL}};
639 srna= RNA_def_struct(brna, "FModifierGenerator", "FModifier");
640 RNA_def_struct_ui_text(srna, "Generator F-Curve Modifier", "Deterministically generates values for the modified F-Curve");
641 RNA_def_struct_sdna_from(srna, "FMod_Generator", "data");
643 /* define common props */
644 prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
645 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
646 RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
647 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
649 // XXX this has a special validation func
650 prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
651 RNA_def_property_enum_items(prop, generator_mode_items);
652 RNA_def_property_ui_text(prop, "Mode", "Type of generator to use");
653 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
656 /* order of the polynomial */
657 // XXX this has a special validation func
658 prop= RNA_def_property(srna, "poly_order", PROP_INT, PROP_NONE);
659 RNA_def_property_ui_text(prop, "Polynomial Order", "The highest power of 'x' for this polynomial. (number of coefficients - 1)");
660 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
662 /* coefficients array */
663 prop= RNA_def_property(srna, "coefficients", PROP_FLOAT, PROP_NONE);
664 RNA_def_property_array(prop, 32);
665 RNA_def_property_flag(prop, PROP_DYNAMIC);
666 RNA_def_property_dynamic_array_funcs(prop, "rna_FModifierGenerator_coefficients_get_length");
667 RNA_def_property_float_funcs(prop, "rna_FModifierGenerator_coefficients_get", "rna_FModifierGenerator_coefficients_set", NULL);
668 RNA_def_property_ui_text(prop, "Coefficients", "Coefficients for 'x' (starting from lowest power of x^0)");
673 static void rna_def_fmodifier_function_generator(BlenderRNA *brna)
678 static EnumPropertyItem prop_type_items[] = {
679 {0, "SIN", 0, "Sine", ""},
680 {1, "COS", 0, "Cosine", ""},
681 {2, "TAN", 0, "Tangent", ""},
682 {3, "SQRT", 0, "Square Root", ""},
683 {4, "LN", 0, "Natural Logarithm", ""},
684 {5, "SINC", 0, "Normalised Sine", "sin(x) / x"},
685 {0, NULL, 0, NULL, NULL}};
687 srna= RNA_def_struct(brna, "FModifierFunctionGenerator", "FModifier");
688 RNA_def_struct_ui_text(srna, "Built-In Function F-Modifier", "Generates values using a Built-In Function");
689 RNA_def_struct_sdna_from(srna, "FMod_FunctionGenerator", "data");
692 prop= RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
693 RNA_def_property_ui_text(prop, "Amplitude", "Scale factor determining the maximum/minimum values");
694 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
696 prop= RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE);
697 RNA_def_property_ui_text(prop, "Phase Multiplier", "Scale factor determining the 'speed' of the function");
698 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
700 prop= RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE);
701 RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function");
702 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
704 prop= RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE);
705 RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by");
706 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
709 prop= RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
710 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_GENERATOR_ADDITIVE);
711 RNA_def_property_ui_text(prop, "Additive", "Values generated by this modifier are applied on top of the existing values instead of overwriting them");
712 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
714 prop= RNA_def_property(srna, "function_type", PROP_ENUM, PROP_NONE);
715 RNA_def_property_enum_sdna(prop, NULL, "type");
716 RNA_def_property_enum_items(prop, prop_type_items);
717 RNA_def_property_ui_text(prop, "Type", "Type of built-in function to use");
718 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
723 static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna)
728 srna= RNA_def_struct(brna, "FModifierEnvelopeControlPoint", NULL);
729 RNA_def_struct_ui_text(srna, "Envelope Control Point", "Control point for envelope F-Modifier");
730 RNA_def_struct_sdna(srna, "FCM_EnvelopeData");
733 * - for now, these are allowed to go past each other, so that we can have inverted action
734 * - technically, the range is limited by the settings in the envelope-modifier data, not here...
736 prop= RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
737 RNA_def_property_float_sdna(prop, NULL, "min");
738 RNA_def_property_ui_text(prop, "Minimum Value", "Lower bound of envelope at this control-point");
739 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
741 prop= RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
742 RNA_def_property_float_sdna(prop, NULL, "max");
743 RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point");
744 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
747 prop= RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
748 RNA_def_property_float_sdna(prop, NULL, "time");
749 RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on");
750 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
753 // - selection flags (not implemented in UI yet though)
756 static void rna_def_fmodifier_envelope(BlenderRNA *brna)
761 srna= RNA_def_struct(brna, "FModifierEnvelope", "FModifier");
762 RNA_def_struct_ui_text(srna, "Envelope F-Modifier", "Scales the values of the modified F-Curve");
763 RNA_def_struct_sdna_from(srna, "FMod_Envelope", "data");
766 prop= RNA_def_property(srna, "control_points", PROP_COLLECTION, PROP_NONE);
767 RNA_def_property_collection_sdna(prop, NULL, "data", "totvert");
768 RNA_def_property_struct_type(prop, "FModifierEnvelopeControlPoint");
769 RNA_def_property_ui_text(prop, "Control Points", "Control points defining the shape of the envelope");
772 prop= RNA_def_property(srna, "reference_value", PROP_FLOAT, PROP_NONE);
773 RNA_def_property_float_sdna(prop, NULL, "midval");
774 RNA_def_property_ui_text(prop, "Reference Value", "Value that envelope's influence is centered around / based on");
775 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
777 prop= RNA_def_property(srna, "default_min", PROP_FLOAT, PROP_NONE);
778 RNA_def_property_float_sdna(prop, NULL, "min");
779 RNA_def_property_ui_text(prop, "Default Minimum", "Lower distance from Reference Value for 1:1 default influence");
780 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
782 prop= RNA_def_property(srna, "default_max", PROP_FLOAT, PROP_NONE);
783 RNA_def_property_float_sdna(prop, NULL, "max");
784 RNA_def_property_ui_text(prop, "Default Maximum", "Upper distance from Reference Value for 1:1 default influence");
785 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
790 static void rna_def_fmodifier_cycles(BlenderRNA *brna)
795 static EnumPropertyItem prop_type_items[] = {
796 {FCM_EXTRAPOLATE_NONE, "NONE", 0, "No Cycles", "Don't do anything"},
797 {FCM_EXTRAPOLATE_CYCLIC, "REPEAT", 0, "Repeat Motion", "Repeat keyframe range as-is"},
798 {FCM_EXTRAPOLATE_CYCLIC_OFFSET, "REPEAT_OFFSET", 0, "Repeat with Offset", "Repeat keyframe range, but with offset based on gradient between values"},
799 {FCM_EXTRAPOLATE_MIRROR, "MIRROR", 0, "Repeat Mirrored", "Alternate between forward and reverse playback of keyframe range"},
800 {0, NULL, 0, NULL, NULL}};
802 srna= RNA_def_struct(brna, "FModifierCycles", "FModifier");
803 RNA_def_struct_ui_text(srna, "Cycles F-Modifier", "Repeats the values of the modified F-Curve");
804 RNA_def_struct_sdna_from(srna, "FMod_Cycles", "data");
807 prop= RNA_def_property(srna, "mode_before", PROP_ENUM, PROP_NONE);
808 RNA_def_property_enum_sdna(prop, NULL, "before_mode");
809 RNA_def_property_enum_items(prop, prop_type_items);
810 RNA_def_property_ui_text(prop, "Before Mode", "Cycling mode to use before first keyframe");
811 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
813 prop= RNA_def_property(srna, "cycles_before", PROP_INT, PROP_NONE);
814 RNA_def_property_int_sdna(prop, NULL, "before_cycles");
815 RNA_def_property_ui_text(prop, "Before Cycles", "Maximum number of cycles to allow before first keyframe. (0 = infinite)");
816 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
819 prop= RNA_def_property(srna, "mode_after", PROP_ENUM, PROP_NONE);
820 RNA_def_property_enum_sdna(prop, NULL, "after_mode");
821 RNA_def_property_enum_items(prop, prop_type_items);
822 RNA_def_property_ui_text(prop, "After Mode", "Cycling mode to use after last keyframe");
823 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
825 prop= RNA_def_property(srna, "cycles_after", PROP_INT, PROP_NONE);
826 RNA_def_property_int_sdna(prop, NULL, "after_cycles");
827 RNA_def_property_ui_text(prop, "After Cycles", "Maximum number of cycles to allow after last keyframe. (0 = infinite)");
828 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
833 static void rna_def_fmodifier_python(BlenderRNA *brna)
838 srna= RNA_def_struct(brna, "FModifierPython", "FModifier");
839 RNA_def_struct_ui_text(srna, "Python F-Modifier", "Performs user-defined operation on the modified F-Curve");
840 RNA_def_struct_sdna_from(srna, "FMod_Python", "data");
845 static void rna_def_fmodifier_limits(BlenderRNA *brna)
850 srna= RNA_def_struct(brna, "FModifierLimits", "FModifier");
851 RNA_def_struct_ui_text(srna, "Limits F-Modifier", "Limits the time/value ranges of the modified F-Curve");
852 RNA_def_struct_sdna_from(srna, "FMod_Limits", "data");
854 prop= RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
855 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMIN);
856 RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value");
857 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
859 prop= RNA_def_property(srna, "use_min_y", PROP_BOOLEAN, PROP_NONE);
860 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMIN);
861 RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
862 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
864 prop= RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
865 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_XMAX);
866 RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
867 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
869 prop= RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
870 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_LIMIT_YMAX);
871 RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
872 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
874 prop= RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
875 RNA_def_property_float_sdna(prop, NULL, "rect.xmin");
876 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_minx_range");
877 RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
878 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
880 prop= RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
881 RNA_def_property_float_sdna(prop, NULL, "rect.ymin");
882 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_miny_range");
883 RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
884 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
886 prop= RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
887 RNA_def_property_float_sdna(prop, NULL, "rect.xmax");
888 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxx_range");
889 RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
890 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
892 prop= RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
893 RNA_def_property_float_sdna(prop, NULL, "rect.ymax");
894 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierLimits_maxy_range");
895 RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
896 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
901 static void rna_def_fmodifier_noise(BlenderRNA *brna)
906 static EnumPropertyItem prop_modification_items[] = {
907 {FCM_NOISE_MODIF_REPLACE, "REPLACE", 0, "Replace", ""},
908 {FCM_NOISE_MODIF_ADD, "ADD", 0, "Add", ""},
909 {FCM_NOISE_MODIF_SUBTRACT, "SUBTRACT", 0, "Subtract", ""},
910 {FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", 0, "Multiply", ""},
911 {0, NULL, 0, NULL, NULL}};
913 srna= RNA_def_struct(brna, "FModifierNoise", "FModifier");
914 RNA_def_struct_ui_text(srna, "Noise F-Modifier", "Gives randomness to the modified F-Curve");
915 RNA_def_struct_sdna_from(srna, "FMod_Noise", "data");
917 prop= RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
918 RNA_def_property_enum_sdna(prop, NULL, "modification");
919 RNA_def_property_enum_items(prop, prop_modification_items);
920 RNA_def_property_ui_text(prop, "Blend Type", "Method of modifying the existing F-Curve");
921 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
923 prop= RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
924 RNA_def_property_float_sdna(prop, NULL, "size");
925 RNA_def_property_ui_text(prop, "Scale", "Scaling (in time) of the noise");
926 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
928 prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
929 RNA_def_property_float_sdna(prop, NULL, "strength");
930 RNA_def_property_ui_text(prop, "Strength", "Amplitude of the noise - the amount that it modifies the underlying curve");
931 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
933 prop= RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
934 RNA_def_property_float_sdna(prop, NULL, "phase");
935 RNA_def_property_ui_text(prop, "Phase", "A random seed for the noise effect");
936 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
938 prop= RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
939 RNA_def_property_int_sdna(prop, NULL, "depth");
940 RNA_def_property_ui_text(prop, "Depth", "Amount of fine level detail present in the noise");
941 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
947 static void rna_def_fmodifier_stepped(BlenderRNA *brna)
952 srna= RNA_def_struct(brna, "FModifierStepped", "FModifier");
953 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");
954 RNA_def_struct_sdna_from(srna, "FMod_Stepped", "data");
957 prop= RNA_def_property(srna, "frame_step", PROP_FLOAT, PROP_NONE);
958 RNA_def_property_float_sdna(prop, NULL, "step_size");
959 RNA_def_property_ui_text(prop, "Step Size", "Number of frames to hold each value");
960 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
962 prop= RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
963 RNA_def_property_float_sdna(prop, NULL, "offset");
964 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");
965 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
967 prop= RNA_def_property(srna, "use_frame_start", PROP_BOOLEAN, PROP_NONE);
968 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_BEFORE);
969 RNA_def_property_ui_text(prop, "Use Start Frame", "Restrict modifier to only act after its 'start' frame");
970 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
972 prop= RNA_def_property(srna, "use_frame_end", PROP_BOOLEAN, PROP_NONE);
973 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCM_STEPPED_NO_AFTER);
974 RNA_def_property_ui_text(prop, "Use End Frame", "Restrict modifier to only act before its 'end' frame");
975 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
977 prop= RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
978 RNA_def_property_float_sdna(prop, NULL, "start_frame");
979 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_start_frame_range");
980 RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
981 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
983 prop= RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
984 RNA_def_property_float_sdna(prop, NULL, "end_frame");
985 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifierStepped_end_frame_range");
986 RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if applicable)");
987 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
993 static void rna_def_fmodifier(BlenderRNA *brna)
998 /* base struct definition */
999 srna= RNA_def_struct(brna, "FModifier", NULL);
1000 RNA_def_struct_refine_func(srna, "rna_FModifierType_refine");
1001 RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve");
1003 #if 0 // XXX not used yet
1005 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1006 RNA_def_struct_name_property(srna, prop);
1007 RNA_def_property_ui_text(prop, "Name", "Short description of F-Curve Modifier");
1008 #endif // XXX not used yet
1011 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1012 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1013 RNA_def_property_enum_items(prop, fmodifier_type_items);
1014 RNA_def_property_ui_text(prop, "Type", "F-Curve Modifier Type");
1017 prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
1018 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_EXPANDED);
1019 RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI");
1020 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1);
1022 prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1023 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_MUTED);
1024 RNA_def_property_ui_text(prop, "Muted", "F-Curve Modifier will not be evaluated");
1025 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1026 RNA_def_property_ui_icon(prop, ICON_MUTE_IPO_OFF, 1);
1028 prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1029 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1030 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FMODIFIER_FLAG_DISABLED);
1031 RNA_def_property_ui_text(prop, "Disabled", "F-Curve Modifier has invalid settings and will not be evaluated");
1032 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1034 // TODO: setting this to true must ensure that all others in stack are turned off too...
1035 prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1036 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_ACTIVE);
1037 RNA_def_property_ui_text(prop, "Active", "F-Curve Modifier is the one being edited ");
1038 RNA_def_property_boolean_funcs(prop, NULL, "rna_FModifier_active_set");
1039 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, "rna_FModifier_active_update");
1040 RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
1042 /* restricted range */
1043 prop= RNA_def_property(srna, "use_restricted_range", PROP_BOOLEAN, PROP_NONE);
1044 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_RANGERESTRICT);
1045 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");
1046 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1047 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); // XXX: depends on UI implementation
1049 prop= RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
1050 RNA_def_property_float_sdna(prop, NULL, "sfra");
1051 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_start_frame_range");
1052 RNA_def_property_ui_text(prop, "Start Frame", "Frame that modifier's influence starts (if Restrict Frame Range is in use)");
1053 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1055 prop= RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
1056 RNA_def_property_float_sdna(prop, NULL, "efra");
1057 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_end_frame_range");
1058 RNA_def_property_ui_text(prop, "End Frame", "Frame that modifier's influence ends (if Restrict Frame Range is in use)");
1059 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1061 prop= RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE);
1062 RNA_def_property_float_sdna(prop, NULL, "blendin");
1063 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_blending_range");
1064 RNA_def_property_ui_text(prop, "Blend In", "Number of frames from start frame for influence to take effect");
1065 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1067 prop= RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE);
1068 RNA_def_property_float_sdna(prop, NULL, "blendout");
1069 RNA_def_property_float_funcs(prop, NULL, NULL, "rna_FModifier_blending_range");
1070 RNA_def_property_ui_text(prop, "Blend Out", "Number of frames from start frame for influence to fade out");
1071 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1074 prop= RNA_def_property(srna, "use_influence", PROP_BOOLEAN, PROP_NONE);
1075 RNA_def_property_boolean_sdna(prop, NULL, "flag", FMODIFIER_FLAG_USEINFLUENCE);
1076 RNA_def_property_ui_text(prop, "Use Influence", "F-Curve Modifier's effects will be tempered by a default factor");
1077 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1078 RNA_def_property_ui_icon(prop, ICON_TRIA_RIGHT, 1); // XXX: depends on UI implementation
1080 prop= RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
1081 RNA_def_property_float_sdna(prop, NULL, "influence");
1082 RNA_def_property_range(prop, 0.0f, 1.0f);
1083 RNA_def_property_float_default(prop, 1.0f);
1084 RNA_def_property_ui_text(prop, "Influence", "Amount of influence F-Curve Modifier will have when not fading in/out");
1085 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1088 /* *********************** */
1090 static void rna_def_drivertarget(BlenderRNA *brna)
1095 static EnumPropertyItem prop_trans_chan_items[] = {
1096 {DTAR_TRANSCHAN_LOCX, "LOC_X", 0, "X Location", ""},
1097 {DTAR_TRANSCHAN_LOCY, "LOC_Y", 0, "Y Location", ""},
1098 {DTAR_TRANSCHAN_LOCZ, "LOC_Z", 0, "Z Location", ""},
1099 {DTAR_TRANSCHAN_ROTX, "ROT_X", 0, "X Rotation", ""},
1100 {DTAR_TRANSCHAN_ROTY, "ROT_Y", 0, "Y Rotation", ""},
1101 {DTAR_TRANSCHAN_ROTZ, "ROT_Z", 0, "Z Rotation", ""},
1102 {DTAR_TRANSCHAN_SCALEX, "SCALE_X", 0, "X Scale", ""},
1103 {DTAR_TRANSCHAN_SCALEY, "SCALE_Y", 0, "Y Scale", ""},
1104 {DTAR_TRANSCHAN_SCALEZ, "SCALE_Z", 0, "Z Scale", ""},
1105 {0, NULL, 0, NULL, NULL}};
1107 static EnumPropertyItem prop_local_space_items[] = {
1108 {0, "WORLD_SPACE", 0, "World Space", "Transforms include effects of parenting/restpose and constraints"},
1109 {DTAR_FLAG_LOCALSPACE, "TRANSFORM_SPACE", 0, "Transform Space", "Transforms don't include parenting/restpose or constraints"},
1110 {DTAR_FLAG_LOCALSPACE|DTAR_FLAG_LOCAL_CONSTS, "LOCAL_SPACE", 0, "Local Space", "Transforms include effects of constraints but not parenting/restpose"},
1111 {0, NULL, 0, NULL, NULL}};
1113 srna= RNA_def_struct(brna, "DriverTarget", NULL);
1114 RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables");
1116 /* Target Properties - ID-block to Drive */
1117 prop= RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1118 RNA_def_property_struct_type(prop, "ID");
1119 RNA_def_property_flag(prop, PROP_EDITABLE);
1120 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
1121 /* note: custom set function is ONLY to avoid rna setting a user for this. */
1122 RNA_def_property_pointer_funcs(prop, NULL, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", NULL);
1123 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)");
1124 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1126 prop= RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
1127 RNA_def_property_enum_sdna(prop, NULL, "idtype");
1128 RNA_def_property_enum_items(prop, id_type_items);
1129 RNA_def_property_enum_default(prop, ID_OB);
1130 RNA_def_property_enum_funcs(prop, NULL, "rna_DriverTarget_id_type_set", NULL);
1131 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_type_editable");
1132 RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
1133 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1135 /* Target Properties - Property to Drive */
1136 prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
1137 RNA_def_property_string_funcs(prop, "rna_DriverTarget_RnaPath_get", "rna_DriverTarget_RnaPath_length", "rna_DriverTarget_RnaPath_set");
1138 RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from ID-block) to property used");
1139 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1141 prop= RNA_def_property(srna, "bone_target", PROP_STRING, PROP_NONE);
1142 RNA_def_property_string_sdna(prop, NULL, "pchan_name");
1143 RNA_def_property_ui_text(prop, "Bone Name", "Name of PoseBone to use as target");
1144 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1146 prop= RNA_def_property(srna, "transform_type", PROP_ENUM, PROP_NONE);
1147 RNA_def_property_enum_sdna(prop, NULL, "transChan");
1148 RNA_def_property_enum_items(prop, prop_trans_chan_items);
1149 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
1150 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1152 prop= RNA_def_property(srna, "transform_space", PROP_ENUM, PROP_NONE);
1153 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
1154 RNA_def_property_enum_items(prop, prop_local_space_items);
1155 RNA_def_property_ui_text(prop, "Transform Space", "Space in which transforms are used");
1156 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1159 static void rna_def_drivervar(BlenderRNA *brna)
1164 static EnumPropertyItem prop_type_items[] = {
1165 {DVAR_TYPE_SINGLE_PROP, "SINGLE_PROP", 0, "Single Property", "Use the value from some RNA property (Default)"},
1166 {DVAR_TYPE_TRANSFORM_CHAN, "TRANSFORMS", 0, "Transform Channel", "Final transformation value of object or bone"},
1167 {DVAR_TYPE_ROT_DIFF, "ROTATION_DIFF", 0, "Rotational Difference", "Use the angle between two bones"},
1168 {DVAR_TYPE_LOC_DIFF, "LOC_DIFF", 0, "Distance", "Distance between two bones or objects"},
1169 {0, NULL, 0, NULL, NULL}};
1172 srna= RNA_def_struct(brna, "DriverVariable", NULL);
1173 RNA_def_struct_sdna(srna, "DriverVar");
1174 RNA_def_struct_ui_text(srna, "Driver Variable", "Variable from some source/target for driver relationship");
1177 prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1178 RNA_def_struct_name_property(srna, prop);
1179 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)");
1180 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_name"); // XXX
1183 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1184 RNA_def_property_enum_items(prop, prop_type_items);
1185 RNA_def_property_enum_funcs(prop, NULL, "rna_DriverVariable_type_set", NULL);
1186 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
1187 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data"); // XXX
1190 // TODO: for nicer api, only expose the relevant props via subclassing, instead of exposing the collection of targets
1191 prop= RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
1192 RNA_def_property_collection_sdna(prop, NULL, "targets", "num_targets");
1193 RNA_def_property_struct_type(prop, "DriverTarget");
1194 RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable");
1198 /* channeldriver.variables.* */
1199 static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop)
1202 // PropertyRNA *prop;
1207 RNA_def_property_srna(cprop, "ChannelDriverVariables");
1208 srna= RNA_def_struct(brna, "ChannelDriverVariables", NULL);
1209 RNA_def_struct_sdna(srna, "ChannelDriver");
1210 RNA_def_struct_ui_text(srna, "ChannelDriver Variables", "Collection of channel driver Variables");
1214 func= RNA_def_function(srna, "new", "rna_Driver_new_variable");
1215 RNA_def_function_ui_description(func, "Add a new variable for the driver");
1217 parm= RNA_def_pointer(func, "var", "DriverVariable", "", "Newly created Driver Variable");
1218 RNA_def_function_return(func, parm);
1220 /* remove variable */
1221 func= RNA_def_function(srna, "remove", "rna_Driver_remove_variable");
1222 RNA_def_function_ui_description(func, "Remove an existing variable from the driver");
1223 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1224 /* target to remove */
1225 parm= RNA_def_pointer(func, "variable", "DriverVariable", "", "Variable to remove from the driver");
1226 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1229 static void rna_def_channeldriver(BlenderRNA *brna)
1234 static EnumPropertyItem prop_type_items[] = {
1235 {DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""},
1236 {DRIVER_TYPE_SUM, "SUM", 0, "Sum Values", ""},
1237 {DRIVER_TYPE_PYTHON, "SCRIPTED", 0, "Scripted Expression", ""},
1238 {DRIVER_TYPE_MIN, "MIN", 0, "Minimum Value", ""},
1239 {DRIVER_TYPE_MAX, "MAX", 0, "Maximum Value", ""},
1240 {0, NULL, 0, NULL, NULL}};
1242 srna= RNA_def_struct(brna, "Driver", NULL);
1243 RNA_def_struct_sdna(srna, "ChannelDriver");
1244 RNA_def_struct_ui_text(srna, "Driver", "Driver for the value of a setting based on an external value");
1245 RNA_def_struct_ui_icon(srna, ICON_DRIVER);
1248 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1249 RNA_def_property_enum_items(prop, prop_type_items);
1250 RNA_def_property_ui_text(prop, "Type", "Driver type");
1251 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data");
1254 prop= RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE);
1255 RNA_def_property_ui_text(prop, "Expression", "Expression to use for Scripted Expression");
1256 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_expr");
1259 prop= RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE);
1260 RNA_def_property_collection_sdna(prop, NULL, "variables", NULL);
1261 RNA_def_property_struct_type(prop, "DriverVariable");
1262 RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver");
1263 rna_def_channeldriver_variables(brna, prop);
1266 prop= RNA_def_property(srna, "show_debug_info", PROP_BOOLEAN, PROP_NONE);
1267 RNA_def_property_boolean_sdna(prop, NULL, "flag", DRIVER_FLAG_SHOWDEBUG);
1268 RNA_def_property_ui_text(prop, "Show Debug Info", "Show intermediate values for the driver calculations to allow debugging of drivers");
1270 /* State Info (for Debugging) */
1271 prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1272 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", DRIVER_FLAG_INVALID);
1273 RNA_def_property_ui_text(prop, "Invalid", "Driver could not be evaluated in past, so should be skipped");
1277 RNA_api_drivers(srna);
1280 /* *********************** */
1282 static void rna_def_fpoint(BlenderRNA *brna)
1287 srna= RNA_def_struct(brna, "FCurveSample", NULL);
1288 RNA_def_struct_sdna(srna, "FPoint");
1289 RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve");
1291 /* Boolean values */
1292 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1293 RNA_def_property_boolean_sdna(prop, NULL, "flag", 1);
1294 RNA_def_property_ui_text(prop, "Select", "Selection status");
1295 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1298 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
1299 RNA_def_property_float_sdna(prop, NULL, "vec");
1300 RNA_def_property_array(prop, 2);
1301 RNA_def_property_ui_text(prop, "Point", "Point coordinates");
1302 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1306 /* duplicate of BezTriple in rna_curve.c
1307 * but with F-Curve specific options updates/functionality
1309 static void rna_def_fkeyframe(BlenderRNA *brna)
1314 srna= RNA_def_struct(brna, "Keyframe", NULL);
1315 RNA_def_struct_sdna(srna, "BezTriple");
1316 RNA_def_struct_ui_text(srna, "Keyframe", "Bezier curve point with two handles defining a Keyframe on an F-Curve");
1318 /* Boolean values */
1319 prop= RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
1320 RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
1321 RNA_def_property_ui_text(prop, "Handle 1 selected", "Left handle selection status");
1322 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1324 prop= RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
1325 RNA_def_property_boolean_sdna(prop, NULL, "f3", 0);
1326 RNA_def_property_ui_text(prop, "Handle 2 selected", "Right handle selection status");
1327 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1329 prop= RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
1330 RNA_def_property_boolean_sdna(prop, NULL, "f2", 0);
1331 RNA_def_property_ui_text(prop, "Select", "Control point selection status");
1332 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1335 prop= RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
1336 RNA_def_property_enum_sdna(prop, NULL, "h1");
1337 RNA_def_property_enum_items(prop, keyframe_handle_type_items);
1338 RNA_def_property_ui_text(prop, "Left Handle Type", "Handle types");
1339 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1341 prop= RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
1342 RNA_def_property_enum_sdna(prop, NULL, "h2");
1343 RNA_def_property_enum_items(prop, keyframe_handle_type_items);
1344 RNA_def_property_ui_text(prop, "Right Handle Type", "Handle types");
1345 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1347 prop= RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
1348 RNA_def_property_enum_sdna(prop, NULL, "ipo");
1349 RNA_def_property_enum_items(prop, beztriple_interpolation_mode_items);
1350 RNA_def_property_ui_text(prop, "Interpolation", "Interpolation method to use for segment of the curve from this Keyframe until the next Keyframe");
1351 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1353 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1354 RNA_def_property_enum_sdna(prop, NULL, "hide");
1355 RNA_def_property_enum_items(prop, beztriple_keyframe_type_items);
1356 RNA_def_property_ui_text(prop, "Type", "The type of keyframe (for visual purposes only");
1357 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1360 prop= RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
1361 RNA_def_property_array(prop, 2);
1362 RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle1_get", "rna_FKeyframe_handle1_set", NULL);
1363 RNA_def_property_ui_text(prop, "Left Handle", "Coordinates of the left handle (before the control point)");
1364 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1366 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
1367 RNA_def_property_array(prop, 2);
1368 RNA_def_property_float_funcs(prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_set", NULL);
1369 RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
1370 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1372 prop= RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
1373 RNA_def_property_array(prop, 2);
1374 RNA_def_property_float_funcs(prop, "rna_FKeyframe_handle2_get", "rna_FKeyframe_handle2_set", NULL);
1375 RNA_def_property_ui_text(prop, "Right Handle", "Coordinates of the right handle (after the control point)");
1376 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
1379 static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
1388 RNA_def_property_srna(cprop, "FCurveModifiers");
1389 srna= RNA_def_struct(brna, "FCurveModifiers", NULL);
1390 RNA_def_struct_sdna(srna, "FCurve");
1391 RNA_def_struct_ui_text(srna, "F-Curve Modifiers", "Collection of F-Curve Modifiers");
1394 /* Collection active property */
1395 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1396 RNA_def_property_struct_type(prop, "FModifier");
1397 RNA_def_property_pointer_funcs(prop, "rna_FCurve_active_modifier_get", "rna_FCurve_active_modifier_set", NULL, NULL);
1398 RNA_def_property_flag(prop, PROP_EDITABLE);
1399 RNA_def_property_ui_text(prop, "Active F-Curve Modifier", "Active F-Curve Modifier");
1401 /* Constraint collection */
1402 func= RNA_def_function(srna, "new", "rna_FCurve_modifiers_new");
1403 RNA_def_function_ui_description(func, "Add a constraint to this object");
1405 parm= RNA_def_pointer(func, "fmodifier", "FModifier", "", "New fmodifier");
1406 RNA_def_function_return(func, parm);
1408 parm= RNA_def_enum(func, "type", fmodifier_type_items, 1, "", "Constraint type to add");
1409 RNA_def_property_flag(parm, PROP_REQUIRED);
1411 func= RNA_def_function(srna, "remove", "rna_FCurve_modifiers_remove");
1412 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1413 RNA_def_function_ui_description(func, "Remove a modifier from this F-Curve");
1414 /* modifier to remove */
1415 parm= RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier");
1416 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1419 /* fcurve.keyframe_points */
1420 static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
1427 static EnumPropertyItem keyframe_flag_items[] = {
1428 {INSERTKEY_REPLACE, "REPLACE", 0, "Replace", "Don't add any new keyframes, but just replace existing ones"},
1429 {INSERTKEY_NEEDED, "NEEDED", 0, "Needed", "Only adds keyframes that are needed"},
1430 {INSERTKEY_FAST, "FAST", 0, "Fast", "Fast keyframe insertion to avoid recalculating the curve each time"},
1431 {0, NULL, 0, NULL, NULL}};
1433 RNA_def_property_srna(cprop, "FCurveKeyframePoints");
1434 srna= RNA_def_struct(brna, "FCurveKeyframePoints", NULL);
1435 RNA_def_struct_sdna(srna, "FCurve");
1436 RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points");
1438 func= RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert");
1439 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve");
1440 parm= RNA_def_float(func, "frame", 0.0f, -FLT_MAX, FLT_MAX, "", "X Value of this keyframe point", -FLT_MAX, FLT_MAX);
1441 RNA_def_property_flag(parm, PROP_REQUIRED);
1442 parm= RNA_def_float(func, "value", 0.0f, -FLT_MAX, FLT_MAX, "", "Y Value of this keyframe point", -FLT_MAX, FLT_MAX);
1443 RNA_def_property_flag(parm, PROP_REQUIRED);
1445 RNA_def_enum_flag(func, "options", keyframe_flag_items, 0, "", "Keyframe options");
1447 parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
1448 RNA_def_function_return(func, parm);
1450 func= RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
1451 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve");
1452 RNA_def_int(func, "count", 1, 1, INT_MAX, "Number", "Number of points to add to the spline", 1, INT_MAX);
1454 func= RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
1455 RNA_def_function_ui_description(func, "Remove keyframe from an F-Curve");
1456 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1457 parm= RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove");
1458 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1460 RNA_def_boolean(func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating the curve each time");
1463 static void rna_def_fcurve(BlenderRNA *brna)
1470 static EnumPropertyItem prop_mode_extend_items[] = {
1471 {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant", ""},
1472 {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear", ""},
1473 {0, NULL, 0, NULL, NULL}};
1474 static EnumPropertyItem prop_mode_color_items[] = {
1475 {FCURVE_COLOR_AUTO_RAINBOW, "AUTO_RAINBOW", 0, "Auto Rainbow", ""},
1476 {FCURVE_COLOR_AUTO_RGB, "AUTO_RGB", 0, "Auto XYZ to RGB", ""},
1477 {FCURVE_COLOR_CUSTOM, "CUSTOM", 0, "User Defined", ""},
1478 {0, NULL, 0, NULL, NULL}};
1480 srna= RNA_def_struct(brna, "FCurve", NULL);
1481 RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time");
1482 RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
1485 prop= RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
1486 RNA_def_property_enum_sdna(prop, NULL, "extend");
1487 RNA_def_property_enum_items(prop, prop_mode_extend_items);
1488 RNA_def_property_ui_text(prop, "Extrapolation", "");
1489 RNA_def_property_update(prop, NC_ANIMATION, NULL); // XXX need an update callback for this so that animation gets evaluated
1492 prop= RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE);
1493 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1494 RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)");
1496 prop= RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
1497 RNA_def_property_pointer_sdna(prop, NULL, "grp");
1498 RNA_def_property_flag(prop, PROP_EDITABLE);
1499 RNA_def_property_ui_text(prop, "Group", "Action Group that this F-Curve belongs to");
1500 RNA_def_property_pointer_funcs(prop, NULL, "rna_FCurve_group_set", NULL, NULL);
1501 RNA_def_property_update(prop, NC_ANIMATION, NULL);
1503 /* Path + Array Index */
1504 prop= RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
1505 RNA_def_property_string_funcs(prop, "rna_FCurve_RnaPath_get", "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set");
1506 RNA_def_property_ui_text(prop, "Data Path", "RNA Path to property affected by F-Curve");
1507 RNA_def_property_update(prop, NC_ANIMATION, NULL); // XXX need an update callback for this to that animation gets evaluated
1509 /* called 'index' when given as function arg */
1510 prop= RNA_def_property(srna, "array_index", PROP_INT, PROP_NONE);
1511 RNA_def_property_ui_text(prop, "RNA Array Index", "Index to the specific property affected by F-Curve if applicable");
1512 RNA_def_property_update(prop, NC_ANIMATION, NULL); // XXX need an update callback for this so that animation gets evaluated
1515 prop= RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
1516 RNA_def_property_enum_items(prop, prop_mode_color_items);
1517 RNA_def_property_ui_text(prop, "Color Mode", "Method used to determine color of F-Curve in Graph Editor");
1518 RNA_def_property_update(prop, NC_ANIMATION, NULL);
1520 prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);
1521 RNA_def_property_array(prop, 3);
1522 RNA_def_property_range(prop, 0.0f, 1.0f);
1523 RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor");
1524 RNA_def_property_update(prop, NC_ANIMATION, NULL);
1527 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1528 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_SELECTED);
1529 RNA_def_property_ui_text(prop, "Select", "F-Curve is selected for editing");
1530 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL);
1532 prop= RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
1533 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_PROTECTED);
1534 RNA_def_property_ui_text(prop, "Lock", "F-Curve's settings cannot be edited");
1535 RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
1537 prop= RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1538 RNA_def_property_boolean_sdna(prop, NULL, "flag", FCURVE_MUTED);
1539 RNA_def_property_ui_text(prop, "Muted", "F-Curve is not evaluated");
1540 RNA_def_property_update(prop, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL);
1542 prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1543 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_VISIBLE);
1544 RNA_def_property_ui_text(prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs");
1545 RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
1547 /* State Info (for Debugging) */
1548 prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1549 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", FCURVE_DISABLED);
1550 RNA_def_property_ui_text(prop, "Valid", "False when F-Curve could not be evaluated in past, so should be skipped when evaluating");
1551 RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL);
1554 prop= RNA_def_property(srna, "sampled_points", PROP_COLLECTION, PROP_NONE);
1555 RNA_def_property_collection_sdna(prop, NULL, "fpt", "totvert");
1556 RNA_def_property_struct_type(prop, "FCurveSample");
1557 RNA_def_property_ui_text(prop, "Sampled Points", "Sampled animation data");
1559 prop= RNA_def_property(srna, "keyframe_points", PROP_COLLECTION, PROP_NONE);
1560 RNA_def_property_collection_sdna(prop, NULL, "bezt", "totvert");
1561 RNA_def_property_struct_type(prop, "Keyframe");
1562 RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes");
1563 rna_def_fcurve_keyframe_points(brna, prop);
1565 prop= RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
1566 RNA_def_property_struct_type(prop, "FModifier");
1567 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the shape of the F-Curve");
1568 rna_def_fcurve_modifiers(brna, prop);
1571 func= RNA_def_function(srna, "evaluate", "evaluate_fcurve"); /* calls the C/API direct */
1572 RNA_def_function_ui_description(func, "Evaluate F-Curve");
1573 parm= RNA_def_float(func, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame", "Evaluate F-Curve at given frame", -FLT_MAX, FLT_MAX);
1574 RNA_def_property_flag(parm, PROP_REQUIRED);
1576 parm= RNA_def_float(func, "position", 0, -FLT_MAX, FLT_MAX, "Position", "F-Curve position", -FLT_MAX, FLT_MAX);
1577 RNA_def_function_return(func, parm);
1579 func= RNA_def_function(srna, "range", "rna_fcurve_range");
1580 RNA_def_function_ui_description(func, "Get the time extents for F-Curve");
1582 parm= RNA_def_float_vector(func, "range", 2, NULL, -FLT_MAX, FLT_MAX, "Range", "Min/Max values", -FLT_MAX, FLT_MAX);
1583 RNA_def_property_flag(parm, PROP_THICK_WRAP);
1584 RNA_def_function_output(func, parm);
1587 /* *********************** */
1589 void RNA_def_fcurve(BlenderRNA *brna)
1591 rna_def_fcurve(brna);
1592 rna_def_fkeyframe(brna);
1593 rna_def_fpoint(brna);
1595 rna_def_drivertarget(brna);
1596 rna_def_drivervar(brna);
1597 rna_def_channeldriver(brna);
1599 rna_def_fmodifier(brna);
1601 rna_def_fmodifier_generator(brna);
1602 rna_def_fmodifier_function_generator(brna);
1603 rna_def_fmodifier_envelope(brna);
1604 rna_def_fmodifier_envelope_ctrl(brna);
1605 rna_def_fmodifier_cycles(brna);
1606 rna_def_fmodifier_python(brna);
1607 rna_def_fmodifier_limits(brna);
1608 rna_def_fmodifier_noise(brna);
1609 rna_def_fmodifier_stepped(brna);