Blender V4.5
rna_nla.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 <cstdlib>
10
11#include "DNA_action_types.h"
12#include "DNA_anim_types.h"
13
14#include "ANIM_action.hh"
15#include "ANIM_nla.hh"
16
17#include "RNA_define.hh"
18#include "RNA_enum_types.hh"
19
20#include "rna_action_tools.hh"
21#include "rna_internal.hh"
22
23#include "WM_api.hh"
24#include "WM_types.hh"
25
26/* Enum defines exported for `rna_animation.cc`. */
27
30 "REPLACE",
31 0,
32 "Replace",
33 "The strip values replace the accumulated results by amount specified by influence"},
35 "COMBINE",
36 0,
37 "Combine",
38 "The strip values are combined with accumulated results by appropriately using addition, "
39 "multiplication, or quaternion math, based on channel type"},
42 "ADD",
43 0,
44 "Add",
45 "Weighted result of strip is added to the accumulated results"},
47 "SUBTRACT",
48 0,
49 "Subtract",
50 "Weighted result of strip is removed from the accumulated results"},
52 "MULTIPLY",
53 0,
54 "Multiply",
55 "Weighted result of strip is multiplied with the accumulated results"},
56 {0, nullptr, 0, nullptr, nullptr},
57};
58
60 {NLASTRIP_EXTEND_NOTHING, "NOTHING", 0, "Nothing", "Strip has no influence past its extents"},
62 "HOLD",
63 0,
64 "Hold",
65 "Hold the first frame if no previous strips in track, and always hold last frame"},
66 {NLASTRIP_EXTEND_HOLD_FORWARD, "HOLD_FORWARD", 0, "Hold Forward", "Only hold last frame"},
67 {0, nullptr, 0, nullptr, nullptr},
68};
69
70#ifdef RNA_RUNTIME
71
72# include <fmt/format.h>
73# include <math.h>
74# include <stdio.h>
75
76/* needed for some of the validation stuff... */
77# include "BKE_anim_data.hh"
78# include "BKE_fcurve.hh"
79# include "BKE_nla.hh"
80
81# include "DNA_object_types.h"
82
83# include "ED_anim_api.hh"
84
85# include "DEG_depsgraph.hh"
86# include "DEG_depsgraph_build.hh"
87
88static void rna_NlaStrip_name_set(PointerRNA *ptr, const char *value)
89{
90 NlaStrip *data = (NlaStrip *)ptr->data;
91
92 /* copy the name first */
93 STRNCPY_UTF8(data->name, value);
94
95 /* validate if there's enough info to do so */
96 if (ptr->owner_id) {
97 AnimData *adt = BKE_animdata_from_id(ptr->owner_id);
99 }
100}
101
102static std::optional<std::string> rna_NlaStrip_path(const PointerRNA *ptr)
103{
104 NlaStrip *strip = (NlaStrip *)ptr->data;
105 AnimData *adt = BKE_animdata_from_id(ptr->owner_id);
106
107 /* if we're attached to AnimData, try to resolve path back to AnimData */
108 if (adt) {
109 NlaTrack *nlt;
110 NlaStrip *nls;
111
112 for (nlt = static_cast<NlaTrack *>(adt->nla_tracks.first); nlt; nlt = nlt->next) {
113 for (nls = static_cast<NlaStrip *>(nlt->strips.first); nls; nls = nls->next) {
114 if (nls == strip) {
115 /* XXX but if we animate like this, the control will never work... */
116 char name_esc_nlt[sizeof(nlt->name) * 2];
117 char name_esc_strip[sizeof(strip->name) * 2];
118
119 BLI_str_escape(name_esc_nlt, nlt->name, sizeof(name_esc_nlt));
120 BLI_str_escape(name_esc_strip, strip->name, sizeof(name_esc_strip));
121 return fmt::format(
122 "animation_data.nla_tracks[\"{}\"].strips[\"{}\"]", name_esc_nlt, name_esc_strip);
123 }
124 }
125 }
126 }
127
128 /* no path */
129 return "";
130}
131
132static void rna_NlaStrip_update(Main *bmain, Scene * /*scene*/, PointerRNA *ptr)
133{
134 ID *id = ptr->owner_id;
135
136 ANIM_id_update(bmain, id);
137}
138
139static void rna_NlaStrip_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr)
140{
142
143 rna_NlaStrip_update(bmain, scene, ptr);
144}
145
146static void rna_NlaStrip_transform_update(Main *bmain, Scene *scene, PointerRNA *ptr)
147{
148 NlaStrip *strip = (NlaStrip *)ptr->data;
149
151
152 /* set the flag */
153 if ((strip->flag & NLASTRIP_FLAG_AUTO_BLENDS) && ptr->owner_id) {
154 /* validate state to ensure that auto-blend gets applied immediately */
155 IdAdtTemplate *iat = (IdAdtTemplate *)ptr->owner_id;
156
157 if (iat->adt) {
158 BKE_nla_validate_state(iat->adt);
159 }
160 }
161
163
164 rna_NlaStrip_update(bmain, scene, ptr);
165}
166
167static void rna_NlaStrip_start_frame_set(PointerRNA *ptr, float value)
168{
169 /* Simply set the frame start in a valid range : if there are any NLA strips before/after, clamp
170 * the start value. If the new start value is past-the-end, clamp it. Otherwise, set it.
171 *
172 * NOTE: Unless neighboring strips are transitions, NLASTRIP_MIN_LEN_THRESH is not needed, as
173 * strips can be 'glued' to one another. If they are however, ensure transitions have a bit of
174 * time allotted in order to be performed.
175 */
176 NlaStrip *data = (NlaStrip *)ptr->data;
177
179 const float limit_next = BKE_nlastrip_compute_frame_to_next_strip(data);
180 CLAMP(value, limit_prev, limit_next);
181
182 data->start = value;
183
184 /* The ONLY case where we actively modify the value set by the user, is in case the start value
185 * value is past the old end frame (here delta = NLASTRIP_MIN_LEN_THRESH) :
186 * - if there's no "room" for the end frame to be placed at (new_start + delta), move old_end to
187 * the limit, and new_start to (limit - delta)
188 * - otherwise, do _not_ change the end frame. This property is not accessible from the UI, and
189 * can only be set via scripts. The script should be responsible of setting the end frame.
190 */
191 if (data->start > (data->end - NLASTRIP_MIN_LEN_THRESH)) {
192 /* If past-the-allowed-end : */
193 if ((data->start + NLASTRIP_MIN_LEN_THRESH) > limit_next) {
194 data->end = limit_next;
195 data->start = data->end - NLASTRIP_MIN_LEN_THRESH;
196 }
197 }
198
199 /* Ensure transitions are kept 'glued' to the strip : */
200 if (data->prev && data->prev->type == NLASTRIP_TYPE_TRANSITION) {
201 data->prev->end = data->start;
202 }
203}
204
205static void rna_NlaStrip_frame_start_ui_set(PointerRNA *ptr, float value)
206{
207 NlaStrip *data = (NlaStrip *)ptr->data;
208
209 /* Changing the NLA strip's start frame is exactly the same as translating it in the NLA editor.
210 * When 'translating' the clip, the length of it should stay identical. Se we also need to set
211 * this strip's end frame after modifying its start (to `start + (old_end - old_start)`).
212 * Of course, we might have a few other strips on this NLA track, so we have to respect the
213 * previous strip's end frame.
214 *
215 * Also, different types of NLA strips (*_CLIP, *_TRANSITION, *_META, *_SOUND) have their own
216 * properties to respect. Needs testing on a real-world use case for the transition, meta, and
217 * sound types.
218 */
219
220 /* The strip's total length before modifying it & also how long we'd like it to be afterwards. */
221 const float striplen = data->end - data->start;
222
223 /* We're only modifying one strip at a time. The start and end times of its neighbors should not
224 * change. As such, here are the 'bookends' (frame limits) for the start position to respect :
225 * - if a next strip exists, don't allow the strip to start after (next->end - striplen - delta),
226 * (delta being the min length of a Nla Strip : the NLASTRIP_MIN_THRESH macro)
227 * - if a previous strip exists, don't allow this strip to start before it (data->prev) ends
228 * - otherwise, limit to the program limit macros defined in DNA_scene_types.h : {MINA|MAX}FRAMEF
229 */
231 const float limit_next = BKE_nlastrip_compute_frame_to_next_strip(data) - striplen;
232 /* For above : we want to be able to fit the entire strip before the next frame limit, so shift
233 * the next limit by 'striplen' no matter the context. */
234
235 CLAMP(value, limit_prev, limit_next);
236 data->start = value;
237
238 if (data->type != NLASTRIP_TYPE_TRANSITION) {
239 data->end = data->start + striplen;
240 }
241
242 /* Update properties of the prev/next strips if they are transitions to ensure consistency : */
243 if (data->prev && data->prev->type == NLASTRIP_TYPE_TRANSITION) {
244 data->prev->end = data->start;
245 }
246 if (data->next && data->next->type == NLASTRIP_TYPE_TRANSITION) {
247 data->next->start = data->end;
248 }
249}
250
251static void rna_NlaStrip_end_frame_set(PointerRNA *ptr, float value)
252{
253 NlaStrip *data = (NlaStrip *)ptr->data;
254
256 const float limit_next = BKE_nlastrip_compute_frame_to_next_strip(data);
257 CLAMP(value, limit_prev, limit_next);
258
259 data->end = value;
260
261 /* The ONLY case where we actively modify the value set by the user, is in case the start value
262 * value is past the old end frame (here delta = NLASTRIP_MIN_LEN_THRESH):
263 * - if there's no "room" for the end frame to be placed at (new_start + delta), move old_end to
264 * the limit, and new_start to (limit - delta)
265 * - otherwise, do _not_ change the end frame. This property is not accessible from the UI, and
266 * can only be set via scripts. The script should be responsible for setting the end frame.
267 */
268 if (data->end < (data->start + NLASTRIP_MIN_LEN_THRESH)) {
269 /* If before-the-allowed-start : */
270 if ((data->end - NLASTRIP_MIN_LEN_THRESH) < limit_prev) {
271 data->start = limit_prev;
272 data->end = data->start + NLASTRIP_MIN_LEN_THRESH;
273 }
274 }
275
276 /* Ensure transitions are kept "glued" to the strip: */
277 if (data->next && data->next->type == NLASTRIP_TYPE_TRANSITION) {
278 data->next->start = data->end;
279 }
280}
281
282static void rna_NlaStrip_frame_end_ui_set(PointerRNA *ptr, float value)
283{
284 NlaStrip *data = (NlaStrip *)ptr->data;
285
286 /* Changing the strip's end frame will update its action 'range' (defined by actstart->actend) to
287 * accommodate the extra length of the strip. No other parameters of the strip will change. But
288 * this means we have to get the current strip's end frame right now :
289 */
290 const float old_strip_end = data->end;
291
292 /* clamp value to lie within valid limits
293 * - must not have zero or negative length strip, so cannot start before the first frame
294 * + some minimum-strip-length threshold
295 * - cannot end later than the start of the next strip (if present)
296 * -> relies on the BKE_nlastrip_compute_frame_to_next_strip() function
297 */
298 const float limit_prev = data->start + NLASTRIP_MIN_LEN_THRESH;
299 const float limit_next = BKE_nlastrip_compute_frame_to_next_strip(data);
300
301 CLAMP(value, limit_prev, limit_next);
302 data->end = value;
303
304 /* Only adjust transitions at this stage : */
305 if (data->next && data->next->type == NLASTRIP_TYPE_TRANSITION) {
306 data->next->start = value;
307 }
308
309 /* calculate the lengths the strip and its action : *
310 * (Meta and transitions shouldn't be updated, but clip and sound should) */
311 if (data->type == NLASTRIP_TYPE_CLIP || data->type == NLASTRIP_TYPE_SOUND) {
312 const float actlen = BKE_nla_clip_length_get_nonzero(data);
313
314 /* Modify the strip's action end frame, or repeat based on :
315 * - if data->repeat == 1.0f, modify the action end frame :
316 * - if the number of frames to subtract is the number of frames, set the action end frame
317 * to the action start + 1 and modify the end of the strip to add that frame
318 * - if the number of frames
319 * - otherwise, modify the repeat property to accommodate for the new length
320 */
321 float action_length_delta = (old_strip_end - data->end) / data->scale;
322 /* If no repeats are used, then modify the action end frame : */
323 if (IS_EQF(data->repeat, 1.0f)) {
324 /* If they're equal, strip has been reduced by the same amount as the whole strip length,
325 * so clamp the action clip length to 1 frame, and add a frame to end so that
326 * `len(strip) != 0`. */
327 if (IS_EQF(action_length_delta, actlen)) {
328 data->actend = data->actstart + 1.0f;
329 data->end += 1.0f;
330 }
331 else if (action_length_delta < actlen) {
332 /* Now, adjust the new strip's actend to the value it's supposed to have : */
333 data->actend = data->actend - action_length_delta;
334 }
335 /* The case where the delta is bigger than the action length should not be possible, since
336 * data->end is guaranteed to be clamped to data->start + threshold above.
337 */
338 }
339 else {
340 data->repeat -= (action_length_delta / actlen);
341 }
342 }
343}
344
345static void rna_NlaStrip_scale_set(PointerRNA *ptr, float value)
346{
347 NlaStrip *data = (NlaStrip *)ptr->data;
348
349 /* set scale value */
350 /* NOTE: these need to be synced with the values in the
351 * property definition in rna_def_nlastrip() */
352 CLAMP(value, 0.0001f, 1000.0f);
353 data->scale = value;
354
355 /* adjust the strip extents in response to this */
357}
358
359static void rna_NlaStrip_repeat_set(PointerRNA *ptr, float value)
360{
361 NlaStrip *data = (NlaStrip *)ptr->data;
362
363 /* set repeat value */
364 /* NOTE: these need to be synced with the values in the
365 * property definition in rna_def_nlastrip() */
366 CLAMP(value, 0.01f, 1000.0f);
367 data->repeat = value;
368
369 /* adjust the strip extents in response to this */
371}
372
373static void rna_NlaStrip_blend_in_set(PointerRNA *ptr, float value)
374{
375 NlaStrip *data = (NlaStrip *)ptr->data;
376 float len;
377
378 /* blend-in is limited to the length of the strip, and also cannot overlap with blendout */
379 len = (data->end - data->start) - data->blendout;
380 CLAMP(value, 0, len);
381
382 data->blendin = value;
383}
384
385static void rna_NlaStrip_blend_out_set(PointerRNA *ptr, float value)
386{
387 NlaStrip *data = (NlaStrip *)ptr->data;
388 float len;
389
390 /* blend-out is limited to the length of the strip */
391 len = (data->end - data->start);
392 CLAMP(value, 0, len);
393
394 /* it also cannot overlap with blendin */
395 if ((len - value) < data->blendin) {
396 value = len - data->blendin;
397 }
398
399 data->blendout = value;
400}
401
402static void rna_NlaStrip_use_auto_blend_set(PointerRNA *ptr, bool value)
403{
404 NlaStrip *data = (NlaStrip *)ptr->data;
405
406 if (value) {
407 /* set the flag */
409
410 /* validate state to ensure that auto-blend gets applied immediately */
411 if (ptr->owner_id) {
412 IdAdtTemplate *iat = (IdAdtTemplate *)ptr->owner_id;
413
414 if (iat->adt) {
415 BKE_nla_validate_state(iat->adt);
416 }
417 }
418 }
419 else {
420 /* clear the flag */
422
423 /* clear the values too, so that it's clear that there has been an effect */
424 /* TODO: it's somewhat debatable whether it's better to leave these in instead... */
425 data->blendin = 0.0f;
426 data->blendout = 0.0f;
427 }
428}
429
430static void rna_NlaStrip_action_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
431{
432 using namespace blender::animrig;
433 BLI_assert(ptr->owner_id);
434 BLI_assert(ptr->data);
435
436 ID &animated_id = *ptr->owner_id;
437 NlaStrip &strip = *static_cast<NlaStrip *>(ptr->data);
438 Action *action = static_cast<Action *>(value.data);
439
440 if (!action) {
441 nla::unassign_action(strip, animated_id);
442 return;
443 }
444
445 if (!nla::assign_action(strip, *action, animated_id)) {
447 RPT_ERROR,
448 "Could not assign action %s to NLA strip %s",
449 action->id.name + 2,
450 strip.name);
451 }
452}
453
454static int rna_NlaStrip_action_editable(const PointerRNA *ptr, const char ** /*r_info*/)
455{
456 NlaStrip *strip = (NlaStrip *)ptr->data;
457
458 /* Strip actions shouldn't be editable if NLA tweak-mode is on. */
459 if (ptr->owner_id) {
460 AnimData *adt = BKE_animdata_from_id(ptr->owner_id);
461
462 if (adt) {
463 /* active action is only editable when it is not a tweaking strip */
464 if ((adt->flag & ADT_NLA_EDIT_ON) || (adt->actstrip) || (adt->tmpact)) {
465 return 0;
466 }
467 }
468 }
469
470 /* check for clues that strip probably shouldn't be used... */
471 if (strip->flag & NLASTRIP_FLAG_TWEAKUSER) {
472 return 0;
473 }
474
475 /* should be ok, though we may still miss some cases */
476 return PROP_EDITABLE;
477}
478
479static void rna_NlaStrip_action_slot_handle_set(
480 PointerRNA *ptr, const blender::animrig::slot_handle_t new_slot_handle)
481{
482 NlaStrip *strip = (NlaStrip *)ptr->data;
483 rna_generic_action_slot_handle_set(new_slot_handle,
484 *ptr->owner_id,
485 strip->act,
486 strip->action_slot_handle,
487 strip->last_slot_identifier);
488}
489
495static void rna_NlaStrip_action_slot_handle_override_diff(
496 Main *bmain, RNAPropertyOverrideDiffContext &rnadiff_ctx)
497{
498 const NlaStrip *strip_a = static_cast<NlaStrip *>(rnadiff_ctx.prop_a->ptr->data);
499 const NlaStrip *strip_b = static_cast<NlaStrip *>(rnadiff_ctx.prop_b->ptr->data);
500
501 rna_generic_action_slot_handle_override_diff(bmain, rnadiff_ctx, strip_a->act, strip_b->act);
502}
503
504static PointerRNA rna_NlaStrip_action_slot_get(PointerRNA *ptr)
505{
506 NlaStrip *strip = (NlaStrip *)ptr->data;
507 return rna_generic_action_slot_get(strip->act, strip->action_slot_handle);
508}
509
510static void rna_NlaStrip_action_slot_set(PointerRNA *ptr, PointerRNA value, ReportList *reports)
511{
512 NlaStrip *strip = (NlaStrip *)ptr->data;
513 rna_generic_action_slot_set(value,
514 *ptr->owner_id,
515 strip->act,
516 strip->action_slot_handle,
518 reports);
519}
520
521static void rna_iterator_nlastrip_action_suitable_slots_begin(CollectionPropertyIterator *iter,
523{
524 NlaStrip *strip = (NlaStrip *)ptr->data;
525 rna_iterator_generic_action_suitable_slots_begin(iter, ptr, strip->act);
526}
527
528static void rna_NlaStrip_action_start_frame_set(PointerRNA *ptr, float value)
529{
530 NlaStrip *data = (NlaStrip *)ptr->data;
531
532 /* prevent start frame from occurring after end of action */
533 CLAMP(value, MINAFRAME, data->actend);
534 data->actstart = value;
535
536 /* adjust the strip extents in response to this */
537 /* TODO: should the strip be moved backwards instead as a special case? */
539}
540
541static void rna_NlaStrip_action_end_frame_set(PointerRNA *ptr, float value)
542{
543 NlaStrip *data = (NlaStrip *)ptr->data;
544
545 /* prevent end frame from starting before start of action */
546 CLAMP(value, data->actstart, MAXFRAME);
547 data->actend = value;
548
549 /* adjust the strip extents in response to this */
551}
552
553static void rna_NlaStrip_animated_influence_set(PointerRNA *ptr, bool value)
554{
555 NlaStrip *data = (NlaStrip *)ptr->data;
556
557 if (value) {
558 /* set the flag, then make sure a curve for this exists */
561 }
562 else {
564 }
565}
566
567static void rna_NlaStrip_animated_time_set(PointerRNA *ptr, bool value)
568{
569 NlaStrip *data = (NlaStrip *)ptr->data;
570
571 if (value) {
572 /* set the flag, then make sure a curve for this exists */
575 }
576 else {
578 }
579}
580
581static FCurve *rna_NlaStrip_fcurve_find(NlaStrip *strip,
583 const char *data_path,
584 int index)
585{
586 if (data_path[0] == '\0') {
587 BKE_report(reports, RPT_ERROR, "F-Curve data path empty, invalid argument");
588 return nullptr;
589 }
590
591 /* Returns nullptr if not found. */
592 return BKE_fcurve_find(&strip->fcurves, data_path, index);
593}
594
595static NlaStrip *rna_NlaStrip_new(ID *id,
596 NlaTrack *track,
597 Main *bmain,
598 bContext *C,
600 const char * /*name*/,
601 int start,
602 bAction *action)
603{
604 BLI_assert(id);
605 NlaStrip *strip = BKE_nlastrip_new(action, *id);
606
607 if (strip == nullptr) {
608 BKE_report(reports, RPT_ERROR, "Unable to create new strip");
609 return nullptr;
610 }
611
612 strip->end += (start - strip->start);
613 strip->start = start;
614
615 if (!BKE_nlastrips_add_strip(&track->strips, strip)) {
617 reports,
618 RPT_ERROR,
619 "Unable to add strip (the track does not have any space to accommodate this new strip)");
620 BKE_nlastrip_free(strip, true);
621 return nullptr;
622 }
623
624 /* create dummy AnimData block so that BKE_nlastrip_validate_name()
625 * can be used to ensure a valid name, as we don't have one here...
626 * - only the nla_tracks list is needed there, which we aim to reverse engineer here...
627 */
628 {
629 AnimData adt = {nullptr};
630 NlaTrack *nlt, *nlt_p;
631
632 /* 'first' NLA track is found by going back up chain of given
633 * track's parents until we fall off. */
634 nlt_p = track;
635 nlt = track;
636 while ((nlt = nlt->prev) != nullptr) {
637 nlt_p = nlt;
638 }
639 adt.nla_tracks.first = nlt_p;
640
641 /* do the same thing to find the last track */
642 nlt_p = track;
643 nlt = track;
644 while ((nlt = nlt->next) != nullptr) {
645 nlt_p = nlt;
646 }
647 adt.nla_tracks.last = nlt_p;
648
649 /* now we can just auto-name as usual */
650 BKE_nlastrip_validate_name(&adt, strip);
651 }
652
654
657
658 return strip;
659}
660
661static void rna_NlaStrip_remove(
662 ID *id, NlaTrack *track, Main *bmain, bContext *C, ReportList *reports, PointerRNA *strip_ptr)
663{
664 NlaStrip *strip = static_cast<NlaStrip *>(strip_ptr->data);
665 if (BLI_findindex(&track->strips, strip) == -1) {
667 reports, RPT_ERROR, "NLA strip '%s' not found in track '%s'", strip->name, track->name);
668 return;
669 }
670
671 BKE_nlastrip_remove_and_free(&track->strips, strip, true);
672 strip_ptr->invalidate();
673
675
678}
679
680/* Set the 'solo' setting for the given NLA-track, making sure that it is the only one
681 * that has this status in its AnimData block.
682 */
683static void rna_NlaTrack_solo_set(PointerRNA *ptr, bool value)
684{
685 NlaTrack *data = (NlaTrack *)ptr->data;
686 AnimData *adt = BKE_animdata_from_id(ptr->owner_id);
687 NlaTrack *nt;
688
689 if (data == nullptr) {
690 return;
691 }
692
693 /* firstly, make sure 'solo' flag for all tracks is disabled */
694 for (nt = data; nt; nt = nt->next) {
695 nt->flag &= ~NLATRACK_SOLO;
696 }
697 for (nt = data; nt; nt = nt->prev) {
698 nt->flag &= ~NLATRACK_SOLO;
699 }
700
701 /* now, enable 'solo' for the given track if appropriate */
702 if (value) {
703 /* set solo status */
704 data->flag |= NLATRACK_SOLO;
705
706 /* set solo-status on AnimData */
707 adt->flag |= ADT_NLA_SOLO_TRACK;
708 }
709 else {
710 /* solo status was already cleared on track */
711
712 /* clear solo-status on AnimData */
714 }
715}
716
717#else
718
720{
721 StructRNA *srna;
722
723 FunctionRNA *func;
724 PropertyRNA *parm;
725
726 RNA_def_property_srna(cprop, "NlaStripFCurves");
727 srna = RNA_def_struct(brna, "NlaStripFCurves", nullptr);
728 RNA_def_struct_sdna(srna, "NlaStrip");
729 RNA_def_struct_ui_text(srna, "NLA-Strip F-Curves", "Collection of NLA strip F-Curves");
730
731 /* `Strip.fcurves.find(...)`. */
732 func = RNA_def_function(srna, "find", "rna_NlaStrip_fcurve_find");
734 func,
735 "Find an F-Curve. Note that this function performs a linear scan "
736 "of all F-Curves in the NLA strip.");
738 parm = RNA_def_string(func, "data_path", nullptr, 0, "Data Path", "F-Curve data path");
740 RNA_def_int(func, "index", 0, 0, INT_MAX, "Index", "Array index", 0, INT_MAX);
741
742 parm = RNA_def_pointer(
743 func, "fcurve", "FCurve", "", "The found F-Curve, or None if it doesn't exist");
744 RNA_def_function_return(func, parm);
745}
746
747static void rna_def_nlastrip(BlenderRNA *brna)
748{
749 StructRNA *srna;
750 PropertyRNA *prop;
751
752 /* Enum definitions. */
753 static const EnumPropertyItem prop_type_items[] = {
754 {NLASTRIP_TYPE_CLIP, "CLIP", 0, "Action Clip", "NLA Strip references some Action"},
756 "TRANSITION",
757 0,
758 "Transition",
759 "NLA Strip 'transitions' between adjacent strips"},
760 {NLASTRIP_TYPE_META, "META", 0, "Meta", "NLA Strip acts as a container for adjacent strips"},
762 "SOUND",
763 0,
764 "Sound Clip",
765 "NLA Strip representing a sound event for speakers"},
766 {0, nullptr, 0, nullptr, nullptr},
767 };
768
769 /* struct definition */
770 srna = RNA_def_struct(brna, "NlaStrip", nullptr);
771 RNA_def_struct_ui_text(srna, "NLA Strip", "A container referencing an existing Action");
772 RNA_def_struct_path_func(srna, "rna_NlaStrip_path");
773 RNA_def_struct_ui_icon(srna, ICON_NLA); /* XXX */
774
776
777 /* name property */
778 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
779 RNA_def_property_ui_text(prop, "Name", "");
780 RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_NlaStrip_name_set");
782 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, nullptr); /* this will do? */
783
784 /* Enums */
785 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
786 RNA_def_property_enum_sdna(prop, nullptr, "type");
788 prop, PROP_EDITABLE); /* XXX for now, not editable, since this is dangerous */
789 RNA_def_property_enum_items(prop, prop_type_items);
790 RNA_def_property_ui_text(prop, "Type", "Type of NLA Strip");
791 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
792
793 prop = RNA_def_property(srna, "extrapolation", PROP_ENUM, PROP_NONE);
794 RNA_def_property_enum_sdna(prop, nullptr, "extendmode");
797 prop, "Extrapolation", "Action to take for gaps past the strip extents");
798 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
799
800 prop = RNA_def_property(srna, "blend_type", PROP_ENUM, PROP_NONE);
801 RNA_def_property_enum_sdna(prop, nullptr, "blendmode");
804 prop, "Blending", "Method used for combining strip's result with accumulated result");
805 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
806
807 /* Strip extents */
808 prop = RNA_def_property(srna, "frame_start", PROP_FLOAT, PROP_TIME);
809 RNA_def_property_float_sdna(prop, nullptr, "start");
810 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_start_frame_set", nullptr);
811 RNA_def_property_ui_text(prop, "Start Frame", "");
813 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
814 /* The `frame_start` and `frame_end` properties should NOT be considered for library overrides,
815 * as their setters always enforce a valid state. While library overrides are applied, the
816 * intermediate state may be invalid, even when the end state is valid. */
818
819 prop = RNA_def_property(srna, "frame_end", PROP_FLOAT, PROP_TIME);
820 RNA_def_property_float_sdna(prop, nullptr, "end");
821 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_end_frame_set", nullptr);
822 RNA_def_property_ui_text(prop, "End Frame", "");
824 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
825 /* The `frame_start` and `frame_end` properties should NOT be considered for library overrides,
826 * as their setters always enforce a valid state. While library overrides are applied, the
827 * intermediate state may be invalid, even when the end state is valid. */
829
830 /* Strip extents without enforcing a valid state. */
831 prop = RNA_def_property(srna, "frame_start_raw", PROP_FLOAT, PROP_TIME);
832 RNA_def_property_float_sdna(prop, nullptr, "start");
834 "Start Frame (raw value)",
835 "Same as frame_start, except that any value can be set, including ones "
836 "that create an invalid state");
838 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
839
840 prop = RNA_def_property(srna, "frame_end_raw", PROP_FLOAT, PROP_TIME);
841 RNA_def_property_float_sdna(prop, nullptr, "end");
843 "End Frame (raw value)",
844 "Same as frame_end, except that any value can be set, including ones "
845 "that create an invalid state");
847 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
848
849 /* Strip extents, when called from UI elements : */
850 prop = RNA_def_property(srna, "frame_start_ui", PROP_FLOAT, PROP_TIME);
851 RNA_def_property_float_sdna(prop, nullptr, "start");
852 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_frame_start_ui_set", nullptr);
854 prop,
855 "Start Frame (manipulated from UI)",
856 "Start frame of the NLA strip. Note: changing this value also updates the value of "
857 "the strip's end frame. If only the start frame should be changed, see the \"frame_start\" "
858 "property instead.");
860 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
861 /* The `..._ui` properties should NOT be considered for library overrides, as they are meant to
862 * have different behavior than when setting their non-`..._ui` counterparts. */
864
865 prop = RNA_def_property(srna, "frame_end_ui", PROP_FLOAT, PROP_TIME);
866 RNA_def_property_float_sdna(prop, nullptr, "end");
867 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_frame_end_ui_set", nullptr);
869 prop,
870 "End Frame (manipulated from UI)",
871 "End frame of the NLA strip. Note: changing this value also updates the value of "
872 "the strip's repeats or its action's end frame. If only the end frame should be "
873 "changed, see the \"frame_end\" property instead.");
875 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
876 /* The `..._ui` properties should NOT be considered for library overrides, as they are meant to
877 * have different behavior than when setting their non-`..._ui` counterparts. */
879
880 /* Blending */
881 prop = RNA_def_property(srna, "blend_in", PROP_FLOAT, PROP_NONE);
882 RNA_def_property_float_sdna(prop, nullptr, "blendin");
883 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_blend_in_set", nullptr);
885 prop, "Blend In", "Number of frames at start of strip to fade in influence");
886 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
887
888 prop = RNA_def_property(srna, "blend_out", PROP_FLOAT, PROP_NONE);
889 RNA_def_property_float_sdna(prop, nullptr, "blendout");
890 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_blend_out_set", nullptr);
891 RNA_def_property_ui_text(prop, "Blend Out", "");
892 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
893
894 prop = RNA_def_property(srna, "use_auto_blend", PROP_BOOLEAN, PROP_NONE);
896 RNA_def_property_boolean_funcs(prop, nullptr, "rna_NlaStrip_use_auto_blend_set");
898 "Auto Blend In/Out",
899 "Number of frames for Blending In/Out is automatically determined from "
900 "overlapping strips");
901 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
902
903 /* Action */
904 prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE);
905 RNA_def_property_pointer_sdna(prop, nullptr, "act");
907 prop, nullptr, "rna_NlaStrip_action_set", nullptr, "rna_Action_id_poll");
909 RNA_def_property_editable_func(prop, "rna_NlaStrip_action_editable");
910 RNA_def_property_ui_text(prop, "Action", "Action referenced by this strip");
912 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_dependency_update");
913
914 /* This property is not necessary for the Python API (that is better off using
915 * slot references/pointers directly), but it is needed for library overrides
916 * to work. */
917 prop = RNA_def_property(srna, "action_slot_handle", PROP_INT, PROP_NONE);
918 RNA_def_property_int_sdna(prop, nullptr, "action_slot_handle");
919 RNA_def_property_int_funcs(prop, nullptr, "rna_NlaStrip_action_slot_handle_set", nullptr);
921 "Action Slot Handle",
922 "A number that identifies which sub-set of the Action is considered "
923 "to be for this NLA strip");
926 prop, "rna_NlaStrip_action_slot_handle_override_diff", nullptr, nullptr);
927 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA_ACTCHANGE, "rna_NlaStrip_dependency_update");
928
929 prop = RNA_def_property(srna, "last_slot_identifier", PROP_STRING, PROP_NONE);
930 RNA_def_property_string_sdna(prop, nullptr, "last_slot_identifier");
932 prop,
933 "Last Action Slot Identifier",
934 "The identifier of the most recently assigned action slot. The slot identifies which "
935 "sub-set of the Action is considered to be for this strip, and its identifier is used to "
936 "find the right slot when assigning an Action.");
937
938 prop = RNA_def_property(srna, "action_slot", PROP_POINTER, PROP_NONE);
939 RNA_def_property_struct_type(prop, "ActionSlot");
943 prop,
944 "Action Slot",
945 "The slot identifies which sub-set of the Action is considered to be for this "
946 "strip, and its name is used to find the right slot when assigning another Action");
948 prop, "rna_NlaStrip_action_slot_get", "rna_NlaStrip_action_slot_set", nullptr, nullptr);
949 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA_ACTCHANGE, "rna_NlaStrip_dependency_update");
950 /* `strip.action_slot` is exposed to RNA as a pointer for things like the action slot selector in
951 * the GUI. The ground truth of the assigned slot, however, is `action_slot_handle` declared
952 * above. That property is used for library override operations, and this pointer property should
953 * just be ignored.
954 *
955 * This needs PROPOVERRIDE_IGNORE; PROPOVERRIDE_NO_COMPARISON is not suitable here. This property
956 * should act as if it is an overridable property (as from the user's perspective, it is), but an
957 * override operation should not be created for it. It will be created for `action_slot_handle`,
958 * and that's enough. */
960
961 prop = RNA_def_property(srna, "action_suitable_slots", PROP_COLLECTION, PROP_NONE);
962 RNA_def_property_struct_type(prop, "ActionSlot");
964 "rna_iterator_nlastrip_action_suitable_slots_begin",
965 "rna_iterator_array_next",
966 "rna_iterator_array_end",
967 "rna_iterator_array_dereference_get",
968 nullptr,
969 nullptr,
970 nullptr,
971 nullptr);
973 prop, "Action Slots", "The list of action slots suitable for this NLA strip");
974
975 /* Action extents */
976 prop = RNA_def_property(srna, "action_frame_start", PROP_FLOAT, PROP_TIME);
977 RNA_def_property_float_sdna(prop, nullptr, "actstart");
978 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_action_start_frame_set", nullptr);
979 RNA_def_property_ui_text(prop, "Action Start Frame", "First frame from action to use");
981 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
982
983 prop = RNA_def_property(srna, "action_frame_end", PROP_FLOAT, PROP_TIME);
984 RNA_def_property_float_sdna(prop, nullptr, "actend");
985 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_action_end_frame_set", nullptr);
986 RNA_def_property_ui_text(prop, "Action End Frame", "Last frame from action to use");
988 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
989
990 /* Action Reuse */
991 prop = RNA_def_property(srna, "repeat", PROP_FLOAT, PROP_NONE);
992 RNA_def_property_float_sdna(prop, nullptr, "repeat");
993 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_repeat_set", nullptr);
994 /* these limits have currently be chosen arbitrarily, but could be extended
995 * (minimum should still be > 0 though) if needed... */
997 RNA_def_property_range(prop, 0.1f, 1000.0f);
998 RNA_def_property_ui_text(prop, "Repeat", "Number of times to repeat the action range");
1000 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
1001
1002 prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
1003 RNA_def_property_float_sdna(prop, nullptr, "scale");
1004 RNA_def_property_float_funcs(prop, nullptr, "rna_NlaStrip_scale_set", nullptr);
1005 /* these limits can be extended, but beyond this, we can get some crazy+annoying bugs
1006 * due to numeric errors */
1008 RNA_def_property_range(prop, 0.0001f, 1000.0f);
1009 RNA_def_property_ui_text(prop, "Scale", "Scaling factor for action");
1011 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
1012
1013 /* Strip's F-Curves */
1014 prop = RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE);
1015 RNA_def_property_collection_sdna(prop, nullptr, "fcurves", nullptr);
1016 RNA_def_property_struct_type(prop, "FCurve");
1018 prop, "F-Curves", "F-Curves for controlling the strip's influence and timing");
1019 rna_def_strip_fcurves(brna, prop);
1020
1021 /* Strip's F-Modifiers */
1022 prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE);
1023 RNA_def_property_struct_type(prop, "FModifier");
1025 prop, "Modifiers", "Modifiers affecting all the F-Curves in the referenced Action");
1026
1027 /* Strip's Sub-Strips (for Meta-Strips) */
1028 prop = RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE);
1029 RNA_def_property_struct_type(prop, "NlaStrip");
1031 prop,
1032 "NLA Strips",
1033 "NLA Strips that this strip acts as a container for (if it is of type Meta)");
1034
1035 /* Settings - Values necessary for evaluation */
1036 prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_FACTOR);
1037 RNA_def_property_range(prop, 0.0f, 1.0f);
1039 prop, "Influence", "Amount the strip contributes to the current result");
1040 /* XXX: Update temporarily disabled so that the property can be edited at all!
1041 * Even auto-key only applies after the curves have been re-evaluated,
1042 * causing the unkeyed values to be lost. */
1044 prop, NC_ANIMATION | ND_NLA | NA_EDITED, /*"rna_NlaStrip_update"*/ nullptr);
1045
1046 prop = RNA_def_property(srna, "strip_time", PROP_FLOAT, PROP_TIME);
1047 RNA_def_property_ui_text(prop, "Strip Time", "Frame of referenced Action to evaluate");
1048 /* XXX: Update temporarily disabled so that the property can be edited at all!
1049 * Even auto-key only applies after the curves have been re-evaluated,
1050 * causing the unkeyed values to be lost. */
1052 prop, NC_ANIMATION | ND_NLA | NA_EDITED, /*"rna_NlaStrip_update"*/ nullptr);
1053
1054 /* TODO: should the animated_influence/time settings be animatable themselves? */
1055 prop = RNA_def_property(srna, "use_animated_influence", PROP_BOOLEAN, PROP_NONE);
1057 RNA_def_property_boolean_funcs(prop, nullptr, "rna_NlaStrip_animated_influence_set");
1059 prop,
1060 "Animated Influence",
1061 "Influence setting is controlled by an F-Curve rather than automatically determined");
1062 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
1063
1064 prop = RNA_def_property(srna, "use_animated_time", PROP_BOOLEAN, PROP_NONE);
1066 RNA_def_property_boolean_funcs(prop, nullptr, "rna_NlaStrip_animated_time_set");
1068 prop,
1069 "Animated Strip Time",
1070 "Strip time is controlled by an F-Curve rather than automatically determined");
1071 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
1072
1073 prop = RNA_def_property(srna, "use_animated_time_cyclic", PROP_BOOLEAN, PROP_NONE);
1076 prop, "Cyclic Strip Time", "Cycle the animated time within the action start and end");
1078 prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_transform_update");
1079
1080 /* settings */
1081 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1082 /* can be made editable by hooking it up to the necessary NLA API methods */
1085 RNA_def_property_ui_text(prop, "Active", "NLA Strip is active");
1086 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, nullptr); /* this will do? */
1087
1088 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1090 RNA_def_property_ui_text(prop, "Select", "NLA Strip is selected");
1091 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, nullptr); /* this will do? */
1092
1093 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1094 RNA_def_property_boolean_sdna(prop, nullptr, "flag", NLASTRIP_FLAG_MUTED);
1095 RNA_def_property_ui_icon(prop, ICON_CHECKBOX_HLT, -1);
1096 RNA_def_property_ui_text(prop, "Mute", "Disable NLA Strip evaluation");
1097 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
1098
1099 prop = RNA_def_property(srna, "use_reverse", PROP_BOOLEAN, PROP_NONE);
1102 "Reversed",
1103 "NLA Strip is played back in reverse order (only when timing is "
1104 "automatically determined)");
1105 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
1106
1107 prop = RNA_def_property(srna, "use_sync_length", PROP_BOOLEAN, PROP_NONE);
1110 "Sync Action Length",
1111 "Update range of frames referenced from action "
1112 "after tweaking strip and its keyframes");
1113 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
1114
1116}
1117
1119{
1120 StructRNA *srna;
1121 PropertyRNA *parm;
1122 FunctionRNA *func;
1123
1124 RNA_def_property_srna(cprop, "NlaStrips");
1125 srna = RNA_def_struct(brna, "NlaStrips", nullptr);
1126 RNA_def_struct_sdna(srna, "NlaTrack");
1127 RNA_def_struct_ui_text(srna, "NLA Strips", "Collection of NLA Strips");
1128
1129 func = RNA_def_function(srna, "new", "rna_NlaStrip_new");
1132 RNA_def_function_ui_description(func, "Add a new Action-Clip strip to the track");
1133 parm = RNA_def_string(func, "name", "NlaStrip", 0, "", "Name for the NLA Strips");
1135 parm = RNA_def_int(func,
1136 "start",
1137 0,
1138 INT_MIN,
1139 INT_MAX,
1140 "Start Frame",
1141 "Start frame for this strip",
1142 INT_MIN,
1143 INT_MAX);
1145 parm = RNA_def_pointer(func, "action", "Action", "", "Action to assign to this strip");
1147 /* return type */
1148 parm = RNA_def_pointer(func, "strip", "NlaStrip", "", "New NLA Strip");
1149 RNA_def_function_return(func, parm);
1150
1151 func = RNA_def_function(srna, "remove", "rna_NlaStrip_remove");
1154 RNA_def_function_ui_description(func, "Remove a NLA Strip");
1155 parm = RNA_def_pointer(func, "strip", "NlaStrip", "", "NLA Strip to remove");
1158}
1159
1161{
1162 StructRNA *srna;
1163 PropertyRNA *prop;
1164
1165 srna = RNA_def_struct(brna, "NlaTrack", nullptr);
1167 srna, "NLA Track", "An animation layer containing Actions referenced as NLA strips");
1168 RNA_def_struct_ui_icon(srna, ICON_NLA);
1169
1170 /* strips collection */
1171 prop = RNA_def_property(srna, "strips", PROP_COLLECTION, PROP_NONE);
1172 RNA_def_property_struct_type(prop, "NlaStrip");
1173 /* We do not support inserting or removing strips in overrides of tracks for now. */
1175 RNA_def_property_ui_text(prop, "NLA Strips", "NLA Strips on this NLA-track");
1176
1177 rna_api_nlatrack_strips(brna, prop);
1178
1179 prop = RNA_def_boolean(srna,
1180 "is_override_data",
1181 false,
1182 "Override Track",
1183 "In a local override data, whether this NLA track comes from the linked "
1184 "reference data, or is local to the override");
1187
1189
1190 /* name property */
1191 prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
1192 RNA_def_property_ui_text(prop, "Name", "");
1193 RNA_def_struct_name_property(srna, prop);
1194 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, nullptr); /* this will do? */
1195
1196 /* settings */
1197 prop = RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
1198 /* can be made editable by hooking it up to the necessary NLA API methods */
1200 RNA_def_property_boolean_sdna(prop, nullptr, "flag", NLATRACK_ACTIVE);
1201 RNA_def_property_ui_text(prop, "Active", "NLA Track is active");
1202 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, nullptr); /* this will do? */
1203
1204 prop = RNA_def_property(srna, "is_solo", PROP_BOOLEAN, PROP_NONE);
1205 /* can be made editable by hooking it up to the necessary NLA API methods */
1206 RNA_def_property_boolean_sdna(prop, nullptr, "flag", NLATRACK_SOLO);
1208 prop,
1209 "Solo",
1210 "NLA Track is evaluated itself (i.e. active Action and all other NLA Tracks in the "
1211 "same AnimData block are disabled)");
1212 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
1213 RNA_def_property_boolean_funcs(prop, nullptr, "rna_NlaTrack_solo_set");
1214
1215 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
1216 RNA_def_property_boolean_sdna(prop, nullptr, "flag", NLATRACK_SELECTED);
1217 RNA_def_property_ui_text(prop, "Select", "NLA Track is selected");
1218 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, nullptr); /* this will do? */
1219
1220 prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE);
1221 RNA_def_property_boolean_sdna(prop, nullptr, "flag", NLATRACK_MUTED);
1222 RNA_def_property_ui_text(prop, "Muted", "Disable NLA Track evaluation");
1223 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA | NA_EDITED, "rna_NlaStrip_update");
1224
1225 prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
1226 RNA_def_property_boolean_sdna(prop, nullptr, "flag", NLATRACK_PROTECTED);
1227 RNA_def_property_ui_text(prop, "Locked", "NLA Track is locked");
1228 RNA_def_property_update(prop, NC_ANIMATION | ND_NLA, nullptr); /* this will do? */
1229
1231}
1232
1233/* --------- */
1234
1236{
1237 rna_def_nlatrack(brna);
1238 rna_def_nlastrip(brna);
1239}
1240
1241#endif
Functions and classes to work with Actions.
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:82
FCurve * BKE_fcurve_find(ListBase *list, const char rna_path[], int array_index)
void BKE_nlastrip_free(NlaStrip *strip, bool do_id_user)
void BKE_nlameta_flush_transforms(NlaStrip *mstrip)
void BKE_nlastrip_remove_and_free(ListBase *strips, NlaStrip *strip, const bool do_id_user)
float BKE_nlastrip_compute_frame_to_next_strip(NlaStrip *strip)
void BKE_nla_validate_state(AnimData *adt)
NlaStrip * BKE_nlastrip_new(bAction *act, ID &animated_id)
void BKE_nlastrip_recalculate_bounds(NlaStrip *strip)
bool BKE_nlastrips_add_strip(ListBase *strips, NlaStrip *strip)
void BKE_nlastrip_recalculate_blend(NlaStrip *strip)
#define NLASTRIP_MIN_LEN_THRESH
Definition BKE_nla.hh:12
float BKE_nla_clip_length_get_nonzero(const NlaStrip *strip)
float BKE_nlastrip_compute_frame_from_previous_strip(NlaStrip *strip)
void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip)
void BKE_nlastrip_validate_fcurves(NlaStrip *strip)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
#define BLI_assert(a)
Definition BLI_assert.h:46
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
size_t BLI_str_escape(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define STRNCPY_UTF8(dst, src)
#define CLAMP(a, b, c)
#define IS_EQF(a, b)
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1026
@ ID_RECALC_ANIMATION
Definition DNA_ID.h:985
@ NLASTRIP_FLAG_ACTIVE
@ NLASTRIP_FLAG_USR_INFLUENCE
@ NLASTRIP_FLAG_USR_TIME
@ NLASTRIP_FLAG_AUTO_BLENDS
@ NLASTRIP_FLAG_REVERSE
@ NLASTRIP_FLAG_MUTED
@ NLASTRIP_FLAG_USR_TIME_CYCLIC
@ NLASTRIP_FLAG_SELECT
@ NLASTRIP_FLAG_TWEAKUSER
@ NLASTRIP_FLAG_SYNC_LENGTH
@ ADT_NLA_SOLO_TRACK
@ ADT_NLA_EDIT_ON
@ NLASTRIP_EXTEND_HOLD_FORWARD
@ NLASTRIP_EXTEND_NOTHING
@ NLASTRIP_EXTEND_HOLD
@ NLASTRIP_MODE_REPLACE
@ NLASTRIP_MODE_ADD
@ NLASTRIP_MODE_SUBTRACT
@ NLASTRIP_MODE_COMBINE
@ NLASTRIP_MODE_MULTIPLY
@ NLASTRIP_TYPE_SOUND
@ NLASTRIP_TYPE_META
@ NLASTRIP_TYPE_TRANSITION
@ NLASTRIP_TYPE_CLIP
@ NLATRACK_SOLO
@ NLATRACK_ACTIVE
@ NLATRACK_MUTED
@ NLATRACK_SELECTED
@ NLATRACK_PROTECTED
@ NLATRACK_OVERRIDELIBRARY_LOCAL
Object is a sort of wrapper for general info.
#define MINAFRAME
#define MAXFRAME
ParameterFlag
Definition RNA_types.hh:510
@ PARM_RNAPTR
Definition RNA_types.hh:513
@ PARM_REQUIRED
Definition RNA_types.hh:511
@ FUNC_USE_REPORTS
Definition RNA_types.hh:805
@ FUNC_USE_MAIN
Definition RNA_types.hh:803
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:804
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:792
@ PROP_FLOAT
Definition RNA_types.hh:152
@ PROP_BOOLEAN
Definition RNA_types.hh:150
@ PROP_ENUM
Definition RNA_types.hh:154
@ PROP_INT
Definition RNA_types.hh:151
@ PROP_STRING
Definition RNA_types.hh:153
@ PROP_POINTER
Definition RNA_types.hh:155
@ PROP_COLLECTION
Definition RNA_types.hh:156
#define RNA_ENUM_ITEM_SEPR
Definition RNA_types.hh:645
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:469
@ PROPOVERRIDE_NO_COMPARISON
Definition RNA_types.hh:477
@ PROPOVERRIDE_IGNORE
Definition RNA_types.hh:489
PropertyFlag
Definition RNA_types.hh:286
@ PROP_THICK_WRAP
Definition RNA_types.hh:397
@ PROP_ANIMATABLE
Definition RNA_types.hh:305
@ PROP_EDITABLE
Definition RNA_types.hh:292
@ PROP_NEVER_NULL
Definition RNA_types.hh:351
@ PROP_TIME
Definition RNA_types.hh:241
@ PROP_NONE
Definition RNA_types.hh:221
@ PROP_FACTOR
Definition RNA_types.hh:239
#define C
Definition RandGen.cpp:29
#define ND_NLA_ACTCHANGE
Definition WM_types.hh:495
#define NC_ANIMATION
Definition WM_types.hh:385
#define NA_ADDED
Definition WM_types.hh:583
#define NA_EDITED
Definition WM_types.hh:581
ReportList * reports
Definition WM_types.hh:1025
#define NA_REMOVED
Definition WM_types.hh:584
#define ND_NLA
Definition WM_types.hh:494
void ANIM_id_update(Main *bmain, ID *id)
Definition anim_deps.cc:103
BMesh const char void * data
DEG_id_tag_update_ex(cb_data->bmain, cb_data->owner_id, ID_RECALC_TAG_FOR_UNDO|ID_RECALC_SYNC_TO_EVAL)
void unassign_action(NlaStrip &strip, ID &animated_id)
bool assign_action(NlaStrip &strip, Action &action, ID &animated_id)
decltype(::ActionSlot::handle) slot_handle_t
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_struct_name_property(StructRNA *srna, PropertyRNA *prop)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_define_lib_overridable(const bool make_overridable)
void RNA_def_struct_path_func(StructRNA *srna, const char *path)
void RNA_def_parameter_clear_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
void RNA_def_property_float_default(PropertyRNA *prop, float value)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_ui_icon(PropertyRNA *prop, int icon, int consecutive)
void RNA_def_property_srna(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *length, const char *lookupint, const char *lookupstring, const char *assignint)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname, const char *propname, const char *lengthpropname)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_property_update(PropertyRNA *prop, int noteflag, const char *func)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_property_editable_func(PropertyRNA *prop, const char *editable)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *set, const char *type_fn, const char *poll)
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_override_funcs(PropertyRNA *prop, const char *diff, const char *store, const char *apply)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void RNA_def_property_boolean_negative_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void RNA_def_nla(BlenderRNA *brna)
Definition rna_nla.cc:1235
static void rna_def_nlastrip(BlenderRNA *brna)
Definition rna_nla.cc:747
static void rna_def_nlatrack(BlenderRNA *brna)
Definition rna_nla.cc:1160
const EnumPropertyItem rna_enum_nla_mode_blend_items[]
Definition rna_nla.cc:28
static void rna_api_nlatrack_strips(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_nla.cc:1118
static void rna_def_strip_fcurves(BlenderRNA *brna, PropertyRNA *cprop)
Definition rna_nla.cc:719
const EnumPropertyItem rna_enum_nla_mode_extend_items[]
Definition rna_nla.cc:59
NlaStrip * actstrip
bAction * tmpact
ListBase nla_tracks
Definition DNA_ID.h:404
char name[66]
Definition DNA_ID.h:415
void * last
void * first
struct NlaStrip * next
ListBase fcurves
char name[64]
char last_slot_identifier[66]
int32_t action_slot_handle
bAction * act
ListBase strips
struct NlaTrack * next
char name[64]
struct NlaTrack * prev
void invalidate()
Definition RNA_types.hh:110
void * data
Definition RNA_types.hh:53
uint len
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
PointerRNA * ptr
Definition wm_files.cc:4226