Refactor: Remove duplicate function get_keyframe_values
#119798
|
@ -203,58 +203,41 @@ static void get_keyframe_values_create_reports(ReportList *reports,
|
|||
MEM_freeN(str_failed_indices);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
static Vector<float> get_keyframe_values(PointerRNA *ptr, PropertyRNA *prop, const bool visual_key)
|
||||
{
|
||||
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
|
||||
* 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);
|
||||
values = visualkey_get_values(ptr, prop);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
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.
|
||||
* 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);
|
||||
|
||||
const int index = fcu->array_index;
|
||||
BitVector<> successful_remaps;
|
||||
Vector<float> values = get_keyframe_values(
|
||||
reports, ptr, prop, index, nla_context, flag, anim_eval_context, nullptr, successful_remaps);
|
||||
const bool visual_keyframing = flag & INSERTKEY_MATRIX;
|
||||
Vector<float> values = get_keyframe_values(&ptr, prop, visual_keyframing);
|
||||
|
||||
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;
|
||||
if (index >= 0 && index < values.size()) {
|
||||
|
@ -594,17 +586,19 @@ int insert_keyframe(Main *bmain,
|
|||
const float nla_mapped_frame = nla_time_remap(
|
||||
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;
|
||||
BitVector successful_remaps;
|
||||
Vector<float> values = get_keyframe_values(reports,
|
||||
ptr,
|
||||
prop,
|
||||
array_index,
|
||||
nla_context,
|
||||
flag,
|
||||
anim_eval_context,
|
||||
&force_all,
|
||||
successful_remaps);
|
||||
BitVector<> successful_remaps = nla_map_keyframe_values_and_generate_reports(
|
||||
values.as_mutable_span(),
|
||||
array_index,
|
||||
ptr,
|
||||
*prop,
|
||||
nla_context,
|
||||
anim_eval_context,
|
||||
reports,
|
||||
&force_all);
|
||||
|
||||
CombinedKeyingResult combined_result;
|
||||
|
||||
|
@ -971,25 +965,6 @@ int insert_key_action(Main *bmain,
|
|||
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,
|
||||
const blender::Span<std::string> rna_paths,
|
||||
const float scene_frame,
|
||||
|
|
Loading…
Reference in New Issue