Fix #112085: Not able to insert keys on subframes
When subframes were enabled, and the time cursor was at a subframe position, the keying would still insert the key at the full frame. This was because the value passed to the key insertion functions was just the full frame value and not the subframe part. Fixing it by using `BKE_scene_frame_get()` which returns the floating point frame including the subframe part. I've added unit tests to ensure that inserting keys at subframe values doesn't cause issues. Pull Request: https://projects.blender.org/blender/blender/pulls/112131
This commit is contained in:
committed by
Christoph Lendenfeld
parent
456d65b00a
commit
8f1bd71992
@@ -48,6 +48,7 @@
|
||||
#include "BKE_material.h"
|
||||
#include "BKE_nla.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_build.h"
|
||||
@@ -1977,8 +1978,7 @@ static int insert_key_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit = CTX_data_edit_object(C);
|
||||
bool ob_edit_mode = false;
|
||||
|
||||
const float cfra = float(
|
||||
scene->r.cfra); /* XXX for now, don't bother about all the yucky offset crap */
|
||||
const float cfra = BKE_scene_frame_get(scene);
|
||||
int num_channels;
|
||||
const bool confirm = op->flag & OP_IS_INVOKE;
|
||||
|
||||
@@ -2200,8 +2200,7 @@ static int delete_key_exec(bContext *C, wmOperator *op)
|
||||
static int delete_key_using_keying_set(bContext *C, wmOperator *op, KeyingSet *ks)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
float cfra = float(
|
||||
scene->r.cfra); /* XXX for now, don't bother about all the yucky offset crap */
|
||||
float cfra = BKE_scene_frame_get(scene);
|
||||
int num_channels;
|
||||
const bool confirm = op->flag & OP_IS_INVOKE;
|
||||
|
||||
@@ -2378,7 +2377,7 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot)
|
||||
static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
float cfra = float(scene->r.cfra);
|
||||
const float cfra = BKE_scene_frame_get(scene);
|
||||
|
||||
int selected_objects_len = 0;
|
||||
int selected_objects_success_len = 0;
|
||||
@@ -2529,7 +2528,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
|
||||
char *path;
|
||||
uiBut *but;
|
||||
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
|
||||
CTX_data_depsgraph_pointer(C), float(scene->r.cfra));
|
||||
CTX_data_depsgraph_pointer(C), BKE_scene_frame_get(scene));
|
||||
bool changed = false;
|
||||
int index;
|
||||
const bool all = RNA_boolean_get(op->ptr, "all");
|
||||
@@ -2705,8 +2704,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
|
||||
PropertyRNA *prop = nullptr;
|
||||
Main *bmain = CTX_data_main(C);
|
||||
char *path;
|
||||
float cfra = float(
|
||||
scene->r.cfra); /* XXX for now, don't bother about all the yucky offset crap */
|
||||
const float cfra = BKE_scene_frame_get(scene);
|
||||
bool changed = false;
|
||||
int index;
|
||||
const bool all = RNA_boolean_get(op->ptr, "all");
|
||||
@@ -2880,7 +2878,7 @@ void ANIM_OT_keyframe_clear_button(wmOperatorType *ot)
|
||||
|
||||
bool autokeyframe_cfra_can_key(const Scene *scene, ID *id)
|
||||
{
|
||||
float cfra = float(scene->r.cfra); /* XXX for now, this will do */
|
||||
const float cfra = BKE_scene_frame_get(scene);
|
||||
|
||||
/* only filter if auto-key mode requires this */
|
||||
if (IS_AUTOKEY_ON(scene) == 0) {
|
||||
@@ -3065,7 +3063,8 @@ bool ED_autokeyframe_object(bContext *C, Scene *scene, Object *ob, KeyingSet *ks
|
||||
* 3) Free the extra info.
|
||||
*/
|
||||
ANIM_relative_keyingset_add_source(&dsources, &ob->id, nullptr, nullptr);
|
||||
ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, float(scene->r.cfra));
|
||||
ANIM_apply_keyingset(
|
||||
C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, BKE_scene_frame_get(scene));
|
||||
BLI_freelistN(&dsources);
|
||||
|
||||
return true;
|
||||
@@ -3085,7 +3084,8 @@ bool ED_autokeyframe_pchan(
|
||||
* 3) Free the extra info.
|
||||
*/
|
||||
ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan);
|
||||
ANIM_apply_keyingset(C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, float(scene->r.cfra));
|
||||
ANIM_apply_keyingset(
|
||||
C, &dsources, nullptr, ks, MODIFYKEY_MODE_INSERT, BKE_scene_frame_get(scene));
|
||||
BLI_freelistN(&dsources);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "BIK_api.h"
|
||||
|
||||
@@ -98,7 +99,7 @@ static void autokeyframe_pose(
|
||||
ListBase nla_cache = {nullptr, nullptr};
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
||||
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
|
||||
depsgraph, float(scene->r.cfra));
|
||||
depsgraph, BKE_scene_frame_get(scene));
|
||||
eInsertKeyFlags flag = eInsertKeyFlags(0);
|
||||
|
||||
/* flag is initialized from UserPref keyframing settings
|
||||
|
||||
@@ -754,7 +754,7 @@ static void autokeyframe_object(
|
||||
ListBase dsources = {nullptr, nullptr};
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
|
||||
const AnimationEvalContext anim_eval_context = BKE_animsys_eval_context_construct(
|
||||
depsgraph, float(scene->r.cfra));
|
||||
depsgraph, BKE_scene_frame_get(scene));
|
||||
eInsertKeyFlags flag = eInsertKeyFlags(0);
|
||||
|
||||
/* Get flags used for inserting keyframes. */
|
||||
|
||||
Reference in New Issue
Block a user