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