Blender V5.3
rna_animation_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "RNA_define.hh"
12#include "RNA_enum_types.hh"
13
14#include "DNA_scene_types.h"
15
16#include "rna_internal.hh" /* own include */
17
18#ifdef RNA_RUNTIME
19
20# include "BKE_animsys.hh"
21# include "BKE_context.hh"
22# include "BKE_nla.hh"
23# include "BKE_report.hh"
24
25# include "ANIM_keyingsets.hh"
26# include "ED_keyframing.hh"
27
28namespace blender {
29
30static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList *reports)
31{
32 using namespace animrig;
33 /* TODO: enable access to providing a list of overrides (dsources)? */
34 const ModifyKeyReturn error = validate_keyingset(C, nullptr, ks);
35
36 if (error == ModifyKeyReturn::SUCCESS) {
37 return;
38 }
39
40 switch (error) {
41 case ModifyKeyReturn::INVALID_CONTEXT:
42 BKE_report(reports, RPT_ERROR, "Invalid context for keying set");
43 break;
44
45 case ModifyKeyReturn::MISSING_TYPEINFO:
47 reports, RPT_ERROR, "Incomplete built-in keying set, appears to be missing type info");
48 break;
49
50 default:
51 break;
52 }
53}
54
55static float rna_AnimData_nla_tweak_strip_time_to_scene(AnimData *adt, float frame, bool invert)
56{
58}
59
60void rna_id_animdata_fix_paths_rename_all(ID *id,
61 AnimData * /*adt*/,
62 Main *bmain,
63 const char *prefix,
64 const char *oldName,
65 const char *newName)
66{
68 prefix,
71 /*verify_paths=*/true,
72 *bmain);
73}
74
75} // namespace blender
76
77#else
78
79namespace blender {
80
82{
83 FunctionRNA *func;
84 // PropertyRNA *parm;
85
86 /* validate relative Keying Set (used to ensure paths are ok for context) */
87 func = RNA_def_function(srna, "refresh", "rna_KeyingSet_context_refresh");
89 func,
90 "Refresh Keying Set to ensure that it is valid for the current context "
91 "(call before each use of one)");
93}
94
96{
97 FunctionRNA *func;
98 PropertyRNA *parm;
99
100 /* Convert between action time and scene time when tweaking a NLA strip. */
101 func = RNA_def_function(
102 srna, "nla_tweak_strip_time_to_scene", "rna_AnimData_nla_tweak_strip_time_to_scene");
104 "Convert a time value from the local time of the tweaked strip "
105 "to scene time, exactly as done by built-in key editing tools. "
106 "Returns the input time unchanged if not tweaking.");
107 parm = RNA_def_float(
108 func, "frame", 0.0, MINAFRAME, MAXFRAME, "", "Input time", MINAFRAME, MAXFRAME);
110 RNA_def_boolean(func, "invert", false, "Invert", "Convert scene time to action time");
111 parm = RNA_def_float(
112 func, "result", 0.0, MINAFRAME, MAXFRAME, "", "Converted time", MINAFRAME, MAXFRAME);
113 RNA_def_function_return(func, parm);
114
115 func = RNA_def_function(srna, "fix_paths_rename_all", "rna_id_animdata_fix_paths_rename_all");
116 RNA_def_string(func, "prefix", nullptr, MAX_IDPROP_NAME, "Prefix", "Name prefix");
117 RNA_def_string(func, "old_name", nullptr, MAX_IDPROP_NAME, "Old Name", "Old name");
118 RNA_def_string(func, "new_name", nullptr, MAX_IDPROP_NAME, "New Name", "New name");
120 func,
121 "Rename the property paths in the animation system, since properties are animated via "
122 "string paths, it's needed to keep them valid after properties has been renamed");
124}
125
126} // namespace blender
127
128#endif
Functionality to interact with keying sets.
#define MAX_IDPROP_NAME
Definition DNA_ID.h:174
#define MINAFRAME
#define MAXFRAME
#define C
Definition RandGen.cpp:29
float2x2 invert(float2x2 mat)
ModifyKeyReturn validate_keyingset(bContext *C, Vector< PointerRNA > *sources, KeyingSet *keyingset)
BMesh Iterators.
void RNA_api_keyingset(StructRNA *srna)
void RNA_api_animdata(StructRNA *srna)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, eNlaTime_ConvertModes mode)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
@ NLATIME_CONVERT_UNMAP
Definition BKE_nla.hh:560
@ NLATIME_CONVERT_MAP
Definition BKE_nla.hh:563
std::string RNA_path_name_to_infix(const StringRefNull string)
Definition rna_path.cc:1419
@ FUNC_USE_REPORTS
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:980
@ FUNC_USE_MAIN
@ FUNC_USE_CONTEXT
void BKE_animdata_fix_paths(ID &id, StringRef prefix, StringRef old_infix, StringRef new_infix, bool verify_paths, const DriverMap &driver_map)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PARM_REQUIRED
Definition RNA_types.hh:631
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)