Fix T70585: Walk Navigation keyframe tweaks (still frame)

Walk Navigation was missing rotation keyframes on confirm (when animation
wasnt playing) after rB22bdd08dfd0.

Because for walk [in contrast to fly], the cursor is constantly warped
(WM_cursor_warp in walkEvent), we cant do something reasonable with
comparing mouse positions (to detect rotation) when mouse comes to rest.

Now remember if rotation changed at any time.

Also tweaked the insertion for location keyframes (which was always
happening even if the camera did not move), now checking the real dvec
(instead on relying on speed)

Reviewed By: dfelinto

Maniphest Tasks: T70585

Differential Revision: https://developer.blender.org/D6018
This commit is contained in:
Philipp Oeser 2019-10-08 13:53:27 +02:00
parent 054ab92f8b
commit 7a1847f0e9
Notes: blender-bot 2023-02-14 02:30:10 +01:00
Referenced by issue #70585, 'View Navigation (Walk/Fly)' inserts Location only keyframes instead of the selected keying set.
1 changed files with 16 additions and 5 deletions

View File

@ -204,6 +204,8 @@ typedef struct WalkInfo {
* (this would need to un-key all previous frames).
*/
bool anim_playing;
bool need_rotation_keyframe;
bool need_translation_keyframe;
/** Previous 2D mouse values. */
int prev_mval[2];
@ -538,6 +540,8 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op)
#endif
walk->anim_playing = ED_screen_animation_playing(wm);
walk->need_rotation_keyframe = false;
walk->need_translation_keyframe = false;
walk->time_lastdraw = PIL_check_seconds_timer();
@ -930,9 +934,12 @@ static void walkMoveCamera(bContext *C,
/* we only consider autokeying on playback or if user confirmed walk on the same frame
* otherwise we get a keyframe even if the user cancels. */
const bool use_autokey = is_confirm || walk->anim_playing;
ED_view3d_cameracontrol_update(
walk->v3d_camera_control, use_autokey, C, do_rotate, do_translate);
if (use_autokey) {
walk->need_rotation_keyframe = false;
walk->need_translation_keyframe = false;
}
}
static float getFreeFallDistance(const float gravity, const float time)
@ -1280,9 +1287,10 @@ static int walkApply(bContext *C, WalkInfo *walk, bool is_confirm)
add_v3_v3(rv3d->ofs, dvec_tmp);
if (rv3d->persp == RV3D_CAMOB) {
const bool do_rotate = (moffset[0] || moffset[1]);
const bool do_translate = (walk->speed != 0.0f);
walkMoveCamera(C, walk, do_rotate, do_translate, is_confirm);
walk->need_rotation_keyframe |= (moffset[0] || moffset[1]);
walk->need_translation_keyframe |= (len_squared_v3(dvec_tmp) > FLT_EPSILON);
walkMoveCamera(
C, walk, walk->need_rotation_keyframe, walk->need_translation_keyframe, is_confirm);
}
}
else {
@ -1322,7 +1330,10 @@ static void walkApply_ndof(bContext *C, WalkInfo *walk, bool is_confirm)
walk->redraw = true;
if (walk->rv3d->persp == RV3D_CAMOB) {
walkMoveCamera(C, walk, has_rotate, has_translate, is_confirm);
walk->need_rotation_keyframe |= has_rotate;
walk->need_translation_keyframe |= has_translate;
walkMoveCamera(
C, walk, walk->need_rotation_keyframe, walk->need_translation_keyframe, is_confirm);
}
}
}