Refactor: Remove duplicate function `get_keyframe_values`
No functional changes. The function `get_keyframe_values` existed twice. Once in a legacy state, which also did NLA logic. And also in a new implementation where it only returned keyframe values. This PR removes the legacy function and moves the NLA logic to a separate function. Pull Request: https://projects.blender.org/blender/blender/pulls/119798
This commit is contained in:
parent
451bf56409
commit
fdf75dcf99
|
@ -203,58 +203,41 @@ static void get_keyframe_values_create_reports(ReportList *reports,
|
||||||
MEM_freeN(str_failed_indices);
|
MEM_freeN(str_failed_indices);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static Vector<float> get_keyframe_values(PointerRNA *ptr, PropertyRNA *prop, const bool visual_key)
|
||||||
* Retrieve current property values to keyframe,
|
|
||||||
* possibly applying NLA correction when necessary.
|
|
||||||
*
|
|
||||||
* \param r_successful_remaps: Enables bits for indices which are both intended to be remapped and
|
|
||||||
* were successfully remapped. Bitmap allocated so it must be freed afterward.
|
|
||||||
*/
|
|
||||||
static Vector<float> get_keyframe_values(ReportList *reports,
|
|
||||||
PointerRNA ptr,
|
|
||||||
PropertyRNA *prop,
|
|
||||||
int index,
|
|
||||||
NlaKeyframingContext *nla_context,
|
|
||||||
eInsertKeyFlags flag,
|
|
||||||
const AnimationEvalContext *anim_eval_context,
|
|
||||||
bool *r_force_all,
|
|
||||||
blender::BitVector<> &r_successful_remaps)
|
|
||||||
{
|
{
|
||||||
Vector<float> values;
|
Vector<float> values;
|
||||||
|
|
||||||
if ((flag & INSERTKEY_MATRIX) && visualkey_can_use(&ptr, prop)) {
|
if (visual_key && visualkey_can_use(ptr, prop)) {
|
||||||
/* Visual-keying is only available for object and pchan datablocks, as
|
/* Visual-keying is only available for object and pchan datablocks, as
|
||||||
* it works by keyframing using a value extracted from the final matrix
|
* it works by keyframing using a value extracted from the final matrix
|
||||||
* instead of using the kt system to extract a value.
|
* instead of using the kt system to extract a value.
|
||||||
*/
|
*/
|
||||||
values = visualkey_get_values(&ptr, prop);
|
values = visualkey_get_values(ptr, prop);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
values = get_rna_values(&ptr, prop);
|
values = get_rna_values(ptr, prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
r_successful_remaps.resize(values.size());
|
|
||||||
|
|
||||||
/* adjust the value for NLA factors */
|
|
||||||
BKE_animsys_nla_remap_keyframe_values(nla_context,
|
|
||||||
&ptr,
|
|
||||||
prop,
|
|
||||||
values.as_mutable_span(),
|
|
||||||
index,
|
|
||||||
anim_eval_context,
|
|
||||||
r_force_all,
|
|
||||||
r_successful_remaps);
|
|
||||||
get_keyframe_values_create_reports(reports,
|
|
||||||
ptr,
|
|
||||||
prop,
|
|
||||||
index,
|
|
||||||
values.size(),
|
|
||||||
r_force_all ? *r_force_all : false,
|
|
||||||
r_successful_remaps);
|
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static BitVector<> nla_map_keyframe_values_and_generate_reports(
|
||||||
|
const MutableSpan<float> values,
|
||||||
|
const int index,
|
||||||
|
PointerRNA &ptr,
|
||||||
|
PropertyRNA &prop,
|
||||||
|
NlaKeyframingContext *nla_context,
|
||||||
|
const AnimationEvalContext *anim_eval_context,
|
||||||
|
ReportList *reports,
|
||||||
|
bool *force_all)
|
||||||
|
{
|
||||||
|
BitVector<> successful_remaps(values.size(), false);
|
||||||
|
BKE_animsys_nla_remap_keyframe_values(
|
||||||
|
nla_context, &ptr, &prop, values, index, anim_eval_context, force_all, successful_remaps);
|
||||||
|
get_keyframe_values_create_reports(
|
||||||
|
reports, ptr, &prop, index, values.size(), false, successful_remaps);
|
||||||
|
return successful_remaps;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the point where a key is about to be inserted to be inside the main cycle range.
|
* Move the point where a key is about to be inserted to be inside the main cycle range.
|
||||||
* Returns the type of the cycle if it is enabled and valid.
|
* Returns the type of the cycle if it is enabled and valid.
|
||||||
|
@ -429,9 +412,18 @@ bool insert_keyframe_direct(ReportList *reports,
|
||||||
update_autoflags_fcurve_direct(fcu, prop);
|
update_autoflags_fcurve_direct(fcu, prop);
|
||||||
|
|
||||||
const int index = fcu->array_index;
|
const int index = fcu->array_index;
|
||||||
BitVector<> successful_remaps;
|
const bool visual_keyframing = flag & INSERTKEY_MATRIX;
|
||||||
Vector<float> values = get_keyframe_values(
|
Vector<float> values = get_keyframe_values(&ptr, prop, visual_keyframing);
|
||||||
reports, ptr, prop, index, nla_context, flag, anim_eval_context, nullptr, successful_remaps);
|
|
||||||
|
BitVector<> successful_remaps = nla_map_keyframe_values_and_generate_reports(
|
||||||
|
values.as_mutable_span(),
|
||||||
|
index,
|
||||||
|
ptr,
|
||||||
|
*prop,
|
||||||
|
nla_context,
|
||||||
|
anim_eval_context,
|
||||||
|
reports,
|
||||||
|
nullptr);
|
||||||
|
|
||||||
float current_value = 0.0f;
|
float current_value = 0.0f;
|
||||||
if (index >= 0 && index < values.size()) {
|
if (index >= 0 && index < values.size()) {
|
||||||
|
@ -594,17 +586,19 @@ int insert_keyframe(Main *bmain,
|
||||||
const float nla_mapped_frame = nla_time_remap(
|
const float nla_mapped_frame = nla_time_remap(
|
||||||
anim_eval_context, &id_ptr, adt, act, &nla_cache, &nla_context);
|
anim_eval_context, &id_ptr, adt, act, &nla_cache, &nla_context);
|
||||||
|
|
||||||
|
const bool visual_keyframing = flag & INSERTKEY_MATRIX;
|
||||||
|
Vector<float> values = get_keyframe_values(&ptr, prop, visual_keyframing);
|
||||||
|
|
||||||
bool force_all;
|
bool force_all;
|
||||||
BitVector successful_remaps;
|
BitVector<> successful_remaps = nla_map_keyframe_values_and_generate_reports(
|
||||||
Vector<float> values = get_keyframe_values(reports,
|
values.as_mutable_span(),
|
||||||
ptr,
|
array_index,
|
||||||
prop,
|
ptr,
|
||||||
array_index,
|
*prop,
|
||||||
nla_context,
|
nla_context,
|
||||||
flag,
|
anim_eval_context,
|
||||||
anim_eval_context,
|
reports,
|
||||||
&force_all,
|
&force_all);
|
||||||
successful_remaps);
|
|
||||||
|
|
||||||
CombinedKeyingResult combined_result;
|
CombinedKeyingResult combined_result;
|
||||||
|
|
||||||
|
@ -971,25 +965,6 @@ int insert_key_action(Main *bmain,
|
||||||
return inserted_keys;
|
return inserted_keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
static blender::Vector<float> get_keyframe_values(PointerRNA *ptr,
|
|
||||||
PropertyRNA *prop,
|
|
||||||
const bool visual_key)
|
|
||||||
{
|
|
||||||
Vector<float> values;
|
|
||||||
|
|
||||||
if (visual_key && visualkey_can_use(ptr, prop)) {
|
|
||||||
/* Visual-keying is only available for object and pchan datablocks, as
|
|
||||||
* it works by keyframing using a value extracted from the final matrix
|
|
||||||
* instead of using the kt system to extract a value.
|
|
||||||
*/
|
|
||||||
values = visualkey_get_values(ptr, prop);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
values = get_rna_values(ptr, prop);
|
|
||||||
}
|
|
||||||
return values;
|
|
||||||
}
|
|
||||||
|
|
||||||
void insert_key_rna(PointerRNA *rna_pointer,
|
void insert_key_rna(PointerRNA *rna_pointer,
|
||||||
const blender::Span<std::string> rna_paths,
|
const blender::Span<std::string> rna_paths,
|
||||||
const float scene_frame,
|
const float scene_frame,
|
||||||
|
|
Loading…
Reference in New Issue