Blender  V2.93
nla_private.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation, Joshua Leung
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #include "BLI_bitmap.h"
27 #include "BLI_ghash.h"
28 #include "RNA_types.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
35 
36 /* --------------- NLA Evaluation DataTypes ----------------------- */
37 
38 /* used for list of strips to accumulate at current time */
39 typedef struct NlaEvalStrip {
40  struct NlaEvalStrip *next, *prev;
41 
42  NlaTrack *track; /* track that this strip belongs to */
43  NlaStrip *strip; /* strip that's being used */
44 
45  short track_index; /* the index of the track within the list */
46  short strip_mode; /* which end of the strip are we looking at */
47 
48  float strip_time; /* time at which which strip is being evaluated */
50 
51 /* NlaEvalStrip->strip_mode */
53  /* standard evaluation */
57 
58  /* transition-strip evaluations */
61 };
62 
63 struct NlaEvalChannel;
64 struct NlaEvalData;
65 
66 /* Unique channel key for GHash. */
67 typedef struct NlaEvalChannelKey {
68  struct PointerRNA ptr;
69  struct PropertyRNA *prop;
71 
72 /* Bitmask of array indices touched by actions. */
73 typedef struct NlaValidMask {
75  BLI_bitmap buffer[sizeof(uint64_t) / sizeof(BLI_bitmap)];
77 
78 /* Set of property values for blending. */
79 typedef struct NlaEvalChannelSnapshot {
81 
84 
85  int length; /* Number of values in the property. */
86  bool is_base; /* Base snapshot of the channel. */
87 
88  float values[]; /* Item values. */
89  /* Memory over-allocated to provide space for values. */
91 
92 /* NlaEvalChannel->mix_mode */
98 };
99 
100 /* Temp channel for accumulating data from NLA for a single property.
101  * Handles array properties as a unit to allow intelligent blending. */
102 typedef struct NlaEvalChannel {
105 
106  /* Original RNA path string and property key. */
107  const char *rna_path;
109 
110  int index;
111  bool is_array;
112  char mix_mode;
113 
114  /* Associated with the RNA property's value(s), marks which elements are affected by NLA. */
116 
117  /* Base set of values. */
119  /* Memory over-allocated to provide space for base_snapshot.values. */
121 
122 /* Set of values for all channels. */
123 typedef struct NlaEvalSnapshot {
124  /* Snapshot this one defaults to. */
126 
127  int size;
130 
131 /* Set of all channels covered by NLA. */
132 typedef struct NlaEvalData {
134 
135  /* Mapping of paths and NlaEvalChannelKeys to channels. */
138 
139  /* Base snapshot. */
142 
143  /* Evaluation result shapshot. */
146 
147 /* Information about the currently edited strip and ones below it for keyframing. */
148 typedef struct NlaKeyframingContext {
150 
151  /* AnimData for which this context was built. */
152  struct AnimData *adt;
153 
154  /* Data of the currently edited strip (copy, or fake strip for the main action). */
157 
158  /* Evaluated NLA stack below the tweak strip. */
161 
162 /* --------------- NLA Functions (not to be used as a proper API) ----------------------- */
163 
164 /* convert from strip time <-> global time */
165 float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode);
166 
167 /* --------------- NLA Evaluation (very-private stuff) ----------------------- */
168 /* these functions are only defined here to avoid problems with the order
169  * in which they get defined. */
170 
172  ListBase *strips,
173  short index,
174  const struct AnimationEvalContext *anim_eval_context,
175  const bool flush_to_original);
177  NlaEvalData *channels,
178  ListBase *modifiers,
179  NlaEvalStrip *nes,
180  NlaEvalSnapshot *snapshot,
181  const struct AnimationEvalContext *anim_eval_context,
182  const bool flush_to_original);
184  NlaEvalData *channels,
185  NlaEvalSnapshot *snapshot,
186  const bool flush_to_original);
187 
189 
190 void nlasnapshot_ensure_channels(NlaEvalData *eval_data, NlaEvalSnapshot *snapshot);
191 
192 void nlasnapshot_blend(NlaEvalData *eval_data,
193  NlaEvalSnapshot *lower_snapshot,
194  NlaEvalSnapshot *upper_snapshot,
195  const short upper_blendmode,
196  const float upper_influence,
197  NlaEvalSnapshot *r_blended_snapshot);
198 
199 #ifdef __cplusplus
200 }
201 #endif
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:32
float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode)
Definition: nla.c:562
struct NlaKeyframingContext NlaKeyframingContext
void nlasnapshot_enable_all_blend_domain(NlaEvalSnapshot *snapshot)
Definition: anim_sys.c:2490
struct NlaEvalChannelSnapshot NlaEvalChannelSnapshot
struct NlaEvalData NlaEvalData
void nlasnapshot_ensure_channels(NlaEvalData *eval_data, NlaEvalSnapshot *snapshot)
Definition: anim_sys.c:2502
void nlasnapshot_blend(NlaEvalData *eval_data, NlaEvalSnapshot *lower_snapshot, NlaEvalSnapshot *upper_snapshot, const short upper_blendmode, const float upper_influence, NlaEvalSnapshot *r_blended_snapshot)
Definition: anim_sys.c:2517
NlaEvalStrip * nlastrips_ctime_get_strip(ListBase *list, ListBase *strips, short index, const struct AnimationEvalContext *anim_eval_context, const bool flush_to_original)
void nlastrip_evaluate(PointerRNA *ptr, NlaEvalData *channels, ListBase *modifiers, NlaEvalStrip *nes, NlaEvalSnapshot *snapshot, const struct AnimationEvalContext *anim_eval_context, const bool flush_to_original)
struct NlaEvalChannelKey NlaEvalChannelKey
struct NlaEvalStrip NlaEvalStrip
struct NlaValidMask NlaValidMask
eNlaEvalChannel_MixMode
Definition: nla_private.h:93
@ NEC_MIX_AXIS_ANGLE
Definition: nla_private.h:97
@ NEC_MIX_ADD
Definition: nla_private.h:94
@ NEC_MIX_MULTIPLY
Definition: nla_private.h:95
@ NEC_MIX_QUATERNION
Definition: nla_private.h:96
eNlaEvalStrip_StripMode
Definition: nla_private.h:52
@ NES_TIME_TRANSITION_END
Definition: nla_private.h:60
@ NES_TIME_TRANSITION_START
Definition: nla_private.h:59
@ NES_TIME_AFTER
Definition: nla_private.h:56
@ NES_TIME_BEFORE
Definition: nla_private.h:54
@ NES_TIME_WITHIN
Definition: nla_private.h:55
struct NlaEvalSnapshot NlaEvalSnapshot
struct NlaEvalChannel NlaEvalChannel
void nladata_flush_channels(PointerRNA *ptr, NlaEvalData *channels, NlaEvalSnapshot *snapshot, const bool flush_to_original)
Definition: anim_sys.c:1980
unsigned __int64 uint64_t
Definition: stdint.h:93
struct PropertyRNA * prop
Definition: nla_private.h:69
struct PointerRNA ptr
Definition: nla_private.h:68
NlaValidMask blend_domain
Definition: nla_private.h:83
struct NlaEvalChannel * channel
Definition: nla_private.h:80
struct NlaEvalData * owner
Definition: nla_private.h:104
struct NlaEvalChannel * next
Definition: nla_private.h:103
NlaEvalChannelSnapshot base_snapshot
Definition: nla_private.h:118
const char * rna_path
Definition: nla_private.h:107
NlaEvalChannelKey key
Definition: nla_private.h:108
struct NlaEvalChannel * prev
Definition: nla_private.h:103
NlaValidMask domain
Definition: nla_private.h:115
NlaEvalSnapshot eval_snapshot
Definition: nla_private.h:144
GHash * path_hash
Definition: nla_private.h:136
NlaEvalSnapshot base_snapshot
Definition: nla_private.h:141
ListBase channels
Definition: nla_private.h:133
GHash * key_hash
Definition: nla_private.h:137
int num_channels
Definition: nla_private.h:140
struct NlaEvalSnapshot * base
Definition: nla_private.h:125
NlaEvalChannelSnapshot ** channels
Definition: nla_private.h:128
struct NlaEvalStrip * next
Definition: nla_private.h:40
NlaStrip * strip
Definition: nla_private.h:43
short track_index
Definition: nla_private.h:45
NlaTrack * track
Definition: nla_private.h:42
short strip_mode
Definition: nla_private.h:46
float strip_time
Definition: nla_private.h:48
struct NlaEvalStrip * prev
Definition: nla_private.h:40
struct NlaKeyframingContext * next
Definition: nla_private.h:149
struct AnimData * adt
Definition: nla_private.h:152
NlaEvalData lower_eval_data
Definition: nla_private.h:159
struct NlaKeyframingContext * prev
Definition: nla_private.h:149
NlaEvalStrip * eval_strip
Definition: nla_private.h:156
BLI_bitmap * ptr
Definition: nla_private.h:74
BLI_bitmap buffer[sizeof(uint64_t)/sizeof(BLI_bitmap)]
Definition: nla_private.h:75
PointerRNA * ptr
Definition: wm_files.c:3157