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