Blender
V5.3
source
blender
depsgraph
intern
eval
deg_eval_runtime_backup_animation.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2019 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#include "
intern/eval/deg_eval_runtime_backup_animation.h
"
10
11
#include "
DNA_anim_types.h
"
12
13
#include "
BKE_anim_data.hh
"
14
#include "
BKE_animsys.hh
"
15
16
#include "
RNA_access.hh
"
17
#include "
RNA_path.hh
"
18
#include "
RNA_types.hh
"
19
20
#include "
intern/depsgraph.hh
"
21
22
namespace
blender::deg
{
23
24
AnimationValueBackup::AnimationValueBackup
(
ParsedRNAPath<>
rna_path
,
int
array_index
,
float
value
)
25
:
rna_path
(
rna_path
),
array_index
(
array_index
),
value
(
value
)
26
{
27
}
28
29
AnimationBackup::AnimationBackup
(
const
Depsgraph
*depsgraph)
30
{
31
meed_value_backup
= !depsgraph->
is_active
;
32
reset
();
33
}
34
35
void
AnimationBackup::reset
() {}
36
37
void
AnimationBackup::init_from_id
(
ID
*
id
)
38
{
39
/* NOTE: This animation backup nicely preserves values which are animated and
40
* are not touched by frame/depsgraph post_update handler.
41
*
42
* But it makes it impossible to have user edits to animated properties: for
43
* example, translation of object with animated location will not work with
44
* the current version of backup. */
45
return
;
46
47
PointerRNA
id_pointer_rna =
RNA_id_pointer_create
(
id
);
48
BKE_fcurves_id_cb
(
id
, [&](
ID
*cb_id,
FCurve
*fcurve) {
49
const
ParsedRNAPathRef
rna_path
= fcurve->rna_path_parsed();
50
if
(
rna_path
.is_empty()) {
51
return
;
52
}
53
if
(
id
!= cb_id) {
54
return
;
55
}
56
57
/* Resolve path to the property. */
58
PathResolvedRNA
resolved_rna;
59
if
(!
BKE_animsys_rna_path_resolve
(
60
&id_pointer_rna,
rna_path
, fcurve->
array_index
, &resolved_rna))
61
{
62
return
;
63
}
64
65
/* Read property value. */
66
float
value;
67
if
(!
BKE_animsys_read_from_rna_path
(&resolved_rna, &value)) {
68
return
;
69
}
70
71
this->
values_backup
.append({
rna_path
, fcurve->
array_index
, value});
72
});
73
}
74
75
void
AnimationBackup::restore_to_id
(
ID
*
id
)
76
{
77
return
;
78
79
PointerRNA
id_pointer_rna =
RNA_id_pointer_create
(
id
);
80
for
(
const
AnimationValueBackup
&value_backup :
values_backup
) {
81
/* Resolve path to the property.
82
*
83
* NOTE: Do it again (after storing), since the sub-data pointers might be
84
* changed after copy-on-evaluation. */
85
PathResolvedRNA
resolved_rna;
86
if
(!
BKE_animsys_rna_path_resolve
(
87
&id_pointer_rna, value_backup.rna_path, value_backup.array_index, &resolved_rna))
88
{
89
return
;
90
}
91
92
/* Write property value. */
93
if
(!
BKE_animsys_write_to_rna_path
(&resolved_rna, value_backup.value)) {
94
return
;
95
}
96
}
97
}
98
99
}
// namespace blender::deg
BKE_anim_data.hh
BKE_animsys.hh
DNA_anim_types.h
RNA_access.hh
RNA_path.hh
RNA_types.hh
blender::ParsedRNAPath
Definition
RNA_path.hh:142
blender::deg::AnimationBackup::restore_to_id
void restore_to_id(ID *id)
Definition
deg_eval_runtime_backup_animation.cc:75
blender::deg::AnimationBackup::reset
void reset()
Definition
deg_eval_runtime_backup_animation.cc:35
blender::deg::AnimationBackup::init_from_id
void init_from_id(ID *id)
Definition
deg_eval_runtime_backup_animation.cc:37
blender::deg::AnimationBackup::values_backup
Vector< AnimationValueBackup > values_backup
Definition
deg_eval_runtime_backup_animation.h:50
blender::deg::AnimationBackup::AnimationBackup
AnimationBackup(const Depsgraph *depsgraph)
Definition
deg_eval_runtime_backup_animation.cc:29
blender::deg::AnimationBackup::meed_value_backup
bool meed_value_backup
Definition
deg_eval_runtime_backup_animation.h:49
blender::deg::AnimationValueBackup
Definition
deg_eval_runtime_backup_animation.h:23
blender::deg::AnimationValueBackup::value
float value
Definition
deg_eval_runtime_backup_animation.h:36
blender::deg::AnimationValueBackup::array_index
int array_index
Definition
deg_eval_runtime_backup_animation.h:35
blender::deg::AnimationValueBackup::AnimationValueBackup
AnimationValueBackup()=default
blender::deg::AnimationValueBackup::rna_path
ParsedRNAPath rna_path
Definition
deg_eval_runtime_backup_animation.h:34
deg_eval_runtime_backup_animation.h
depsgraph.hh
blender::deg
Definition
DEG_depsgraph_light_linking.hh:15
blender::rna_path
Definition
rna_path.cc:244
blender::RNA_id_pointer_create
PointerRNA RNA_id_pointer_create(ID *id)
Definition
rna_access.cc:170
blender::BKE_fcurves_id_cb
void BKE_fcurves_id_cb(struct ID *id, FunctionRef< void(ID *, FCurve *)> func)
blender::ParsedRNAPathRef
Span< rna_path::Item > ParsedRNAPathRef
Definition
RNA_path.hh:113
blender::BKE_animsys_read_from_rna_path
bool BKE_animsys_read_from_rna_path(PathResolvedRNA *anim_rna, float *r_value)
Definition
anim_sys.cc:400
blender::BKE_animsys_write_to_rna_path
bool BKE_animsys_write_to_rna_path(PathResolvedRNA *anim_rna, float value, bool force_write=false)
Definition
anim_sys.cc:461
blender::BKE_animsys_rna_path_resolve
bool BKE_animsys_rna_path_resolve(PointerRNA *ptr, ParsedRNAPathRef rna_path, int array_index, PathResolvedRNA *r_result)
Definition
anim_sys.cc:356
blender::FCurve
Definition
DNA_anim_types.h:353
blender::FCurve::array_index
int array_index
Definition
DNA_anim_types.h:402
blender::ID
Definition
DNA_ID.h:415
blender::PathResolvedRNA
Definition
RNA_types.hh:200
blender::PointerRNA
Definition
RNA_types.hh:52
blender::deg::Depsgraph
Definition
depsgraph.hh:50
blender::deg::Depsgraph::is_active
bool is_active
Definition
depsgraph.hh:163
Generated on
for Blender by
doxygen
1.18.0