Blender V4.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
9#include <cstdio>
10#include <cstdlib>
11
12#include "RNA_define.hh"
13#include "RNA_enum_types.hh"
14
15#include "DNA_anim_types.h"
16#include "DNA_object_types.h"
17#include "DNA_scene_types.h"
18
19#include "rna_internal.hh" /* own include */
20
21#ifdef RNA_RUNTIME
22
23# include "BKE_animsys.h"
24# include "BKE_context.hh"
25# include "BKE_nla.hh"
26# include "BKE_report.hh"
27
28# include "ANIM_keyingsets.hh"
29# include "ED_keyframing.hh"
30
31static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList *reports)
32{
33 using namespace blender::animrig;
34 /* TODO: enable access to providing a list of overrides (dsources)? */
35 const ModifyKeyReturn error = ANIM_validate_keyingset(C, nullptr, ks);
36
37 if (error == ModifyKeyReturn::SUCCESS) {
38 return;
39 }
40
41 switch (error) {
42 case ModifyKeyReturn::INVALID_CONTEXT:
43 BKE_report(reports, RPT_ERROR, "Invalid context for keying set");
44 break;
45
46 case ModifyKeyReturn::MISSING_TYPEINFO:
48 reports, RPT_ERROR, "Incomplete built-in keying set, appears to be missing type info");
49 break;
50
51 default:
52 break;
53 }
54}
55
56static float rna_AnimData_nla_tweak_strip_time_to_scene(AnimData *adt, float frame, bool invert)
57{
59}
60
61void rna_id_animdata_fix_paths_rename_all(ID *id,
62 AnimData * /*adt*/,
63 Main *bmain,
64 const char *prefix,
65 const char *oldName,
66 const char *newName)
67{
68 BKE_animdata_fix_paths_rename_all_ex(bmain, id, prefix, oldName, newName, 0, 0, true);
69}
70
71#else
72
74{
75 FunctionRNA *func;
76 // PropertyRNA *parm;
77
78 /* validate relative Keying Set (used to ensure paths are ok for context) */
79 func = RNA_def_function(srna, "refresh", "rna_KeyingSet_context_refresh");
81 func,
82 "Refresh Keying Set to ensure that it is valid for the current context "
83 "(call before each use of one)");
85}
86
88{
89 FunctionRNA *func;
90 PropertyRNA *parm;
91
92 /* Convert between action time and scene time when tweaking a NLA strip. */
93 func = RNA_def_function(
94 srna, "nla_tweak_strip_time_to_scene", "rna_AnimData_nla_tweak_strip_time_to_scene");
96 "Convert a time value from the local time of the tweaked strip "
97 "to scene time, exactly as done by built-in key editing tools. "
98 "Returns the input time unchanged if not tweaking.");
99 parm = RNA_def_float(
100 func, "frame", 0.0, MINAFRAME, MAXFRAME, "", "Input time", MINAFRAME, MAXFRAME);
102 RNA_def_boolean(func, "invert", false, "Invert", "Convert scene time to action time");
103 parm = RNA_def_float(
104 func, "result", 0.0, MINAFRAME, MAXFRAME, "", "Converted time", MINAFRAME, MAXFRAME);
105 RNA_def_function_return(func, parm);
106
107 func = RNA_def_function(srna, "fix_paths_rename_all", "rna_id_animdata_fix_paths_rename_all");
108 RNA_def_string(func, "prefix", nullptr, MAX_IDPROP_NAME, "Prefix", "Name prefix");
109 RNA_def_string(func, "old_name", nullptr, MAX_IDPROP_NAME, "Old Name", "Old name");
110 RNA_def_string(func, "new_name", nullptr, MAX_IDPROP_NAME, "New Name", "New name");
112 func,
113 "Rename the property paths in the animation system, since properties are animated via "
114 "string paths, it's needed to keep them valid after properties has been renamed");
116}
117
118#endif
Functionality to interact with keying sets.
void BKE_animdata_fix_paths_rename_all_ex(struct Main *bmain, struct ID *ref_id, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
float BKE_nla_tweakedit_remap(AnimData *adt, float cframe, short mode)
@ NLATIME_CONVERT_MAP
Definition BKE_nla.hh:516
@ NLATIME_CONVERT_UNMAP
Definition BKE_nla.hh:513
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
#define MAX_IDPROP_NAME
Definition DNA_ID.h:185
Object is a sort of wrapper for general info.
#define MINAFRAME
#define MAXFRAME
@ PARM_REQUIRED
Definition RNA_types.hh:397
@ FUNC_USE_REPORTS
Definition RNA_types.hh:680
@ FUNC_USE_MAIN
Definition RNA_types.hh:678
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:679
@ FUNC_USE_SELF_ID
Definition RNA_types.hh:667
PropertyFlag
Definition RNA_types.hh:201
CCL_NAMESPACE_BEGIN ccl_device float invert(float color, float factor)
Definition invert.h:9
blender::animrig::ModifyKeyReturn ANIM_validate_keyingset(bContext *C, blender::Vector< PointerRNA > *sources, KeyingSet *keyingset)
static void error(const char *str)
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)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
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)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_def_function_flag(FunctionRNA *func, int flag)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
Definition DNA_ID.h:413