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");
1363
1364 prop = RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE);
1367 prop, "Phase Multiple", "Scale factor determining the 'speed' of the function");
1368 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1370
1371 prop = RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE);
1373 RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function");
1374 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1375
1376 prop = RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE);
1378 RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by");
1379 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1380
1381 /* flags */
1382 prop = RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
1386 "Additive",
1387 "Values generated by this modifier are applied on top of "
1388 "the existing values instead of overwriting them");
1389 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1390
1391 prop = RNA_def_property(srna, "function_type", PROP_ENUM, PROP_NONE);
1393 RNA_def_property_enum_sdna(prop, nullptr, "type");
1394 RNA_def_property_enum_items(prop, prop_type_items);
1395 RNA_def_property_ui_text(prop, "Type", "Type of built-in function to use");
1396 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1397}
1398
1399/* --------- */
1400
1402{
1403 StructRNA *srna;
1404 PropertyRNA *prop;
1405
1406 srna = RNA_def_struct(brna, "FModifierEnvelopeControlPoint", nullptr);
1407 RNA_def_struct_ui_text(srna, "Envelope Control Point", "Control point for envelope F-Modifier");
1408 RNA_def_struct_sdna(srna, "FCM_EnvelopeData");
1409
1410 /* min/max extents
1411 * - for now, these are allowed to go past each other, so that we can have inverted action
1412 * - technically, the range is limited by the settings in the envelope-modifier data, not here...
1413 */
1414 prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
1415 RNA_def_property_float_sdna(prop, nullptr, "min");
1417 RNA_def_property_ui_text(prop, "Minimum Value", "Lower bound of envelope at this control-point");
1418 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1419
1420 prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
1421 RNA_def_property_float_sdna(prop, nullptr, "max");
1423 RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point");
1424 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1425
1426 /* Frame */
1427 prop = RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
1428 RNA_def_property_float_sdna(prop, nullptr, "time");
1430 RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on");
1431 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1432
1433 /* TODO: */
1434 /* - selection flags (not implemented in UI yet though) */
1435}
1436
1438{
1439 StructRNA *srna;
1440
1441 FunctionRNA *func;
1442 PropertyRNA *parm;
1443
1444 RNA_def_property_srna(cprop, "FModifierEnvelopeControlPoints");
1445 srna = RNA_def_struct(brna, "FModifierEnvelopeControlPoints", nullptr);
1446 RNA_def_struct_sdna(srna, "FModifier");
1447
1449 srna, "Control Points", "Control points defining the shape of the envelope");
1450
1451 func = RNA_def_function(srna, "add", "rna_FModifierEnvelope_points_add");
1452 RNA_def_function_ui_description(func, "Add a control point to a FModifierEnvelope");
1454 parm = RNA_def_float(func,
1455 "frame",
1456 0.0f,
1457 -FLT_MAX,
1458 FLT_MAX,
1459 "",
1460 "Frame to add this control-point",
1461 -FLT_MAX,
1462 FLT_MAX);
1464 parm = RNA_def_pointer(
1465 func, "point", "FModifierEnvelopeControlPoint", "", "Newly created control-point");
1466 RNA_def_function_return(func, parm);
1467
1468 func = RNA_def_function(srna, "remove", "rna_FModifierEnvelope_points_remove");
1469 RNA_def_function_ui_description(func, "Remove a control-point from an FModifierEnvelope");
1471 parm = RNA_def_pointer(
1472 func, "point", "FModifierEnvelopeControlPoint", "", "Control-point to remove");
1474}
1475
1477{
1478 StructRNA *srna;
1479 PropertyRNA *prop;
1480
1481 srna = RNA_def_struct(brna, "FModifierEnvelope", "FModifier");
1482 RNA_def_struct_ui_text(srna, "Envelope F-Modifier", "Scale the values of the modified F-Curve");
1483 RNA_def_struct_sdna_from(srna, "FMod_Envelope", "data");
1484
1485 /* Collections */
1486 prop = RNA_def_property(srna, "control_points", PROP_COLLECTION, PROP_NONE);
1487 RNA_def_property_collection_sdna(prop, nullptr, "data", "totvert");
1489 RNA_def_property_struct_type(prop, "FModifierEnvelopeControlPoint");
1491 prop, "Control Points", "Control points defining the shape of the envelope");
1493
1494 /* Range Settings */
1495 prop = RNA_def_property(srna, "reference_value", PROP_FLOAT, PROP_NONE);
1496 RNA_def_property_float_sdna(prop, nullptr, "midval");
1499 prop, "Reference Value", "Value that envelope's influence is centered around / based on");
1500 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1501
1502 prop = RNA_def_property(srna, "default_min", PROP_FLOAT, PROP_NONE);
1503 RNA_def_property_float_sdna(prop, nullptr, "min");
1506 prop, "Default Minimum", "Lower distance from Reference Value for 1:1 default influence");
1507 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1509
1510 prop = RNA_def_property(srna, "default_max", PROP_FLOAT, PROP_NONE);
1511 RNA_def_property_float_sdna(prop, nullptr, "max");
1514 prop, "Default Maximum", "Upper distance from Reference Value for 1:1 default influence");
1515 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1517}
1518
1519/* --------- */
1520
1522{
1523 StructRNA *srna;
1524 PropertyRNA *prop;
1525
1526 static const EnumPropertyItem prop_type_items[] = {
1527 {FCM_EXTRAPOLATE_NONE, "NONE", 0, "No Cycles", "Don't do anything"},
1528 {FCM_EXTRAPOLATE_CYCLIC, "REPEAT", 0, "Repeat Motion", "Repeat keyframe range as-is"},
1530 "REPEAT_OFFSET",
1531 0,
1532 "Repeat with Offset",
1533 "Repeat keyframe range, but with offset based on gradient between "
1534 "start and end values"},
1536 "MIRROR",
1537 0,
1538 "Repeat Mirrored",
1539 "Alternate between forward and reverse playback of keyframe range"},
1540 {0, nullptr, 0, nullptr, nullptr},
1541 };
1542
1543 srna = RNA_def_struct(brna, "FModifierCycles", "FModifier");
1544 RNA_def_struct_ui_text(srna, "Cycles F-Modifier", "Repeat the values of the modified F-Curve");
1545 RNA_def_struct_sdna_from(srna, "FMod_Cycles", "data");
1546
1547 /* before */
1548 prop = RNA_def_property(srna, "mode_before", PROP_ENUM, PROP_NONE);
1550 RNA_def_property_enum_sdna(prop, nullptr, "before_mode");
1551 RNA_def_property_enum_items(prop, prop_type_items);
1552 RNA_def_property_ui_text(prop, "Before Mode", "Cycling mode to use before first keyframe");
1553 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1554
1555 prop = RNA_def_property(srna, "cycles_before", PROP_INT, PROP_NONE);
1557 RNA_def_property_int_sdna(prop, nullptr, "before_cycles");
1559 prop,
1560 "Before Cycles",
1561 "Maximum number of cycles to allow before first keyframe (0 = infinite)");
1562 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1563
1564 /* after */
1565 prop = RNA_def_property(srna, "mode_after", PROP_ENUM, PROP_NONE);
1567 RNA_def_property_enum_sdna(prop, nullptr, "after_mode");
1568 RNA_def_property_enum_items(prop, prop_type_items);
1569 RNA_def_property_ui_text(prop, "After Mode", "Cycling mode to use after last keyframe");
1570 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1571
1572 prop = RNA_def_property(srna, "cycles_after", PROP_INT, PROP_NONE);
1574 RNA_def_property_int_sdna(prop, nullptr, "after_cycles");
1576 "After Cycles",
1577 "Maximum number of cycles to allow after last keyframe (0 = infinite)");
1578 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1579}
1580
1581/* --------- */
1582
1584{
1585 StructRNA *srna;
1586 PropertyRNA *prop;
1587
1588 srna = RNA_def_struct(brna, "FModifierLimits", "FModifier");
1590 srna, "Limit F-Modifier", "Limit the time/value ranges of the modified F-Curve");
1591 RNA_def_struct_sdna_from(srna, "FMod_Limits", "data");
1592
1593 prop = RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
1594 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_XMIN);
1596 RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum X value");
1597 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1598
1599 prop = RNA_def_property(srna, "use_min_y", PROP_BOOLEAN, PROP_NONE);
1600 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_YMIN);
1602 RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
1603 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1604
1605 prop = RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
1606 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_XMAX);
1608 RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
1609 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1610
1611 prop = RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
1612 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_YMAX);
1614 RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
1615 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1616
1617 prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
1618 RNA_def_property_float_sdna(prop, nullptr, "rect.xmin");
1621 prop, nullptr, "rna_FModifierLimits_minx_set", "rna_FModifierLimits_minx_range");
1622 RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
1623 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1624
1625 prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
1626 RNA_def_property_float_sdna(prop, nullptr, "rect.ymin");
1629 prop, nullptr, "rna_FModifierLimits_miny_set", "rna_FModifierLimits_miny_range");
1630 RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
1631 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1632
1633 prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
1634 RNA_def_property_float_sdna(prop, nullptr, "rect.xmax");
1637 prop, nullptr, "rna_FModifierLimits_maxx_set", "rna_FModifierLimits_maxx_range");
1638 RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
1639 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1640
1641 prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
1642 RNA_def_property_float_sdna(prop, nullptr, "rect.ymax");
1645 prop, nullptr, "rna_FModifierLimits_maxy_set", "rna_FModifierLimits_maxy_range");
1646 RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
1647 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1648}
1649
1650/* --------- */
1651
1653{
1654 StructRNA *srna;
1655 PropertyRNA *prop;
1656
1657 static const EnumPropertyItem prop_modification_items[] = {
1658 {FCM_NOISE_MODIF_REPLACE, "REPLACE", 0, "Replace", ""},
1659 {FCM_NOISE_MODIF_ADD, "ADD", 0, "Add", ""},
1660 {FCM_NOISE_MODIF_SUBTRACT, "SUBTRACT", 0, "Subtract", ""},
1661 {FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", 0, "Multiply", ""},
1662 {0, nullptr, 0, nullptr, nullptr},
1663 };
1664
1665 srna = RNA_def_struct(brna, "FModifierNoise", "FModifier");
1666 RNA_def_struct_ui_text(srna, "Noise F-Modifier", "Give randomness to the modified F-Curve");
1667 RNA_def_struct_sdna_from(srna, "FMod_Noise", "data");
1668
1669 prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
1670 RNA_def_property_enum_sdna(prop, nullptr, "modification");
1671 RNA_def_property_enum_items(prop, prop_modification_items);
1673 RNA_def_property_ui_text(prop, "Blend Type", "Method of modifying the existing F-Curve");
1674 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1675
1676 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
1677 RNA_def_property_float_sdna(prop, nullptr, "size");
1679 RNA_def_property_ui_text(prop, "Scale", "Scaling (in time) of the noise");
1680 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1682
1683 prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
1684 RNA_def_property_float_sdna(prop, nullptr, "strength");
1687 prop,
1688 "Strength",
1689 "Amplitude of the noise - the amount that it modifies the underlying curve");
1691 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1693
1694 prop = RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
1695 RNA_def_property_float_sdna(prop, nullptr, "phase");
1697 RNA_def_property_ui_text(prop, "Phase", "A random seed for the noise effect");
1698 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1700
1701 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
1702 RNA_def_property_float_sdna(prop, nullptr, "offset");
1704 RNA_def_property_ui_text(prop, "Offset", "Time offset for the noise effect");
1705 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1707
1708 prop = RNA_def_property(srna, "lacunarity", PROP_FLOAT, PROP_NONE);
1709 RNA_def_property_float_sdna(prop, nullptr, "lacunarity");
1713 "Lacunarity",
1714 "Gap between successive frequencies. Depth needs to be greater than 0 "
1715 "for this to have an effect");
1716 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1717
1718 prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_NONE);
1719 RNA_def_property_float_sdna(prop, nullptr, "roughness");
1723 "Roughness",
1724 "Amount of high frequency detail. Depth needs to be greater than 0 for "
1725 "this to have an effect");
1726 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1727
1728 prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
1729 RNA_def_property_int_sdna(prop, nullptr, "depth");
1731 RNA_def_property_ui_text(prop, "Depth", "Amount of fine level detail present in the noise");
1732 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1733
1734 prop = RNA_def_property(srna, "use_legacy_noise", PROP_BOOLEAN, PROP_NONE);
1735 RNA_def_property_boolean_sdna(prop, nullptr, "legacy_noise", 1);
1738 "Legacy Noise",
1739 "Use the legacy way of generating noise. Has the issue that it can "
1740 "produce values outside of -1/1");
1741 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1742}
1743
1744/* --------- */
1745
1747{
1748 StructRNA *srna;
1749 PropertyRNA *prop;
1750
1751 srna = RNA_def_struct(brna, "FModifierStepped", "FModifier");
1753 srna,
1754 "Stepped Interpolation F-Modifier",
1755 "Hold each interpolated value from the F-Curve for several frames without "
1756 "changing the timing");
1757 RNA_def_struct_sdna_from(srna, "FMod_Stepped", "data");
1758
1759 /* properties */
1760 prop = RNA_def_property(srna, "frame_step", PROP_FLOAT, PROP_NONE);
1761 RNA_def_property_float_sdna(prop, nullptr, "step_size");
1763 RNA_def_property_ui_text(prop, "Step Size", "Number of frames to hold each value");
1764 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1766
1767 prop = RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
1768 RNA_def_property_float_sdna(prop, nullptr, "offset");
1771 "Offset",
1772 "Reference number of frames before frames get held "
1773 "(use to get hold for '1-3' vs '5-7' holding patterns)");
1774 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1775
1776 prop = RNA_def_property(srna, "use_frame_start", PROP_BOOLEAN, PROP_NONE);
1780 prop, "Use Start Frame", "Restrict modifier to only act after its 'start' frame");
1781 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1782
1783 prop = RNA_def_property(srna, "use_frame_end", PROP_BOOLEAN, PROP_NONE);
1787 prop, "Use End Frame", "Restrict modifier to only act before its 'end' frame");
1788 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1789
1790 prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
1791 RNA_def_property_float_sdna(prop, nullptr, "start_frame");
1794 nullptr,
1795 "rna_FModifierStepped_frame_start_set",
1796 "rna_FModifierStepped_start_frame_range");
1798 prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
1799 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1800
1801 prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
1802 RNA_def_property_float_sdna(prop, nullptr, "end_frame");
1805 prop, nullptr, "rna_FModifierStepped_frame_end_set", "rna_FModifierStepped_end_frame_range");
1807 prop, "End Frame", "Frame that modifier's influence ends (if applicable)");
1808 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1809}
1810
1811/* --------- */
1812
1814{
1815 StructRNA *srna;
1816 PropertyRNA *prop;
1817
1818 /* base struct definition */
1819 srna = RNA_def_struct(brna, "FModifier", nullptr);
1820 RNA_def_struct_refine_func(srna, "rna_FModifierType_refine");
1821 RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve");
1822
1823 /* name */
1824 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1825 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_fModifier_name_set");
1826 RNA_def_property_ui_text(prop, "Name", "F-Curve Modifier name");
1828 RNA_def_struct_name_property(srna, prop);
1829
1830 /* type */
1831 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1835 RNA_def_property_ui_text(prop, "Type", "F-Curve Modifier Type");
1836
1837 /* settings */
1838 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
1840 RNA_def_property_boolean_sdna(prop, nullptr, "ui_expand_flag", 0);
1841 // RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
1842 RNA_def_property_boolean_funcs(prop, nullptr, "rna_FModifier_show_expanded_set");
1843 RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI");
1844 RNA_def_property_ui_icon(prop, ICON_RIGHTARROW, 1);
1845
1846 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1849 RNA_def_property_ui_text(prop, "Enabled", "Enable F-Curve modifier evaluation");
1850 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1851 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_HLT, -1);
1852
1853 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1856 // RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
1858 prop, "Disabled", "F-Curve Modifier has invalid settings and will not be evaluated");
1859 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1860
1861 /* TODO: setting this to true must ensure that all others in stack are turned off too... */
1862 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1865 RNA_def_property_ui_text(prop, "Active", "F-Curve modifier will show settings in the editor");
1866 RNA_def_property_boolean_funcs(prop, nullptr, "rna_FModifier_active_set");
1867 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_active_update");
1868 RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
1869
1870 /* restricted range */
1871 prop = RNA_def_property(srna, "use_restricted_range", PROP_BOOLEAN, PROP_NONE);
1875 prop,
1876 "Restrict Frame Range",
1877 "F-Curve Modifier is only applied for the specified frame range to help "
1878 "mask off effects in order to chain them");
1879 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1880
1881 prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
1882 RNA_def_property_float_sdna(prop, nullptr, "sfra");
1885 prop, nullptr, "rna_FModifier_start_frame_set", "rna_FModifier_start_frame_range");
1887 prop,
1888 "Start Frame",
1889 "Frame that modifier's influence starts (if Restrict Frame Range is in use)");
1890 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1891
1892 prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
1893 RNA_def_property_float_sdna(prop, nullptr, "efra");
1896 prop, nullptr, "rna_FModifier_end_frame_set", "rna_FModifier_end_frame_range");
1898 prop,
1899 "End Frame",
1900 "Frame that modifier's influence ends (if Restrict Frame Range is in use)");
1901 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1902
1903 prop = RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE);
1904 RNA_def_property_float_sdna(prop, nullptr, "blendin");
1906 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_FModifier_blending_range");
1908 prop, "Blend In", "Number of frames from start frame for influence to take effect");
1909 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1910
1911 prop = RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE);
1912 RNA_def_property_float_sdna(prop, nullptr, "blendout");
1914 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_FModifier_blending_range");
1916 prop, "Blend Out", "Number of frames from end frame for influence to fade out");
1917 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1918
1919 /* influence */
1920 prop = RNA_def_property(srna, "use_influence", PROP_BOOLEAN, PROP_NONE);
1924 prop, "Use Influence", "F-Curve Modifier's effects will be tempered by a default factor");
1925 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1926
1927 prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
1928 RNA_def_property_float_sdna(prop, nullptr, "influence");
1930 RNA_def_property_range(prop, 0.0f, 1.0f);
1933 prop, "Influence", "Amount of influence F-Curve Modifier will have when not fading in/out");
1934 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1935}
1936
1937/* *********************** */
1938
1940{
1941 StructRNA *srna;
1942 PropertyRNA *prop;
1943
1944 static const EnumPropertyItem prop_trans_chan_items[] = {
1945 {DTAR_TRANSCHAN_LOCX, "LOC_X", 0, "X Location", ""},
1946 {DTAR_TRANSCHAN_LOCY, "LOC_Y", 0, "Y Location", ""},
1947 {DTAR_TRANSCHAN_LOCZ, "LOC_Z", 0, "Z Location", ""},
1949 {DTAR_TRANSCHAN_ROTX, "ROT_X", 0, "X Rotation", ""},
1950 {DTAR_TRANSCHAN_ROTY, "ROT_Y", 0, "Y Rotation", ""},
1951 {DTAR_TRANSCHAN_ROTZ, "ROT_Z", 0, "Z Rotation", ""},
1952 {DTAR_TRANSCHAN_ROTW, "ROT_W", 0, "W Rotation", ""},
1954 {DTAR_TRANSCHAN_SCALEX, "SCALE_X", 0, "X Scale", ""},
1955 {DTAR_TRANSCHAN_SCALEY, "SCALE_Y", 0, "Y Scale", ""},
1956 {DTAR_TRANSCHAN_SCALEZ, "SCALE_Z", 0, "Z Scale", ""},
1957 {DTAR_TRANSCHAN_SCALE_AVG, "SCALE_AVG", 0, "Average Scale", ""},
1958 {0, nullptr, 0, nullptr, nullptr},
1959 };
1960
1961 static const EnumPropertyItem prop_local_space_items[] = {
1962 {0,
1963 "WORLD_SPACE",
1964 0,
1965 "World Space",
1966 "Transforms include effects of parenting/restpose and constraints"},
1968 "TRANSFORM_SPACE",
1969 0,
1970 "Transform Space",
1971 "Transforms don't include parenting/restpose or constraints"},
1973 "LOCAL_SPACE",
1974 0,
1975 "Local Space",
1976 "Transforms include effects of constraints but not "
1977 "parenting/restpose"},
1978 {0, nullptr, 0, nullptr, nullptr},
1979 };
1980
1981 srna = RNA_def_struct(brna, "DriverTarget", nullptr);
1982 RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables");
1983
1984 /* Target Properties - ID-block to Drive */
1985 prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1986 RNA_def_property_struct_type(prop, "ID");
1989 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
1990 /* NOTE: custom set function is ONLY to avoid rna setting a user for this. */
1992 prop, nullptr, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", nullptr);
1994 "ID",
1995 "ID-block that the specific property used can be found from "
1996 "(id_type property must be set first)");
1997 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
1998
1999 prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
2000 RNA_def_property_enum_sdna(prop, nullptr, "idtype");
2003 RNA_def_property_enum_funcs(prop, nullptr, "rna_DriverTarget_id_type_set", nullptr);
2004 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_type_editable");
2005 RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
2007 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2008
2009 /* Target Properties - Property to Drive */
2010 prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
2012 "rna_DriverTarget_RnaPath_get",
2013 "rna_DriverTarget_RnaPath_length",
2014 "rna_DriverTarget_RnaPath_set");
2015 RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from ID-block) to property used");
2016 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2017
2018 prop = RNA_def_property(srna, "bone_target", PROP_STRING, PROP_NONE);
2019 RNA_def_property_string_sdna(prop, nullptr, "pchan_name");
2020 RNA_def_property_ui_text(prop, "Bone Name", "Name of PoseBone to use as target");
2021 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2022
2023 prop = RNA_def_property(srna, "transform_type", PROP_ENUM, PROP_NONE);
2024 RNA_def_property_enum_sdna(prop, nullptr, "transChan");
2025 RNA_def_property_enum_items(prop, prop_trans_chan_items);
2026 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
2027 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2028
2029 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
2030 RNA_def_property_enum_sdna(prop, nullptr, "rotation_mode");
2032 RNA_def_property_ui_text(prop, "Rotation Mode", "Mode for calculating rotation channel values");
2033 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2034
2035 prop = RNA_def_property(srna, "transform_space", PROP_ENUM, PROP_NONE);
2036 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
2037 RNA_def_property_enum_items(prop, prop_local_space_items);
2038 RNA_def_property_ui_text(prop, "Transform Space", "Space in which transforms are used");
2039 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2040
2041 prop = RNA_def_property(srna, "context_property", PROP_ENUM, PROP_NONE);
2042 RNA_def_property_enum_sdna(prop, nullptr, "context_property");
2046 prop, "Context Property", "Type of a context-dependent data-block to access property from");
2047 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2048
2049 prop = RNA_def_property(srna, "use_fallback_value", PROP_BOOLEAN, PROP_NONE);
2052 "Use Fallback",
2053 "Use the fallback value if the data path can't be resolved, instead of "
2054 "failing to evaluate the driver");
2055 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2056
2057 prop = RNA_def_property(srna, "fallback_value", PROP_FLOAT, PROP_NONE);
2058 RNA_def_property_float_sdna(prop, nullptr, "fallback_value");
2060 prop, "Fallback", "The value to use if the data path can't be resolved");
2061 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2062
2063 prop = RNA_def_property(srna, "is_fallback_used", PROP_BOOLEAN, PROP_NONE);
2067 prop,
2068 "Is Fallback Used",
2069 "Indicates that the most recent variable evaluation used the fallback value");
2070}
2071
2073{
2074 StructRNA *srna;
2075 PropertyRNA *prop;
2076
2077 static const EnumPropertyItem prop_type_items[] = {
2079 "SINGLE_PROP",
2080 ICON_RNA,
2081 "Single Property",
2082 "Use the value from some RNA property"},
2084 "TRANSFORMS",
2085 ICON_DRIVER_TRANSFORM,
2086 "Transform Channel",
2087 "Final transformation value of object or bone"},
2089 "ROTATION_DIFF",
2090 ICON_DRIVER_ROTATIONAL_DIFFERENCE,
2091 "Rotational Difference",
2092 "Use the angle between two bones"},
2094 "LOC_DIFF",
2095 ICON_DRIVER_DISTANCE,
2096 "Distance",
2097 "Distance between two bones or objects"},
2099 "CONTEXT_PROP",
2100 ICON_RNA,
2101 "Context Property",
2102 "Use the value from some RNA property within the current evaluation context"},
2103 {0, nullptr, 0, nullptr, nullptr},
2104 };
2105
2106 srna = RNA_def_struct(brna, "DriverVariable", nullptr);
2107 RNA_def_struct_sdna(srna, "DriverVar");
2109 srna, "Driver Variable", "Variable from some source/target for driver relationship");
2110
2111 /* Variable Name */
2112 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2113 RNA_def_struct_name_property(srna, prop);
2114 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_DriverVariable_name_set");
2116 prop,
2117 "Name",
2118 "Name to use in scripted expressions/functions (no spaces or dots are allowed, "
2119 "and must start with a letter)");
2120 RNA_def_property_update(prop, 0, "rna_DriverVariable_update_name");
2121
2122 /* Enums */
2123 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2124 RNA_def_property_enum_items(prop, prop_type_items);
2125 RNA_def_property_enum_funcs(prop, nullptr, "rna_DriverVariable_type_set", nullptr);
2126 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
2127 RNA_def_property_update(prop, 0, "rna_DriverVariable_update_data");
2128
2129 /* Targets */
2130 /* TODO: for nicer API, only expose the relevant props via subclassing,
2131 * instead of exposing the collection of targets */
2132 prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
2133 RNA_def_property_collection_sdna(prop, nullptr, "targets", "num_targets");
2134 RNA_def_property_struct_type(prop, "DriverTarget");
2136 RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable");
2137
2138 /* Name Validity Flags */
2139 prop = RNA_def_property(srna, "is_name_valid", PROP_BOOLEAN, PROP_NONE);
2142 RNA_def_property_ui_text(prop, "Is Name Valid", "Is this a valid name for a driver variable");
2143}
2144
2145/* channeldriver.variables.* */
2147{
2148 StructRNA *srna;
2149 // PropertyRNA *prop;
2150
2151 FunctionRNA *func;
2152 PropertyRNA *parm;
2153
2154 RNA_def_property_srna(cprop, "ChannelDriverVariables");
2155 srna = RNA_def_struct(brna, "ChannelDriverVariables", nullptr);
2156 RNA_def_struct_sdna(srna, "ChannelDriver");
2158 srna, "ChannelDriver Variables", "Collection of channel driver Variables");
2159
2160 /* add variable */
2161 func = RNA_def_function(srna, "new", "rna_Driver_new_variable");
2162 RNA_def_function_ui_description(func, "Add a new variable for the driver");
2163 /* return type */
2164 parm = RNA_def_pointer(func, "var", "DriverVariable", "", "Newly created Driver Variable");
2165 RNA_def_function_return(func, parm);
2166
2167 /* remove variable */
2168 func = RNA_def_function(srna, "remove", "rna_Driver_remove_variable");
2169 RNA_def_function_ui_description(func, "Remove an existing variable from the driver");
2171 /* target to remove */
2172 parm = RNA_def_pointer(
2173 func, "variable", "DriverVariable", "", "Variable to remove from the driver");
2176}
2177
2179{
2180 StructRNA *srna;
2181 PropertyRNA *prop;
2182
2183 static const EnumPropertyItem prop_type_items[] = {
2184 {DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""},
2185 {DRIVER_TYPE_SUM, "SUM", 0, "Sum Values", ""},
2186 {DRIVER_TYPE_PYTHON, "SCRIPTED", 0, "Scripted Expression", ""},
2187 {DRIVER_TYPE_MIN, "MIN", 0, "Minimum Value", ""},
2188 {DRIVER_TYPE_MAX, "MAX", 0, "Maximum Value", ""},
2189 {0, nullptr, 0, nullptr, nullptr},
2190 };
2191
2192 srna = RNA_def_struct(brna, "Driver", nullptr);
2193 RNA_def_struct_sdna(srna, "ChannelDriver");
2195 srna, "Driver", "Driver for the value of a setting based on an external value");
2196 RNA_def_struct_ui_icon(srna, ICON_DRIVER);
2197
2198 /* Enums */
2199 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2200 RNA_def_property_enum_items(prop, prop_type_items);
2201 RNA_def_property_ui_text(prop, "Type", "Driver type");
2202 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data");
2203
2204 /* String values */
2205 prop = RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE);
2206 RNA_def_property_ui_text(prop, "Expression", "Expression to use for Scripted Expression");
2207 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_expr");
2208
2209 /* Collections */
2210 prop = RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE);
2211 RNA_def_property_collection_sdna(prop, nullptr, "variables", nullptr);
2212 RNA_def_property_struct_type(prop, "DriverVariable");
2214 RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver");
2216
2217 /* Settings */
2218 prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE);
2221 prop,
2222 "Use Self",
2223 "Include a 'self' variable in the name-space, "
2224 "so drivers can easily reference the data being modified (object, bone, etc...)");
2225
2226 /* State Info (for Debugging) */
2227 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
2230 prop, "Invalid", "Driver could not be evaluated in past, so should be skipped");
2231
2232 prop = RNA_def_property(srna, "is_simple_expression", PROP_BOOLEAN, PROP_NONE);
2234 RNA_def_property_boolean_funcs(prop, "rna_ChannelDriver_is_simple_expression_get", nullptr);
2236 prop,
2237 "Simple Expression",
2238 "The scripted expression can be evaluated without using the full Python interpreter");
2239
2240 /* Functions */
2241 RNA_api_drivers(srna);
2242}
2243
2244/* *********************** */
2245
2246static void rna_def_fpoint(BlenderRNA *brna)
2247{
2248 StructRNA *srna;
2249 PropertyRNA *prop;
2250
2251 srna = RNA_def_struct(brna, "FCurveSample", nullptr);
2252 RNA_def_struct_sdna(srna, "FPoint");
2253 RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve");
2254
2255 /* Boolean values */
2256 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2257 RNA_def_property_boolean_sdna(prop, nullptr, "flag", 1);
2258 RNA_def_property_ui_text(prop, "Select", "Selection status");
2260
2261 /* Vector value */
2262 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2263 RNA_def_property_float_sdna(prop, nullptr, "vec");
2264 RNA_def_property_array(prop, 2);
2265 RNA_def_property_ui_text(prop, "Point", "Point coordinates");
2267}
2268
2274{
2275 StructRNA *srna;
2276 PropertyRNA *prop;
2277
2278 srna = RNA_def_struct(brna, "Keyframe", nullptr);
2279 RNA_def_struct_sdna(srna, "BezTriple");
2281 srna, "Keyframe", "Bézier curve point with two handles defining a Keyframe on an F-Curve");
2282
2283 /* Boolean values */
2284 prop = RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
2285 RNA_def_property_boolean_sdna(prop, nullptr, "f1", SELECT);
2286 RNA_def_property_ui_text(prop, "Handle 1 selected", "Left handle selection status");
2288
2289 prop = RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
2290 RNA_def_property_boolean_sdna(prop, nullptr, "f3", SELECT);
2291 RNA_def_property_ui_text(prop, "Handle 2 selected", "Right handle selection status");
2293
2294 prop = RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
2295 RNA_def_property_boolean_sdna(prop, nullptr, "f2", SELECT);
2296 RNA_def_property_ui_text(prop, "Select", "Control point selection status");
2298
2299 /* Enums */
2300 prop = RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
2301 RNA_def_property_enum_sdna(prop, nullptr, "h1");
2303 RNA_def_property_ui_text(prop, "Left Handle Type", "Handle types");
2304 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2305
2306 prop = RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
2307 RNA_def_property_enum_sdna(prop, nullptr, "h2");
2309 RNA_def_property_ui_text(prop, "Right Handle Type", "Handle types");
2310 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2311
2312 prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
2313 RNA_def_property_enum_sdna(prop, nullptr, "ipo");
2316 "Interpolation",
2317 "Interpolation method to use for segment of the F-Curve from "
2318 "this Keyframe until the next Keyframe");
2320 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2321
2322 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2323 RNA_def_property_enum_sdna(prop, nullptr, "hide");
2325 RNA_def_property_ui_text(prop, "Type", "Type of keyframe (for visual purposes only)");
2327 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2328
2329 prop = RNA_def_property(srna, "easing", PROP_ENUM, PROP_NONE);
2330 RNA_def_property_enum_sdna(prop, nullptr, "easing");
2333 "Easing",
2334 "Which ends of the segment between this and the next keyframe easing "
2335 "interpolation is applied to");
2336 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2337
2338 prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_NONE);
2339 RNA_def_property_float_sdna(prop, nullptr, "back");
2340 RNA_def_property_ui_text(prop, "Back", "Amount of overshoot for 'back' easing");
2342 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2343
2344 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
2345 RNA_def_property_float_sdna(prop, nullptr, "amplitude");
2346 RNA_def_property_range(prop, 0.0f, FLT_MAX); /* only positive values... */
2348 prop, "Amplitude", "Amount to boost elastic bounces for 'elastic' easing");
2349 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2350
2351 prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE);
2352 RNA_def_property_float_sdna(prop, nullptr, "period");
2353 RNA_def_property_ui_text(prop, "Period", "Time between bounces for elastic easing");
2354 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2355
2356 /* Vector values */
2357 prop = RNA_def_property(
2358 srna, "handle_left", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2359 RNA_def_property_array(prop, 2);
2361 prop, "rna_FKeyframe_handle1_get", "rna_FKeyframe_handle1_set", nullptr);
2363 prop, "Left Handle", "Coordinates of the left handle (before the control point)");
2364 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2365
2366 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2367 RNA_def_property_array(prop, 2);
2369 prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_set", nullptr);
2370 RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
2371 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2372
2373 prop = RNA_def_property(
2374 srna, "co_ui", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2375 RNA_def_property_array(prop, 2);
2377 prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_ui_set", nullptr);
2379 prop,
2380 "Control Point",
2381 "Coordinates of the control point. Note: Changing this value also updates the handles "
2382 "similar to using the graph editor transform operator");
2383 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2384
2385 prop = RNA_def_property(
2386 srna, "handle_right", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2387 RNA_def_property_array(prop, 2);
2389 prop, "rna_FKeyframe_handle2_get", "rna_FKeyframe_handle2_set", nullptr);
2391 prop, "Right Handle", "Coordinates of the right handle (after the control point)");
2392 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2393}
2394
2396{
2397 /* add modifiers */
2398 StructRNA *srna;
2399 PropertyRNA *prop;
2400
2401 FunctionRNA *func;
2402 PropertyRNA *parm;
2403
2404 RNA_def_property_srna(cprop, "FCurveModifiers");
2405 srna = RNA_def_struct(brna, "FCurveModifiers", nullptr);
2406 RNA_def_struct_sdna(srna, "FCurve");
2407 RNA_def_struct_ui_text(srna, "F-Curve Modifiers", "Collection of F-Curve Modifiers");
2408
2409 /* Collection active property */
2410 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2411 RNA_def_property_struct_type(prop, "FModifier");
2414 prop, "rna_FCurve_active_modifier_get", "rna_FCurve_active_modifier_set", nullptr, nullptr);
2416 RNA_def_property_ui_text(prop, "Active F-Curve Modifier", "Active F-Curve Modifier");
2417
2418 /* Constraint collection */
2419 func = RNA_def_function(srna, "new", "rna_FCurve_modifiers_new");
2420 RNA_def_function_ui_description(func, "Add a constraint to this object");
2421 /* return type */
2422 parm = RNA_def_pointer(func, "fmodifier", "FModifier", "", "New fmodifier");
2423 RNA_def_function_return(func, parm);
2424 /* object to add */
2425 parm = RNA_def_enum(
2426 func, "type", rna_enum_fmodifier_type_items, 1, "", "Constraint type to add");
2428
2429 func = RNA_def_function(srna, "remove", "rna_FCurve_modifiers_remove");
2431 RNA_def_function_ui_description(func, "Remove a modifier from this F-Curve");
2432 /* modifier to remove */
2433 parm = RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier");
2436}
2437
2438/* fcurve.keyframe_points */
2440{
2441 StructRNA *srna;
2442
2443 FunctionRNA *func;
2444 PropertyRNA *parm;
2445
2446 static const EnumPropertyItem keyframe_flag_items[] = {
2448 "REPLACE",
2449 0,
2450 "Replace",
2451 "Don't add any new keyframes, but just replace existing ones"},
2452 {INSERTKEY_NEEDED, "NEEDED", 0, "Needed", "Only adds keyframes that are needed"},
2454 "FAST",
2455 0,
2456 "Fast",
2457 "Fast keyframe insertion to avoid recalculating the curve each time"},
2458 {0, nullptr, 0, nullptr, nullptr},
2459 };
2460
2461 RNA_def_property_srna(cprop, "FCurveKeyframePoints");
2462 srna = RNA_def_struct(brna, "FCurveKeyframePoints", nullptr);
2463 RNA_def_struct_sdna(srna, "FCurve");
2464 RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points");
2465
2466 func = RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert");
2467 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve");
2469 parm = RNA_def_float(func,
2470 "frame",
2471 0.0f,
2472 -FLT_MAX,
2473 FLT_MAX,
2474 "",
2475 "X Value of this keyframe point",
2476 -FLT_MAX,
2477 FLT_MAX);
2479 parm = RNA_def_float(func,
2480 "value",
2481 0.0f,
2482 -FLT_MAX,
2483 FLT_MAX,
2484 "",
2485 "Y Value of this keyframe point",
2486 -FLT_MAX,
2487 FLT_MAX);
2489 RNA_def_enum_flag(func, "options", keyframe_flag_items, 0, "", "Keyframe options");
2490 RNA_def_enum(func,
2491 "keyframe_type",
2494 "",
2495 "Type of keyframe to insert");
2496 parm = RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
2497 RNA_def_function_return(func, parm);
2498
2499 func = RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
2500 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve");
2502 parm = RNA_def_int(
2503 func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
2505
2506 func = RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
2507 RNA_def_function_ui_description(func, "Remove keyframe from an F-Curve");
2509 parm = RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove");
2512 /* optional */
2513 RNA_def_boolean(func,
2514 "fast",
2515 false,
2516 "Fast",
2517 "Fast keyframe removal to avoid recalculating the curve each time");
2518
2519 func = RNA_def_function(srna, "clear", "rna_FKeyframe_points_clear");
2520 RNA_def_function_ui_description(func, "Remove all keyframes from an F-Curve");
2522
2523 func = RNA_def_function(srna, "sort", "rna_FKeyframe_points_sort");
2524 RNA_def_function_ui_description(func, "Ensure all keyframe points are chronologically sorted");
2526
2527 func = RNA_def_function(srna, "deduplicate", "rna_FKeyframe_points_deduplicate");
2529 func,
2530 "Ensure there are no duplicate keys. Assumes that the points have already been sorted");
2532
2533 func = RNA_def_function(srna, "handles_recalc", "rna_FKeyframe_points_handles_recalc");
2535 "Update handles after modifications to the keyframe points, to "
2536 "update things like auto-clamping");
2538}
2539
2540static void rna_def_fcurve(BlenderRNA *brna)
2541{
2542 StructRNA *srna;
2543 PropertyRNA *prop;
2544 FunctionRNA *func;
2545 PropertyRNA *parm;
2546
2547 static const EnumPropertyItem prop_mode_extend_items[] = {
2549 "CONSTANT",
2550 0,
2551 "Constant",
2552 "Hold values of endpoint keyframes"},
2554 "LINEAR",
2555 0,
2556 "Linear",
2557 "Use slope of curve leading in/out of endpoint keyframes"},
2558 {0, nullptr, 0, nullptr, nullptr},
2559 };
2560 static const EnumPropertyItem prop_mode_color_items[] = {
2562 "AUTO_RAINBOW",
2563 0,
2564 "Auto Rainbow",
2565 "Cycle through the rainbow, trying to give each curve a unique color"},
2567 "AUTO_RGB",
2568 0,
2569 "Auto XYZ to RGB",
2570 "Use axis colors for transform and color properties, and auto-rainbow for the rest"},
2572 "AUTO_YRGB",
2573 0,
2574 "Auto WXYZ to YRGB",
2575 "Use axis colors for XYZ parts of transform, and yellow for the 'W' channel"},
2577 "CUSTOM",
2578 0,
2579 "User Defined",
2580 "Use custom hand-picked color for F-Curve"},
2581 {0, nullptr, 0, nullptr, nullptr},
2582 };
2583
2584 srna = RNA_def_struct(brna, "FCurve", nullptr);
2585 RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time");
2586 RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
2587 RNA_def_struct_path_func(srna, "rna_FCurve_path");
2588
2589 /* Enums */
2590 prop = RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
2591 RNA_def_property_enum_sdna(prop, nullptr, "extend");
2592 RNA_def_property_enum_items(prop, prop_mode_extend_items);
2594 prop,
2595 "Extrapolation",
2596 "Method used for evaluating value of F-Curve outside first and last keyframes");
2597 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FCurve_update_data");
2598
2599 /* Pointers */
2600 prop = RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE);
2603 RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)");
2604
2605 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
2606 RNA_def_property_pointer_sdna(prop, nullptr, "grp");
2608 RNA_def_property_ui_text(prop, "Group", "Action Group that this F-Curve belongs to");
2609 RNA_def_property_pointer_funcs(prop, nullptr, "rna_FCurve_group_set", nullptr, nullptr);
2610 RNA_def_property_update(prop, NC_ANIMATION, nullptr);
2611
2612 /* Path + Array Index */
2613 prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
2615 prop, "rna_FCurve_RnaPath_get", "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set");
2616 RNA_def_property_ui_text(prop, "Data Path", "RNA Path to property affected by F-Curve");
2617 /* XXX need an update callback for this to that animation gets evaluated */
2618 RNA_def_property_update(prop, NC_ANIMATION, "rna_FCurve_update_data_relations");
2619
2620 /* called 'index' when given as function arg */
2621 prop = RNA_def_property(srna, "array_index", PROP_INT, PROP_UNSIGNED);
2623 prop, "RNA Array Index", "Index to the specific property affected by F-Curve if applicable");
2624 /* XXX need an update callback for this so that animation gets evaluated */
2625 RNA_def_property_update(prop, NC_ANIMATION, "rna_FCurve_update_data_relations");
2626
2627 /* Color */
2628 prop = RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
2629 RNA_def_property_enum_items(prop, prop_mode_color_items);
2631 prop, "Color Mode", "Method used to determine color of F-Curve in Graph Editor");
2632 RNA_def_property_update(prop, NC_ANIMATION, nullptr);
2633
2634 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
2635 RNA_def_property_array(prop, 3);
2636 RNA_def_property_range(prop, 0.0f, 1.0f);
2637 RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor");
2638 RNA_def_property_update(prop, NC_ANIMATION, nullptr);
2639
2640 /* Flags */
2641 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2642 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCURVE_SELECTED);
2643 RNA_def_property_ui_text(prop, "Select", "F-Curve is selected for editing");
2645
2646 prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
2647 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCURVE_PROTECTED);
2648 RNA_def_property_ui_text(prop, "Lock", "F-Curve's settings cannot be edited");
2650
2651 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
2652 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCURVE_MUTED);
2654 RNA_def_property_ui_text(prop, "Muted", "Disable F-Curve evaluation");
2655 RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, "rna_FCurve_update_eval");
2656
2657 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2660 prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs");
2662
2663 prop = RNA_def_property(srna, "auto_smoothing", PROP_ENUM, PROP_NONE);
2666 prop, "Auto Handle Smoothing", "Algorithm used to compute automatic handles");
2667 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FCurve_update_data");
2668
2669 /* State Info (for Debugging) */
2670 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
2673 prop,
2674 "Valid",
2675 "False when F-Curve could not be evaluated in past, so should be skipped "
2676 "when evaluating");
2678
2679 prop = RNA_def_property(srna, "is_empty", PROP_BOOLEAN, PROP_NONE);
2680 RNA_def_property_boolean_funcs(prop, "rna_FCurve_is_empty_get", nullptr);
2683 "Empty",
2684 "True if the curve contributes no animation due to lack of "
2685 "keyframes or useful modifiers, and should be deleted");
2686
2687 /* Collections */
2688 prop = RNA_def_property(srna, "sampled_points", PROP_COLLECTION, PROP_NONE);
2689 RNA_def_property_collection_sdna(prop, nullptr, "fpt", "totvert");
2690 RNA_def_property_struct_type(prop, "FCurveSample");
2691 RNA_def_property_ui_text(prop, "Sampled Points", "Sampled animation data");
2692
2693 prop = RNA_def_property(srna, "keyframe_points", PROP_COLLECTION, PROP_NONE);
2694 RNA_def_property_collection_sdna(prop, nullptr, "bezt", "totvert");
2695 RNA_def_property_struct_type(prop, "Keyframe");
2696 RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes");
2698
2699 prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
2700 RNA_def_property_struct_type(prop, "FModifier");
2701 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the shape of the F-Curve");
2702 rna_def_fcurve_modifiers(brna, prop);
2703
2704 /* Functions */
2705 /* -- evaluate -- */
2706 func = RNA_def_function(srna, "evaluate", "evaluate_fcurve"); /* calls the C/API direct */
2707 RNA_def_function_ui_description(func, "Evaluate F-Curve");
2708 parm = RNA_def_float(func,
2709 "frame",
2710 1.0f,
2711 -FLT_MAX,
2712 FLT_MAX,
2713 "Frame",
2714 "Evaluate F-Curve at given frame",
2715 -FLT_MAX,
2716 FLT_MAX);
2718 /* return value */
2719 parm = RNA_def_float(func,
2720 "value",
2721 0,
2722 -FLT_MAX,
2723 FLT_MAX,
2724 "Value",
2725 "Value of F-Curve specific frame",
2726 -FLT_MAX,
2727 FLT_MAX);
2728 RNA_def_function_return(func, parm);
2729
2730 /* -- update / recalculate -- */
2731 func = RNA_def_function(srna, "update", "rna_FCurve_update_data_ex");
2734 func, "Ensure keyframes are sorted in chronological order and handles are set correctly");
2735
2736 /* -- time extents/range -- */
2737 func = RNA_def_function(srna, "range", "rna_FCurve_range");
2738 RNA_def_function_ui_description(func, "Get the time extents for F-Curve");
2739 /* return value */
2740 parm = RNA_def_float_vector(
2741 func, "range", 2, nullptr, -FLT_MAX, FLT_MAX, "Range", "Min/Max values", -FLT_MAX, FLT_MAX);
2743 RNA_def_function_output(func, parm);
2744
2745 /* -- auto-flag validity (ensures valid handling for data type) -- */
2746 func = RNA_def_function(
2747 srna, "update_autoflags", "update_autoflags_fcurve"); /* calls the C/API direct */
2749 func,
2750 "Update FCurve flags set automatically from affected property "
2751 "(currently, integer/discrete flags set when the property is not a float)");
2753 parm = RNA_def_pointer(
2754 func, "data", "AnyType", "Data", "Data containing the property controlled by given FCurve");
2756
2757 /* Functions */
2758 RNA_api_fcurves(srna);
2759}
2760
2761/* *********************** */
2762
2764{
2765 rna_def_fcurve(brna);
2766 rna_def_fkeyframe(brna);
2767 rna_def_fpoint(brna);
2768
2770 rna_def_drivervar(brna);
2772
2773 rna_def_fmodifier(brna);
2774
2777
2780
2785}
2786
2787#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:4227
uint8_t flag
Definition wm_window.cc:139