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