Blender V5.0
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_idtype.hh"
195# include "BKE_lib_id.hh"
196# include "BKE_report.hh"
197
198# include "DEG_depsgraph.hh"
199# include "DEG_depsgraph_build.hh"
200
201# include "WM_api.hh"
202
203static StructRNA *rna_FModifierType_refine(PointerRNA *ptr)
204{
205 FModifier *fcm = (FModifier *)ptr->data;
206
207 switch (fcm->type) {
209 return &RNA_FModifierGenerator;
211 return &RNA_FModifierFunctionGenerator;
213 return &RNA_FModifierEnvelope;
215 return &RNA_FModifierCycles;
217 return &RNA_FModifierNoise;
219 return &RNA_FModifierLimits;
221 return &RNA_FModifierStepped;
222 default:
223 return &RNA_UnknownType;
224 }
225}
226
231static FCurve *rna_FCurve_find_driver_by_variable(ID *owner_id, DriverVar *dvar)
232{
233 AnimData *adt = BKE_animdata_from_id(owner_id);
234 BLI_assert(adt != nullptr);
235 LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) {
236 ChannelDriver *driver = fcu->driver;
237 if (driver == nullptr) {
238 continue;
239 }
240 if (BLI_findindex(&driver->variables, dvar) != -1) {
241 return fcu;
242 }
243 }
244 return nullptr;
245}
246
251static FCurve *rna_FCurve_find_driver_by_target(ID *owner_id, DriverTarget *dtar)
252{
253 AnimData *adt = BKE_animdata_from_id(owner_id);
254 BLI_assert(adt != nullptr);
255 LISTBASE_FOREACH (FCurve *, fcu, &adt->drivers) {
256 ChannelDriver *driver = fcu->driver;
257 if (driver == nullptr) {
258 continue;
259 }
260 LISTBASE_FOREACH (DriverVar *, dvar, &driver->variables) {
261 /* NOTE: Use #MAX_DRIVER_TARGETS instead of `dvar->num_targets` because
262 * it's possible RNA holds a reference to a target that has been removed.
263 * In this case it's best to return the #FCurve it belongs to instead of nothing. */
264 if (ARRAY_HAS_ITEM(dtar, &dvar->targets[0], MAX_DRIVER_TARGETS)) {
265 return fcu;
266 }
267 }
268 }
269 return nullptr;
270}
271
272static bool rna_ChannelDriver_is_simple_expression_get(PointerRNA *ptr)
273{
274 ChannelDriver *driver = static_cast<ChannelDriver *>(ptr->data);
275
277}
278
279static void rna_ChannelDriver_update_data_impl(Main *bmain,
280 Scene *scene,
281 ID *owner_id,
282 ChannelDriver *driver)
283{
284 driver->flag &= ~DRIVER_FLAG_INVALID;
285
286 /* TODO: this really needs an update guard... */
289
291}
292
293static void rna_ChannelDriver_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
294{
295 ID *id = ptr->owner_id;
296 ChannelDriver *driver = static_cast<ChannelDriver *>(ptr->data);
297 rna_ChannelDriver_update_data_impl(bmain, scene, id, driver);
298}
299
300static void rna_ChannelDriver_update_expr(Main *bmain, Scene *scene, PointerRNA *ptr)
301{
302 ChannelDriver *driver = static_cast<ChannelDriver *>(ptr->data);
303
304 /* tag driver as needing to be recompiled */
305 BKE_driver_invalidate_expression(driver, true, false);
306
307 /* update_data() clears invalid flag and schedules for updates */
308 rna_ChannelDriver_update_data(bmain, scene, ptr);
309}
310
311static void rna_DriverTarget_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
312{
313 DriverTarget *dtar = (DriverTarget *)ptr->data;
314 FCurve *fcu = rna_FCurve_find_driver_by_target(ptr->owner_id, dtar);
315 BLI_assert(fcu); /* This hints at an internal error, data may be corrupt. */
316 if (UNLIKELY(fcu == nullptr)) {
317 return;
318 }
319 /* Find function ensures it's never nullptr. */
320 ChannelDriver *driver = fcu->driver;
321 fcu->flag &= ~FCURVE_DISABLED;
322 rna_ChannelDriver_update_data_impl(bmain, scene, ptr->owner_id, driver);
323}
324
325static void rna_DriverVariable_update_name(Main *bmain, Scene *scene, PointerRNA *ptr)
326{
327 DriverVar *dvar = (DriverVar *)ptr->data;
328 FCurve *fcu = rna_FCurve_find_driver_by_variable(ptr->owner_id, dvar);
329 BLI_assert(fcu); /* This hints at an internal error, data may be corrupt. */
330 if (UNLIKELY(fcu == nullptr)) {
331 return;
332 }
333 /* Find function ensures it's never nullptr. */
334 ChannelDriver *driver = fcu->driver;
335 fcu->flag &= ~FCURVE_DISABLED;
336 rna_ChannelDriver_update_data_impl(bmain, scene, ptr->owner_id, driver);
337 BKE_driver_invalidate_expression(driver, false, true);
338}
339
340static void rna_DriverVariable_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
341{
342 DriverVar *dvar = (DriverVar *)ptr->data;
343 FCurve *fcu = rna_FCurve_find_driver_by_variable(ptr->owner_id, dvar);
344 BLI_assert(fcu); /* This hints at an internal error, data may be corrupt. */
345 if (UNLIKELY(fcu == nullptr)) {
346 return;
347 }
348 /* Find function ensures it's never nullptr. */
349 ChannelDriver *driver = fcu->driver;
350 fcu->flag &= ~FCURVE_DISABLED;
351 rna_ChannelDriver_update_data_impl(bmain, scene, ptr->owner_id, driver);
352}
353
354/* ----------- */
355
356void rna_DriverTarget_id_set(PointerRNA *ptr, PointerRNA value, struct ReportList * /*reports*/)
357{
358 DriverTarget *data = ptr->data_as<DriverTarget>();
359 ID *id = value.data_as<ID>();
360 if (!id) {
361 data->id = nullptr;
362 return;
363 }
364 BLI_assert(id == value.owner_id);
365 if (ptr->owner_id && !BKE_id_can_use_id(*ptr->owner_id, *id)) {
366 return;
367 }
368 /* Driver targets may be local data referencing unlinkable data like shape keys. These cannot be
369 * directly linked.
370 * FIXME: Band-aid, find a better way to handle this. */
371 if (BKE_idtype_idcode_is_linkable(GS(id->name))) {
372 id_lib_extern(id);
373 }
374 data->id = id;
375}
376
377static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr)
378{
379 DriverTarget *dtar = (DriverTarget *)ptr->data;
380 return ID_code_to_RNA_type(dtar->idtype);
381}
382
383static int rna_DriverTarget_id_editable(const PointerRNA *ptr, const char ** /*r_info*/)
384{
385 DriverTarget *dtar = (DriverTarget *)ptr->data;
386 return (dtar->idtype) ? PROP_EDITABLE : PropertyFlag(0);
387}
388
389static int rna_DriverTarget_id_type_editable(const PointerRNA *ptr, const char ** /*r_info*/)
390{
391 DriverTarget *dtar = (DriverTarget *)ptr->data;
392
393 /* when the id-type can only be object, don't allow editing
394 * otherwise, there may be strange crashes
395 */
396 return ((dtar->flag & DTAR_FLAG_ID_OB_ONLY) == 0);
397}
398
399static void rna_DriverTarget_id_type_set(PointerRNA *ptr, int value)
400{
401 DriverTarget *data = (DriverTarget *)(ptr->data);
402
403 /* check if ID-type is settable */
404 if ((data->flag & DTAR_FLAG_ID_OB_ONLY) == 0) {
405 /* change ID-type to the new type */
406 data->idtype = value;
407 }
408 else {
409 /* make sure ID-type is Object */
410 data->idtype = ID_OB;
411 }
412
413 /* clear the id-block if the type is invalid */
414 if ((data->id) && (GS(data->id->name) != data->idtype)) {
415 data->id = nullptr;
416 }
417}
418
419static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value)
420{
421 DriverTarget *dtar = (DriverTarget *)ptr->data;
422
423 if (dtar->rna_path) {
424 strcpy(value, dtar->rna_path);
425 }
426 else {
427 value[0] = '\0';
428 }
429}
430
431static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr)
432{
433 DriverTarget *dtar = (DriverTarget *)ptr->data;
434
435 if (dtar->rna_path) {
436 return strlen(dtar->rna_path);
437 }
438 return 0;
439}
440
441static void rna_DriverTarget_RnaPath_set(PointerRNA *ptr, const char *value)
442{
443 DriverTarget *dtar = (DriverTarget *)ptr->data;
444
445 /* XXX in this case we need to be very careful,
446 * as this will require some new dependencies to be added! */
447 if (dtar->rna_path) {
448 MEM_freeN(dtar->rna_path);
449 }
450
451 if (value[0]) {
452 dtar->rna_path = BLI_strdup(value);
453 }
454 else {
455 dtar->rna_path = nullptr;
456 }
457}
458
459static void rna_DriverVariable_type_set(PointerRNA *ptr, int value)
460{
461 DriverVar *dvar = (DriverVar *)ptr->data;
462
463 /* call the API function for this */
464 driver_change_variable_type(dvar, value);
465}
466
467void rna_DriverVariable_name_set(PointerRNA *ptr, const char *value)
468{
469 DriverVar *data = (DriverVar *)(ptr->data);
470
471 STRNCPY_UTF8(data->name, value);
474}
475
476/* ----------- */
477
478static DriverVar *rna_Driver_new_variable(ChannelDriver *driver)
479{
480 /* call the API function for this */
481 return driver_add_new_variable(driver);
482}
483
484static void rna_Driver_remove_variable(ChannelDriver *driver,
485 ReportList *reports,
486 PointerRNA *dvar_ptr)
487{
488 DriverVar *dvar = static_cast<DriverVar *>(dvar_ptr->data);
489 if (BLI_findindex(&driver->variables, dvar) == -1) {
490 BKE_report(reports, RPT_ERROR, "Variable does not exist in this driver");
491 return;
492 }
493
494 driver_free_variable_ex(driver, dvar);
495 dvar_ptr->invalidate();
496}
497
498/* ****************************** */
499
500static void rna_FKeyframe_handle1_get(PointerRNA *ptr, float *values)
501{
502 BezTriple *bezt = (BezTriple *)ptr->data;
503
504 values[0] = bezt->vec[0][0];
505 values[1] = bezt->vec[0][1];
506}
507
508static void rna_FKeyframe_handle1_set(PointerRNA *ptr, const float *values)
509{
510 BezTriple *bezt = (BezTriple *)ptr->data;
511
512 bezt->vec[0][0] = values[0];
513 bezt->vec[0][1] = values[1];
514}
515
516static void rna_FKeyframe_handle2_get(PointerRNA *ptr, float *values)
517{
518 BezTriple *bezt = (BezTriple *)ptr->data;
519
520 values[0] = bezt->vec[2][0];
521 values[1] = bezt->vec[2][1];
522}
523
524static void rna_FKeyframe_handle2_set(PointerRNA *ptr, const float *values)
525{
526 BezTriple *bezt = (BezTriple *)ptr->data;
527
528 bezt->vec[2][0] = values[0];
529 bezt->vec[2][1] = values[1];
530}
531
532static void rna_FKeyframe_ctrlpoint_get(PointerRNA *ptr, float *values)
533{
534 BezTriple *bezt = (BezTriple *)ptr->data;
535
536 values[0] = bezt->vec[1][0];
537 values[1] = bezt->vec[1][1];
538}
539
540static void rna_FKeyframe_ctrlpoint_set(PointerRNA *ptr, const float *values)
541{
542 BezTriple *bezt = (BezTriple *)ptr->data;
543
544 bezt->vec[1][0] = values[0];
545 bezt->vec[1][1] = values[1];
546}
547
548static void rna_FKeyframe_ctrlpoint_ui_set(PointerRNA *ptr, const float *values)
549{
550 BezTriple *bezt = (BezTriple *)ptr->data;
551
552 const float frame_delta = values[0] - bezt->vec[1][0];
553 const float value_delta = values[1] - bezt->vec[1][1];
554
555 /* To match the behavior of transforming the keyframe Co using the Graph Editor
556 * (`transform_convert_graph.cc`) flushTransGraphData(), we will also move the handles by
557 * the same amount as the Co delta. */
558
559 bezt->vec[0][0] += frame_delta;
560 bezt->vec[0][1] += value_delta;
561
562 bezt->vec[1][0] = values[0];
563 bezt->vec[1][1] = values[1];
564
565 bezt->vec[2][0] += frame_delta;
566 bezt->vec[2][1] += value_delta;
567}
568
569/* ****************************** */
570
571static std::optional<std::string> rna_FCurve_path(const PointerRNA *ptr)
572{
573 using namespace blender;
574 FCurve *fcurve = reinterpret_cast<FCurve *>(ptr->data);
575
576 /* If the F-Curve is not owned by an Action, bail out early. It could be a driver, NLA control
577 * curve, or stored in some place that's yet unknown at the time of writing of this code. */
578 if (GS(ptr->owner_id) != ID_AC) {
579 return {};
580 }
581
582 animrig::Action &action = reinterpret_cast<bAction *>(ptr->owner_id)->wrap();
583
584 for (animrig::Layer *layer : action.layers()) {
585 for (animrig::Strip *strip : layer->strips()) {
586 if (strip->type() != animrig::Strip::Type::Keyframe) {
587 continue;
588 }
589
590 animrig::StripKeyframeData &strip_data = strip->data<animrig::StripKeyframeData>(action);
591 for (animrig::Channelbag *channelbag : strip_data.channelbags()) {
592 const int fcurve_index = channelbag->fcurves().first_index_try(fcurve);
593 if (fcurve_index != -1) {
595 &action.id, &RNA_ActionChannelbag, channelbag);
596 const std::optional<std::string> channelbag_path = rna_Channelbag_path(&channelbag_ptr);
597 return fmt::format("{}.fcurves[{}]", *channelbag_path, fcurve_index);
598 }
599 }
600 }
601 }
602
603 return std::nullopt;
604}
605
606static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value)
607{
608 FCurve *fcu = (FCurve *)ptr->data;
609
610 if (fcu->rna_path) {
611 strcpy(value, fcu->rna_path);
612 }
613 else {
614 value[0] = '\0';
615 }
616}
617
618static int rna_FCurve_RnaPath_length(PointerRNA *ptr)
619{
620 FCurve *fcu = (FCurve *)ptr->data;
621
622 if (fcu->rna_path) {
623 return strlen(fcu->rna_path);
624 }
625 return 0;
626}
627
628static void rna_FCurve_RnaPath_set(PointerRNA *ptr, const char *value)
629{
630 FCurve *fcu = (FCurve *)ptr->data;
631
632 if (fcu->rna_path) {
633 MEM_freeN(fcu->rna_path);
634 }
635
636 if (value[0]) {
637 fcu->rna_path = BLI_strdup(value);
638 fcu->flag &= ~FCURVE_DISABLED;
639 }
640 else {
641 fcu->rna_path = nullptr;
642 }
643}
644
645static void rna_FCurve_group_set(PointerRNA *ptr, PointerRNA value, ReportList * /*reports*/)
646{
647 ID *pid = ptr->owner_id;
648 ID *vid = value.owner_id;
649 FCurve *fcu = static_cast<FCurve *>(ptr->data);
650 bAction *act = nullptr;
651
652 /* get action */
653 if (ELEM(nullptr, pid, vid)) {
654 printf("ERROR: one of the ID's for the groups to assign to is invalid (ptr=%p, val=%p)\n",
655 pid,
656 vid);
657 return;
658 }
659 if (value.data && (pid != vid)) {
660 /* ids differ, can't do this, should raise an error */
661 printf("ERROR: IDs differ - ptr=%p vs value=%p\n", pid, vid);
662 return;
663 }
664
665 if (GS(pid->name) == ID_AC && GS(vid->name) == ID_AC) {
666 /* The ID given is the action already -
667 * usually when F-Curve is obtained from an action's pointer. */
668 act = (bAction *)pid;
669 }
670 else {
671 /* the ID given is the owner of the F-Curve (for drivers) */
672 AnimData *adt = BKE_animdata_from_id(ptr->owner_id);
673 act = (adt) ? adt->action : nullptr;
674 }
675
676 /* already belongs to group? */
677 if (fcu->grp == value.data) {
678 /* nothing to do */
679 printf("ERROR: F-Curve already belongs to this group\n");
680 return;
681 }
682
683 /* can only change group if we have info about the action the F-Curve is in
684 * (i.e. for drivers or random F-Curves, this cannot be done)
685 */
686 if (act == nullptr) {
687 /* can't change the grouping of F-Curve when it doesn't belong to an action */
688 printf("ERROR: cannot assign F-Curve to group, since F-Curve is not attached to any ID\n");
689 return;
690 }
691
692 blender::animrig::Action &action = act->wrap();
693
694 /* Legacy action. */
695 if (!action.is_action_layered()) {
696
697 /* make sure F-Curve exists in this action first, otherwise we could still have been tricked */
698 if (BLI_findindex(&act->curves, fcu) == -1) {
699 printf("ERROR: F-Curve (%p) doesn't exist in action '%s'\n", fcu, act->id.name);
700 return;
701 }
702
703 /* try to remove F-Curve from action (including from any existing groups) */
705
706 /* Add the F-Curve back to the action now in the right place. */
707 /* TODO: make the API function handle the case where there isn't any group to assign to. */
708 if (value.data) {
709 /* add to its group using API function, which makes sure everything goes ok */
710 action_groups_add_channel(act, static_cast<bActionGroup *>(value.data), fcu);
711 }
712 else {
713 /* Need to add this back, but it can only go at the end of the list
714 * (or else will corrupt groups). */
715 BLI_addtail(&act->curves, fcu);
716 }
717
718 return;
719 }
720
721 /* Layered action. */
722 bActionGroup *group = static_cast<bActionGroup *>(value.data);
723
724 BLI_assert(group->channelbag != nullptr);
725 blender::animrig::Channelbag &channelbag = group->channelbag->wrap();
726
727 if (!channelbag.fcurve_assign_to_channel_group(*fcu, *group)) {
728 printf(
729 "ERROR: F-Curve (datapath: '%s') doesn't belong to the same channel bag as "
730 "channel group '%s'\n",
731 fcu->rna_path,
732 group->name);
733 return;
734 }
735}
736
737/* calculate time extents of F-Curve */
738static void rna_FCurve_range(FCurve *fcu, float range[2])
739{
740 BKE_fcurve_calc_range(fcu, range, range + 1, false);
741}
742
743static bool rna_FCurve_is_empty_get(PointerRNA *ptr)
744{
745 FCurve *fcu = (FCurve *)ptr->data;
746 return BKE_fcurve_is_empty(fcu);
747}
748
749static void rna_tag_animation_update(Main *bmain, ID *id)
750{
751 const int tags = ID_RECALC_ANIMATION;
753
754 if (adt && adt->action) {
755 /* Action is separate datablock, needs separate tag. */
756 DEG_id_tag_update_ex(bmain, &adt->action->id, tags);
757 }
758
759 DEG_id_tag_update_ex(bmain, id, tags);
760}
761
762/* allow scripts to update curve after editing manually */
763static void rna_FCurve_update_data_ex(ID *id, FCurve *fcu, Main *bmain)
764{
765 sort_time_fcurve(fcu);
768
769 rna_tag_animation_update(bmain, id);
770}
771
772/* RNA update callback for F-Curves after curve shape changes */
773static void rna_FCurve_update_data(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
774{
775 BLI_assert(ptr->type == &RNA_FCurve);
776 rna_FCurve_update_data_ex(ptr->owner_id, (FCurve *)ptr->data, bmain);
777}
778
779static void rna_FCurve_update_data_relations(Main *bmain, Scene * /*scene*/, PointerRNA * /*ptr*/)
780{
782}
783
784/* RNA update callback for F-Curves to indicate that there are copy-on-evaluation tagging/flushing
785 * needed (e.g. for properties that affect how animation gets evaluated).
786 */
787static void rna_FCurve_update_eval(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
788{
789 rna_tag_animation_update(bmain, ptr->owner_id);
790}
791
792static PointerRNA rna_FCurve_active_modifier_get(PointerRNA *ptr)
793{
794 FCurve *fcu = (FCurve *)ptr->data;
796 return RNA_pointer_create_with_parent(*ptr, &RNA_FModifier, fcm);
797}
798
799static void rna_FCurve_active_modifier_set(PointerRNA *ptr,
800 PointerRNA value,
801 ReportList * /*reports*/)
802{
803 FCurve *fcu = (FCurve *)ptr->data;
805}
806
807static FModifier *rna_FCurve_modifiers_new(FCurve *fcu, int type)
808{
809 return add_fmodifier(&fcu->modifiers, type, fcu);
810}
811
812static void rna_FCurve_modifiers_remove(FCurve *fcu, ReportList *reports, PointerRNA *fcm_ptr)
813{
814 FModifier *fcm = static_cast<FModifier *>(fcm_ptr->data);
815 if (BLI_findindex(&fcu->modifiers, fcm) == -1) {
816 BKE_reportf(reports, RPT_ERROR, "F-Curve modifier '%s' not found in F-Curve", fcm->name);
817 return;
818 }
819
820 remove_fmodifier(&fcu->modifiers, fcm);
822 fcm_ptr->invalidate();
823}
824
825static void rna_FModifier_active_set(PointerRNA *ptr, bool /*value*/)
826{
827 FModifier *fcm = (FModifier *)ptr->data;
828
829 /* don't toggle, always switch on */
831}
832
833static void rna_FModifier_start_frame_set(PointerRNA *ptr, float value)
834{
835 FModifier *fcm = (FModifier *)ptr->data;
836
837 CLAMP(value, MINAFRAMEF, MAXFRAMEF);
838 fcm->sfra = value;
839
840 /* XXX: maintain old offset? */
841 fcm->efra = std::max(fcm->sfra, fcm->efra);
842}
843
844static void rna_FModifier_end_frame_set(PointerRNA *ptr, float value)
845{
846 FModifier *fcm = (FModifier *)ptr->data;
847
848 CLAMP(value, MINAFRAMEF, MAXFRAMEF);
849 fcm->efra = value;
850
851 /* XXX: maintain old offset? */
852 fcm->sfra = std::min(fcm->efra, fcm->sfra);
853}
854
855static void rna_FModifier_start_frame_range(
856 PointerRNA * /*ptr*/, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
857{
858 // FModifier *fcm = (FModifier *)ptr->data;
859
860 /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
861 * or else it becomes tricky to adjust the range, see: #36844.
862 *
863 * NOTE: we do not set soft-limits on lower bounds, as it's too confusing when you
864 * can't easily use the slider to set things here
865 */
866 *min = MINAFRAMEF;
867 *max = MAXFRAMEF;
868}
869
870static void rna_FModifier_end_frame_range(
871 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
872{
873 FModifier *fcm = (FModifier *)ptr->data;
874
875 /* Technically, "sfra <= efra" must hold; however, we can't strictly enforce that,
876 * or else it becomes tricky to adjust the range, see: #36844. */
877 *min = MINAFRAMEF;
878 *softmin = (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) ? fcm->sfra : MINAFRAMEF;
879
880 *softmax = MAXFRAMEF;
881 *max = MAXFRAMEF;
882}
883
884static void rna_FModifier_blending_range(
885 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
886{
887 FModifier *fcm = (FModifier *)ptr->data;
888
889 *min = 0.0f;
890 *max = fcm->efra - fcm->sfra;
891}
892
893static void rna_FModifier_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
894{
895 ID *id = ptr->owner_id;
896 FModifier *fcm = (FModifier *)ptr->data;
897
898 if (fcm->curve && fcm->type == FMODIFIER_TYPE_CYCLES) {
899 BKE_fcurve_handles_recalc(fcm->curve);
900 }
901
902 rna_tag_animation_update(bmain, id);
903}
904
905static void rna_fModifier_name_set(PointerRNA *ptr, const char *value)
906{
907 FModifier *fcm = (FModifier *)ptr->data;
908 BKE_fmodifier_name_set(fcm, value);
909}
910
911static void rna_FModifier_verify_data_update(Main *bmain, Scene *scene, PointerRNA *ptr)
912{
913 FModifier *fcm = (FModifier *)ptr->data;
915
916 /* call the verify callback on the modifier if applicable */
917 if (fmi && fmi->verify_data) {
918 fmi->verify_data(fcm);
919 }
920
921 rna_FModifier_update(bmain, scene, ptr);
922}
923
924static void rna_FModifier_active_update(Main *bmain, Scene *scene, PointerRNA *ptr)
925{
926 FModifier *fm, *fmo = (FModifier *)ptr->data;
927
928 /* clear active state of other FModifiers in this list */
929 for (fm = fmo->prev; fm; fm = fm->prev) {
930 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
931 }
932 for (fm = fmo->next; fm; fm = fm->next) {
933 fm->flag &= ~FMODIFIER_FLAG_ACTIVE;
934 }
935
936 rna_FModifier_update(bmain, scene, ptr);
937}
938
939static int rna_FModifierGenerator_coefficients_get_length(const PointerRNA *ptr,
941{
942 const FModifier *fcm = (FModifier *)ptr->data;
943 const FMod_Generator *gen = static_cast<const FMod_Generator *>(fcm->data);
944
945 if (gen) {
946 length[0] = gen->arraysize;
947 }
948 else {
949 length[0] = 0;
950 }
951
952 return length[0];
953}
954
955static void rna_FModifierGenerator_coefficients_get(PointerRNA *ptr, float *values)
956{
957 FModifier *fcm = (FModifier *)ptr->data;
958 FMod_Generator *gen = static_cast<FMod_Generator *>(fcm->data);
959 memcpy(values, gen->coefficients, gen->arraysize * sizeof(float));
960}
961
962static void rna_FModifierGenerator_coefficients_set(PointerRNA *ptr, const float *values)
963{
964 FModifier *fcm = (FModifier *)ptr->data;
965 FMod_Generator *gen = static_cast<FMod_Generator *>(fcm->data);
966 memcpy(gen->coefficients, values, gen->arraysize * sizeof(float));
967}
968
969static void rna_FModifierLimits_minx_set(PointerRNA *ptr, float value)
970{
971 FModifier *fcm = (FModifier *)ptr->data;
972 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
973
974 data->rect.xmin = value;
975
976 data->rect.xmax = std::max(data->rect.xmin, data->rect.xmax);
977}
978
979static void rna_FModifierLimits_maxx_set(PointerRNA *ptr, float value)
980{
981 FModifier *fcm = (FModifier *)ptr->data;
982 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
983
984 data->rect.xmax = value;
985
986 data->rect.xmin = std::min(data->rect.xmax, data->rect.xmin);
987}
988
989static void rna_FModifierLimits_miny_set(PointerRNA *ptr, float value)
990{
991 FModifier *fcm = (FModifier *)ptr->data;
992 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
993
994 data->rect.ymin = value;
995
996 data->rect.ymax = std::max(data->rect.ymin, data->rect.ymax);
997}
998
999static void rna_FModifierLimits_maxy_set(PointerRNA *ptr, float value)
1000{
1001 FModifier *fcm = (FModifier *)ptr->data;
1002 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
1003
1004 data->rect.ymax = value;
1005
1006 data->rect.ymin = std::min(data->rect.ymax, data->rect.ymin);
1007}
1008
1009static void rna_FModifierLimits_minx_range(
1010 PointerRNA * /*ptr*/, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
1011{
1012 // FModifier *fcm = (FModifier *)ptr->data;
1013 // FMod_Limits *data = fcm->data;
1014
1015 /* No soft-limits on lower bound -
1016 * it's too confusing when you can't easily use the slider to set things here. */
1017 *min = MINAFRAMEF;
1018 *max = MAXFRAMEF;
1019}
1020
1021static void rna_FModifierLimits_maxx_range(
1022 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
1023{
1024 FModifier *fcm = (FModifier *)ptr->data;
1025 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
1026
1027 *min = MINAFRAMEF;
1028 *softmin = (data->flag & FCM_LIMIT_XMIN) ? data->rect.xmin : MINAFRAMEF;
1029
1030 *softmax = MAXFRAMEF;
1031 *max = MAXFRAMEF;
1032}
1033
1034static void rna_FModifierLimits_miny_range(
1035 PointerRNA * /*ptr*/, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
1036{
1037 // FModifier *fcm = (FModifier *)ptr->data;
1038 // FMod_Limits *data = fcm->data;
1039
1040 /* No soft-limits on lower bound -
1041 * it's too confusing when you can't easily use the slider to set things here. */
1042 *min = -FLT_MAX;
1043 *max = FLT_MAX;
1044}
1045
1046static void rna_FModifierLimits_maxy_range(
1047 PointerRNA *ptr, float *min, float *max, float *softmin, float *softmax)
1048{
1049 FModifier *fcm = (FModifier *)ptr->data;
1050 FMod_Limits *data = static_cast<FMod_Limits *>(fcm->data);
1051
1052 *min = -FLT_MAX;
1053 *softmin = (data->flag & FCM_LIMIT_YMIN) ? data->rect.ymin : -FLT_MAX;
1054
1055 *softmax = FLT_MAX;
1056 *max = FLT_MAX;
1057}
1058
1059static void rna_FModifierStepped_start_frame_range(
1060 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
1061{
1062 FModifier *fcm = (FModifier *)ptr->data;
1063 FMod_Stepped *data = static_cast<FMod_Stepped *>(fcm->data);
1064
1065 *min = MINAFRAMEF;
1066 *max = (data->flag & FCM_STEPPED_NO_AFTER) ? data->end_frame : MAXFRAMEF;
1067}
1068
1069static void rna_FModifierStepped_end_frame_range(
1070 PointerRNA *ptr, float *min, float *max, float * /*softmin*/, float * /*softmax*/)
1071{
1072 FModifier *fcm = (FModifier *)ptr->data;
1073 FMod_Stepped *data = static_cast<FMod_Stepped *>(fcm->data);
1074
1075 *min = (data->flag & FCM_STEPPED_NO_BEFORE) ? data->start_frame : MINAFRAMEF;
1076 *max = MAXFRAMEF;
1077}
1078
1079static void rna_FModifierStepped_frame_start_set(PointerRNA *ptr, float value)
1080{
1081 FModifier *fcm = (FModifier *)ptr->data;
1082 FMod_Stepped *data = static_cast<FMod_Stepped *>(fcm->data);
1083
1084 float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
1085 rna_FModifierStepped_start_frame_range(
1086 ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
1087 value = std::clamp(value, prop_clamp_min, prop_clamp_max);
1088
1089 /* Need to set both step-data's start/end and the start/end on the base-data,
1090 * or else Restrict-Range doesn't work due to RNA-property shadowing (#52009)
1091 */
1092 data->start_frame = value;
1093 fcm->sfra = value;
1094}
1095
1096static void rna_FModifierStepped_frame_end_set(PointerRNA *ptr, float value)
1097{
1098 FModifier *fcm = (FModifier *)ptr->data;
1099 FMod_Stepped *data = static_cast<FMod_Stepped *>(fcm->data);
1100
1101 float prop_clamp_min = -FLT_MAX, prop_clamp_max = FLT_MAX, prop_soft_min, prop_soft_max;
1102 rna_FModifierStepped_end_frame_range(
1103 ptr, &prop_clamp_min, &prop_clamp_max, &prop_soft_min, &prop_soft_max);
1104 value = std::clamp(value, prop_clamp_min, prop_clamp_max);
1105
1106 /* Need to set both step-data's start/end and the start/end on the base-data,
1107 * or else Restrict-Range doesn't work due to RNA-property shadowing (#52009)
1108 */
1109 data->end_frame = value;
1110 fcm->efra = value;
1111}
1112
1113static BezTriple *rna_FKeyframe_points_insert(
1114 ID *id, FCurve *fcu, Main *bmain, float frame, float value, int flag, int keyframe_type)
1115{
1116 using namespace blender::animrig;
1117 KeyframeSettings settings = get_keyframe_settings(false);
1118 settings.keyframe_type = eBezTriple_KeyframeType(keyframe_type);
1120 fcu, {frame, value}, settings, eInsertKeyFlags(flag));
1121
1122 if ((fcu->bezt) && (result == SingleKeyingResult::SUCCESS)) {
1123 rna_tag_animation_update(bmain, id);
1124
1125 bool replace;
1126 const int index = BKE_fcurve_bezt_binarysearch_index(fcu->bezt, frame, fcu->totvert, &replace);
1127
1128 return fcu->bezt + index;
1129 }
1130
1131 return nullptr;
1132}
1133
1134static void rna_FKeyframe_points_add(ID *id, FCurve *fcu, Main *bmain, int tot)
1135{
1136 if (tot <= 0) {
1137 return;
1138 }
1139
1140 ED_keyframes_add(fcu, tot);
1141 rna_tag_animation_update(bmain, id);
1142}
1143
1144static void rna_FKeyframe_points_remove(
1145 ID *id, FCurve *fcu, Main *bmain, ReportList *reports, PointerRNA *bezt_ptr, bool do_fast)
1146{
1147 BezTriple *bezt = static_cast<BezTriple *>(bezt_ptr->data);
1148 int index = int(bezt - fcu->bezt);
1149 if (index < 0 || index >= fcu->totvert) {
1150 BKE_report(reports, RPT_ERROR, "Keyframe not in F-Curve");
1151 return;
1152 }
1153
1154 BKE_fcurve_delete_key(fcu, index);
1155 bezt_ptr->invalidate();
1156
1157 if (!do_fast) {
1159 }
1160
1161 rna_tag_animation_update(bmain, id);
1162}
1163
1164static void rna_FKeyframe_points_clear(ID *id, FCurve *fcu, Main *bmain)
1165{
1167
1168 rna_tag_animation_update(bmain, id);
1169}
1170
1171static void rna_FKeyframe_points_sort(ID *id, FCurve *fcu, Main *bmain)
1172{
1173 sort_time_fcurve(fcu);
1174 rna_tag_animation_update(bmain, id);
1175}
1176
1177static void rna_FKeyframe_points_deduplicate(ID *id, FCurve *fcu, Main *bmain)
1178{
1180 rna_tag_animation_update(bmain, id);
1181}
1182
1183static void rna_FKeyframe_points_handles_recalc(ID *id, FCurve *fcu, Main *bmain)
1184{
1186 rna_tag_animation_update(bmain, id);
1187}
1188
1189static FCM_EnvelopeData *rna_FModifierEnvelope_points_add(
1190 ID *id, FModifier *fmod, Main *bmain, ReportList *reports, float frame)
1191{
1192 FCM_EnvelopeData fed;
1193 FMod_Envelope *env = (FMod_Envelope *)fmod->data;
1194 int i;
1195
1196 rna_tag_animation_update(bmain, id);
1197
1198 /* init template data */
1199 fed.min = -1.0f;
1200 fed.max = 1.0f;
1201 fed.time = frame;
1202 fed.f1 = fed.f2 = 0;
1203
1204 if (env->data) {
1205 bool exists;
1206 i = BKE_fcm_envelope_find_index(env->data, frame, env->totvert, &exists);
1207 if (exists) {
1208 BKE_reportf(reports, RPT_ERROR, "Already a control point at frame %.6f", frame);
1209 return nullptr;
1210 }
1211
1212 /* realloc memory for extra point */
1213 env->data = (FCM_EnvelopeData *)MEM_reallocN((void *)env->data,
1214 (env->totvert + 1) * sizeof(FCM_EnvelopeData));
1215
1216 /* move the points after the added point */
1217 if (i < env->totvert) {
1218 memmove(env->data + i + 1, env->data + i, (env->totvert - i) * sizeof(FCM_EnvelopeData));
1219 }
1220
1221 env->totvert++;
1222 }
1223 else {
1224 env->data = MEM_mallocN<FCM_EnvelopeData>("FCM_EnvelopeData");
1225 env->totvert = 1;
1226 i = 0;
1227 }
1228
1229 /* add point to paste at index i */
1230 *(env->data + i) = fed;
1231 return (env->data + i);
1232}
1233
1234static void rna_FModifierEnvelope_points_remove(
1235 ID *id, FModifier *fmod, Main *bmain, ReportList *reports, PointerRNA *point)
1236{
1237 FCM_EnvelopeData *cp = static_cast<FCM_EnvelopeData *>(point->data);
1238 FMod_Envelope *env = (FMod_Envelope *)fmod->data;
1239
1240 int index = int(cp - env->data);
1241
1242 /* test point is in range */
1243 if (index < 0 || index >= env->totvert) {
1244 BKE_report(reports, RPT_ERROR, "Control point not in Envelope F-Modifier");
1245 return;
1246 }
1247
1248 rna_tag_animation_update(bmain, id);
1249
1250 if (env->totvert > 1) {
1251 /* move data after the removed point */
1252
1253 memmove(env->data + index,
1254 env->data + (index + 1),
1255 sizeof(FCM_EnvelopeData) * ((env->totvert - index) - 1));
1256
1257 /* realloc smaller array */
1258 env->totvert--;
1259 env->data = (FCM_EnvelopeData *)MEM_reallocN((void *)env->data,
1260 (env->totvert) * sizeof(FCM_EnvelopeData));
1261 }
1262 else {
1263 /* just free array, since the only vert was deleted */
1264 if (env->data) {
1265 MEM_freeN(env->data);
1266 env->data = nullptr;
1267 }
1268 env->totvert = 0;
1269 }
1270 point->invalidate();
1271}
1272
1273static void rna_Keyframe_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
1274{
1275 rna_tag_animation_update(bmain, ptr->owner_id);
1276}
1277
1278static void rna_FModifier_show_expanded_set(PointerRNA *ptr, bool value)
1279{
1280 FModifier *fcm = static_cast<FModifier *>(ptr->data);
1282}
1283
1284#else
1285
1287{
1288 StructRNA *srna;
1289 PropertyRNA *prop;
1290
1291 static const EnumPropertyItem generator_mode_items[] = {
1292 {FCM_GENERATOR_POLYNOMIAL, "POLYNOMIAL", 0, "Expanded Polynomial", ""},
1294 "POLYNOMIAL_FACTORISED",
1295 0,
1296 "Factorized Polynomial",
1297 ""},
1298 {0, nullptr, 0, nullptr, nullptr},
1299 };
1300
1301 srna = RNA_def_struct(brna, "FModifierGenerator", "FModifier");
1303 srna, "Generator F-Modifier", "Deterministically generate values for the modified F-Curve");
1304 RNA_def_struct_sdna_from(srna, "FMod_Generator", "data");
1305
1306 /* define common props */
1307 prop = RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
1311 "Additive",
1312 "Values generated by this modifier are applied on top of "
1313 "the existing values instead of overwriting them");
1314 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1315
1316 prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
1317 RNA_def_property_enum_items(prop, generator_mode_items);
1319 RNA_def_property_ui_text(prop, "Mode", "Type of generator to use");
1321 prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_verify_data_update");
1322
1323 /* order of the polynomial */
1324 prop = RNA_def_property(srna, "poly_order", PROP_INT, PROP_NONE);
1327 prop,
1328 "Polynomial Order",
1329 "The highest power of 'x' for this polynomial (number of coefficients - 1)");
1330 RNA_def_property_range(prop, 1, 100);
1332 prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_verify_data_update");
1333
1334 /* coefficients array */
1335 prop = RNA_def_property(srna, "coefficients", PROP_FLOAT, PROP_NONE);
1337 RNA_def_property_array(prop, 32);
1339 RNA_def_property_dynamic_array_funcs(prop, "rna_FModifierGenerator_coefficients_get_length");
1341 "rna_FModifierGenerator_coefficients_get",
1342 "rna_FModifierGenerator_coefficients_set",
1343 nullptr);
1345 prop, "Coefficients", "Coefficients for 'x' (starting from lowest power of x^0)");
1347 prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_verify_data_update");
1348}
1349
1350/* --------- */
1351
1353{
1354 StructRNA *srna;
1355 PropertyRNA *prop;
1356
1357 static const EnumPropertyItem prop_type_items[] = {
1358 {0, "SIN", 0, "Sine", ""},
1359 {1, "COS", 0, "Cosine", ""},
1360 {2, "TAN", 0, "Tangent", ""},
1361 {3, "SQRT", 0, "Square Root", ""},
1362 {4, "LN", 0, "Natural Logarithm", ""},
1363 {5, "SINC", 0, "Normalized Sine", "sin(x) / x"},
1364 {0, nullptr, 0, nullptr, nullptr},
1365 };
1366
1367 srna = RNA_def_struct(brna, "FModifierFunctionGenerator", "FModifier");
1369 srna, "Built-In Function F-Modifier", "Generate values using a built-in function");
1370 RNA_def_struct_sdna_from(srna, "FMod_FunctionGenerator", "data");
1371
1372 /* coefficients */
1373 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
1376 prop, "Amplitude", "Scale factor determining the maximum/minimum values");
1377 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1378
1379 prop = RNA_def_property(srna, "phase_multiplier", PROP_FLOAT, PROP_NONE);
1382 prop, "Phase Multiple", "Scale factor determining the 'speed' of the function");
1383 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1384
1385 prop = RNA_def_property(srna, "phase_offset", PROP_FLOAT, PROP_NONE);
1387 RNA_def_property_ui_text(prop, "Phase Offset", "Constant factor to offset time by for function");
1388 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1389
1390 prop = RNA_def_property(srna, "value_offset", PROP_FLOAT, PROP_NONE);
1392 RNA_def_property_ui_text(prop, "Value Offset", "Constant factor to offset values by");
1393 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1394
1395 /* flags */
1396 prop = RNA_def_property(srna, "use_additive", PROP_BOOLEAN, PROP_NONE);
1400 "Additive",
1401 "Values generated by this modifier are applied on top of "
1402 "the existing values instead of overwriting them");
1403 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1404
1405 prop = RNA_def_property(srna, "function_type", PROP_ENUM, PROP_NONE);
1407 RNA_def_property_enum_sdna(prop, nullptr, "type");
1408 RNA_def_property_enum_items(prop, prop_type_items);
1409 RNA_def_property_ui_text(prop, "Type", "Type of built-in function to use");
1410 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1411}
1412
1413/* --------- */
1414
1416{
1417 StructRNA *srna;
1418 PropertyRNA *prop;
1419
1420 srna = RNA_def_struct(brna, "FModifierEnvelopeControlPoint", nullptr);
1421 RNA_def_struct_ui_text(srna, "Envelope Control Point", "Control point for envelope F-Modifier");
1422 RNA_def_struct_sdna(srna, "FCM_EnvelopeData");
1423
1424 /* min/max extents
1425 * - for now, these are allowed to go past each other, so that we can have inverted action
1426 * - technically, the range is limited by the settings in the envelope-modifier data, not here...
1427 */
1428 prop = RNA_def_property(srna, "min", PROP_FLOAT, PROP_NONE);
1429 RNA_def_property_float_sdna(prop, nullptr, "min");
1431 RNA_def_property_ui_text(prop, "Minimum Value", "Lower bound of envelope at this control-point");
1432 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1433
1434 prop = RNA_def_property(srna, "max", PROP_FLOAT, PROP_NONE);
1435 RNA_def_property_float_sdna(prop, nullptr, "max");
1437 RNA_def_property_ui_text(prop, "Maximum Value", "Upper bound of envelope at this control-point");
1438 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1439
1440 /* Frame */
1441 prop = RNA_def_property(srna, "frame", PROP_FLOAT, PROP_TIME);
1442 RNA_def_property_float_sdna(prop, nullptr, "time");
1444 RNA_def_property_ui_text(prop, "Frame", "Frame this control-point occurs on");
1445 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1446
1447 /* TODO: */
1448 /* - selection flags (not implemented in UI yet though) */
1449}
1450
1452{
1453 StructRNA *srna;
1454
1455 FunctionRNA *func;
1456 PropertyRNA *parm;
1457
1458 RNA_def_property_srna(cprop, "FModifierEnvelopeControlPoints");
1459 srna = RNA_def_struct(brna, "FModifierEnvelopeControlPoints", nullptr);
1460 RNA_def_struct_sdna(srna, "FModifier");
1461
1463 srna, "Control Points", "Control points defining the shape of the envelope");
1464
1465 func = RNA_def_function(srna, "add", "rna_FModifierEnvelope_points_add");
1466 RNA_def_function_ui_description(func, "Add a control point to a FModifierEnvelope");
1468 parm = RNA_def_float(func,
1469 "frame",
1470 0.0f,
1471 -FLT_MAX,
1472 FLT_MAX,
1473 "",
1474 "Frame to add this control-point",
1475 -FLT_MAX,
1476 FLT_MAX);
1478 parm = RNA_def_pointer(
1479 func, "point", "FModifierEnvelopeControlPoint", "", "Newly created control-point");
1480 RNA_def_function_return(func, parm);
1481
1482 func = RNA_def_function(srna, "remove", "rna_FModifierEnvelope_points_remove");
1483 RNA_def_function_ui_description(func, "Remove a control-point from an FModifierEnvelope");
1485 parm = RNA_def_pointer(
1486 func, "point", "FModifierEnvelopeControlPoint", "", "Control-point to remove");
1488}
1489
1491{
1492 StructRNA *srna;
1493 PropertyRNA *prop;
1494
1495 srna = RNA_def_struct(brna, "FModifierEnvelope", "FModifier");
1496 RNA_def_struct_ui_text(srna, "Envelope F-Modifier", "Scale the values of the modified F-Curve");
1497 RNA_def_struct_sdna_from(srna, "FMod_Envelope", "data");
1498
1499 /* Collections */
1500 prop = RNA_def_property(srna, "control_points", PROP_COLLECTION, PROP_NONE);
1501 RNA_def_property_collection_sdna(prop, nullptr, "data", "totvert");
1503 RNA_def_property_struct_type(prop, "FModifierEnvelopeControlPoint");
1505 prop, "Control Points", "Control points defining the shape of the envelope");
1507
1508 /* Range Settings */
1509 prop = RNA_def_property(srna, "reference_value", PROP_FLOAT, PROP_NONE);
1510 RNA_def_property_float_sdna(prop, nullptr, "midval");
1513 prop, "Reference Value", "Value that envelope's influence is centered around / based on");
1514 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1515
1516 prop = RNA_def_property(srna, "default_min", PROP_FLOAT, PROP_NONE);
1517 RNA_def_property_float_sdna(prop, nullptr, "min");
1520 prop, "Default Minimum", "Lower distance from Reference Value for 1:1 default influence");
1521 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1522
1523 prop = RNA_def_property(srna, "default_max", PROP_FLOAT, PROP_NONE);
1524 RNA_def_property_float_sdna(prop, nullptr, "max");
1527 prop, "Default Maximum", "Upper distance from Reference Value for 1:1 default influence");
1528 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1529}
1530
1531/* --------- */
1532
1534{
1535 StructRNA *srna;
1536 PropertyRNA *prop;
1537
1538 static const EnumPropertyItem prop_type_items[] = {
1539 {FCM_EXTRAPOLATE_NONE, "NONE", 0, "No Cycles", "Don't do anything"},
1540 {FCM_EXTRAPOLATE_CYCLIC, "REPEAT", 0, "Repeat Motion", "Repeat keyframe range as-is"},
1542 "REPEAT_OFFSET",
1543 0,
1544 "Repeat with Offset",
1545 "Repeat keyframe range, but with offset based on gradient between "
1546 "start and end values"},
1548 "MIRROR",
1549 0,
1550 "Repeat Mirrored",
1551 "Alternate between forward and reverse playback of keyframe range"},
1552 {0, nullptr, 0, nullptr, nullptr},
1553 };
1554
1555 srna = RNA_def_struct(brna, "FModifierCycles", "FModifier");
1556 RNA_def_struct_ui_text(srna, "Cycles F-Modifier", "Repeat the values of the modified F-Curve");
1557 RNA_def_struct_sdna_from(srna, "FMod_Cycles", "data");
1558
1559 /* before */
1560 prop = RNA_def_property(srna, "mode_before", PROP_ENUM, PROP_NONE);
1562 RNA_def_property_enum_sdna(prop, nullptr, "before_mode");
1563 RNA_def_property_enum_items(prop, prop_type_items);
1564 RNA_def_property_ui_text(prop, "Before Mode", "Cycling mode to use before first keyframe");
1565 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1566
1567 prop = RNA_def_property(srna, "cycles_before", PROP_INT, PROP_NONE);
1569 RNA_def_property_int_sdna(prop, nullptr, "before_cycles");
1571 prop,
1572 "Before Cycles",
1573 "Maximum number of cycles to allow before first keyframe (0 = infinite)");
1574 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1575
1576 /* after */
1577 prop = RNA_def_property(srna, "mode_after", PROP_ENUM, PROP_NONE);
1579 RNA_def_property_enum_sdna(prop, nullptr, "after_mode");
1580 RNA_def_property_enum_items(prop, prop_type_items);
1581 RNA_def_property_ui_text(prop, "After Mode", "Cycling mode to use after last keyframe");
1582 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1583
1584 prop = RNA_def_property(srna, "cycles_after", PROP_INT, PROP_NONE);
1586 RNA_def_property_int_sdna(prop, nullptr, "after_cycles");
1588 "After Cycles",
1589 "Maximum number of cycles to allow after last keyframe (0 = infinite)");
1590 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1591}
1592
1593/* --------- */
1594
1596{
1597 StructRNA *srna;
1598 PropertyRNA *prop;
1599
1600 srna = RNA_def_struct(brna, "FModifierLimits", "FModifier");
1602 srna, "Limit F-Modifier", "Limit the time/value ranges of the modified F-Curve");
1603 RNA_def_struct_sdna_from(srna, "FMod_Limits", "data");
1604
1605 prop = RNA_def_property(srna, "use_min_x", PROP_BOOLEAN, PROP_NONE);
1606 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_XMIN);
1608 RNA_def_property_ui_text(prop, "Minimum X", "Use the minimum 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_min_y", PROP_BOOLEAN, PROP_NONE);
1612 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_YMIN);
1614 RNA_def_property_ui_text(prop, "Minimum Y", "Use the minimum Y value");
1615 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1616
1617 prop = RNA_def_property(srna, "use_max_x", PROP_BOOLEAN, PROP_NONE);
1618 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_XMAX);
1620 RNA_def_property_ui_text(prop, "Maximum X", "Use the maximum X value");
1621 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1622
1623 prop = RNA_def_property(srna, "use_max_y", PROP_BOOLEAN, PROP_NONE);
1624 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCM_LIMIT_YMAX);
1626 RNA_def_property_ui_text(prop, "Maximum Y", "Use the maximum Y value");
1627 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1628
1629 prop = RNA_def_property(srna, "min_x", PROP_FLOAT, PROP_NONE);
1630 RNA_def_property_float_sdna(prop, nullptr, "rect.xmin");
1633 prop, nullptr, "rna_FModifierLimits_minx_set", "rna_FModifierLimits_minx_range");
1634 RNA_def_property_ui_text(prop, "Minimum X", "Lowest X value to allow");
1635 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1636
1637 prop = RNA_def_property(srna, "min_y", PROP_FLOAT, PROP_NONE);
1638 RNA_def_property_float_sdna(prop, nullptr, "rect.ymin");
1641 prop, nullptr, "rna_FModifierLimits_miny_set", "rna_FModifierLimits_miny_range");
1642 RNA_def_property_ui_text(prop, "Minimum Y", "Lowest Y value to allow");
1643 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1644
1645 prop = RNA_def_property(srna, "max_x", PROP_FLOAT, PROP_NONE);
1646 RNA_def_property_float_sdna(prop, nullptr, "rect.xmax");
1649 prop, nullptr, "rna_FModifierLimits_maxx_set", "rna_FModifierLimits_maxx_range");
1650 RNA_def_property_ui_text(prop, "Maximum X", "Highest X value to allow");
1651 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1652
1653 prop = RNA_def_property(srna, "max_y", PROP_FLOAT, PROP_NONE);
1654 RNA_def_property_float_sdna(prop, nullptr, "rect.ymax");
1657 prop, nullptr, "rna_FModifierLimits_maxy_set", "rna_FModifierLimits_maxy_range");
1658 RNA_def_property_ui_text(prop, "Maximum Y", "Highest Y value to allow");
1659 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1660}
1661
1662/* --------- */
1663
1665{
1666 StructRNA *srna;
1667 PropertyRNA *prop;
1668
1669 static const EnumPropertyItem prop_modification_items[] = {
1670 {FCM_NOISE_MODIF_REPLACE, "REPLACE", 0, "Replace", ""},
1671 {FCM_NOISE_MODIF_ADD, "ADD", 0, "Add", ""},
1672 {FCM_NOISE_MODIF_SUBTRACT, "SUBTRACT", 0, "Subtract", ""},
1673 {FCM_NOISE_MODIF_MULTIPLY, "MULTIPLY", 0, "Multiply", ""},
1674 {0, nullptr, 0, nullptr, nullptr},
1675 };
1676
1677 srna = RNA_def_struct(brna, "FModifierNoise", "FModifier");
1678 RNA_def_struct_ui_text(srna, "Noise F-Modifier", "Give randomness to the modified F-Curve");
1679 RNA_def_struct_sdna_from(srna, "FMod_Noise", "data");
1680
1681 prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
1682 RNA_def_property_enum_sdna(prop, nullptr, "modification");
1683 RNA_def_property_enum_items(prop, prop_modification_items);
1685 RNA_def_property_ui_text(prop, "Blend Type", "Method of modifying the existing F-Curve");
1686 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1687
1688 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
1689 RNA_def_property_float_sdna(prop, nullptr, "size");
1691 RNA_def_property_ui_text(prop, "Scale", "Scaling (in time) of the noise");
1692 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1693
1694 prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE);
1695 RNA_def_property_float_sdna(prop, nullptr, "strength");
1698 prop,
1699 "Strength",
1700 "Amplitude of the noise - the amount that it modifies the underlying curve");
1702 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1703
1704 prop = RNA_def_property(srna, "phase", PROP_FLOAT, PROP_NONE);
1705 RNA_def_property_float_sdna(prop, nullptr, "phase");
1707 RNA_def_property_ui_text(prop, "Phase", "A random seed for the noise effect");
1708 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1709
1710 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
1711 RNA_def_property_float_sdna(prop, nullptr, "offset");
1713 RNA_def_property_ui_text(prop, "Offset", "Time offset for the noise effect");
1714 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1715
1716 prop = RNA_def_property(srna, "lacunarity", PROP_FLOAT, PROP_NONE);
1717 RNA_def_property_float_sdna(prop, nullptr, "lacunarity");
1721 "Lacunarity",
1722 "Gap between successive frequencies. Depth needs to be greater than 0 "
1723 "for this to have an effect");
1724 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1725
1726 prop = RNA_def_property(srna, "roughness", PROP_FLOAT, PROP_NONE);
1727 RNA_def_property_float_sdna(prop, nullptr, "roughness");
1731 "Roughness",
1732 "Amount of high frequency detail. Depth needs to be greater than 0 for "
1733 "this to have an effect");
1734 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1735
1736 prop = RNA_def_property(srna, "depth", PROP_INT, PROP_UNSIGNED);
1737 RNA_def_property_int_sdna(prop, nullptr, "depth");
1739 RNA_def_property_ui_text(prop, "Depth", "Amount of fine level detail present in the noise");
1740 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1741
1742 prop = RNA_def_property(srna, "use_legacy_noise", PROP_BOOLEAN, PROP_NONE);
1743 RNA_def_property_boolean_sdna(prop, nullptr, "legacy_noise", 1);
1746 "Legacy Noise",
1747 "Use the legacy way of generating noise. Has the issue that it can "
1748 "produce values outside of -1/1");
1749 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1750}
1751
1752/* --------- */
1753
1755{
1756 StructRNA *srna;
1757 PropertyRNA *prop;
1758
1759 srna = RNA_def_struct(brna, "FModifierStepped", "FModifier");
1761 srna,
1762 "Stepped Interpolation F-Modifier",
1763 "Hold each interpolated value from the F-Curve for several frames without "
1764 "changing the timing");
1765 RNA_def_struct_sdna_from(srna, "FMod_Stepped", "data");
1766
1767 /* properties */
1768 prop = RNA_def_property(srna, "frame_step", PROP_FLOAT, PROP_NONE);
1769 RNA_def_property_float_sdna(prop, nullptr, "step_size");
1771 RNA_def_property_ui_text(prop, "Step Size", "Number of frames to hold each value");
1772 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1773
1774 prop = RNA_def_property(srna, "frame_offset", PROP_FLOAT, PROP_NONE);
1775 RNA_def_property_float_sdna(prop, nullptr, "offset");
1778 "Offset",
1779 "Reference number of frames before frames get held "
1780 "(use to get hold for '1-3' vs '5-7' holding patterns)");
1781 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1782
1783 prop = RNA_def_property(srna, "use_frame_start", PROP_BOOLEAN, PROP_NONE);
1787 prop, "Use Start Frame", "Restrict modifier to only act after its 'start' frame");
1788 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1789
1790 prop = RNA_def_property(srna, "use_frame_end", PROP_BOOLEAN, PROP_NONE);
1794 prop, "Use End Frame", "Restrict modifier to only act before its 'end' frame");
1795 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1796
1797 prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
1798 RNA_def_property_float_sdna(prop, nullptr, "start_frame");
1801 nullptr,
1802 "rna_FModifierStepped_frame_start_set",
1803 "rna_FModifierStepped_start_frame_range");
1805 prop, "Start Frame", "Frame that modifier's influence starts (if applicable)");
1806 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1807
1808 prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
1809 RNA_def_property_float_sdna(prop, nullptr, "end_frame");
1812 prop, nullptr, "rna_FModifierStepped_frame_end_set", "rna_FModifierStepped_end_frame_range");
1814 prop, "End Frame", "Frame that modifier's influence ends (if applicable)");
1815 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FModifier_update");
1816}
1817
1818/* --------- */
1819
1821{
1822 StructRNA *srna;
1823 PropertyRNA *prop;
1824
1825 /* base struct definition */
1826 srna = RNA_def_struct(brna, "FModifier", nullptr);
1827 RNA_def_struct_refine_func(srna, "rna_FModifierType_refine");
1828 RNA_def_struct_ui_text(srna, "F-Modifier", "Modifier for values of F-Curve");
1829
1830 /* name */
1831 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1832 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_fModifier_name_set");
1833 RNA_def_property_ui_text(prop, "Name", "F-Curve Modifier name");
1835 RNA_def_struct_name_property(srna, prop);
1836
1837 /* type */
1838 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1842 RNA_def_property_ui_text(prop, "Type", "F-Curve Modifier Type");
1843
1844 /* settings */
1845 prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE);
1847 RNA_def_property_boolean_sdna(prop, nullptr, "ui_expand_flag", 0);
1848 // RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
1849 RNA_def_property_boolean_funcs(prop, nullptr, "rna_FModifier_show_expanded_set");
1850 RNA_def_property_ui_text(prop, "Expanded", "F-Curve Modifier's panel is expanded in UI");
1851 RNA_def_property_ui_icon(prop, ICON_RIGHTARROW, 1);
1852
1853 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1856 RNA_def_property_ui_text(prop, "Enabled", "Enable F-Curve modifier evaluation");
1857 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1858 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_HLT, -1);
1859
1860 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
1863 // RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
1865 prop, "Disabled", "F-Curve Modifier has invalid settings and will not be evaluated");
1866 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1867
1868 /* TODO: setting this to true must ensure that all others in stack are turned off too... */
1869 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1872 RNA_def_property_ui_text(prop, "Active", "F-Curve modifier will show settings in the editor");
1873 RNA_def_property_boolean_funcs(prop, nullptr, "rna_FModifier_active_set");
1874 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_active_update");
1875 RNA_def_property_ui_icon(prop, ICON_RADIOBUT_OFF, 1);
1876
1877 /* restricted range */
1878 prop = RNA_def_property(srna, "use_restricted_range", PROP_BOOLEAN, PROP_NONE);
1882 prop,
1883 "Restrict Frame Range",
1884 "F-Curve Modifier is only applied for the specified frame range to help "
1885 "mask off effects in order to chain them");
1886 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1887
1888 prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_NONE);
1889 RNA_def_property_float_sdna(prop, nullptr, "sfra");
1892 prop, nullptr, "rna_FModifier_start_frame_set", "rna_FModifier_start_frame_range");
1894 prop,
1895 "Start Frame",
1896 "Frame that modifier's influence starts (if Restrict Frame Range is in use)");
1897 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1898
1899 prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_NONE);
1900 RNA_def_property_float_sdna(prop, nullptr, "efra");
1903 prop, nullptr, "rna_FModifier_end_frame_set", "rna_FModifier_end_frame_range");
1905 prop,
1906 "End Frame",
1907 "Frame that modifier's influence ends (if Restrict Frame Range is in use)");
1908 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1909
1910 prop = RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE);
1911 RNA_def_property_float_sdna(prop, nullptr, "blendin");
1913 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_FModifier_blending_range");
1915 prop, "Blend In", "Number of frames from start frame for influence to take effect");
1916 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1917
1918 prop = RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE);
1919 RNA_def_property_float_sdna(prop, nullptr, "blendout");
1921 RNA_def_property_float_funcs(prop, nullptr, nullptr, "rna_FModifier_blending_range");
1923 prop, "Blend Out", "Number of frames from end frame for influence to fade out");
1924 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1925
1926 /* influence */
1927 prop = RNA_def_property(srna, "use_influence", PROP_BOOLEAN, PROP_NONE);
1931 prop, "Use Influence", "F-Curve Modifier's effects will be tempered by a default factor");
1932 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1933
1934 prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
1935 RNA_def_property_float_sdna(prop, nullptr, "influence");
1937 RNA_def_property_range(prop, 0.0f, 1.0f);
1940 prop, "Influence", "Amount of influence F-Curve Modifier will have when not fading in/out");
1941 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_FModifier_update");
1942}
1943
1944/* *********************** */
1945
1947{
1948 StructRNA *srna;
1949 PropertyRNA *prop;
1950
1951 static const EnumPropertyItem prop_trans_chan_items[] = {
1952 {DTAR_TRANSCHAN_LOCX, "LOC_X", 0, "X Location", ""},
1953 {DTAR_TRANSCHAN_LOCY, "LOC_Y", 0, "Y Location", ""},
1954 {DTAR_TRANSCHAN_LOCZ, "LOC_Z", 0, "Z Location", ""},
1956 {DTAR_TRANSCHAN_ROTX, "ROT_X", 0, "X Rotation", ""},
1957 {DTAR_TRANSCHAN_ROTY, "ROT_Y", 0, "Y Rotation", ""},
1958 {DTAR_TRANSCHAN_ROTZ, "ROT_Z", 0, "Z Rotation", ""},
1959 {DTAR_TRANSCHAN_ROTW, "ROT_W", 0, "W Rotation", ""},
1961 {DTAR_TRANSCHAN_SCALEX, "SCALE_X", 0, "X Scale", ""},
1962 {DTAR_TRANSCHAN_SCALEY, "SCALE_Y", 0, "Y Scale", ""},
1963 {DTAR_TRANSCHAN_SCALEZ, "SCALE_Z", 0, "Z Scale", ""},
1964 {DTAR_TRANSCHAN_SCALE_AVG, "SCALE_AVG", 0, "Average Scale", ""},
1965 {0, nullptr, 0, nullptr, nullptr},
1966 };
1967
1968 static const EnumPropertyItem prop_local_space_items[] = {
1969 {0,
1970 "WORLD_SPACE",
1971 0,
1972 "World Space",
1973 "Transforms include effects of parenting/restpose and constraints"},
1975 "TRANSFORM_SPACE",
1976 0,
1977 "Transform Space",
1978 "Transforms don't include parenting/restpose or constraints"},
1980 "LOCAL_SPACE",
1981 0,
1982 "Local Space",
1983 "Transforms include effects of constraints but not "
1984 "parenting/restpose"},
1985 {0, nullptr, 0, nullptr, nullptr},
1986 };
1987
1988 srna = RNA_def_struct(brna, "DriverTarget", nullptr);
1989 RNA_def_struct_ui_text(srna, "Driver Target", "Source of input values for driver variables");
1990
1991 /* Target Properties - ID-block to Drive */
1992 prop = RNA_def_property(srna, "id", PROP_POINTER, PROP_NONE);
1993 RNA_def_property_struct_type(prop, "ID");
1997 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable");
1999 prop, nullptr, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", nullptr);
2001 "ID",
2002 "ID-block that the specific property used can be found from "
2003 "(id_type property must be set first)");
2004 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2005
2006 prop = RNA_def_property(srna, "id_type", PROP_ENUM, PROP_NONE);
2007 RNA_def_property_enum_sdna(prop, nullptr, "idtype");
2010 RNA_def_property_enum_funcs(prop, nullptr, "rna_DriverTarget_id_type_set", nullptr);
2011 RNA_def_property_editable_func(prop, "rna_DriverTarget_id_type_editable");
2012 RNA_def_property_ui_text(prop, "ID Type", "Type of ID-block that can be used");
2014 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2015
2016 /* Target Properties - Property to Drive */
2017 prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
2019 "rna_DriverTarget_RnaPath_get",
2020 "rna_DriverTarget_RnaPath_length",
2021 "rna_DriverTarget_RnaPath_set");
2022 RNA_def_property_ui_text(prop, "Data Path", "RNA Path (from ID-block) to property used");
2023 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2024
2025 prop = RNA_def_property(srna, "bone_target", PROP_STRING, PROP_NONE);
2026 RNA_def_property_string_sdna(prop, nullptr, "pchan_name");
2027 RNA_def_property_ui_text(prop, "Bone Name", "Name of PoseBone to use as target");
2028 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2029
2030 prop = RNA_def_property(srna, "transform_type", PROP_ENUM, PROP_NONE);
2031 RNA_def_property_enum_sdna(prop, nullptr, "transChan");
2032 RNA_def_property_enum_items(prop, prop_trans_chan_items);
2033 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
2034 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2035
2036 prop = RNA_def_property(srna, "rotation_mode", PROP_ENUM, PROP_NONE);
2037 RNA_def_property_enum_sdna(prop, nullptr, "rotation_mode");
2039 RNA_def_property_ui_text(prop, "Rotation Mode", "Mode for calculating rotation channel values");
2040 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2041
2042 prop = RNA_def_property(srna, "transform_space", PROP_ENUM, PROP_NONE);
2043 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "flag");
2044 RNA_def_property_enum_items(prop, prop_local_space_items);
2045 RNA_def_property_ui_text(prop, "Transform Space", "Space in which transforms are used");
2046 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2047
2048 prop = RNA_def_property(srna, "context_property", PROP_ENUM, PROP_NONE);
2049 RNA_def_property_enum_sdna(prop, nullptr, "context_property");
2053 prop, "Context Property", "Type of a context-dependent data-block to access property from");
2054 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2055
2056 prop = RNA_def_property(srna, "use_fallback_value", PROP_BOOLEAN, PROP_NONE);
2059 "Use Fallback",
2060 "Use the fallback value if the data path cannot be resolved, instead "
2061 "of failing to evaluate the driver");
2062 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2063
2064 prop = RNA_def_property(srna, "fallback_value", PROP_FLOAT, PROP_NONE);
2065 RNA_def_property_float_sdna(prop, nullptr, "fallback_value");
2067 prop, "Fallback", "The value to use if the data path cannot be resolved");
2068 RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data");
2069
2070 prop = RNA_def_property(srna, "is_fallback_used", PROP_BOOLEAN, PROP_NONE);
2074 prop,
2075 "Is Fallback Used",
2076 "Indicates that the most recent variable evaluation used the fallback value");
2077}
2078
2080{
2081 StructRNA *srna;
2082 PropertyRNA *prop;
2083
2084 static const EnumPropertyItem prop_type_items[] = {
2086 "SINGLE_PROP",
2087 ICON_RNA,
2088 "Single Property",
2089 "Use the value from some RNA property"},
2091 "TRANSFORMS",
2092 ICON_DRIVER_TRANSFORM,
2093 "Transform Channel",
2094 "Final transformation value of object or bone"},
2096 "ROTATION_DIFF",
2097 ICON_DRIVER_ROTATIONAL_DIFFERENCE,
2098 "Rotational Difference",
2099 "Use the angle between two bones"},
2101 "LOC_DIFF",
2102 ICON_DRIVER_DISTANCE,
2103 "Distance",
2104 "Distance between two bones or objects"},
2106 "CONTEXT_PROP",
2107 ICON_RNA,
2108 "Context Property",
2109 "Use the value from some RNA property within the current evaluation context"},
2110 {0, nullptr, 0, nullptr, nullptr},
2111 };
2112
2113 srna = RNA_def_struct(brna, "DriverVariable", nullptr);
2114 RNA_def_struct_sdna(srna, "DriverVar");
2116 srna, "Driver Variable", "Variable from some source/target for driver relationship");
2117
2118 /* Variable Name */
2119 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
2120 RNA_def_struct_name_property(srna, prop);
2121 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_DriverVariable_name_set");
2123 prop,
2124 "Name",
2125 "Name to use in scripted expressions/functions (no spaces or dots are allowed, "
2126 "and must start with a letter)");
2127 RNA_def_property_update(prop, 0, "rna_DriverVariable_update_name");
2128
2129 /* Enums */
2130 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2131 RNA_def_property_enum_items(prop, prop_type_items);
2132 RNA_def_property_enum_funcs(prop, nullptr, "rna_DriverVariable_type_set", nullptr);
2133 RNA_def_property_ui_text(prop, "Type", "Driver variable type");
2134 RNA_def_property_update(prop, 0, "rna_DriverVariable_update_data");
2135
2136 /* Targets */
2137 /* TODO: for nicer API, only expose the relevant props via subclassing,
2138 * instead of exposing the collection of targets */
2139 prop = RNA_def_property(srna, "targets", PROP_COLLECTION, PROP_NONE);
2140 RNA_def_property_collection_sdna(prop, nullptr, "targets", "num_targets");
2141 RNA_def_property_struct_type(prop, "DriverTarget");
2143 RNA_def_property_ui_text(prop, "Targets", "Sources of input data for evaluating this variable");
2144
2145 /* Name Validity Flags */
2146 prop = RNA_def_property(srna, "is_name_valid", PROP_BOOLEAN, PROP_NONE);
2149 RNA_def_property_ui_text(prop, "Is Name Valid", "Is this a valid name for a driver variable");
2150}
2151
2152/* channeldriver.variables.* */
2154{
2155 StructRNA *srna;
2156 // PropertyRNA *prop;
2157
2158 FunctionRNA *func;
2159 PropertyRNA *parm;
2160
2161 RNA_def_property_srna(cprop, "ChannelDriverVariables");
2162 srna = RNA_def_struct(brna, "ChannelDriverVariables", nullptr);
2163 RNA_def_struct_sdna(srna, "ChannelDriver");
2165 srna, "ChannelDriver Variables", "Collection of channel driver Variables");
2166
2167 /* add variable */
2168 func = RNA_def_function(srna, "new", "rna_Driver_new_variable");
2169 RNA_def_function_ui_description(func, "Add a new variable for the driver");
2170 /* return type */
2171 parm = RNA_def_pointer(func, "var", "DriverVariable", "", "Newly created Driver Variable");
2172 RNA_def_function_return(func, parm);
2173
2174 /* remove variable */
2175 func = RNA_def_function(srna, "remove", "rna_Driver_remove_variable");
2176 RNA_def_function_ui_description(func, "Remove an existing variable from the driver");
2178 /* target to remove */
2179 parm = RNA_def_pointer(
2180 func, "variable", "DriverVariable", "", "Variable to remove from the driver");
2183}
2184
2186{
2187 StructRNA *srna;
2188 PropertyRNA *prop;
2189
2190 static const EnumPropertyItem prop_type_items[] = {
2191 {DRIVER_TYPE_AVERAGE, "AVERAGE", 0, "Averaged Value", ""},
2192 {DRIVER_TYPE_SUM, "SUM", 0, "Sum Values", ""},
2193 {DRIVER_TYPE_PYTHON, "SCRIPTED", 0, "Scripted Expression", ""},
2194 {DRIVER_TYPE_MIN, "MIN", 0, "Minimum Value", ""},
2195 {DRIVER_TYPE_MAX, "MAX", 0, "Maximum Value", ""},
2196 {0, nullptr, 0, nullptr, nullptr},
2197 };
2198
2199 srna = RNA_def_struct(brna, "Driver", nullptr);
2200 RNA_def_struct_sdna(srna, "ChannelDriver");
2202 srna, "Driver", "Driver for the value of a setting based on an external value");
2203 RNA_def_struct_ui_icon(srna, ICON_DRIVER);
2204
2205 /* Enums */
2206 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2207 RNA_def_property_enum_items(prop, prop_type_items);
2208 RNA_def_property_ui_text(prop, "Type", "Driver type");
2209 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_data");
2210
2211 /* String values */
2212 prop = RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE);
2213 RNA_def_property_ui_text(prop, "Expression", "Expression to use for Scripted Expression");
2214 RNA_def_property_update(prop, 0, "rna_ChannelDriver_update_expr");
2215
2216 /* Collections */
2217 prop = RNA_def_property(srna, "variables", PROP_COLLECTION, PROP_NONE);
2218 RNA_def_property_collection_sdna(prop, nullptr, "variables", nullptr);
2219 RNA_def_property_struct_type(prop, "DriverVariable");
2221 RNA_def_property_ui_text(prop, "Variables", "Properties acting as inputs for this driver");
2223
2224 /* Settings */
2225 prop = RNA_def_property(srna, "use_self", PROP_BOOLEAN, PROP_NONE);
2228 prop,
2229 "Use Self",
2230 "Include a 'self' variable in the name-space, "
2231 "so drivers can easily reference the data being modified (object, bone, etc...)");
2232
2233 /* State Info (for Debugging) */
2234 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
2237 prop, "Invalid", "Driver could not be evaluated in past, so should be skipped");
2238
2239 prop = RNA_def_property(srna, "is_simple_expression", PROP_BOOLEAN, PROP_NONE);
2241 RNA_def_property_boolean_funcs(prop, "rna_ChannelDriver_is_simple_expression_get", nullptr);
2243 prop,
2244 "Simple Expression",
2245 "The scripted expression can be evaluated without using the full Python interpreter");
2246
2247 /* Functions */
2248 RNA_api_drivers(srna);
2249}
2250
2251/* *********************** */
2252
2253static void rna_def_fpoint(BlenderRNA *brna)
2254{
2255 StructRNA *srna;
2256 PropertyRNA *prop;
2257
2258 srna = RNA_def_struct(brna, "FCurveSample", nullptr);
2259 RNA_def_struct_sdna(srna, "FPoint");
2260 RNA_def_struct_ui_text(srna, "F-Curve Sample", "Sample point for F-Curve");
2261
2262 /* Boolean values */
2263 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2264 RNA_def_property_boolean_sdna(prop, nullptr, "flag", 1);
2265 RNA_def_property_ui_text(prop, "Select", "Selection status");
2267
2268 /* Vector value */
2269 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2270 RNA_def_property_float_sdna(prop, nullptr, "vec");
2271 RNA_def_property_array(prop, 2);
2272 RNA_def_property_ui_text(prop, "Point", "Point coordinates");
2274}
2275
2281{
2282 StructRNA *srna;
2283 PropertyRNA *prop;
2284
2285 srna = RNA_def_struct(brna, "Keyframe", nullptr);
2286 RNA_def_struct_sdna(srna, "BezTriple");
2288 srna, "Keyframe", "Bézier curve point with two handles defining a Keyframe on an F-Curve");
2289
2290 /* Boolean values */
2291 prop = RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
2292 RNA_def_property_boolean_sdna(prop, nullptr, "f1", SELECT);
2293 RNA_def_property_ui_text(prop, "Handle 1 selected", "Left handle selection status");
2295
2296 prop = RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
2297 RNA_def_property_boolean_sdna(prop, nullptr, "f3", SELECT);
2298 RNA_def_property_ui_text(prop, "Handle 2 selected", "Right handle selection status");
2300
2301 prop = RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
2302 RNA_def_property_boolean_sdna(prop, nullptr, "f2", SELECT);
2303 RNA_def_property_ui_text(prop, "Select", "Control point selection status");
2305
2306 /* Enums */
2307 prop = RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
2308 RNA_def_property_enum_sdna(prop, nullptr, "h1");
2310 RNA_def_property_ui_text(prop, "Left Handle Type", "Handle types");
2311 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2312
2313 prop = RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
2314 RNA_def_property_enum_sdna(prop, nullptr, "h2");
2316 RNA_def_property_ui_text(prop, "Right Handle Type", "Handle types");
2317 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2318
2319 prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE);
2320 RNA_def_property_enum_sdna(prop, nullptr, "ipo");
2323 "Interpolation",
2324 "Interpolation method to use for segment of the F-Curve from "
2325 "this Keyframe until the next Keyframe");
2327 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2328
2329 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
2330 RNA_def_property_enum_sdna(prop, nullptr, "hide");
2332 RNA_def_property_ui_text(prop, "Type", "Type of keyframe (for visual purposes only)");
2334 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2335
2336 prop = RNA_def_property(srna, "easing", PROP_ENUM, PROP_NONE);
2337 RNA_def_property_enum_sdna(prop, nullptr, "easing");
2340 "Easing",
2341 "Which ends of the segment between this and the next keyframe easing "
2342 "interpolation is applied to");
2343 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2344
2345 prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_NONE);
2346 RNA_def_property_float_sdna(prop, nullptr, "back");
2347 RNA_def_property_ui_text(prop, "Back", "Amount of overshoot for 'back' easing");
2349 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2350
2351 prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE);
2352 RNA_def_property_float_sdna(prop, nullptr, "amplitude");
2353 RNA_def_property_range(prop, 0.0f, FLT_MAX); /* only positive values... */
2355 prop, "Amplitude", "Amount to boost elastic bounces for 'elastic' easing");
2356 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2357
2358 prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE);
2359 RNA_def_property_float_sdna(prop, nullptr, "period");
2360 RNA_def_property_ui_text(prop, "Period", "Time between bounces for elastic easing");
2361 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, "rna_Keyframe_update");
2362
2363 /* Vector values */
2364 prop = RNA_def_property(
2365 srna, "handle_left", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2366 RNA_def_property_array(prop, 2);
2368 prop, "rna_FKeyframe_handle1_get", "rna_FKeyframe_handle1_set", nullptr);
2370 prop, "Left Handle", "Coordinates of the left handle (before the control point)");
2371 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2372
2373 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2374 RNA_def_property_array(prop, 2);
2376 prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_set", nullptr);
2377 RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
2378 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2379
2380 prop = RNA_def_property(
2381 srna, "co_ui", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2382 RNA_def_property_array(prop, 2);
2384 prop, "rna_FKeyframe_ctrlpoint_get", "rna_FKeyframe_ctrlpoint_ui_set", nullptr);
2386 prop,
2387 "Control Point",
2388 "Coordinates of the control point. Note: Changing this value also updates the handles "
2389 "similar to using the graph editor transform operator");
2390 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2391
2392 prop = RNA_def_property(
2393 srna, "handle_right", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */
2394 RNA_def_property_array(prop, 2);
2396 prop, "rna_FKeyframe_handle2_get", "rna_FKeyframe_handle2_set", nullptr);
2398 prop, "Right Handle", "Coordinates of the right handle (after the control point)");
2399 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_Keyframe_update");
2400}
2401
2403{
2404 /* add modifiers */
2405 StructRNA *srna;
2406 PropertyRNA *prop;
2407
2408 FunctionRNA *func;
2409 PropertyRNA *parm;
2410
2411 RNA_def_property_srna(cprop, "FCurveModifiers");
2412 srna = RNA_def_struct(brna, "FCurveModifiers", nullptr);
2413 RNA_def_struct_sdna(srna, "FCurve");
2414 RNA_def_struct_ui_text(srna, "F-Curve Modifiers", "Collection of F-Curve Modifiers");
2415
2416 /* Collection active property */
2417 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
2418 RNA_def_property_struct_type(prop, "FModifier");
2421 prop, "rna_FCurve_active_modifier_get", "rna_FCurve_active_modifier_set", nullptr, nullptr);
2423 RNA_def_property_ui_text(prop, "Active F-Curve Modifier", "Active F-Curve Modifier");
2424
2425 /* Constraint collection */
2426 func = RNA_def_function(srna, "new", "rna_FCurve_modifiers_new");
2427 RNA_def_function_ui_description(func, "Add a constraint to this object");
2428 /* return type */
2429 parm = RNA_def_pointer(func, "fmodifier", "FModifier", "", "New fmodifier");
2430 RNA_def_function_return(func, parm);
2431 /* object to add */
2432 parm = RNA_def_enum(
2433 func, "type", rna_enum_fmodifier_type_items, 1, "", "Constraint type to add");
2435
2436 func = RNA_def_function(srna, "remove", "rna_FCurve_modifiers_remove");
2438 RNA_def_function_ui_description(func, "Remove a modifier from this F-Curve");
2439 /* modifier to remove */
2440 parm = RNA_def_pointer(func, "modifier", "FModifier", "", "Removed modifier");
2443}
2444
2445/* fcurve.keyframe_points */
2447{
2448 StructRNA *srna;
2449
2450 FunctionRNA *func;
2451 PropertyRNA *parm;
2452
2453 static const EnumPropertyItem keyframe_flag_items[] = {
2455 "REPLACE",
2456 0,
2457 "Replace",
2458 "Don't add any new keyframes, but just replace existing ones"},
2459 {INSERTKEY_NEEDED, "NEEDED", 0, "Needed", "Only adds keyframes that are needed"},
2461 "FAST",
2462 0,
2463 "Fast",
2464 "Fast keyframe insertion to avoid recalculating the curve each time"},
2465 {0, nullptr, 0, nullptr, nullptr},
2466 };
2467
2468 RNA_def_property_srna(cprop, "FCurveKeyframePoints");
2469 srna = RNA_def_struct(brna, "FCurveKeyframePoints", nullptr);
2470 RNA_def_struct_sdna(srna, "FCurve");
2471 RNA_def_struct_ui_text(srna, "Keyframe Points", "Collection of keyframe points");
2472
2473 func = RNA_def_function(srna, "insert", "rna_FKeyframe_points_insert");
2474 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve");
2476 parm = RNA_def_float(func,
2477 "frame",
2478 0.0f,
2479 -FLT_MAX,
2480 FLT_MAX,
2481 "",
2482 "X Value of this keyframe point",
2483 -FLT_MAX,
2484 FLT_MAX);
2486 parm = RNA_def_float(func,
2487 "value",
2488 0.0f,
2489 -FLT_MAX,
2490 FLT_MAX,
2491 "",
2492 "Y Value of this keyframe point",
2493 -FLT_MAX,
2494 FLT_MAX);
2496 RNA_def_enum_flag(func, "options", keyframe_flag_items, 0, "", "Keyframe options");
2497 RNA_def_enum(func,
2498 "keyframe_type",
2501 "",
2502 "Type of keyframe to insert");
2503 parm = RNA_def_pointer(func, "keyframe", "Keyframe", "", "Newly created keyframe");
2504 RNA_def_function_return(func, parm);
2505
2506 func = RNA_def_function(srna, "add", "rna_FKeyframe_points_add");
2507 RNA_def_function_ui_description(func, "Add a keyframe point to a F-Curve");
2509 parm = RNA_def_int(
2510 func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
2512
2513 func = RNA_def_function(srna, "remove", "rna_FKeyframe_points_remove");
2514 RNA_def_function_ui_description(func, "Remove keyframe from an F-Curve");
2516 parm = RNA_def_pointer(func, "keyframe", "Keyframe", "", "Keyframe to remove");
2519 /* optional */
2520 RNA_def_boolean(func,
2521 "fast",
2522 false,
2523 "Fast",
2524 "Fast keyframe removal to avoid recalculating the curve each time");
2525
2526 func = RNA_def_function(srna, "clear", "rna_FKeyframe_points_clear");
2527 RNA_def_function_ui_description(func, "Remove all keyframes from an F-Curve");
2529
2530 func = RNA_def_function(srna, "sort", "rna_FKeyframe_points_sort");
2531 RNA_def_function_ui_description(func, "Ensure all keyframe points are chronologically sorted");
2533
2534 func = RNA_def_function(srna, "deduplicate", "rna_FKeyframe_points_deduplicate");
2536 func,
2537 "Ensure there are no duplicate keys. Assumes that the points have already been sorted");
2539
2540 func = RNA_def_function(srna, "handles_recalc", "rna_FKeyframe_points_handles_recalc");
2542 "Update handles after modifications to the keyframe points, to "
2543 "update things like auto-clamping");
2545}
2546
2547static void rna_def_fcurve(BlenderRNA *brna)
2548{
2549 StructRNA *srna;
2550 PropertyRNA *prop;
2551 FunctionRNA *func;
2552 PropertyRNA *parm;
2553
2554 static const EnumPropertyItem prop_mode_extend_items[] = {
2556 "CONSTANT",
2557 0,
2558 "Constant",
2559 "Hold values of endpoint keyframes"},
2561 "LINEAR",
2562 0,
2563 "Linear",
2564 "Use slope of curve leading in/out of endpoint keyframes"},
2565 {0, nullptr, 0, nullptr, nullptr},
2566 };
2567 static const EnumPropertyItem prop_mode_color_items[] = {
2569 "AUTO_RAINBOW",
2570 0,
2571 "Auto Rainbow",
2572 "Cycle through the rainbow, trying to give each curve a unique color"},
2574 "AUTO_RGB",
2575 0,
2576 "Auto XYZ to RGB",
2577 "Use axis colors for transform and color properties, and auto-rainbow for the rest"},
2579 "AUTO_YRGB",
2580 0,
2581 "Auto WXYZ to YRGB",
2582 "Use WXYZ axis colors for quaternion/axis-angle rotations, XYZ axis colors for other "
2583 "transform and color properties, and auto-rainbow for the rest"},
2585 "CUSTOM",
2586 0,
2587 "User Defined",
2588 "Use custom hand-picked color for F-Curve"},
2589 {0, nullptr, 0, nullptr, nullptr},
2590 };
2591
2592 srna = RNA_def_struct(brna, "FCurve", nullptr);
2593 RNA_def_struct_ui_text(srna, "F-Curve", "F-Curve defining values of a period of time");
2594 RNA_def_struct_ui_icon(srna, ICON_ANIM_DATA);
2595 RNA_def_struct_path_func(srna, "rna_FCurve_path");
2596
2597 /* Enums */
2598 prop = RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
2599 RNA_def_property_enum_sdna(prop, nullptr, "extend");
2600 RNA_def_property_enum_items(prop, prop_mode_extend_items);
2602 prop,
2603 "Extrapolation",
2604 "Method used for evaluating value of F-Curve outside first and last keyframes");
2605 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FCurve_update_data");
2606
2607 /* Pointers */
2608 prop = RNA_def_property(srna, "driver", PROP_POINTER, PROP_NONE);
2611 RNA_def_property_ui_text(prop, "Driver", "Channel Driver (only set for Driver F-Curves)");
2612
2613 prop = RNA_def_property(srna, "group", PROP_POINTER, PROP_NONE);
2614 RNA_def_property_pointer_sdna(prop, nullptr, "grp");
2616 RNA_def_property_ui_text(prop, "Group", "Action Group that this F-Curve belongs to");
2617 RNA_def_property_pointer_funcs(prop, nullptr, "rna_FCurve_group_set", nullptr, nullptr);
2618 RNA_def_property_update(prop, NC_ANIMATION, nullptr);
2619
2620 /* Path + Array Index */
2621 prop = RNA_def_property(srna, "data_path", PROP_STRING, PROP_NONE);
2623 prop, "rna_FCurve_RnaPath_get", "rna_FCurve_RnaPath_length", "rna_FCurve_RnaPath_set");
2624 RNA_def_property_ui_text(prop, "Data Path", "RNA Path to property affected by F-Curve");
2625 /* XXX need an update callback for this to that animation gets evaluated */
2626 RNA_def_property_update(prop, NC_ANIMATION, "rna_FCurve_update_data_relations");
2627
2628 /* called 'index' when given as function arg */
2629 prop = RNA_def_property(srna, "array_index", PROP_INT, PROP_UNSIGNED);
2631 prop, "RNA Array Index", "Index to the specific property affected by F-Curve if applicable");
2632 /* XXX need an update callback for this so that animation gets evaluated */
2633 RNA_def_property_update(prop, NC_ANIMATION, "rna_FCurve_update_data_relations");
2634
2635 /* Color */
2636 prop = RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE);
2637 RNA_def_property_enum_items(prop, prop_mode_color_items);
2639 prop, "Color Mode", "Method used to determine color of F-Curve in Graph Editor");
2640 RNA_def_property_update(prop, NC_ANIMATION, nullptr);
2641
2642 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
2643 RNA_def_property_array(prop, 3);
2644 RNA_def_property_range(prop, 0.0f, 1.0f);
2645 RNA_def_property_ui_text(prop, "Color", "Color of the F-Curve in the Graph Editor");
2646 RNA_def_property_update(prop, NC_ANIMATION, nullptr);
2647
2648 /* Flags */
2649 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
2650 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCURVE_SELECTED);
2651 RNA_def_property_ui_text(prop, "Select", "F-Curve is selected for editing");
2653
2654 prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
2655 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCURVE_PROTECTED);
2656 RNA_def_property_ui_text(prop, "Lock", "F-Curve's settings cannot be edited");
2658
2659 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
2660 RNA_def_property_boolean_sdna(prop, nullptr, "flag", FCURVE_MUTED);
2662 RNA_def_property_ui_text(prop, "Muted", "Disable F-Curve evaluation");
2663 RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, "rna_FCurve_update_eval");
2664
2665 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
2668 prop, "Hide", "F-Curve and its keyframes are hidden in the Graph Editor graphs");
2670
2671 prop = RNA_def_property(srna, "auto_smoothing", PROP_ENUM, PROP_NONE);
2674 prop, "Auto Handle Smoothing", "Algorithm used to compute automatic handles");
2675 RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, "rna_FCurve_update_data");
2676
2677 /* State Info (for Debugging) */
2678 prop = RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE);
2681 prop,
2682 "Valid",
2683 "False when F-Curve could not be evaluated in past, so should be skipped "
2684 "when evaluating");
2686
2687 prop = RNA_def_property(srna, "is_empty", PROP_BOOLEAN, PROP_NONE);
2688 RNA_def_property_boolean_funcs(prop, "rna_FCurve_is_empty_get", nullptr);
2691 "Empty",
2692 "True if the curve contributes no animation due to lack of "
2693 "keyframes or useful modifiers, and should be deleted");
2694
2695 /* Collections */
2696 prop = RNA_def_property(srna, "sampled_points", PROP_COLLECTION, PROP_NONE);
2697 RNA_def_property_collection_sdna(prop, nullptr, "fpt", "totvert");
2698 RNA_def_property_struct_type(prop, "FCurveSample");
2699 RNA_def_property_ui_text(prop, "Sampled Points", "Sampled animation data");
2700
2701 prop = RNA_def_property(srna, "keyframe_points", PROP_COLLECTION, PROP_NONE);
2702 RNA_def_property_collection_sdna(prop, nullptr, "bezt", "totvert");
2703 RNA_def_property_struct_type(prop, "Keyframe");
2704 RNA_def_property_ui_text(prop, "Keyframes", "User-editable keyframes");
2706
2707 prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
2708 RNA_def_property_struct_type(prop, "FModifier");
2709 RNA_def_property_ui_text(prop, "Modifiers", "Modifiers affecting the shape of the F-Curve");
2710 rna_def_fcurve_modifiers(brna, prop);
2711
2712 /* Functions */
2713 /* -- evaluate -- */
2714 func = RNA_def_function(srna, "evaluate", "evaluate_fcurve"); /* calls the C/API direct */
2715 RNA_def_function_ui_description(func, "Evaluate F-Curve");
2716 parm = RNA_def_float(func,
2717 "frame",
2718 1.0f,
2719 -FLT_MAX,
2720 FLT_MAX,
2721 "Frame",
2722 "Evaluate F-Curve at given frame",
2723 -FLT_MAX,
2724 FLT_MAX);
2726 /* return value */
2727 parm = RNA_def_float(func,
2728 "value",
2729 0,
2730 -FLT_MAX,
2731 FLT_MAX,
2732 "Value",
2733 "Value of F-Curve specific frame",
2734 -FLT_MAX,
2735 FLT_MAX);
2736 RNA_def_function_return(func, parm);
2737
2738 /* -- update / recalculate -- */
2739 func = RNA_def_function(srna, "update", "rna_FCurve_update_data_ex");
2742 func, "Ensure keyframes are sorted in chronological order and handles are set correctly");
2743
2744 /* -- time extents/range -- */
2745 func = RNA_def_function(srna, "range", "rna_FCurve_range");
2746 RNA_def_function_ui_description(func, "Get the time extents for F-Curve");
2747 /* return value */
2748 parm = RNA_def_float_vector(
2749 func, "range", 2, nullptr, -FLT_MAX, FLT_MAX, "Range", "Min/Max values", -FLT_MAX, FLT_MAX);
2751 RNA_def_function_output(func, parm);
2752
2753 /* -- auto-flag validity (ensures valid handling for data type) -- */
2754 func = RNA_def_function(
2755 srna, "update_autoflags", "update_autoflags_fcurve"); /* calls the C/API direct */
2757 func,
2758 "Update FCurve flags set automatically from affected property "
2759 "(currently, integer/discrete flags set when the property is not a float)");
2761 parm = RNA_def_pointer(
2762 func, "data", "AnyType", "Data", "Data containing the property controlled by given FCurve");
2764
2765 /* Functions */
2766 RNA_api_fcurves(srna);
2767}
2768
2769/* *********************** */
2770
2772{
2773 rna_def_fcurve(brna);
2774 rna_def_fkeyframe(brna);
2775 rna_def_fpoint(brna);
2776
2778 rna_def_drivervar(brna);
2780
2781 rna_def_fmodifier(brna);
2782
2785
2788
2793}
2794
2795#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:83
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)
bool BKE_idtype_idcode_is_linkable(short idcode)
Definition idtype.cc:197
void id_lib_extern(ID *id)
Definition lib_id.cc:290
bool BKE_id_can_use_id(const ID &id_from, const ID &id_to)
Definition lib_id.cc:2528
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
@ RPT_ERROR
Definition BKE_report.hh:39
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:153
#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:1054
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:1077
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ 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
#define MEM_reallocN(vmemh, len)
StructRNA * ID_code_to_RNA_type(short idcode)
#define RNA_MAX_ARRAY_DIMENSION
Definition RNA_define.hh:27
ParameterFlag
Definition RNA_types.hh:544
@ PARM_RNAPTR
Definition RNA_types.hh:547
@ PARM_REQUIRED
Definition RNA_types.hh:545
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ FUNC_USE_MAIN
Definition RNA_types.hh:912
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:913
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:889
@ PROP_FLOAT
Definition RNA_types.hh:164
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_STRING
Definition RNA_types.hh:165
@ PROP_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:676
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:503
PropertyFlag
Definition RNA_types.hh:300
@ PROP_THICK_WRAP
Definition RNA_types.hh:423
@ PROP_DYNAMIC
Definition RNA_types.hh:428
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_NEVER_NULL
Definition RNA_types.hh:377
@ PROP_NO_DEG_UPDATE
Definition RNA_types.hh:439
@ PROP_PTR_NO_OWNERSHIP
Definition RNA_types.hh:395
@ PROP_ID_REFCOUNT
Definition RNA_types.hh:364
@ PROP_TIME
Definition RNA_types.hh:253
@ PROP_COORDS
Definition RNA_types.hh:274
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_FACTOR
Definition RNA_types.hh:251
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:272
@ PROP_UNSIGNED
Definition RNA_types.hh:249
#define NC_ANIMATION
Definition WM_types.hh:388
#define NC_SCENE
Definition WM_types.hh:378
#define ND_MODIFIER
Definition WM_types.hh:462
#define NA_EDITED
Definition WM_types.hh:584
#define ND_SPACE_GRAPH
Definition WM_types.hh:532
#define ND_KEYFRAME_PROP
Definition WM_types.hh:495
#define ND_FRAME
Definition WM_types.hh:434
#define NA_RENAME
Definition WM_types.hh:588
#define ND_KEYFRAME
Definition WM_types.hh:494
#define NC_OBJECT
Definition WM_types.hh:379
#define ND_ANIMCHAN
Definition WM_types.hh:496
#define NC_SPACE
Definition WM_types.hh:392
#define NA_SELECTED
Definition WM_types.hh:589
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 GS(x)
#define printf(...)
float length(VecOp< float, D >) RET
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:103
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:414
char name[258]
Definition DNA_ID.h:432
T * data_as() const
Definition RNA_types.hh:124
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:4238
uint8_t flag
Definition wm_window.cc:145