Blender V5.0
rna_animviz.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_scene_types.h"
13
14#include "RNA_define.hh"
15#include "RNA_enum_types.hh"
16
17#include "rna_internal.hh"
18
19#include "WM_types.hh"
20
21/* Which part of bone(s) get baked */
22/* TODO: icons? */
24 {MOTIONPATH_BAKE_HEADS, "HEADS", 0, "Heads", "Calculate bone paths from heads"},
25 {0, "TAILS", 0, "Tails", "Calculate bone paths from tails"},
26#if 0
27 {MOTIONPATH_BAKE_CENTERS,
28 "CENTROID",
29 0,
30 "Centers",
31 "Calculate bone paths from center of mass"},
32#endif
33 {0, nullptr, 0, nullptr, nullptr},
34};
35
38 "CURRENT_FRAME",
39 0,
40 "Around Frame",
41 "Display Paths of poses within a fixed number of frames around the current frame"},
43 "RANGE",
44 0,
45 "In Range",
46 "Display Paths of poses within specified range"},
47 {0, nullptr, 0, nullptr, nullptr},
48};
49
51 {MOTIONPATH_RANGE_KEYS_ALL, "KEYS_ALL", 0, "All Keys", "From the first keyframe to the last"},
53 "KEYS_SELECTED",
54 0,
55 "Selected Keys",
56 "From the first selected keyframe to the last"},
57 {MOTIONPATH_RANGE_SCENE, "SCENE", 0, "Scene Frame Range", "The entire Scene / Preview range"},
58 {MOTIONPATH_RANGE_MANUAL, "MANUAL", 0, "Manual Range", "Manually determined frame range"},
59 {0, nullptr, 0, nullptr, nullptr},
60};
61
62#ifdef RNA_RUNTIME
63
64# include "DNA_userdef_types.h"
65
66static PointerRNA rna_AnimViz_motion_paths_get(PointerRNA *ptr)
67{
68 return RNA_pointer_create_with_parent(*ptr, &RNA_AnimVizMotionPaths, ptr->data);
69}
70
71static void rna_AnimViz_path_start_frame_set(PointerRNA *ptr, int value)
72{
74
75 /* XXX: Watch it! Path Start > MAXFRAME/2 could be a problem. */
76 data->path_sf = value;
78
79 CLAMP(data->path_ef, data->path_sf + 1, MAXFRAME / 2);
80}
81
82static void rna_AnimViz_path_end_frame_set(PointerRNA *ptr, int value)
83{
85
86 data->path_ef = value;
87 CLAMP_MAX(data->path_sf, data->path_ef - 1);
88 if (U.flag & USER_NONEGFRAMES) {
89 CLAMP_MIN(data->path_sf, 0);
90 CLAMP_MIN(data->path_ef, 1);
91 }
92}
93
94#else
95
97{
98 PropertyRNA *prop;
99
100 prop = RNA_def_property(srna, "motion_path", PROP_POINTER, PROP_NONE);
101 RNA_def_property_pointer_sdna(prop, nullptr, "mpath");
102 RNA_def_property_ui_text(prop, "Motion Path", "Motion Path for this element");
103}
104
106{
107 StructRNA *srna;
108 PropertyRNA *prop;
109
110 srna = RNA_def_struct(brna, "MotionPathVert", nullptr);
111 RNA_def_struct_sdna(srna, "bMotionPathVert");
112 RNA_def_struct_ui_text(srna, "Motion Path Cache Point", "Cached location on path");
113
114 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_XYZ);
115 RNA_def_property_array(prop, 3);
116 RNA_def_property_ui_text(prop, "Coordinates", "");
117
118 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
120 RNA_def_property_ui_text(prop, "Select", "Path point is selected for editing");
121}
122
124{
125 StructRNA *srna;
126 PropertyRNA *prop;
127
128 srna = RNA_def_struct(brna, "MotionPath", nullptr);
129 RNA_def_struct_sdna(srna, "bMotionPath");
131 srna, "Motion Path", "Cache of the world-space positions of an element over a frame range");
132
133 /* Collections */
134 prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
135 RNA_def_property_collection_sdna(prop, nullptr, "points", "length");
136 RNA_def_property_struct_type(prop, "MotionPathVert");
137 RNA_def_property_ui_text(prop, "Motion Path Points", "Cached positions per frame");
138
139 /* Playback Ranges */
140 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
141 RNA_def_property_int_sdna(prop, nullptr, "start_frame");
143 RNA_def_property_ui_text(prop, "Start Frame", "Starting frame of the stored range");
144
145 prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
146 RNA_def_property_int_sdna(prop, nullptr, "end_frame");
148 RNA_def_property_ui_text(prop, "End Frame", "End frame of the stored range");
149
150 prop = RNA_def_property(srna, "length", PROP_INT, PROP_TIME);
152 RNA_def_property_ui_text(prop, "Length", "Number of frames cached");
153
154 /* Custom Color */
155 prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
156 RNA_def_property_array(prop, 3);
158 prop, "Color Pre", "Custom color for motion path before the current frame");
161
162 prop = RNA_def_property(srna, "color_post", PROP_FLOAT, PROP_COLOR_GAMMA);
163 RNA_def_property_array(prop, 3);
165 prop, "Color Post", "Custom color for motion path after the current frame");
168
169 /* Line width */
170 prop = RNA_def_property(srna, "line_thickness", PROP_INT, PROP_NONE);
171 RNA_def_property_int_sdna(prop, nullptr, "line_thickness");
172 RNA_def_property_range(prop, 1, 6);
173 RNA_def_property_ui_text(prop, "Line Thickness", "Line thickness for motion path");
176
177 /* Settings */
178 prop = RNA_def_property(srna, "use_bone_head", PROP_BOOLEAN, PROP_NONE);
182 prop,
183 "Use Bone Heads",
184 "For PoseBone paths, use the bone head location when calculating this path");
185
186 /* FIXME: Motion Paths are not currently editable... */
187 prop = RNA_def_property(srna, "is_modified", PROP_BOOLEAN, PROP_NONE);
189 RNA_def_property_ui_text(prop, "Edit Path", "Path is being edited");
190
191 /* Use custom color */
192 prop = RNA_def_property(srna, "use_custom_color", PROP_BOOLEAN, PROP_NONE);
194 RNA_def_property_ui_text(prop, "Custom Colors", "Use custom color for this motion path");
197
198 /* Draw lines between keyframes */
199 prop = RNA_def_property(srna, "lines", PROP_BOOLEAN, PROP_NONE);
201 RNA_def_property_ui_text(prop, "Lines", "Use straight lines between keyframe points");
203}
204
205/* --- */
206
208{
209 StructRNA *srna;
210 PropertyRNA *prop;
211
212 srna = RNA_def_struct(brna, "AnimVizMotionPaths", nullptr);
213 RNA_def_struct_sdna(srna, "bAnimVizSettings");
214 RNA_def_struct_nested(brna, srna, "AnimViz");
216 srna, "Motion Path Settings", "Motion Path settings for animation visualization");
217
219
220 /* Enums */
221 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
222 RNA_def_property_enum_sdna(prop, nullptr, "path_type");
224 RNA_def_property_ui_text(prop, "Paths Type", "Type of range to show for Motion Paths");
226
227 prop = RNA_def_property(srna, "range", PROP_ENUM, PROP_NONE);
228 RNA_def_property_enum_sdna(prop, nullptr, "path_range");
230 RNA_def_property_ui_text(prop, "Paths Range", "Type of range to calculate for Motion Paths");
232
233 prop = RNA_def_property(srna, "bake_location", PROP_ENUM, PROP_NONE);
234 RNA_def_property_enum_bitflag_sdna(prop, nullptr, "path_bakeflag");
236 RNA_def_property_ui_text(prop, "Bake Location", "When calculating Bone Paths, use Head or Tips");
238
239 /* Settings */
240 prop = RNA_def_property(srna, "show_frame_numbers", PROP_BOOLEAN, PROP_NONE);
241 RNA_def_property_boolean_sdna(prop, nullptr, "path_viewflag", MOTIONPATH_VIEW_FNUMS);
242 RNA_def_property_ui_text(prop, "Show Frame Numbers", "Show frame numbers on Motion Paths");
244
245 prop = RNA_def_property(srna, "show_keyframe_highlight", PROP_BOOLEAN, PROP_NONE);
246 RNA_def_property_boolean_sdna(prop, nullptr, "path_viewflag", MOTIONPATH_VIEW_KFRAS);
248 prop, "Highlight Keyframes", "Emphasize position of keyframes on Motion Paths");
250
251 prop = RNA_def_property(srna, "show_keyframe_numbers", PROP_BOOLEAN, PROP_NONE);
252 RNA_def_property_boolean_sdna(prop, nullptr, "path_viewflag", MOTIONPATH_VIEW_KFNOS);
254 prop, "Show Keyframe Numbers", "Show frame numbers of Keyframes on Motion Paths");
256
257 prop = RNA_def_property(srna, "show_keyframe_action_all", PROP_BOOLEAN, PROP_NONE);
258 RNA_def_property_boolean_sdna(prop, nullptr, "path_viewflag", MOTIONPATH_VIEW_KFACT);
260 prop,
261 "All Action Keyframes",
262 "For bone motion paths, search whole Action for keyframes instead of in group"
263 " with matching name only (is slower)");
265
266 prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE);
267 RNA_def_property_int_sdna(prop, nullptr, "path_step");
268 RNA_def_property_range(prop, 1, 100);
270 prop,
271 "Frame Step",
272 "Number of frames between paths shown (not for 'On Keyframes' Onion-skinning method)");
274
275 /* Playback Ranges */
276 prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME);
277 RNA_def_property_int_sdna(prop, nullptr, "path_sf");
278 RNA_def_property_int_funcs(prop, nullptr, "rna_AnimViz_path_start_frame_set", nullptr);
280 "Start Frame",
281 "Starting frame of range of paths to display/calculate "
282 "(not for 'Around Frame' Onion-skinning method)");
284
285 prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME);
286 RNA_def_property_int_sdna(prop, nullptr, "path_ef");
287 RNA_def_property_int_funcs(prop, nullptr, "rna_AnimViz_path_end_frame_set", nullptr);
289 "End Frame",
290 "End frame of range of paths to display/calculate "
291 "(not for 'Around Frame' Onion-skinning method)");
293
294 /* Around Current Ranges */
295 prop = RNA_def_property(srna, "frame_before", PROP_INT, PROP_TIME);
296 RNA_def_property_int_sdna(prop, nullptr, "path_bc");
297 RNA_def_property_range(prop, 1, MAXFRAMEF / 2);
299 "Before Current",
300 "Number of frames to show before the current frame "
301 "(only for 'Around Frame' Onion-skinning method)");
303
304 prop = RNA_def_property(srna, "frame_after", PROP_INT, PROP_TIME);
305 RNA_def_property_int_sdna(prop, nullptr, "path_ac");
306 RNA_def_property_range(prop, 1, MAXFRAMEF / 2);
308 "After Current",
309 "Number of frames to show after the current frame "
310 "(only for 'Around Frame' Onion-skinning method)");
312
313 /* Readonly Property - Do any motion paths exist/need updating? (Mainly for bone paths) */
314 prop = RNA_def_property(srna, "has_motion_paths", PROP_BOOLEAN, PROP_NONE);
315 RNA_def_property_boolean_sdna(prop, nullptr, "path_bakeflag", MOTIONPATH_BAKE_HAS_PATHS);
316 /* NOTE: This is really an internal state var for convenience, so don't allow edits! */
319 prop, "Has Motion Paths", "Are there any bone paths that will need updating (read-only)");
320
321 /* If enabled, bakes the motion paths into camera space. */
322 prop = RNA_def_property(srna, "use_camera_space_bake", PROP_BOOLEAN, PROP_NONE);
323 RNA_def_property_boolean_sdna(prop, nullptr, "path_bakeflag", MOTIONPATH_BAKE_CAMERA_SPACE);
325 prop,
326 "Bake to active Camera",
327 "Motion path points will be baked into the camera space of the active camera. This means "
328 "they will only look right when looking through that camera. Switching cameras using "
329 "markers is not supported.");
330
332}
333
334/* --- */
335
337{
338 PropertyRNA *prop;
339
340 prop = RNA_def_property(srna, "animation_visualization", PROP_POINTER, PROP_NONE);
342 RNA_def_property_pointer_sdna(prop, nullptr, "avs");
344 RNA_def_property_ui_text(prop, "Animation Visualization", "Animation data for this data-block");
345}
346
347static void rna_def_animviz(BlenderRNA *brna)
348{
349 StructRNA *srna;
350 PropertyRNA *prop;
351
352 srna = RNA_def_struct(brna, "AnimViz", nullptr);
353 RNA_def_struct_sdna(srna, "bAnimVizSettings");
355 srna, "Animation Visualization", "Settings for the visualization of motion");
356
357 /* motion path settings (nested struct) */
358 prop = RNA_def_property(srna, "motion_path", PROP_POINTER, PROP_NONE);
361 RNA_def_property_struct_type(prop, "AnimVizMotionPaths");
362 RNA_def_property_pointer_funcs(prop, "rna_AnimViz_motion_paths_get", nullptr, nullptr, nullptr);
363 RNA_def_property_ui_text(prop, "Motion Paths", "Motion Path settings for visualization");
364}
365
366/* --- */
367
376
377#endif
#define CLAMP(a, b, c)
#define CLAMP_MAX(a, c)
#define CLAMP_MIN(a, b)
@ MOTIONPATH_BAKE_CAMERA_SPACE
@ MOTIONPATH_BAKE_HEADS
@ MOTIONPATH_BAKE_HAS_PATHS
@ MOTIONPATH_TYPE_ACFRA
@ MOTIONPATH_TYPE_RANGE
@ MOTIONPATH_VERT_SEL
@ MOTIONPATH_VIEW_KFACT
@ MOTIONPATH_VIEW_KFNOS
@ MOTIONPATH_VIEW_FNUMS
@ MOTIONPATH_VIEW_KFRAS
@ MOTIONPATH_RANGE_KEYS_ALL
@ MOTIONPATH_RANGE_KEYS_SELECTED
@ MOTIONPATH_RANGE_SCENE
@ MOTIONPATH_RANGE_MANUAL
@ MOTIONPATH_FLAG_LINES
@ MOTIONPATH_FLAG_CUSTOM
@ MOTIONPATH_FLAG_EDIT
@ MOTIONPATH_FLAG_BHEAD
#define MAXFRAMEF
#define MAXFRAME
#define FRAMENUMBER_MIN_CLAMP(cfra)
@ USER_NONEGFRAMES
@ 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_POINTER
Definition RNA_types.hh:167
@ PROP_COLLECTION
Definition RNA_types.hh:168
@ PROPOVERRIDE_OVERRIDABLE_LIBRARY
Definition RNA_types.hh:503
@ PROP_EDITABLE
Definition RNA_types.hh:306
@ PROP_NEVER_NULL
Definition RNA_types.hh:377
@ PROP_TIME
Definition RNA_types.hh:253
@ PROP_XYZ
Definition RNA_types.hh:269
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:272
#define ND_DRAW_ANIMVIZ
Definition WM_types.hh:473
#define NC_OBJECT
Definition WM_types.hh:379
#define U
BMesh const char void * data
PointerRNA RNA_pointer_create_with_parent(const PointerRNA &parent, StructRNA *type, void *data)
const EnumPropertyItem rna_enum_motionpath_display_type_items[]
static void rna_def_animviz_motionpath_vert(BlenderRNA *brna)
const EnumPropertyItem rna_enum_motionpath_range_items[]
void rna_def_animviz_common(StructRNA *srna)
const EnumPropertyItem rna_enum_motionpath_bake_location_items[]
void RNA_def_animviz(BlenderRNA *brna)
static void rna_def_animviz_motion_path(BlenderRNA *brna)
static void rna_def_animviz(BlenderRNA *brna)
void rna_def_motionpath_common(StructRNA *srna)
static void rna_def_animviz_paths(BlenderRNA *brna)
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int64_t booleanbit)
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_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_struct_ui_text(StructRNA *srna, const char *name, const char *description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
void RNA_def_struct_sdna(StructRNA *srna, const char *structname)
void RNA_def_property_array(PropertyRNA *prop, int length)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
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_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_enum_bitflag_sdna(PropertyRNA *prop, const char *structname, const char *propname)
StructRNA * RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *from)
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_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const char *propname)
void RNA_def_struct_nested(BlenderRNA *brna, StructRNA *srna, const char *structname)
void RNA_def_property_override_flag(PropertyRNA *prop, PropertyOverrideFlag flag)
PointerRNA * ptr
Definition wm_files.cc:4238