Blender V4.3
rna_fcurve.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cstdlib>
10
11#include "DNA_anim_types.h"
12#include "DNA_curve_types.h"
13#include "DNA_object_types.h"
14#include "DNA_scene_types.h"
15
16#include "MEM_guardedalloc.h"
17
18#include "BLT_translation.hh"
19
20#include "BKE_action.hh"
21
22#include "RNA_access.hh"
23#include "RNA_define.hh"
24#include "RNA_enum_types.hh"
25
26#include "rna_internal.hh"
27
28#include "WM_types.hh"
29
30#include "ED_keyframes_edit.hh"
31#include "ED_keyframing.hh"
32
33#ifdef RNA_RUNTIME
34# include "ANIM_action.hh"
35# include "ANIM_fcurve.hh"
36#endif
37
39 {FMODIFIER_TYPE_NULL, "NULL", 0, "Invalid", ""},
41 "GENERATOR",
42 0,
43 "Generator",
44 "Generate a curve using a factorized or expanded polynomial"},
46 "FNGENERATOR",
47 0,
48 "Built-In Function",
49 "Generate a curve using standard math functions such as sin and cos"},
51 "ENVELOPE",
52 0,
53 "Envelope",
54 "Reshape F-Curve values, e.g. change amplitude of movements"},
55 {FMODIFIER_TYPE_CYCLES, "CYCLES", 0, "Cycles", "Cyclic extend/repeat keyframe sequence"},
56 {FMODIFIER_TYPE_NOISE, "NOISE", 0, "Noise", "Add pseudo-random noise on top of F-Curves"},
58 "LIMITS",
59 0,
60 "Limits",
61 "Restrict maximum and minimum values of F-Curve"},
63 "STEPPED",
64 0,
65 "Stepped Interpolation",
66 "Snap values to nearest grid step, e.g. for a stop-motion look"},
67 {0, nullptr, 0, nullptr, nullptr},
68};
69
72 "NONE",
73 0,
74 "None",
75 "Automatic handles only take immediately adjacent keys into account"},
77 "CONT_ACCEL",
78 0,
79 "Continuous Acceleration",
80 "Automatic handles are adjusted to avoid jumps in acceleration, resulting "
81 "in smoother curves. However, key changes may affect interpolation over a "
82 "larger stretch of the curve."},
83 {0, nullptr, 0, nullptr, nullptr},
84};
85
88 "KEYFRAME",
89 ICON_KEYTYPE_KEYFRAME_VEC,
90 "Keyframe",
91 "Normal keyframe, e.g. for key poses"},
93 "BREAKDOWN",
94 ICON_KEYTYPE_BREAKDOWN_VEC,
95 "Breakdown",
96 "A breakdown pose, e.g. for transitions between key poses"},
98 "MOVING_HOLD",
99 ICON_KEYTYPE_MOVING_HOLD_VEC,
100 "Moving Hold",
101 "A keyframe that is part of a moving hold"},
103 "EXTREME",
104 ICON_KEYTYPE_EXTREME_VEC,
105 "Extreme",
106 "An \"extreme\" pose, or some other purpose as needed"},
108 "JITTER",
109 ICON_KEYTYPE_JITTER_VEC,
110 "Jitter",
111 "A filler or baked keyframe for keying on ones, or some other purpose as needed"},
113 "GENERATED",
114 ICON_KEYTYPE_GENERATED_VEC,
115 "Generated",
116 "A key generated automatically by a tool, not manually created"},
117 {0, nullptr, 0, nullptr, nullptr},
118};
119
121 /* XXX: auto-easing is currently using a placeholder icon... */
123 "AUTO",
124 ICON_IPO_EASE_IN_OUT,
125 "Automatic Easing",
126 "Easing type is chosen automatically based on what the type of interpolation used "
127 "(e.g. Ease In for transitional types, and Ease Out for dynamic effects)"},
128
130 "EASE_IN",
131 ICON_IPO_EASE_IN,
132 "Ease In",
133 "Only on the end closest to the next keyframe"},
135 "EASE_OUT",
136 ICON_IPO_EASE_OUT,
137 "Ease Out",
138 "Only on the end closest to the first keyframe"},
140 "EASE_IN_OUT",
141 ICON_IPO_EASE_IN_OUT,
142 "Ease In and Out",
143 "Segment between both keyframes"},
144 {0, nullptr, 0, nullptr, nullptr},
145};
146
148 {DTAR_ROTMODE_AUTO, "AUTO", 0, "Auto Euler", "Euler using the rotation order of the target"},
149 {DTAR_ROTMODE_EULER_XYZ, "XYZ", 0, "XYZ Euler", "Euler using the XYZ rotation order"},
150 {DTAR_ROTMODE_EULER_XZY, "XZY", 0, "XZY Euler", "Euler using the XZY rotation order"},
151 {DTAR_ROTMODE_EULER_YXZ, "YXZ", 0, "YXZ Euler", "Euler using the YXZ rotation order"},
152 {DTAR_ROTMODE_EULER_YZX, "YZX", 0, "YZX Euler", "Euler using the YZX rotation order"},
153 {DTAR_ROTMODE_EULER_ZXY, "ZXY", 0, "ZXY Euler", "Euler using the ZXY rotation order"},
154 {DTAR_ROTMODE_EULER_ZYX, "ZYX", 0, "ZYX Euler", "Euler using the ZYX rotation order"},
155 {DTAR_ROTMODE_QUATERNION, "QUATERNION", 0, "Quaternion", "Quaternion rotation"},
157 "SWING_TWIST_X",
158 0,
159 "Swing and X Twist",
160 "Decompose into a swing rotation to aim the X axis, followed by twist around it"},
162 "SWING_TWIST_Y",
163 0,
164 "Swing and Y Twist",
165 "Decompose into a swing rotation to aim the Y axis, followed by twist around it"},
167 "SWING_TWIST_Z",
168 0,
169 "Swing and Z Twist",
170 "Decompose into a swing rotation to aim the Z axis, followed by twist around it"},
171 {0, nullptr, 0, nullptr, nullptr},
172};
173
176 "ACTIVE_SCENE",
177 ICON_NONE,
178 "Active Scene",
179 "Currently evaluating scene"},
181 "ACTIVE_VIEW_LAYER",
182 ICON_NONE,
183 "Active View Layer",
184 "Currently evaluating view layer"},
185 {0, nullptr, 0, nullptr, nullptr},
186};
187
188#ifdef RNA_RUNTIME
189
190# include <algorithm>
191
192# include "WM_api.hh"
193
194static StructRNA *rna_FModifierType_refine(PointerRNA *ptr)
195{
196 FModifier *fcm = (FModifier *)ptr->data;
197
198 switch (fcm->type) {
200 return &RNA_FModifierGenerator;
202 return &RNA_FModifierFunctionGenerator;
204 return &RNA_FModifierEnvelope;
206 return &RNA_FModifierCycles;
208 return &RNA_FModifierNoise;
210 return &RNA_FModifierLimits;
212 return &RNA_FModifierStepped;
213 default:
214 return &RNA_UnknownType;
215 }
216}
217
218/* ****************************** */
219
220# include "BKE_anim_data.hh"
221# include "BKE_fcurve.hh"
222# include "BKE_fcurve_driver.h"
223
224# include "DEG_depsgraph.hh"
225# include "DEG_depsgraph_build.hh"
226
231static FCurve *rna_FCurve_find_driver_by_variable(ID *owner_id, DriverVar *dvar)
232{
233 AnimData *adt = BKE_animdata_from_id(owner_id);
234 BLI_assert(adt != nullptr);
235 LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) {
236 ChannelDriver *driver = fcu->driver;
237 if (driver == nullptr) {
238 continue;
239 }
240 if (BLI_findindex(&driver->variables, dvar) != -1) {
241 return fcu;
242 }
243 }
244 return nullptr;
245}
246
251static FCurve *rna_FCurve_find_driver_by_target(ID *owner_id, DriverTarget *dtar)
252{
253 AnimData *adt = BKE_animdata_from_id(owner_id);
254 BLI_assert(adt != nullptr);
255 LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) {
256 ChannelDriver *driver = fcu->driver;
257 if (driver == nullptr) {
258 continue;
259 }
260 LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
261 /* NOTE: Use #MAX_DRIVER_TARGETS instead of `dvar->num_targets` because
262 * it's possible RNA holds a reference to a target that has been removed.
263 * In this case it's best to return the #FCurve it belongs to instead of nothing. */
264 if (ARRAY_HAS_ITEM(dtar, &dvar->targets[0], MAX_DRIVER_TARGETS)) {
265 return fcu;
266 }
267 }
268 }
269 return nullptr;
270}
271
272static bool rna_ChannelDriver_is_simple_expression_get(PointerRNA *ptr)
273{
274 ChannelDriver *driver = static_cast<ChannelDriver *>(ptr->data);
275
277}
278
279static void rna_ChannelDriver_update_data_impl(Main *bmain,
280 Scene *scene,
281 ID *owner_id,
282 ChannelDriver *driver)
283{
284 driver->flag &= ~DRIVER_FLAG_INVALID;
285
286 /* TODO: this really needs an update guard... */
289
291}
292
293static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
294{
295 ID *id = ptr->owner_id;
296 ChannelDriver *driver = static_cast<ChannelDriver *>(ptr->data);
297 rna_ChannelDriver_update_data_impl(bmain, scene, id, driver);
298}
299
300static void rna_ChannelDriver_update_expr(Main *bmain, Scene *scene, PointerRNA *ptr)
301{
302 ChannelDriver *driver = static_cast<ChannelDriver *>(ptr->data);
303
304 /* tag driver as needing to be recompiled */
305 BKE_driver_invalidate_expression(driver, true, false);
306
307 /* update_data() clears invalid flag and schedules for updates */
308 rna_ChannelDriver_update_data(bmain, scene, ptr);
309}
310
311static void rna_DriverTarget_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
312{
313 DriverTarget *dtar = (DriverTarget *)ptr->data;
314 FCurve *fcu = rna_FCurve_find_driver_by_target(ptr->owner_id, dtar);
315 BLI_assert(fcu); /* This hints at an internal error, data may be corrupt. */
316 if (UNLIKELY(fcu == nullptr)) {
317 return;
318 }
319 /* Find function ensures it's never nullptr. */
320 ChannelDriver *driver = fcu->driver;
321 fcu->flag &= ~FCURVE_DISABLED;
322 rna_ChannelDriver_update_data_impl(bmain, scene, ptr->owner_id, driver);
323}
324
325static void rna_DriverVariable_update_name(Main *bmain, Scene *scene, PointerRNA *ptr)
326{
327 DriverVar *dvar = (DriverVar *)ptr->data;
328 FCurve *fcu = rna_FCurve_find_driver_by_variable(ptr->owner_id, dvar);
329 BLI_assert(fcu); /* This hints at an internal error, data may be corrupt. */
330 if (UNLIKELY(fcu == nullptr)) {
331 return;
332 }
333 /* Find function ensures it's never nullptr. */
334 ChannelDriver *driver = fcu->driver;
335 fcu->flag &= ~FCURVE_DISABLED;
336 rna_ChannelDriver_update_data_impl(bmain, scene, ptr->owner_id, driver);
337 BKE_driver_invalidate_expression(driver, false, true);
338}
339
340static void rna_DriverVariable_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
341{
342 DriverVar *dvar = (DriverVar *)ptr->data;
343 FCurve *fcu = rna_FCurve_find_driver_by_variable(ptr->owner_id, dvar);
344 BLI_assert(fcu); /* This hints at an internal error, data may be corrupt. */
345 if (UNLIKELY(fcu == nullptr)) {
346 return;
347 }
348 /* Find function ensures it's never nullptr. */
349 ChannelDriver *driver = fcu->driver;
350 fcu->flag &= ~FCURVE_DISABLED;
351 rna_ChannelDriver_update_data_impl(bmain, scene, ptr->owner_id, driver);
352}
353
354/* ----------- */
355
356/* NOTE: this function exists only to avoid id reference-counting. */
357static void rna_DriverTarget_id_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
358{
359 DriverTarget *dtar = (DriverTarget *)ptr->data;
360 dtar->id = static_cast<ID *>(value.data);
361}
362
363static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr)
364{
365 DriverTarget *dtar = (DriverTarget *)ptr->data;
366 return ID_code_to_RNA_type(dtar->idtype);
367}
368
369static int rna_DriverTarget_id_editable(const PointerRNA *ptr, const char ** /*r_info*/)
370{
371 DriverTarget *dtar = (DriverTarget *)ptr->data;
372 return (dtar->idtype) ? PROP_EDITABLE : PropertyFlag(0);
373}
374
375static int rna_DriverTarget_id_type_editable(const PointerRNA *ptr, const char ** /*r_info*/)
376{
377 DriverTarget *dtar = (DriverTarget *)ptr->data;
378
379 /* when the id-type can only be object, don't allow editing
380 * otherwise, there may be strange crashes
381 */
382 return ((dtar->flag & DTAR_FLAG_ID_OB_ONLY) == 0);
383}
384
385static void rna_DriverTarget_id_type_set(PointerRNA *ptr, int value)
386{
387 DriverTarget *data = (DriverTarget *)(ptr->data);
388
389 /* check if ID-type is settable */
390 if ((data->flag & DTAR_FLAG_ID_OB_ONLY) == 0) {
391 /* change ID-type to the new type */
392 data->idtype = value;
393 }
394 else {
395 /* make sure ID-type is Object */
396 data->idtype = ID_OB;
397 }
398
399 /* clear the id-block if the type is invalid */
400 if ((data->id) && (GS(data->id->name) != data->idtype)) {
401 data->id = nullptr;
402 }
403}
404
405static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value)
406{
407 DriverTarget *dtar = (DriverTarget *)ptr->data;
408
409 if (dtar->rna_path) {
410 strcpy(value, dtar->rna_path);
411 }
412 else {
413 value[0] = '\0';
414 }
415}
416
417static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr)
418{
419 DriverTarget *dtar = (DriverTarget *)ptr->data;
420
421 if (dtar->rna_path) {
422 return strlen(dtar->rna_path);
423 }
424 else {
425 return 0;
426 }
427}
428
429static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value)
430{
431 DriverTarget *dtar = (DriverTarget *)ptr->data;
432
433 /* XXX in this case we need to be very careful,
434 * as this will require some new dependencies to be added! */
435 if (dtar->rna_path) {
436 MEM_freeN(dtar->rna_path);
437 }
438
439 if (value[0]) {
440 dtar->rna_path = BLI_strdup(value);
441 }
442 else {
443 dtar->rna_path = nullptr;
444 }
445}
446
447static void rna_DriverVariable_type_set(PointerRNA *ptr, int value)
448{
449 DriverVar *dvar = (DriverVar *)ptr->data;
450
451 /* call the API function for this */
452 driver_change_variable_type(dvar, value);
453}
454
455void rna_DriverVariable_name_set(PointerRNA *ptr, const char *value)
456{
457 DriverVar *data = (DriverVar *)(ptr->data);
458
459 STRNCPY_UTF8(data->name, value);
462}
463
464/* ----------- */
465
466static DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
467{
468 /* call the API function for this */
469 return driver_add_new_variable(driver);
470}
471
472static void rna_Driver_remove_variable(ChannelDriver *driver,
473 ReportList *reports,
474 PointerRNA *dvar_ptr)
475{
476 DriverVar *dvar = static_cast<DriverVar *>(dvar_ptr->data);
477 if (BLI_findindex(&driver->variables, dvar) == -1) {
478 BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver");
479 return;
480 }
481
482 driver_free_variable_ex(driver, dvar);
483 RNA_POINTER_INVALIDATE(dvar_ptr);
484}
485
486/* ****************************** */
487
488static void rna_FKeyframe_handle1_get(PointerRNA *ptr, float *values)
489{
490 BezTriple *bezt = (BezTriple *)ptr->data;
491
492 values[0] = bezt->vec[0][0];
493 values[1] = bezt->vec[0][1];
494}
495
496static void rna_FKeyframe_handle1_set(PointerRNA *ptr, const float *values)
497{
498 BezTriple *bezt = (BezTriple *)ptr->data;
499
500 bezt->vec[0][0] = values[0];
501 bezt->vec[0][1] = values[1];
502}
503
504static void rna_FKeyframe_handle2_get(PointerRNA *ptr, float *values)
505{
506 BezTriple *bezt = (BezTriple *)ptr->data;
507
508 values[0] = bezt->vec[2][0];
509 values[1] = bezt->vec[2][1];
510}
511
512static void rna_FKeyframe_handle2_set(PointerRNA *ptr, const float *values)
513{
514 BezTriple *bezt = (BezTriple *)ptr->data;
515
516 bezt->vec[2][0] = values[0];
517 bezt->vec[2][1] = values[1];
518}
519
520static void rna_FKeyframe_ctrlpoint_get(PointerRNA *ptr, float *values)
521{
522 BezTriple *bezt = (BezTriple *)ptr->data;
523
524 values[0] = bezt->vec[1][0];
525 values[1] = bezt->vec[1][1];
526}
527
528static void rna_FKeyframe_ctrlpoint_set(PointerRNA *ptr, const float *values)
529{
530 BezTriple *bezt = (BezTriple *)ptr->data;
531
532 bezt->vec[1][0] = values[0];
533 bezt->vec[1][1] = values[1];
534}
535
536static void rna_FKeyframe_ctrlpoint_ui_set(PointerRNA *ptr, const float *values)
537{
538 BezTriple *bezt = (BezTriple *)ptr->data;
539
540 const float frame_delta = values[0] - bezt->vec[1][0];
541 const float value_delta = values[1] - bezt->vec[1][1];
542
543 /* To match the behavior of transforming the keyframe Co using the Graph Editor
544 * (`transform_convert_graph.cc`) flushTransGraphData(), we will also move the handles by
545 * the same amount as the Co delta. */
546
547 bezt->vec[0][0] += frame_delta;
548 bezt->vec[0][1] += value_delta;
549
550 bezt->vec[1][0] = values[0];
551 bezt->vec[1][1] = values[1];
552
553 bezt->vec[2][0] += frame_delta;
554 bezt->vec[2][1] += value_delta;
555}
556
557/* ****************************** */
558
559static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value)
560{
561 FCurve *fcu = (FCurve *)ptr->data;
562
563 if (fcu->rna_path) {
564 strcpy(value, fcu->rna_path);
565 }
566 else {
567 value[0] = '\0';
568 }
569}
570
571static int rna_FCurve_RnaPath_length(PointerRNA *ptr)
572{
573 FCurve *fcu = (FCurve *)ptr->data;
574
575 if (fcu->rna_path) {
576 return strlen(fcu->rna_path);
577 }
578 else {
579 return 0;
580 }
581}
582
583static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
584{
585 FCurve *fcu = (FCurve *)ptr->data;
586
587 if (fcu->rna_path) {
588 MEM_freeN(fcu->rna_path);
589 }
590
591 if (value[0]) {
592 fcu->rna_path = BLI_strdup(value);
593 fcu->flag &= ~FCURVE_DISABLED;
594 }
595 else {
596 fcu->rna_path = nullptr;
597 }
598}
599
600static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
601{
602 ID *pid = ptr->owner_id;
603 ID *vid = value.owner_id;
604 FCurve *fcu = static_cast<FCurve *>(ptr->data);
605 bAction *act = nullptr;
606
607 /* get action */
608 if (ELEM(nullptr, pid, vid)) {
609 printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n",
610 pid,
611 vid);
612 return;
613 }
614 else if (value.data && (pid != vid)) {
615 /* ids differ, can't do this, should raise an error */
616 printf("ERROR: IDs differ - ptr=%p vs value=%p\n", pid, vid);
617 return;
618 }
619
620 if (GS(pid->name) == ID_AC && GS(vid->name) == ID_AC) {
621 /* The ID given is the action already -
622 * usually when F-Curve is obtained from an action's pointer. */
623 act = (bAction *)pid;
624 }
625 else {
626 /* the ID given is the owner of the F-Curve (for drivers) */
628 act = (adt) ? adt->action : nullptr;
629 }
630
631 /* already belongs to group? */
632 if (fcu->grp == value.data) {
633 /* nothing to do */
634 printf("ERROR: F-Curve already belongs to this group\n");
635 return;
636 }
637
638 /* can only change group if we have info about the action the F-Curve is in
639 * (i.e. for drivers or random F-Curves, this cannot be done)
640 */
641 if (act == nullptr) {
642 /* can't change the grouping of F-Curve when it doesn't belong to an action */
643 printf("ERROR: cannot assign F-Curve to group, since F-Curve is not attached to any ID\n");
644 return;
645 }
646
647 blender::animrig::Action &action = act->wrap();
648
649 /* Legacy action. */
650 if (!action.is_action_layered()) {
651
652 /* make sure F-Curve exists in this action first, otherwise we could still have been tricked */
653 if (BLI_findindex(&act->curves, fcu) == -1) {
654 printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name);
655 return;
656 }
657
658 /* try to remove F-Curve from action (including from any existing groups) */
660
661 /* add the F-Curve back to the action now in the right place */
662 /* TODO: make the api function handle the case where there isn't any group to assign to. */
663 if (value.data) {
664 /* add to its group using API function, which makes sure everything goes ok */
665 action_groups_add_channel(act, static_cast<bActionGroup *>(value.data), fcu);
666 }
667 else {
668 /* Need to add this back, but it can only go at the end of the list
669 * (or else will corrupt groups). */
670 BLI_addtail(&act->curves, fcu);
671 }
672
673 return;
674 }
675
676 /* Layered action. */
677 bActionGroup *group = static_cast<bActionGroup *>(value.data);
678
679 BLI_assert(group->channel_bag != nullptr);
680 blender::animrig::ChannelBag &channel_bag = group->channel_bag->wrap();
681
682 if (!channel_bag.fcurve_assign_to_channel_group(*fcu, *group)) {
683 printf(
684 "ERROR: F-Curve (datapath: '%s') doesn't belong to the same channel bag as "
685 "channel group '%s'\n",
686 fcu->rna_path,
687 group->name);
688 return;
689 }
690}
691
692/* calculate time extents of F-Curve */
693static void rna_FCurve_range(FCurve *fcu, float range[2])
694{
695 BKE_fcurve_calc_range(fcu, range, range + 1, false);
696}
697
698static bool rna_FCurve_is_empty_get(PointerRNA *ptr)
699{
700 FCurve *fcu = (FCurve *)ptr->data;
701 return BKE_fcurve_is_empty(fcu);
702}
703
704static void rna_tag_animation_update(Main *bmain, ID *id)
705{
706 const int tags = ID_RECALC_ANIMATION;
708
709 if (adt && adt->action) {
710 /* Action is separate datablock, needs separate tag. */
711 DEG_id_tag_update_ex(bmain, &adt->action->id, tags);
712 }
713
714 DEG_id_tag_update_ex(bmain, id, tags);
715}
716
717/* allow scripts to update curve after editing manually */
718static void rna_FCurve_update_data_ex(ID *id, FCurve *fcu, Main *bmain)
719{
720 sort_time_fcurve(fcu);
723
724 rna_tag_animation_update(bmain, id);
725}
726
727/* RNA update callback for F-Curves after curve shape changes */
728static void rna_FCurve_update_data(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
729{
730 BLI_assert(ptr->type == &RNA_FCurve);
731 rna_FCurve_update_data_ex(ptr->owner_id, (FCurve *)ptr->data, bmain);
732}
733
734static void rna_FCurve_update_data_relations(Main *bmain, Scene * /*scene*/, PointerRNA * /*ptr*/)
735{
737}
738
739/* RNA update callback for F-Curves to indicate that there are copy-on-evaluation tagging/flushing
740 * needed (e.g. for properties that affect how animation gets evaluated).
741 */
742static void rna_FCurve_update_eval(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
743{
744 rna_tag_animation_update(bmain, ptr->owner_id);
745}
746
747static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
748{
749 FCurve *fcu = (FCurve *)ptr->data;
751 return rna_pointer_inherit_refine(ptr, &RNA_FModifier, fcm);
752}
753
754static void rna_FCurve_active_modifier_set(PointerRNA *ptr,
755 PointerRNA value,
756 ReportList * /*reports*/)
757{
758 FCurve *fcu = (FCurve *)ptr->data;
759 set_active_fmodifier(&fcu->modifiers, (FModifier *)value.data);
760}
761
762static FModifier *rna_FCurve_modifiers_new(FCurve *fcu, int type)
763{
764 return add_fmodifier(&fcu->modifiers, type, fcu);
765}
766
767static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, PointerRNA *fcm_ptr)
768{
769 FModifier *fcm = static_cast<FModifier *>(fcm_ptr->data);
770 if (BLI_findindex(&fcu->modifiers, fcm) == -1) {
771 BKE_reportf(reports, RPT_ERROR, "F-Curve modifier '%s' not found in F-Curve", fcm->name);
772 return;
773 }
774
775 remove_fmodifier(&fcu->modifiers, fcm);
777 RNA_POINTER_INVALIDATE(fcm_ptr);
778}
779
780static void rna_FModifier_active_set(PointerRNA *ptr, bool /*value*/)
781{
782 FModifier *fcm = (FModifier *)ptr->data;
783
784 /* don't toggle, always switch on */
786}
787
788static void rna_FModifier_start_frame_set(PointerRNA *ptr, float value)
789{
790 FModifier *fcm = (FModifier *)ptr->data;
791
792 CLAMP(value, MINAFRAMEF, MAXFRAMEF);
793 fcm->sfra = value;
794
795 /* XXX: maintain old offset? */
796 if (fcm->sfra >= fcm->efra) {
797 fcm->efra = fcm->sfra;
798 }
799}
800
801static void rna_FModifier_end_frame_set(PointerRNA *ptr, float value)
802{
803 FModifier *fcm = (FModifier *)ptr->data;
804
805 CLAMP(value, MINAFRAMEF, MAXFRAMEF);
806 fcm->efra = value;
807
808 /* XXX: maintain old offset? */
809 if (fcm->efra <= fcm->sfra) {
810 fcm->sfra = fcm->efra;
811 }
812}
813
814static void rna_FModifier_start_frame_range(
815 PointerRNA * /*ptr*/, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
816{
817 // FModifier *fcm = (FModifier *)ptr->data;
818
819 /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
820 * or else it becomes tricky to adjust the range, see: #36844.
821 *
822 * NOTE: we do not set soft-limits on lower bounds, as it's too confusing when you
823 * can't easily use the slider to set things here
824 */
825 *min = MINAFRAMEF;
826 *max = MAXFRAMEF;
827}
828
829static void rna_FModifier_end_frame_range(
830 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
831{
832 FModifier *fcm = (FModifier *)ptr->data;
833
834 /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
835 * or else it becomes tricky to adjust the range, see: #36844. */
836 *min = MINAFRAMEF;
837 *softmin = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->sfra : MINAFRAMEF;
838
839 *softmax = MAXFRAMEF;
840 *max = MAXFRAMEF;
841}
842
843static void rna_FModifier_blending_range(
844 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
845{
846 FModifier *fcm = (FModifier *)ptr->data;
847
848 *min = 0.0f;
849 *max = fcm->efra - fcm->sfra;
850}
851
852static void rna_FModifier_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
853{
854 ID *id = ptr->owner_id;
855 FModifier *fcm = (FModifier *)ptr->data;
856
857 if (fcm->curve && fcm->type == FMODIFIER_TYPE_CYCLES) {
858 BKE_fcurve_handles_recalc(fcm->curve);
859 }
860
861 rna_tag_animation_update(bmain, id);
862}
863
864static void rna_fModifier_name_set(PointerRNA *ptr, const char *value)
865{
866 FModifier *fcm = (FModifier *)ptr->data;
867 BKE_fmodifier_name_set(fcm, value);
868}
869
870static void rna_FModifier_verify_data_update(Main *bmain, Scene *scene, PointerRNA *ptr)
871{
872 FModifier *fcm = (FModifier *)ptr->data;
874
875 /* call the verify callback on the modifier if applicable */
876 if (fmi && fmi->verify_data) {
877 fmi->verify_data(fcm);
878 }
879
880 rna_FModifier_update(bmain, scene, ptr);
881}
882
883static void rna_FModifier_active_update(Main *bmain, Scene *scene, PointerRNA *ptr)
884{
885 FModifier *fm, *fmo = (FModifier *)ptr->data;
886
887 /* clear active state of other FModifiers in this list */
888 for (fm = fmo->prev; fm; fm = fm->prev) {
889 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
890 }
891 for (fm = fmo->next; fm; fm = fm->next) {
892 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
893 }
894
895 rna_FModifier_update(bmain, scene, ptr);
896}
897
898static int rna_FModifierGenerator_coefficients_get_length(const PointerRNA *ptr,
899 int length[RNA_MAX_ARRAY_DIMENSION])
900{
901 const FModifier *fcm = (FModifier *)ptr->data;
902 const FMod_Generator *gen = static_cast<const FMod_Generator *>(fcm->data);
903
904 if (gen) {
905 length[0] = gen->arraysize;
906 }
907 else {
908 length[0] = 0;
909 }
910
911 return length[0];
912}
913
914static void rna_FModifierGenerator_coefficients_get(PointerRNA *ptr, float *values)
915{
916 FModifier *fcm = (FModifier *)ptr->data;
917 FMod_Generator *gen = static_cast<FMod_Generator *>(fcm->data);
918 memcpy(values, gen->coefficients, gen->arraysize * sizeof(float));
919}
920
921static void rna_FModifierGenerator_coefficients_set(PointerRNA *ptr, const float *values)
922{
923 FModifier *fcm = (FModifier *)ptr->data;
924 FMod_Generator *gen = static_cast<FMod_Generator *>(fcm->data);
925 memcpy(gen->coefficients, values, gen->arraysize * sizeof(float));
926}
927
928static void rna_FModifierLimits_minx_set(PointerRNA *ptr, float value)
929{
930 FModifier *fcm = (FModifier *)ptr->data;
931 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
932
933 data->rect.xmin = value;
934
935 if (data->rect.xmin >= data->rect.xmax) {
936 data->rect.xmax = data->rect.xmin;
937 }
938}
939
940static void rna_FModifierLimits_maxx_set(PointerRNA *ptr, float value)
941{
942 FModifier *fcm = (FModifier *)ptr->data;
943 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
944
945 data->rect.xmax = value;
946
947 if (data->rect.xmax <= data->rect.xmin) {
948 data->rect.xmin = data->rect.xmax;
949 }
950}
951
952static void rna_FModifierLimits_miny_set(PointerRNA *ptr, float value)
953{
954 FModifier *fcm = (FModifier *)ptr->data;
955 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
956
957 data->rect.ymin = value;
958
959 if (data->rect.ymin >= data->rect.ymax) {
960 data->rect.ymax = data->rect.ymin;
961 }
962}
963
964static void rna_FModifierLimits_maxy_set(PointerRNA *ptr, float value)
965{
966 FModifier *fcm = (FModifier *)ptr->data;
967 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
968
969 data->rect.ymax = value;
970
971 if (data->rect.ymax <= data->rect.ymin) {
972 data->rect.ymin = data->rect.ymax;
973 }
974}
975
976static void rna_FModifierLimits_minx_range(
977 PointerRNA * /*ptr*/, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
978{
979 // FModifier *fcm = (FModifier *)ptr->data;
980 // FMod_Limits *data = fcm->data;
981
982 /* No soft-limits on lower bound -
983 * it's too confusing when you can't easily use the slider to set things here. */
984 *min = MINAFRAMEF;
985 *max = MAXFRAMEF;
986}
987
988static void rna_FModifierLimits_maxx_range(
989 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
990{
991 FModifier *fcm = (FModifier *)ptr->data;
992 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
993
994 *min = MINAFRAMEF;
995 *softmin = (data->flag & FCM_LIMIT_XMIN) ? data->rect.xmin : MINAFRAMEF;
996
997 *softmax = MAXFRAMEF;
998 *max = MAXFRAMEF;
999}
1000
1001static void rna_FModifierLimits_miny_range(
1002 PointerRNA * /*ptr*/, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
1003{
1004 // FModifier *fcm = (FModifier *)ptr->data;
1005 // FMod_Limits *data = fcm->data;
1006
1007 /* No soft-limits on lower bound -
1008 * it's too confusing when you can't easily use the slider to set things here. */
1009 *min = -FLT_MAX;
1010 *max = FLT_MAX;
1011}
1012
1013static void rna_FModifierLimits_maxy_range(
1014 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
1015{
1016 FModifier *fcm = (FModifier *)ptr->data;
1017 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
1018
1019 *min = -FLT_MAX;
1020 *softmin = (data->flag & FCM_LIMIT_YMIN) ? data->rect.ymin : -FLT_MAX;
1021
1022 *softmax = FLT_MAX;
1023 *max = FLT_MAX;
1024}
1025
1026static void rna_FModifierStepped_start_frame_range(
1027 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
1028{
1029 FModifier *fcm = (FModifier *)ptr->data;
1030 FMod_Stepped *data = static_cast<FMod_Stepped *>(fcm->data);
1031
1032 *min = MINAFRAMEF;
1033 *max = (data->flag & FCM_STEPPED_NO_AFTER) ? data->end_frame : MAXFRAMEF;
1034}
1035
1036static void rna_FModifierStepped_end_frame_range(
1037 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
1038{
1039 FModifier *fcm = (FModifier *)ptr->data;
1040 FMod_Stepped *data = static_cast<FMod_Stepped *>(fcm->data);
1041
1042 *min = (data->flag & FCM_STEPPED_NO_BEFORE) ? data->start_frame : MINAFRAMEF;
1043 *max = MAXFRAMEF;
1044}
1045
1046static void rna_FModifierStepped_frame_start_set(PointerRNA *ptr, float value)
1047{
1048 FModifier *fcm = (FModifier *)ptr->data;
1049 FMod_Stepped *data = static_cast<FMod_Stepped *>(fcm->data);
1050
1051 float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
1052 rna_FModifierStepped_start_frame_range(
1053 ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
1054 value = std::clamp(value, prop_clamp_min, prop_clamp_max);
1055
1056 /* Need to set both step-data's start/end and the start/end on the base-data,
1057 * or else Restrict-Range doesn't work due to RNA-property shadowing (#52009)
1058 */
1059 data->start_frame = value;
1060 fcm->sfra = value;
1061}
1062
1063static void rna_FModifierStepped_frame_end_set(PointerRNA *ptr, float value)
1064{
1065 FModifier *fcm = (FModifier *)ptr->data;
1066 FMod_Stepped *data = static_cast<FMod_Stepped *>(fcm->data);
1067
1068 float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
1069 rna_FModifierStepped_end_frame_range(
1070 ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
1071 value = std::clamp(value, prop_clamp_min, prop_clamp_max);
1072
1073 /* Need to set both step-data's start/end and the start/end on the base-data,
1074 * or else Restrict-Range doesn't work due to RNA-property shadowing (#52009)
1075 */
1076 data->end_frame = value;
1077 fcm->efra = value;
1078}
1079
1080static BezTriple *rna_FKeyframe_points_insert(
1081 ID *id, FCurve *fcu, Main *bmain, float frame, float value, int keyframe_type, int flag)
1082{
1083 using namespace blender::animrig;
1084 KeyframeSettings settings = get_keyframe_settings(false);
1085 settings.keyframe_type = eBezTriple_KeyframeType(keyframe_type);
1087 fcu, {frame, value}, settings, eInsertKeyFlags(flag));
1088
1089 if ((fcu->bezt) && (result == SingleKeyingResult::SUCCESS)) {
1090 rna_tag_animation_update(bmain, id);
1091
1092 bool replace;
1093 const int index = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, frame, fcu->totvert, &replace);
1094
1095 return fcu->bezt + index;
1096 }
1097
1098 return nullptr;
1099}
1100
1101static void rna_FKeyframe_points_add(ID *id, FCurve *fcu, Main *bmain, int tot)
1102{
1103 if (tot <= 0) {
1104 return;
1105 }
1106
1107 ED_keyframes_add(fcu, tot);
1108 rna_tag_animation_update(bmain, id);
1109}
1110
1111static void rna_FKeyframe_points_remove(
1112 ID *id, FCurve *fcu, Main *bmain, ReportList *reports, PointerRNA *bezt_ptr, bool do_fast)
1113{
1114 BezTriple *bezt = static_cast<BezTriple *>(bezt_ptr->data);
1115 int index = int(bezt - fcu->bezt);
1116 if (index < 0 || index >= fcu->totvert) {
1117 BKE_report(reports, RPT_ERROR, "Keyframe not in F-Curve");
1118 return;
1119 }
1120
1121 BKE_fcurve_delete_key(fcu, index);
1122 RNA_POINTER_INVALIDATE(bezt_ptr);
1123
1124 if (!do_fast) {
1126 }
1127
1128 rna_tag_animation_update(bmain, id);
1129}
1130
1131static void rna_FKeyframe_points_clear(ID *id, FCurve *fcu, Main *bmain)
1132{
1134
1135 rna_tag_animation_update(bmain, id);
1136}
1137
1138static void rna_FKeyframe_points_sort(ID *id, FCurve *fcu, Main *bmain)
1139{
1140 sort_time_fcurve(fcu);
1141 rna_tag_animation_update(bmain, id);
1142}
1143
1144static void rna_FKeyframe_points_deduplicate(ID *id, FCurve *fcu, Main *bmain)
1145{
1147 rna_tag_animation_update(bmain, id);
1148}
1149
1150static void rna_FKeyframe_points_handles_recalc(ID *id, FCurve *fcu, Main *bmain)
1151{
1153 rna_tag_animation_update(bmain, id);
1154}
1155
1156static FCM_EnvelopeData *rna_FModifierEnvelope_points_add(
1157 ID *id, FModifier *fmod, Main *bmain, ReportList *reports, float frame)
1158{
1159 FCM_EnvelopeData fed;
1160 FMod_Envelope *env = (FMod_Envelope *)fmod->data;
1161 int i;
1162
1163 rna_tag_animation_update(bmain, id);
1164
1165 /* init template data */
1166 fed.min = -1.0f;
1167 fed.max = 1.0f;
1168 fed.time = frame;
1169 fed.f1 = fed.f2 = 0;
1170
1171 if (env->data) {
1172 bool exists;
1173 i = BKE_fcm_envelope_find_index(env->data, frame, env->totvert, &exists);
1174 if (exists) {
1175 BKE_reportf(reports, RPT_ERROR, "Already a control point at frame %.6f", frame);
1176 return nullptr;
1177 }
1178
1179 /* realloc memory for extra point */
1180 env->data = (FCM_EnvelopeData *)MEM_reallocN((void *)env->data,
1181 (env->totvert + 1) * sizeof(FCM_EnvelopeData));
1182
1183 /* move the points after the added point */
1184 if (i < env->totvert) {
1185 memmove(env->data + i + 1, env->data + i, (env->totvert - i) * sizeof(FCM_EnvelopeData));
1186 }
1187
1188 env->totvert++;
1189 }
1190 else {
1191 env->data = static_cast<FCM_EnvelopeData *>(
1192 MEM_mallocN(sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"));
1193 env->totvert = 1;
1194 i = 0;
1195 }
1196
1197 /* add point to paste at index i */
1198 *(env->data + i) = fed;
1199 return (env->data + i);
1200}
1201
1202static void rna_FModifierEnvelope_points_remove(
1203 ID *id, FModifier *fmod, Main *bmain, ReportList *reports, PointerRNA *point)
1204{
1205 FCM_EnvelopeData *cp = static_cast<FCM_EnvelopeData *>(point->data);
1206 FMod_Envelope *env = (FMod_Envelope *)fmod->data;
1207
1208 int index = int(cp - env->data);
1209
1210 /* test point is in range */
1211 if (index < 0 || index >= env->totvert) {
1212 BKE_report(reports, RPT_ERROR, "Control point not in Envelope F-Modifier");
1213 return;
1214 }
1215
1216 rna_tag_animation_update(bmain, id);
1217
1218 if (env->totvert > 1) {
1219 /* move data after the removed point */
1220
1221 memmove(env->data + index,
1222 env->data + (index + 1),
1223 sizeof(FCM_EnvelopeData) * ((env->totvert - index) - 1));
1224
1225 /* realloc smaller array */
1226 env->totvert--;
1227 env->data = (FCM_EnvelopeData *)MEM_reallocN((void *)env->data,
1228 (env->totvert) * sizeof(FCM_EnvelopeData));
1229 }
1230 else {
1231 /* just free array, since the only vert was deleted */
1232 if (env->data) {
1233 MEM_freeN(env->data);
1234 env->data = nullptr;
1235 }
1236 env->totvert = 0;
1237 }
1239}
1240
1241static void rna_Keyframe_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
1242{
1243 rna_tag_animation_update(bmain, ptr->owner_id);
1244}
1245
1246static void rna_FModifier_show_expanded_set(PointerRNA *ptr, bool value)
1247{
1248 FModifier *fcm = static_cast<FModifier *>(ptr->data);
1250}
1251
1252#else
1253
1255{
1256 StructRNA *srna;
1257 PropertyRNA *prop;
1258
1259 static const EnumPropertyItem generator_mode_items[] = {
1260 {FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""},
1262 "POLYNOMIAL_FACTORISED",
1263 0,
1264 "Factorized Polynomial",
1265 ""},
1266 {0, nullptr, 0, nullptr, nullptr},
1267 };
1268
1269 srna = RNA_def_struct(brna, "FModifierGenerator", "FModifier");
1271 srna, "Generator F-Modifier", "Deterministically generate values for the modified F-Curve");
1272 RNA_def_struct_sdna_from(srna, "FMod_Generator", "data");
1273
1274 /* define common props */
1275 prop = RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
1279 "Additive",
1280 "Values generated by this modifier are applied on top of "
1281 "the existing values instead of overwriting them");
1282 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1283
1284 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
1285 RNA_def_property_enum_items(prop, generator_mode_items);
1287 RNA_def_property_ui_text(prop, "Mode", "Type of generator to use");
1289 prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_verify_data_update");
1290
1291 /* order of the polynomial */
1292 prop = RNA_def_property(srna, "poly_order", PROP_INT, PROP_NONE);
1295 prop,
1296 "Polynomial Order",
1297 "The highest power of 'x' for this polynomial (number of coefficients - 1)");
1298 RNA_def_property_range(prop, 1, 100);
1300 prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_verify_data_update");
1301
1302 /* coefficients array */
1303 prop = RNA_def_property(srna, "coefficients", PROP_FLOAT, PROP_NONE);
1305 RNA_def_property_array(prop, 32);
1307 RNA_def_property_dynamic_array_funcs(prop, "rna_FModifierGenerator_coefficients_get_length");
1309 "rna_FModifierGenerator_coefficients_get",
1310 "rna_FModifierGenerator_coefficients_set",
1311 nullptr);
1313 prop, "Coefficients", "Coefficients for 'x' (starting from lowest power of x^0)");
1315 prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_verify_data_update");
1316}
1317
1318/* --------- */
1319
1321{
1322 StructRNA *srna;
1323 PropertyRNA *prop;
1324
1325 static const EnumPropertyItem prop_type_items[] = {
1326 {0, "SIN", 0, "Sine", ""},
1327 {1, "COS", 0, "Cosine", ""},
1328 {2, "TAN", 0, "Tangent", ""},
1329 {3, "SQRT", 0, "Square Root", ""},
1330 {4, "LN", 0, "Natural Logarithm", ""},
1331 {5, "SINC", 0, "Normalized Sine", "sin(x) / x"},
1332 {0, nullptr, 0, nullptr, nullptr},
1333 };
1334
1335 srna = RNA_def_struct(brna, "FModifierFunctionGenerator", "FModifier");
1337 srna, "Built-In Function F-Modifier", "Generate values using a built-in function");
1338 RNA_def_struct_sdna_from(srna, "FMod_FunctionGenerator", "data");
1339
1340 /* coefficients */
1341 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
1344 prop, "Amplitude", "Scale factor determining the maximum/minimum values");
1345 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1346
1347 prop = RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE);
1350 prop, "Phase Multiple", "Scale factor determining the 'speed' of the function");
1351 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1352
1353 prop = RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE);
1355 RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function");
1356 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1357
1358 prop = RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE);
1360 RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by");
1361 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1362
1363 /* flags */
1364 prop = RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
1368 "Additive",
1369 "Values generated by this modifier are applied on top of "
1370 "the existing values instead of overwriting them");
1371 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1372
1373 prop = RNA_def_property(srna, "function_type", PROP_ENUM, PROP_NONE);
1375 RNA_def_property_enum_sdna(prop, nullptr, "type");
1376 RNA_def_property_enum_items(prop, prop_type_items);
1377 RNA_def_property_ui_text(prop, "Type", "Type of built-in function to use");
1378 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1379}
1380
1381/* --------- */
1382
1384{
1385 StructRNA *srna;
1386 PropertyRNA *prop;
1387
1388 srna = RNA_def_struct(brna, "FModifierEnvelopeControlPoint", nullptr);
1389 RNA_def_struct_ui_text(srna, "Envelope Control Point", "Control point for envelope F-Modifier");
1390 RNA_def_struct_sdna(srna, "FCM_EnvelopeData");
1391
1392 /* min/max extents
1393 * - for now, these are allowed to go past each other, so that we can have inverted action
1394 * - technically, the range is limited by the settings in the envelope-modifier data, not here...
1395 */
1396 prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
1397 RNA_def_property_float_sdna(prop, nullptr, "min");
1399 RNA_def_property_ui_text(prop, "Minimum Value", "Lower bound of envelope at this control-point");
1400 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1401
1402 prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
1403 RNA_def_property_float_sdna(prop, nullptr, "max");
1405 RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point");
1406 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1407
1408 /* Frame */
1409 prop = RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
1410 RNA_def_property_float_sdna(prop, nullptr, "time");
1412 RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on");
1413 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1414
1415 /* TODO: */
1416 /* - selection flags (not implemented in UI yet though) */
1417}
1418
1420{
1421 StructRNA *srna;
1422
1423 FunctionRNA *func;
1424 PropertyRNA *parm;
1425
1426 RNA_def_property_srna(cprop, "FModifierEnvelopeControlPoints");
1427 srna = RNA_def_struct(brna, "FModifierEnvelopeControlPoints", nullptr);
1428 RNA_def_struct_sdna(srna, "FModifier");
1429
1431 srna, "Control Points", "Control points defining the shape of the envelope");
1432
1433 func = RNA_def_function(srna, "add", "rna_FModifierEnvelope_points_add");
1434 RNA_def_function_ui_description(func, "Add a control point to a FModifierEnvelope");
1436 parm = RNA_def_float(func,
1437 "frame",
1438 0.0f,
1439 -FLT_MAX,
1440 FLT_MAX,
1441 "",
1442 "Frame to add this control-point",
1443 -FLT_MAX,
1444 FLT_MAX);
1446 parm = RNA_def_pointer(
1447 func, "point", "FModifierEnvelopeControlPoint", "", "Newly created control-point");
1448 RNA_def_function_return(func, parm);
1449
1450 func = RNA_def_function(srna, "remove", "rna_FModifierEnvelope_points_remove");
1451 RNA_def_function_ui_description(func, "Remove a control-point from an FModifierEnvelope");
1453 parm = RNA_def_pointer(
1454 func, "point", "FModifierEnvelopeControlPoint", "", "Control-point to remove");
1456}
1457
1459{
1460 StructRNA *srna;
1461 PropertyRNA *prop;
1462
1463 srna = RNA_def_struct(brna, "FModifierEnvelope", "FModifier");
1464 RNA_def_struct_ui_text(srna, "Envelope F-Modifier", "Scale the values of the modified F-Curve");
1465 RNA_def_struct_sdna_from(srna, "FMod_Envelope", "data");
1466
1467 /* Collections */
1468 prop = RNA_def_property(srna, "control_points", PROP_COLLECTION, PROP_NONE);
1469 RNA_def_property_collection_sdna(prop, nullptr, "data", "totvert");
1471 RNA_def_property_struct_type(prop, "FModifierEnvelopeControlPoint");
1473 prop, "Control Points", "Control points defining the shape of the envelope");
1475
1476 /* Range Settings */
1477 prop = RNA_def_property(srna, "reference_value", PROP_FLOAT, PROP_NONE);
1478 RNA_def_property_float_sdna(prop, nullptr, "midval");
1481 prop, "Reference Value", "Value that envelope's influence is centered around / based on");
1482 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1483
1484 prop = RNA_def_property(srna, "default_min", PROP_FLOAT, PROP_NONE);
1485 RNA_def_property_float_sdna(prop, nullptr, "min");
1488 prop, "Default Minimum", "Lower distance from Reference Value for 1:1 default influence");
1489 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1490
1491 prop = RNA_def_property(srna, "default_max", PROP_FLOAT, PROP_NONE);
1492 RNA_def_property_float_sdna(prop, nullptr, "max");
1495 prop, "Default Maximum", "Upper distance from Reference Value for 1:1 default influence");
1496 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1497}
1498
1499/* --------- */
1500
1502{
1503 StructRNA *srna;
1504 PropertyRNA *prop;
1505
1506 static const EnumPropertyItem prop_type_items[] = {
1507 {FCM_EXTRAPOLATE_NONE, "NONE", 0, "No Cycles", "Don't do anything"},
1508 {FCM_EXTRAPOLATE_CYCLIC, "REPEAT", 0, "Repeat Motion", "Repeat keyframe range as-is"},
1510 "REPEAT_OFFSET",
1511 0,
1512 "Repeat with Offset",
1513 "Repeat keyframe range, but with offset based on gradient between "
1514 "start and end values"},
1516 "MIRROR",
1517 0,
1518 "Repeat Mirrored",
1519 "Alternate between forward and reverse playback of keyframe range"},
1520 {0, nullptr, 0, nullptr, nullptr},
1521 };
1522
1523 srna = RNA_def_struct(brna, "FModifierCycles", "FModifier");
1524 RNA_def_struct_ui_text(srna, "Cycles F-Modifier", "Repeat the values of the modified F-Curve");
1525 RNA_def_struct_sdna_from(srna, "FMod_Cycles", "data");
1526
1527 /* before */
1528 prop = RNA_def_property(srna, "mode_before", PROP_ENUM, PROP_NONE);
1530 RNA_def_property_enum_sdna(prop, nullptr, "before_mode");
1531 RNA_def_property_enum_items(prop, prop_type_items);
1532 RNA_def_property_ui_text(prop, "Before Mode", "Cycling mode to use before first keyframe");
1533 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1534
1535 prop = RNA_def_property(srna, "cycles_before", PROP_INT, PROP_NONE);
1537 RNA_def_property_int_sdna(prop, nullptr, "before_cycles");
1539 prop,
1540 "Before Cycles",
1541 "Maximum number of cycles to allow before first keyframe (0 = infinite)");
1542 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1543
1544 /* after */
1545 prop = RNA_def_property(srna, "mode_after", PROP_ENUM, PROP_NONE);
1547 RNA_def_property_enum_sdna(prop, nullptr, "after_mode");
1548 RNA_def_property_enum_items(prop, prop_type_items);
1549 RNA_def_property_ui_text(prop, "After Mode", "Cycling mode to use after last keyframe");
1550 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1551
1552 prop = RNA_def_property(srna, "cycles_after", PROP_INT, PROP_NONE);
1554 RNA_def_property_int_sdna(prop, nullptr, "after_cycles");
1556 "After Cycles",
1557 "Maximum number of cycles to allow after last keyframe (0 = infinite)");
1558 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1559}
1560
1561/* --------- */
1562
1564{
1565 StructRNA *srna;
1566 PropertyRNA *prop;
1567
1568 srna = RNA_def_struct(brna, "FModifierLimits", "FModifier");
1570 srna, "Limit F-Modifier", "Limit the time/value ranges of the modified F-Curve");
1571 RNA_def_struct_sdna_from(srna, "FMod_Limits", "data");
1572
1573 prop = RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
1574 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_XMIN);
1576 RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value");
1577 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1578
1579 prop = RNA_def_property(srna, "use_min_y", PROP_BOOLEAN, PROP_NONE);
1580 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_YMIN);
1582 RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
1583 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1584
1585 prop = RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
1586 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_XMAX);
1588 RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
1589 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1590
1591 prop = RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
1592 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_YMAX);
1594 RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
1595 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1596
1597 prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
1598 RNA_def_property_float_sdna(prop, nullptr, "rect.xmin");
1601 prop, nullptr, "rna_FModifierLimits_minx_set", "rna_FModifierLimits_minx_range");
1602 RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
1603 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1604
1605 prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
1606 RNA_def_property_float_sdna(prop, nullptr, "rect.ymin");
1609 prop, nullptr, "rna_FModifierLimits_miny_set", "rna_FModifierLimits_miny_range");
1610 RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
1611 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1612
1613 prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
1614 RNA_def_property_float_sdna(prop, nullptr, "rect.xmax");
1617 prop, nullptr, "rna_FModifierLimits_maxx_set", "rna_FModifierLimits_maxx_range");
1618 RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
1619 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1620
1621 prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
1622 RNA_def_property_float_sdna(prop, nullptr, "rect.ymax");
1625 prop, nullptr, "rna_FModifierLimits_maxy_set", "rna_FModifierLimits_maxy_range");
1626 RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
1627 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1628}
1629
1630/* --------- */
1631
1633{
1634 StructRNA *srna;
1635 PropertyRNA *prop;
1636
1637 static const EnumPropertyItem prop_modification_items[] = {
1638 {FCM_NOISE_MODIF_REPLACE, "REPLACE", 0, "Replace", ""},
1639 {FCM_NOISE_MODIF_ADD, "ADD", 0, "Add", ""},
1640 {FCM_NOISE_MODIF_SUBTRACT, "SUBTRACT", 0, "Subtract", ""},
1641 {FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", 0, "Multiply", ""},
1642 {0, nullptr, 0, nullptr, nullptr},
1643 };
1644
1645 srna = RNA_def_struct(brna, "FModifierNoise", "FModifier");
1646 RNA_def_struct_ui_text(srna, "Noise F-Modifier", "Give randomness to the modified F-Curve");
1647 RNA_def_struct_sdna_from(srna, "FMod_Noise", "data");
1648
1649 prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
1650 RNA_def_property_enum_sdna(prop, nullptr, "modification");
1651 RNA_def_property_enum_items(prop, prop_modification_items);
1653 RNA_def_property_ui_text(prop, "Blend Type", "Method of modifying the existing F-Curve");
1654 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1655
1656 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
1657 RNA_def_property_float_sdna(prop, nullptr, "size");
1659 RNA_def_property_ui_text(prop, "Scale", "Scaling (in time) of the noise");
1660 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1661
1662 prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
1663 RNA_def_property_float_sdna(prop, nullptr, "strength");
1666 prop,
1667 "Strength",
1668 "Amplitude of the noise - the amount that it modifies the underlying curve");
1669 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1670
1671 prop = RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
1672 RNA_def_property_float_sdna(prop, nullptr, "phase");
1674 RNA_def_property_ui_text(prop, "Phase", "A random seed for the noise effect");
1675 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1676
1677 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
1678 RNA_def_property_float_sdna(prop, nullptr, "offset");
1680 RNA_def_property_ui_text(prop, "Offset", "Time offset for the noise effect");
1681 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1682
1683 prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
1684 RNA_def_property_int_sdna(prop, nullptr, "depth");
1686 RNA_def_property_ui_text(prop, "Depth", "Amount of fine level detail present in the noise");
1687 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1688}
1689
1690/* --------- */
1691
1693{
1694 StructRNA *srna;
1695 PropertyRNA *prop;
1696
1697 srna = RNA_def_struct(brna, "FModifierStepped", "FModifier");
1699 srna,
1700 "Stepped Interpolation F-Modifier",
1701 "Hold each interpolated value from the F-Curve for several frames without "
1702 "changing the timing");
1703 RNA_def_struct_sdna_from(srna, "FMod_Stepped", "data");
1704
1705 /* properties */
1706 prop = RNA_def_property(srna, "frame_step", PROP_FLOAT, PROP_NONE);
1707 RNA_def_property_float_sdna(prop, nullptr, "step_size");
1709 RNA_def_property_ui_text(prop, "Step Size", "Number of frames to hold each value");
1710 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1711
1712 prop = RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
1713 RNA_def_property_float_sdna(prop, nullptr, "offset");
1716 "Offset",
1717 "Reference number of frames before frames get held "
1718 "(use to get hold for '1-3' vs '5-7' holding patterns)");
1719 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1720
1721 prop = RNA_def_property(srna, "use_frame_start", PROP_BOOLEAN, PROP_NONE);
1725 prop, "Use Start Frame", "Restrict modifier to only act after its 'start' frame");
1726 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1727
1728 prop = RNA_def_property(srna, "use_frame_end", PROP_BOOLEAN, PROP_NONE);
1732 prop, "Use End Frame", "Restrict modifier to only act before its 'end' frame");
1733 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1734
1735 prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
1736 RNA_def_property_float_sdna(prop, nullptr, "start_frame");
1739 nullptr,
1740 "rna_FModifierStepped_frame_start_set",
1741 "rna_FModifierStepped_start_frame_range");
1743 prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
1744 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1745
1746 prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
1747 RNA_def_property_float_sdna(prop, nullptr, "end_frame");
1750 prop, nullptr, "rna_FModifierStepped_frame_end_set", "rna_FModifierStepped_end_frame_range");
1752 prop, "End Frame", "Frame that modifier's influence ends (if applicable)");
1753 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1754}
1755
1756/* --------- */
1757
1759{
1760 StructRNA *srna;
1761 PropertyRNA *prop;
1762
1763 /* base struct definition */
1764 srna = RNA_def_struct(brna, "FModifier", nullptr);
1765 RNA_def_struct_refine_func(srna, "rna_FModifierType_refine");
1766 RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve");
1767
1768 /* name */
1769 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1770 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_fModifier_name_set");
1771 RNA_def_property_ui_text(prop, "Name", "F-Curve Modifier name");
1773 RNA_def_struct_name_property(srna, prop);
1774
1775 /* type */
1776 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1780 RNA_def_property_ui_text(prop, "Type", "F-Curve Modifier Type");
1781
1782 /* settings */
1783 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
1785 RNA_def_property_boolean_sdna(prop, nullptr, "ui_expand_flag", 0);
1786 // RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
1787 RNA_def_property_boolean_funcs(prop, nullptr, "rna_FModifier_show_expanded_set");
1788 RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI");
1789 RNA_def_property_ui_icon(prop, ICON_RIGHTARROW, 1);
1790
1791 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1794 RNA_def_property_ui_text(prop, "Enabled", "Enable F-Curve modifier evaluation");
1795 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1796 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_HLT, -1);
1797
1798 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1801 // RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
1803 prop, "Disabled", "F-Curve Modifier has invalid settings and will not be evaluated");
1804 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1805
1806 /* TODO: setting this to true must ensure that all others in stack are turned off too... */
1807 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1810 RNA_def_property_ui_text(prop, "Active", "F-Curve modifier will show settings in the editor");
1811 RNA_def_property_boolean_funcs(prop, nullptr, "rna_FModifier_active_set");
1812 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_active_update");
1813 RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
1814
1815 /* restricted range */
1816 prop = RNA_def_property(srna, "use_restricted_range", PROP_BOOLEAN, PROP_NONE);
1820 prop,
1821 "Restrict Frame Range",
1822 "F-Curve Modifier is only applied for the specified frame range to help "
1823 "mask off effects in order to chain them");
1824 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1825
1826 prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
1827 RNA_def_property_float_sdna(prop, nullptr, "sfra");
1830 prop, nullptr, "rna_FModifier_start_frame_set", "rna_FModifier_start_frame_range");
1832 prop,
1833 "Start Frame",
1834 "Frame that modifier's influence starts (if Restrict Frame Range is in use)");
1835 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1836
1837 prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
1838 RNA_def_property_float_sdna(prop, nullptr, "efra");
1841 prop, nullptr, "rna_FModifier_end_frame_set", "rna_FModifier_end_frame_range");
1843 prop,
1844 "End Frame",
1845 "Frame that modifier's influence ends (if Restrict Frame Range is in use)");
1846 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1847
1848 prop = RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE);
1849 RNA_def_property_float_sdna(prop, nullptr, "blendin");
1851 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_FModifier_blending_range");
1853 prop, "Blend In", "Number of frames from start frame for influence to take effect");
1854 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1855
1856 prop = RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE);
1857 RNA_def_property_float_sdna(prop, nullptr, "blendout");
1859 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_FModifier_blending_range");
1861 prop, "Blend Out", "Number of frames from end frame for influence to fade out");
1862 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1863
1864 /* influence */
1865 prop = RNA_def_property(srna, "use_influence", PROP_BOOLEAN, PROP_NONE);
1869 prop, "Use Influence", "F-Curve Modifier's effects will be tempered by a default factor");
1870 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1871
1872 prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
1873 RNA_def_property_float_sdna(prop, nullptr, "influence");
1875 RNA_def_property_range(prop, 0.0f, 1.0f);
1878 prop, "Influence", "Amount of influence F-Curve Modifier will have when not fading in/out");
1879 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1880}
1881
1882/* *********************** */
1883
1885{
1886 StructRNA *srna;
1887 PropertyRNA *prop;
1888
1889 static const EnumPropertyItem prop_trans_chan_items[] = {
1890 {DTAR_TRANSCHAN_LOCX, "LOC_X", 0, "X Location", ""},
1891 {DTAR_TRANSCHAN_LOCY, "LOC_Y", 0, "Y Location", ""},
1892 {DTAR_TRANSCHAN_LOCZ, "LOC_Z", 0, "Z Location", ""},
1894 {DTAR_TRANSCHAN_ROTX, "ROT_X", 0, "X Rotation", ""},
1895 {DTAR_TRANSCHAN_ROTY, "ROT_Y", 0, "Y Rotation", ""},
1896 {DTAR_TRANSCHAN_ROTZ, "ROT_Z", 0, "Z Rotation", ""},
1897 {DTAR_TRANSCHAN_ROTW, "ROT_W", 0, "W Rotation", ""},
1899 {DTAR_TRANSCHAN_SCALEX, "SCALE_X", 0, "X Scale", ""},
1900 {DTAR_TRANSCHAN_SCALEY, "SCALE_Y", 0, "Y Scale", ""},
1901 {DTAR_TRANSCHAN_SCALEZ, "SCALE_Z", 0, "Z Scale", ""},
1902 {DTAR_TRANSCHAN_SCALE_AVG, "SCALE_AVG", 0, "Average Scale", ""},
1903 {0, nullptr, 0, nullptr, nullptr},
1904 };
1905
1906 static const EnumPropertyItem prop_local_space_items[] = {
1907 {0,
1908 "WORLD_SPACE",
1909 0,
1910 "World Space",
1911 "Transforms include effects of parenting/restpose and constraints"},
1913 "TRANSFORM_SPACE",
1914 0,
1915 "Transform Space",
1916 "Transforms don't include parenting/restpose or constraints"},
1918 "LOCAL_SPACE",
1919 0,
1920 "Local Space",
1921 "Transforms include effects of constraints but not "
1922 "parenting/restpose"},
1923 {0, nullptr, 0, nullptr, nullptr},
1924 };
1925
1926 srna = RNA_def_struct(brna, "DriverTarget", nullptr);
1927 RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables");
1928
1929 /* Target Properties - ID-block to Drive */
1930 prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1931 RNA_def_property_struct_type(prop, "ID");
1934 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
1935 /* NOTE: custom set function is ONLY to avoid rna setting a user for this. */
1937 prop, nullptr, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", nullptr);
1939 "ID",
1940 "ID-block that the specific property used can be found from "
1941 "(id_type property must be set first)");
1942 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1943
1944 prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
1945 RNA_def_property_enum_sdna(prop, nullptr, "idtype");
1948 RNA_def_property_enum_funcs(prop, nullptr, "rna_DriverTarget_id_type_set", nullptr);
1949 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_type_editable");
1950 RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
1952 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1953
1954 /* Target Properties - Property to Drive */
1955 prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
1957 "rna_DriverTarget_RnaPath_get",
1958 "rna_DriverTarget_RnaPath_length",
1959 "rna_DriverTarget_RnaPath_set");
1960 RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from ID-block) to property used");
1961 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1962
1963 prop = RNA_def_property(srna, "bone_target", PROP_STRING, PROP_NONE);
1964 RNA_def_property_string_sdna(prop, nullptr, "pchan_name");
1965 RNA_def_property_ui_text(prop, "Bone Name", "Name of PoseBone to use as target");
1966 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1967
1968 prop = RNA_def_property(srna, "transform_type", PROP_ENUM, PROP_NONE);
1969 RNA_def_property_enum_sdna(prop, nullptr, "transChan");
1970 RNA_def_property_enum_items(prop, prop_trans_chan_items);
1971 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
1972 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1973
1974 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
1975 RNA_def_property_enum_sdna(prop, nullptr, "rotation_mode");
1977 RNA_def_property_ui_text(prop, "Rotation Mode", "Mode for calculating rotation channel values");
1978 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1979
1980 prop = RNA_def_property(srna, "transform_space", PROP_ENUM, PROP_NONE);
1981 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
1982 RNA_def_property_enum_items(prop, prop_local_space_items);
1983 RNA_def_property_ui_text(prop, "Transform Space", "Space in which transforms are used");
1984 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1985
1986 prop = RNA_def_property(srna, "context_property", PROP_ENUM, PROP_NONE);
1987 RNA_def_property_enum_sdna(prop, nullptr, "context_property");
1991 prop, "Context Property", "Type of a context-dependent data-block to access property from");
1992 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1993
1994 prop = RNA_def_property(srna, "use_fallback_value", PROP_BOOLEAN, PROP_NONE);
1997 "Use Fallback",
1998 "Use the fallback value if the data path can't be resolved, instead of "
1999 "failing to evaluate the driver");
2000 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2001
2002 prop = RNA_def_property(srna, "fallback_value", PROP_FLOAT, PROP_NONE);
2003 RNA_def_property_float_sdna(prop, nullptr, "fallback_value");
2005 prop, "Fallback", "The value to use if the data path can't be resolved");
2006 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2007
2008 prop = RNA_def_property(srna, "is_fallback_used", PROP_BOOLEAN, PROP_NONE);
2012 prop,
2013 "Is Fallback Used",
2014 "Indicates that the most recent variable evaluation used the fallback value");
2015}
2016
2018{
2019 StructRNA *srna;
2020 PropertyRNA *prop;
2021
2022 static const EnumPropertyItem prop_type_items[] = {
2024 "SINGLE_PROP",
2025 ICON_RNA,
2026 "Single Property",
2027 "Use the value from some RNA property"},
2029 "TRANSFORMS",
2030 ICON_DRIVER_TRANSFORM,
2031 "Transform Channel",
2032 "Final transformation value of object or bone"},
2034 "ROTATION_DIFF",
2035 ICON_DRIVER_ROTATIONAL_DIFFERENCE,
2036 "Rotational Difference",
2037 "Use the angle between two bones"},
2039 "LOC_DIFF",
2040 ICON_DRIVER_DISTANCE,
2041 "Distance",
2042 "Distance between two bones or objects"},
2044 "CONTEXT_PROP",
2045 ICON_RNA,
2046 "Context Property",
2047 "Use the value from some RNA property within the current evaluation context"},
2048 {0, nullptr, 0, nullptr, nullptr},
2049 };
2050
2051 srna = RNA_def_struct(brna, "DriverVariable", nullptr);
2052 RNA_def_struct_sdna(srna, "DriverVar");
2054 srna, "Driver Variable", "Variable from some source/target for driver relationship");
2055
2056 /* Variable Name */
2057 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2058 RNA_def_struct_name_property(srna, prop);
2059 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_DriverVariable_name_set");
2061 prop,
2062 "Name",
2063 "Name to use in scripted expressions/functions (no spaces or dots are allowed, "
2064 "and must start with a letter)");
2065 RNA_def_property_update(prop, 0, "rna_DriverVariable_update_name");
2066
2067 /* Enums */
2068 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2069 RNA_def_property_enum_items(prop, prop_type_items);
2070 RNA_def_property_enum_funcs(prop, nullptr, "rna_DriverVariable_type_set", nullptr);
2071 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
2072 RNA_def_property_update(prop, 0, "rna_DriverVariable_update_data");
2073
2074 /* Targets */
2075 /* TODO: for nicer api, only expose the relevant props via subclassing,
2076 * instead of exposing the collection of targets */
2077 prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
2078 RNA_def_property_collection_sdna(prop, nullptr, "targets", "num_targets");
2079 RNA_def_property_struct_type(prop, "DriverTarget");
2081 RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable");
2082
2083 /* Name Validity Flags */
2084 prop = RNA_def_property(srna, "is_name_valid", PROP_BOOLEAN, PROP_NONE);
2087 RNA_def_property_ui_text(prop, "Is Name Valid", "Is this a valid name for a driver variable");
2088}
2089
2090/* channeldriver.variables.* */
2092{
2093 StructRNA *srna;
2094 // PropertyRNA *prop;
2095
2096 FunctionRNA *func;
2097 PropertyRNA *parm;
2098
2099 RNA_def_property_srna(cprop, "ChannelDriverVariables");
2100 srna = RNA_def_struct(brna, "ChannelDriverVariables", nullptr);
2101 RNA_def_struct_sdna(srna, "ChannelDriver");
2103 srna, "ChannelDriver Variables", "Collection of channel driver Variables");
2104
2105 /* add variable */
2106 func = RNA_def_function(srna, "new", "rna_Driver_new_variable");
2107 RNA_def_function_ui_description(func, "Add a new variable for the driver");
2108 /* return type */
2109 parm = RNA_def_pointer(func, "var", "DriverVariable", "", "Newly created Driver Variable");
2110 RNA_def_function_return(func, parm);
2111
2112 /* remove variable */
2113 func = RNA_def_function(srna, "remove", "rna_Driver_remove_variable");
2114 RNA_def_function_ui_description(func, "Remove an existing variable from the driver");
2116 /* target to remove */
2117 parm = RNA_def_pointer(
2118 func, "variable", "DriverVariable", "", "Variable to remove from the driver");
2121}
2122
2124{
2125 StructRNA *srna;
2126 PropertyRNA *prop;
2127
2128 static const EnumPropertyItem prop_type_items[] = {
2129 {DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""},
2130 {DRIVER_TYPE_SUM, "SUM", 0, "Sum Values", ""},
2131 {DRIVER_TYPE_PYTHON, "SCRIPTED", 0, "Scripted Expression", ""},
2132 {DRIVER_TYPE_MIN, "MIN", 0, "Minimum Value", ""},
2133 {DRIVER_TYPE_MAX, "MAX", 0, "Maximum Value", ""},
2134 {0, nullptr, 0, nullptr, nullptr},
2135 };
2136
2137 srna = RNA_def_struct(brna, "Driver", nullptr);
2138 RNA_def_struct_sdna(srna, "ChannelDriver");
2140 srna, "Driver", "Driver for the value of a setting based on an external value");
2141 RNA_def_struct_ui_icon(srna, ICON_DRIVER);
2142
2143 /* Enums */
2144 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2145 RNA_def_property_enum_items(prop, prop_type_items);
2146 RNA_def_property_ui_text(prop, "Type", "Driver type");
2147 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data");
2148
2149 /* String values */
2150 prop = RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE);
2151 RNA_def_property_ui_text(prop, "Expression", "Expression to use for Scripted Expression");
2152 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_expr");
2153
2154 /* Collections */
2155 prop = RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE);
2156 RNA_def_property_collection_sdna(prop, nullptr, "variables", nullptr);
2157 RNA_def_property_struct_type(prop, "DriverVariable");
2159 RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver");
2161
2162 /* Settings */
2163 prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE);
2166 prop,
2167 "Use Self",
2168 "Include a 'self' variable in the name-space, "
2169 "so drivers can easily reference the data being modified (object, bone, etc...)");
2170
2171 /* State Info (for Debugging) */
2172 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
2175 prop, "Invalid", "Driver could not be evaluated in past, so should be skipped");
2176
2177 prop = RNA_def_property(srna, "is_simple_expression", PROP_BOOLEAN, PROP_NONE);
2179 RNA_def_property_boolean_funcs(prop, "rna_ChannelDriver_is_simple_expression_get", nullptr);
2181 prop,
2182 "Simple Expression",
2183 "The scripted expression can be evaluated without using the full Python interpreter");
2184
2185 /* Functions */
2186 RNA_api_drivers(srna);
2187}
2188
2189/* *********************** */
2190
2191static void rna_def_fpoint(BlenderRNA *brna)
2192{
2193 StructRNA *srna;
2194 PropertyRNA *prop;
2195
2196 srna = RNA_def_struct(brna, "FCurveSample", nullptr);
2197 RNA_def_struct_sdna(srna, "FPoint");
2198 RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve");
2199
2200 /* Boolean values */
2201 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2202 RNA_def_property_boolean_sdna(prop, nullptr, "flag", 1);
2203 RNA_def_property_ui_text(prop, "Select", "Selection status");
2205
2206 /* Vector value */
2207 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2208 RNA_def_property_float_sdna(prop, nullptr, "vec");
2209 RNA_def_property_array(prop, 2);
2210 RNA_def_property_ui_text(prop, "Point", "Point coordinates");
2212}
2213
2219{
2220 StructRNA *srna;
2221 PropertyRNA *prop;
2222
2223 srna = RNA_def_struct(brna, "Keyframe", nullptr);
2224 RNA_def_struct_sdna(srna, "BezTriple");
2226 srna, "Keyframe", "Bézier curve point with two handles defining a Keyframe on an F-Curve");
2227
2228 /* Boolean values */
2229 prop = RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
2230 RNA_def_property_boolean_sdna(prop, nullptr, "f1", SELECT);
2231 RNA_def_property_ui_text(prop, "Handle 1 selected", "Left handle selection status");
2233
2234 prop = RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
2235 RNA_def_property_boolean_sdna(prop, nullptr, "f3", SELECT);
2236 RNA_def_property_ui_text(prop, "Handle 2 selected", "Right handle selection status");
2238
2239 prop = RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
2240 RNA_def_property_boolean_sdna(prop, nullptr, "f2", SELECT);
2241 RNA_def_property_ui_text(prop, "Select", "Control point selection status");
2243
2244 /* Enums */
2245 prop = RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
2246 RNA_def_property_enum_sdna(prop, nullptr, "h1");
2248 RNA_def_property_ui_text(prop, "Left Handle Type", "Handle types");
2249 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2250
2251 prop = RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
2252 RNA_def_property_enum_sdna(prop, nullptr, "h2");
2254 RNA_def_property_ui_text(prop, "Right Handle Type", "Handle types");
2255 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2256
2257 prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
2258 RNA_def_property_enum_sdna(prop, nullptr, "ipo");
2261 "Interpolation",
2262 "Interpolation method to use for segment of the F-Curve from "
2263 "this Keyframe until the next Keyframe");
2265 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2266
2267 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2268 RNA_def_property_enum_sdna(prop, nullptr, "hide");
2270 RNA_def_property_ui_text(prop, "Type", "Type of keyframe (for visual purposes only)");
2271 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2272
2273 prop = RNA_def_property(srna, "easing", PROP_ENUM, PROP_NONE);
2274 RNA_def_property_enum_sdna(prop, nullptr, "easing");
2277 "Easing",
2278 "Which ends of the segment between this and the next keyframe easing "
2279 "interpolation is applied to");
2280 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2281
2282 prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_NONE);
2283 RNA_def_property_float_sdna(prop, nullptr, "back");
2284 RNA_def_property_ui_text(prop, "Back", "Amount of overshoot for 'back' easing");
2286 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2287
2288 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
2289 RNA_def_property_float_sdna(prop, nullptr, "amplitude");
2290 RNA_def_property_range(prop, 0.0f, FLT_MAX); /* only positive values... */
2292 prop, "Amplitude", "Amount to boost elastic bounces for 'elastic' easing");
2293 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2294
2295 prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE);
2296 RNA_def_property_float_sdna(prop, nullptr, "period");
2297 RNA_def_property_ui_text(prop, "Period", "Time between bounces for elastic easing");
2298 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2299
2300 /* Vector values */
2301 prop = RNA_def_property(
2302 srna, "handle_left", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2303 RNA_def_property_array(prop, 2);
2305 prop, "rna_FKeyframe_handle1_get", "rna_FKeyframe_handle1_set", nullptr);
2307 prop, "Left Handle", "Coordinates of the left handle (before the control point)");
2308 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2309
2310 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2311 RNA_def_property_array(prop, 2);
2313 prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_set", nullptr);
2314 RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
2315 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2316
2317 prop = RNA_def_property(
2318 srna, "co_ui", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2319 RNA_def_property_array(prop, 2);
2321 prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_ui_set", nullptr);
2323 prop,
2324 "Control Point",
2325 "Coordinates of the control point. Note: Changing this value also updates the handles "
2326 "similar to using the graph editor transform operator");
2327 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2328
2329 prop = RNA_def_property(
2330 srna, "handle_right", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2331 RNA_def_property_array(prop, 2);
2333 prop, "rna_FKeyframe_handle2_get", "rna_FKeyframe_handle2_set", nullptr);
2335 prop, "Right Handle", "Coordinates of the right handle (after the control point)");
2336 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2337}
2338
2340{
2341 /* add modifiers */
2342 StructRNA *srna;
2343 PropertyRNA *prop;
2344
2345 FunctionRNA *func;
2346 PropertyRNA *parm;
2347
2348 RNA_def_property_srna(cprop, "FCurveModifiers");
2349 srna = RNA_def_struct(brna, "FCurveModifiers", nullptr);
2350 RNA_def_struct_sdna(srna, "FCurve");
2351 RNA_def_struct_ui_text(srna, "F-Curve Modifiers", "Collection of F-Curve Modifiers");
2352
2353 /* Collection active property */
2354 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2355 RNA_def_property_struct_type(prop, "FModifier");
2358 prop, "rna_FCurve_active_modifier_get", "rna_FCurve_active_modifier_set", nullptr, nullptr);
2360 RNA_def_property_ui_text(prop, "Active F-Curve Modifier", "Active F-Curve Modifier");
2361
2362 /* Constraint collection */
2363 func = RNA_def_function(srna, "new", "rna_FCurve_modifiers_new");
2364 RNA_def_function_ui_description(func, "Add a constraint to this object");
2365 /* return type */
2366 parm = RNA_def_pointer(func, "fmodifier", "FModifier", "", "New fmodifier");
2367 RNA_def_function_return(func, parm);
2368 /* object to add */
2369 parm = RNA_def_enum(
2370 func, "type", rna_enum_fmodifier_type_items, 1, "", "Constraint type to add");
2372
2373 func = RNA_def_function(srna, "remove", "rna_FCurve_modifiers_remove");
2375 RNA_def_function_ui_description(func, "Remove a modifier from this F-Curve");
2376 /* modifier to remove */
2377 parm = RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier");
2380}
2381
2382/* fcurve.keyframe_points */
2384{
2385 StructRNA *srna;
2386
2387 FunctionRNA *func;
2388 PropertyRNA *parm;
2389
2390 static const EnumPropertyItem keyframe_flag_items[] = {
2392 "REPLACE",
2393 0,
2394 "Replace",
2395 "Don't add any new keyframes, but just replace existing ones"},
2396 {INSERTKEY_NEEDED, "NEEDED", 0, "Needed", "Only adds keyframes that are needed"},
2398 "FAST",
2399 0,
2400 "Fast",
2401 "Fast keyframe insertion to avoid recalculating the curve each time"},
2402 {0, nullptr, 0, nullptr, nullptr},
2403 };
2404
2405 RNA_def_property_srna(cprop, "FCurveKeyframePoints");
2406 srna = RNA_def_struct(brna, "FCurveKeyframePoints", nullptr);
2407 RNA_def_struct_sdna(srna, "FCurve");
2408 RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points");
2409
2410 func = RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert");
2411 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve");
2413 parm = RNA_def_float(func,
2414 "frame",
2415 0.0f,
2416 -FLT_MAX,
2417 FLT_MAX,
2418 "",
2419 "X Value of this keyframe point",
2420 -FLT_MAX,
2421 FLT_MAX);
2423 parm = RNA_def_float(func,
2424 "value",
2425 0.0f,
2426 -FLT_MAX,
2427 FLT_MAX,
2428 "",
2429 "Y Value of this keyframe point",
2430 -FLT_MAX,
2431 FLT_MAX);
2433 RNA_def_enum_flag(func, "options", keyframe_flag_items, 0, "", "Keyframe options");
2434 RNA_def_enum(func,
2435 "keyframe_type",
2438 "",
2439 "Type of keyframe to insert");
2440 parm = RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
2441 RNA_def_function_return(func, parm);
2442
2443 func = RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
2444 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve");
2446 parm = RNA_def_int(
2447 func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
2449
2450 func = RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
2451 RNA_def_function_ui_description(func, "Remove keyframe from an F-Curve");
2453 parm = RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove");
2456 /* optional */
2457 RNA_def_boolean(func,
2458 "fast",
2459 false,
2460 "Fast",
2461 "Fast keyframe removal to avoid recalculating the curve each time");
2462
2463 func = RNA_def_function(srna, "clear", "rna_FKeyframe_points_clear");
2464 RNA_def_function_ui_description(func, "Remove all keyframes from an F-Curve");
2466
2467 func = RNA_def_function(srna, "sort", "rna_FKeyframe_points_sort");
2468 RNA_def_function_ui_description(func, "Ensure all keyframe points are chronologically sorted");
2470
2471 func = RNA_def_function(srna, "deduplicate", "rna_FKeyframe_points_deduplicate");
2473 func,
2474 "Ensure there are no duplicate keys. Assumes that the points have already been sorted");
2476
2477 func = RNA_def_function(srna, "handles_recalc", "rna_FKeyframe_points_handles_recalc");
2479 "Update handles after modifications to the keyframe points, to "
2480 "update things like auto-clamping");
2482}
2483
2484static void rna_def_fcurve(BlenderRNA *brna)
2485{
2486 StructRNA *srna;
2487 PropertyRNA *prop;
2488 FunctionRNA *func;
2489 PropertyRNA *parm;
2490
2491 static const EnumPropertyItem prop_mode_extend_items[] = {
2493 "CONSTANT",
2494 0,
2495 "Constant",
2496 "Hold values of endpoint keyframes"},
2498 "LINEAR",
2499 0,
2500 "Linear",
2501 "Use slope of curve leading in/out of endpoint keyframes"},
2502 {0, nullptr, 0, nullptr, nullptr},
2503 };
2504 static const EnumPropertyItem prop_mode_color_items[] = {
2506 "AUTO_RAINBOW",
2507 0,
2508 "Auto Rainbow",
2509 "Cycle through the rainbow, trying to give each curve a unique color"},
2511 "AUTO_RGB",
2512 0,
2513 "Auto XYZ to RGB",
2514 "Use axis colors for transform and color properties, and auto-rainbow for the rest"},
2516 "AUTO_YRGB",
2517 0,
2518 "Auto WXYZ to YRGB",
2519 "Use axis colors for XYZ parts of transform, and yellow for the 'W' channel"},
2521 "CUSTOM",
2522 0,
2523 "User Defined",
2524 "Use custom hand-picked color for F-Curve"},
2525 {0, nullptr, 0, nullptr, nullptr},
2526 };
2527
2528 srna = RNA_def_struct(brna, "FCurve", nullptr);
2529 RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time");
2530 RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
2531
2532 /* Enums */
2533 prop = RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
2534 RNA_def_property_enum_sdna(prop, nullptr, "extend");
2535 RNA_def_property_enum_items(prop, prop_mode_extend_items);
2537 prop,
2538 "Extrapolation",
2539 "Method used for evaluating value of F-Curve outside first and last keyframes");
2540 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FCurve_update_data");
2541
2542 /* Pointers */
2543 prop = RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE);
2546 RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)");
2547
2548 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
2549 RNA_def_property_pointer_sdna(prop, nullptr, "grp");
2551 RNA_def_property_ui_text(prop, "Group", "Action Group that this F-Curve belongs to");
2552 RNA_def_property_pointer_funcs(prop, nullptr, "rna_FCurve_group_set", nullptr, nullptr);
2553 RNA_def_property_update(prop, NC_ANIMATION, nullptr);
2554
2555 /* Path + Array Index */
2556 prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
2558 prop, "rna_FCurve_RnaPath_get", "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set");
2559 RNA_def_property_ui_text(prop, "Data Path", "RNA Path to property affected by F-Curve");
2560 /* XXX need an update callback for this to that animation gets evaluated */
2561 RNA_def_property_update(prop, NC_ANIMATION, "rna_FCurve_update_data_relations");
2562
2563 /* called 'index' when given as function arg */
2564 prop = RNA_def_property(srna, "array_index", PROP_INT, PROP_UNSIGNED);
2566 prop, "RNA Array Index", "Index to the specific property affected by F-Curve if applicable");
2567 /* XXX need an update callback for this so that animation gets evaluated */
2568 RNA_def_property_update(prop, NC_ANIMATION, "rna_FCurve_update_data_relations");
2569
2570 /* Color */
2571 prop = RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
2572 RNA_def_property_enum_items(prop, prop_mode_color_items);
2574 prop, "Color Mode", "Method used to determine color of F-Curve in Graph Editor");
2575 RNA_def_property_update(prop, NC_ANIMATION, nullptr);
2576
2577 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
2578 RNA_def_property_array(prop, 3);
2579 RNA_def_property_range(prop, 0.0f, 1.0f);
2580 RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor");
2581 RNA_def_property_update(prop, NC_ANIMATION, nullptr);
2582
2583 /* Flags */
2584 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2585 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCURVE_SELECTED);
2586 RNA_def_property_ui_text(prop, "Select", "F-Curve is selected for editing");
2588
2589 prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
2590 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCURVE_PROTECTED);
2591 RNA_def_property_ui_text(prop, "Lock", "F-Curve's settings cannot be edited");
2593
2594 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
2595 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCURVE_MUTED);
2597 RNA_def_property_ui_text(prop, "Muted", "Disable F-Curve evaluation");
2598 RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, "rna_FCurve_update_eval");
2599
2600 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2603 prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs");
2605
2606 prop = RNA_def_property(srna, "auto_smoothing", PROP_ENUM, PROP_NONE);
2609 prop, "Auto Handle Smoothing", "Algorithm used to compute automatic handles");
2610 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FCurve_update_data");
2611
2612 /* State Info (for Debugging) */
2613 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
2616 prop,
2617 "Valid",
2618 "False when F-Curve could not be evaluated in past, so should be skipped "
2619 "when evaluating");
2621
2622 prop = RNA_def_property(srna, "is_empty", PROP_BOOLEAN, PROP_NONE);
2623 RNA_def_property_boolean_funcs(prop, "rna_FCurve_is_empty_get", nullptr);
2626 "Empty",
2627 "True if the curve contributes no animation due to lack of "
2628 "keyframes or useful modifiers, and should be deleted");
2629
2630 /* Collections */
2631 prop = RNA_def_property(srna, "sampled_points", PROP_COLLECTION, PROP_NONE);
2632 RNA_def_property_collection_sdna(prop, nullptr, "fpt", "totvert");
2633 RNA_def_property_struct_type(prop, "FCurveSample");
2634 RNA_def_property_ui_text(prop, "Sampled Points", "Sampled animation data");
2635
2636 prop = RNA_def_property(srna, "keyframe_points", PROP_COLLECTION, PROP_NONE);
2637 RNA_def_property_collection_sdna(prop, nullptr, "bezt", "totvert");
2638 RNA_def_property_struct_type(prop, "Keyframe");
2639 RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes");
2641
2642 prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
2643 RNA_def_property_struct_type(prop, "FModifier");
2644 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the shape of the F-Curve");
2645 rna_def_fcurve_modifiers(brna, prop);
2646
2647 /* Functions */
2648 /* -- evaluate -- */
2649 func = RNA_def_function(srna, "evaluate", "evaluate_fcurve"); /* calls the C/API direct */
2650 RNA_def_function_ui_description(func, "Evaluate F-Curve");
2651 parm = RNA_def_float(func,
2652 "frame",
2653 1.0f,
2654 -FLT_MAX,
2655 FLT_MAX,
2656 "Frame",
2657 "Evaluate F-Curve at given frame",
2658 -FLT_MAX,
2659 FLT_MAX);
2661 /* return value */
2662 parm = RNA_def_float(func,
2663 "value",
2664 0,
2665 -FLT_MAX,
2666 FLT_MAX,
2667 "Value",
2668 "Value of F-Curve specific frame",
2669 -FLT_MAX,
2670 FLT_MAX);
2671 RNA_def_function_return(func, parm);
2672
2673 /* -- update / recalculate -- */
2674 func = RNA_def_function(srna, "update", "rna_FCurve_update_data_ex");
2677 func, "Ensure keyframes are sorted in chronological order and handles are set correctly");
2678
2679 /* -- time extents/range -- */
2680 func = RNA_def_function(srna, "range", "rna_FCurve_range");
2681 RNA_def_function_ui_description(func, "Get the time extents for F-Curve");
2682 /* return value */
2683 parm = RNA_def_float_vector(
2684 func, "range", 2, nullptr, -FLT_MAX, FLT_MAX, "Range", "Min/Max values", -FLT_MAX, FLT_MAX);
2686 RNA_def_function_output(func, parm);
2687
2688 /* -- auto-flag validity (ensures valid handling for data type) -- */
2689 func = RNA_def_function(
2690 srna, "update_autoflags", "update_autoflags_fcurve"); /* calls the C/API direct */
2692 func,
2693 "Update FCurve flags set automatically from affected property "
2694 "(currently, integer/discrete flags set when the property is not a float)");
2696 parm = RNA_def_pointer(
2697 func, "data", "AnyType", "Data", "Data containing the property controlled by given FCurve");
2699
2700 /* Functions */
2701 RNA_api_fcurves(srna);
2702}
2703
2704/* *********************** */
2705
2707{
2708 rna_def_fcurve(brna);
2709 rna_def_fkeyframe(brna);
2710 rna_def_fpoint(brna);
2711
2713 rna_def_drivervar(brna);
2715
2716 rna_def_fmodifier(brna);
2717
2720
2723
2728}
2729
2730#endif
Functions and classes to work with Actions.
Functions to modify FCurves.
Blender kernel action and pose functionality.
void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve)
void action_groups_remove_channel(bAction *act, FCurve *fcu)
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:89
int BKE_fcm_envelope_find_index(FCM_EnvelopeData *array, float frame, int arraylen, bool *r_exists)
void BKE_fcurve_deduplicate_keys(FCurve *fcu)
void BKE_fmodifier_name_set(FModifier *fcm, const char *name)
int BKE_fcurve_bezt_binarysearch_index(const BezTriple array[], float frame, int arraylen, bool *r_replace)
void BKE_fcurve_handles_recalc(FCurve *fcu)
FModifier * add_fmodifier(ListBase *modifiers, int type, FCurve *owner_fcu)
bool remove_fmodifier(ListBase *modifiers, FModifier *fcm)
void set_active_fmodifier(ListBase *modifiers, FModifier *fcm)
bool BKE_fcurve_is_empty(const FCurve *fcu)
FModifier * find_active_fmodifier(ListBase *modifiers)
bool BKE_fcurve_calc_range(const FCurve *fcu, float *r_min, float *r_max, bool selected_keys_only)
void sort_time_fcurve(FCurve *fcu)
const FModifierTypeInfo * fmodifier_get_typeinfo(const FModifier *fcm)
void BKE_fcurve_delete_key(FCurve *fcu, int index)
void BKE_fcurve_delete_keys_all(FCurve *fcu)
struct DriverVar * driver_add_new_variable(struct ChannelDriver *driver)
void driver_variable_unique_name(struct DriverVar *dvar)
void BKE_driver_invalidate_expression(struct ChannelDriver *driver, bool expr_changed, bool varname_changed)
bool BKE_driver_has_simple_expression(struct ChannelDriver *driver)
void driver_free_variable_ex(struct ChannelDriver *driver, struct DriverVar *dvar)
void driver_change_variable_type(struct DriverVar *dvar, int type)
void driver_variable_name_validate(struct DriverVar *dvar)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
#define BLI_assert(a)
Definition BLI_assert.h:50
#define LISTBASE_FOREACH(type, var, list)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:110
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
Definition string.c:40
#define STRNCPY_UTF8(dst, src)
#define CLAMP(a, b, c)
#define ARRAY_HAS_ITEM(arr_item, arr_start, arr_len)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define UNLIKELY(x)
#define ELEM(...)
#define BLT_I18NCONTEXT_ID_ACTION
#define BLT_I18NCONTEXT_ID_ID
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_id_tag_update_ex(Main *bmain, ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1021
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1044
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
@ ID_AC
@ ID_OB
#define MAX_DRIVER_TARGETS
@ FCM_STEPPED_NO_AFTER
@ FCM_STEPPED_NO_BEFORE
@ DTAR_TRANSCHAN_ROTZ
@ DTAR_TRANSCHAN_SCALEX
@ DTAR_TRANSCHAN_SCALEZ
@ DTAR_TRANSCHAN_LOCX
@ DTAR_TRANSCHAN_ROTW
@ DTAR_TRANSCHAN_LOCY
@ DTAR_TRANSCHAN_ROTX
@ DTAR_TRANSCHAN_LOCZ
@ DTAR_TRANSCHAN_SCALE_AVG
@ DTAR_TRANSCHAN_SCALEY
@ DTAR_TRANSCHAN_ROTY
@ FCM_EXTRAPOLATE_MIRROR
@ FCM_EXTRAPOLATE_CYCLIC
@ FCM_EXTRAPOLATE_CYCLIC_OFFSET
@ FCM_EXTRAPOLATE_NONE
@ DTAR_OPTION_USE_FALLBACK
@ DRIVER_TYPE_AVERAGE
@ DRIVER_TYPE_PYTHON
@ DRIVER_TYPE_MAX
@ DRIVER_TYPE_MIN
@ DRIVER_TYPE_SUM
@ FCURVE_COLOR_AUTO_RGB
@ FCURVE_COLOR_AUTO_RAINBOW
@ FCURVE_COLOR_CUSTOM
@ FCURVE_COLOR_AUTO_YRGB
@ FCM_GENERATOR_ADDITIVE
@ FCM_LIMIT_XMIN
@ FCM_LIMIT_YMAX
@ FCM_LIMIT_XMAX
@ FCM_LIMIT_YMIN
@ FCM_NOISE_MODIF_REPLACE
@ FCM_NOISE_MODIF_SUBTRACT
@ FCM_NOISE_MODIF_ADD
@ FCM_NOISE_MODIF_MULTIPLY
@ DVAR_TYPE_LOC_DIFF
@ DVAR_TYPE_TRANSFORM_CHAN
@ DVAR_TYPE_ROT_DIFF
@ DVAR_TYPE_SINGLE_PROP
@ DVAR_TYPE_CONTEXT_PROP
eInsertKeyFlags
@ INSERTKEY_FAST
@ INSERTKEY_REPLACE
@ INSERTKEY_NEEDED
@ FMODIFIER_TYPE_CYCLES
@ FMODIFIER_TYPE_STEPPED
@ FMODIFIER_TYPE_FN_GENERATOR
@ FMODIFIER_TYPE_NOISE
@ FMODIFIER_TYPE_NULL
@ FMODIFIER_TYPE_GENERATOR
@ FMODIFIER_TYPE_ENVELOPE
@ FMODIFIER_TYPE_LIMITS
@ FCM_GENERATOR_POLYNOMIAL_FACTORISED
@ FCM_GENERATOR_POLYNOMIAL
@ FMODIFIER_FLAG_MUTED
@ FMODIFIER_FLAG_USEINFLUENCE
@ FMODIFIER_FLAG_ACTIVE
@ FMODIFIER_FLAG_DISABLED
@ FMODIFIER_FLAG_RANGERESTRICT
@ DTAR_ROTMODE_QUATERNION
@ DTAR_ROTMODE_SWING_TWIST_X
@ DTAR_ROTMODE_EULER_ZXY
@ DTAR_ROTMODE_SWING_TWIST_Y
@ DTAR_ROTMODE_EULER_XYZ
@ DTAR_ROTMODE_EULER_ZYX
@ DTAR_ROTMODE_AUTO
@ DTAR_ROTMODE_EULER_YXZ
@ DTAR_ROTMODE_EULER_XZY
@ DTAR_ROTMODE_SWING_TWIST_Z
@ DTAR_ROTMODE_EULER_YZX
@ DTAR_FLAG_LOCAL_CONSTS
@ DTAR_FLAG_LOCALSPACE
@ DTAR_FLAG_ID_OB_ONLY
@ DTAR_FLAG_FALLBACK_USED
@ DRIVER_FLAG_INVALID
@ DRIVER_FLAG_USE_SELF
@ FCURVE_DISABLED
@ FCURVE_MUTED
@ FCURVE_SELECTED
@ FCURVE_PROTECTED
@ FCURVE_VISIBLE
@ FCURVE_EXTRAPOLATE_CONSTANT
@ FCURVE_EXTRAPOLATE_LINEAR
@ FCURVE_SMOOTH_NONE
@ FCURVE_SMOOTH_CONT_ACCEL
@ DTAR_CONTEXT_PROPERTY_ACTIVE_SCENE
@ DTAR_CONTEXT_PROPERTY_ACTIVE_VIEW_LAYER
@ DVAR_FLAG_INVALID_NAME
@ BEZT_IPO_EASE_OUT
@ BEZT_IPO_EASE_AUTO
@ BEZT_IPO_EASE_IN
@ BEZT_IPO_EASE_IN_OUT
eBezTriple_KeyframeType
@ BEZT_KEYTYPE_EXTREME
@ BEZT_KEYTYPE_JITTER
@ BEZT_KEYTYPE_BREAKDOWN
@ BEZT_KEYTYPE_MOVEHOLD
@ BEZT_KEYTYPE_GENERATED
@ BEZT_KEYTYPE_KEYFRAME
Object is a sort of wrapper for general info.
#define MAXFRAMEF
#define MINAFRAMEF
@ UI_PANEL_DATA_EXPAND_ROOT
Read Guarded memory(de)allocation.
#define MEM_reallocN(vmemh, len)
#define RNA_POINTER_INVALIDATE(ptr)
StructRNA * ID_code_to_RNA_type(short idcode)
#define RNA_MAX_ARRAY_DIMENSION
Definition RNA_define.hh:26
ParameterFlag
Definition RNA_types.hh:396
@ PARM_RNAPTR
Definition RNA_types.hh:399
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:679
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
@ PROP_FLOAT
Definition RNA_types.hh:67
@ PROP_BOOLEAN
Definition RNA_types.hh:65
@ PROP_ENUM
Definition RNA_types.hh:69
@ PROP_INT
Definition RNA_types.hh:66
@ PROP_STRING
Definition RNA_types.hh:68
@ PROP_POINTER
Definition RNA_types.hh:70
@ PROP_COLLECTION
Definition RNA_types.hh:71
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:528
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:355
PropertyFlag
Definition RNA_types.hh:201
@ PROP_THICK_WRAP
Definition RNA_types.hh:312
@ PROP_DYNAMIC
Definition RNA_types.hh:317
@ PROP_EDITABLE
Definition RNA_types.hh:207
@ PROP_NEVER_NULL
Definition RNA_types.hh:266
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:328
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:284
@ PROP_TIME
Definition RNA_types.hh:156
@ PROP_COORDS
Definition RNA_types.hh:177
@ PROP_NONE
Definition RNA_types.hh:136
@ PROP_FACTOR
Definition RNA_types.hh:154
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:175
@ PROP_UNSIGNED
Definition RNA_types.hh:152
#define NC_ANIMATION
Definition WM_types.hh:355
#define NC_SCENE
Definition WM_types.hh:345
#define ND_MODIFIER
Definition WM_types.hh:429
#define NA_EDITED
Definition WM_types.hh:550
#define ND_SPACE_GRAPH
Definition WM_types.hh:498
#define ND_KEYFRAME_PROP
Definition WM_types.hh:462
#define ND_FRAME
Definition WM_types.hh:401
#define NA_RENAME
Definition WM_types.hh:554
#define ND_KEYFRAME
Definition WM_types.hh:461
#define NC_OBJECT
Definition WM_types.hh:346
#define ND_ANIMCHAN
Definition WM_types.hh:463
#define NC_SPACE
Definition WM_types.hh:359
#define NA_SELECTED
Definition WM_types.hh:555
bool fcurve_assign_to_channel_group(FCurve &fcurve, bActionGroup &to_group)
#define printf
#define SELECT
void ED_keyframes_add(FCurve *fcu, int num_keys_to_add)
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define GS(x)
Definition iris.cc:202
void *(* MEM_mallocN)(size_t len, const char *str)
Definition mallocn.cc:44
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
ccl_device_inline float2 fmod(const float2 a, const float b)
KeyframeSettings get_keyframe_settings(bool from_userprefs)
SingleKeyingResult insert_vert_fcurve(FCurve *fcu, const float2 position, const KeyframeSettings &settings, eInsertKeyFlags flag)
Main Key-framing API call.
const EnumPropertyItem rna_enum_id_type_items[]
Definition rna_ID.cc:35
PointerRNA rna_pointer_inherit_refine(const PointerRNA *ptr, StructRNA *type, void *data)
const EnumPropertyItem rna_enum_beztriple_interpolation_mode_items[]
Definition rna_curve.cc:67
const EnumPropertyItem rna_enum_keyframe_handle_type_items[]
Definition rna_curve.cc:39
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
void RNA_def_struct_refine_func(StructRNA *srna, const char *refine)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t bit)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_enum_default(PropertyRNA *prop, int value)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
PropertyRNA * RNA_def_float_vector(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_dynamic_array_funcs(PropertyRNA *prop, const char *getlength)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_struct_sdna_from(StructRNA *srna, const char *structname, const char *propname)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set, const char *item)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
PropertyRNA * RNA_def_enum_flag(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_translation_context(PropertyRNA *prop, const char *context)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
static void rna_def_fmodifier_noise(BlenderRNA *brna)
static void rna_def_fmodifier_envelope(BlenderRNA *brna)
void RNA_def_fcurve(BlenderRNA *brna)
const EnumPropertyItem rna_enum_fmodifier_type_items[]
Definition rna_fcurve.cc:38
static const EnumPropertyItem rna_enum_driver_target_context_property_items[]
static void rna_def_fmodifier(BlenderRNA *brna)
static void rna_def_channeldriver(BlenderRNA *brna)
static void rna_def_channeldriver_variables(BlenderRNA *brna, PropertyRNA *cprop)
const EnumPropertyItem rna_enum_beztriple_interpolation_easing_items[]
static void rna_def_drivervar(BlenderRNA *brna)
static void rna_def_fmodifier_cycles(BlenderRNA *brna)
static void rna_def_drivertarget(BlenderRNA *brna)
static void rna_def_fcurve_keyframe_points(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_fmodifier_stepped(BlenderRNA *brna)
static void rna_def_fmodifier_generator(BlenderRNA *brna)
const EnumPropertyItem rna_enum_beztriple_keyframe_type_items[]
Definition rna_fcurve.cc:86
const EnumPropertyItem rna_enum_fcurve_auto_smoothing_items[]
Definition rna_fcurve.cc:70
static void rna_def_fcurve(BlenderRNA *brna)
const EnumPropertyItem rna_enum_driver_target_rotation_mode_items[]
static void rna_def_fmodifier_limits(BlenderRNA *brna)
static void rna_def_fpoint(BlenderRNA *brna)
static void rna_def_fmodifier_envelope_ctrl(BlenderRNA *brna)
static void rna_def_fmodifier_function_generator(BlenderRNA *brna)
static void rna_def_fmodifier_envelope_control_points(BlenderRNA *brna, PropertyRNA *cprop)
static void rna_def_fkeyframe(BlenderRNA *brna)
static void rna_def_fcurve_modifiers(BlenderRNA *brna, PropertyRNA *cprop)
void RNA_api_fcurves(StructRNA *srna)
void RNA_api_drivers(StructRNA *)
#define min(a, b)
Definition sort.c:32
#define FLT_MAX
Definition stdcycles.h:14
bAction * action
ListBase drivers
DriverTarget targets[8]
bActionGroup * grp
char * rna_path
ChannelDriver * driver
BezTriple * bezt
unsigned int totvert
ListBase modifiers
unsigned int arraysize
void(* verify_data)(FModifier *fcm)
Definition BKE_fcurve.hh:74
char name[64]
short ui_expand_flag
Definition DNA_ID.h:413
char name[66]
Definition DNA_ID.h:425
ID * owner_id
Definition RNA_types.hh:40
StructRNA * type
Definition RNA_types.hh:41
void * data
Definition RNA_types.hh:42
ListBase curves
float xmax
float xmin
float ymax
float ymin
void WM_main_add_notifier(uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4126
uint8_t flag
Definition wm_window.cc:138