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