@@ -32,6 +32,9 @@ Variable sar_cam_drive("sar_cam_drive", "2", 0, 2,
3232 " (turning it on is not required for demo player)\n "
3333 " 1 = enabled when LMB is held\n "
3434 " 2 = always enabled\n " );
35+ Variable sar_cam_drive_base_speed (" sar_cam_drive_base_speed" , " 175" , 0 , 10000 , " Base speed of camera drive mode, in units per seconds.\n " );
36+ Variable sar_cam_drive_buildup_scale (" sar_cam_drive_buildup_scale" , " 0.5" , 0 , 10 ,
37+ " Defines how much to increase multiplier of drive speed over time of movement every second.\n " );
3538
3639Variable sar_cam_ortho (" sar_cam_ortho" , " 0" , 0 , 1 , " Enables or disables camera orthographic projection.\n " );
3740Variable sar_cam_ortho_scale (" sar_cam_ortho_scale" , " 1" , 0 .001f , " Changes the scale of orthographic projection (how many units per pixel).\n " );
@@ -444,6 +447,7 @@ void Camera::OverrideView(ViewSetup *m_View) {
444447 // resetting cvars to their actual values when switching control off
445448 ResetCameraRelatedCvars ();
446449 this ->manualActive = false ;
450+ driveMovementTime = 0 .0f ;
447451 }
448452 controlType = newControlType;
449453 }
@@ -474,6 +478,7 @@ void Camera::OverrideView(ViewSetup *m_View) {
474478 if (manualActive) {
475479 in_forceuser.SetValue (in_forceuser.GetString ());
476480 manualActive = false ;
481+ driveMovementTime = 0 .0f ;
477482 }
478483 }
479484 if (manualActive) {
@@ -520,24 +525,29 @@ void Camera::OverrideView(ViewSetup *m_View) {
520525 right.y = (-1 * sr * sp * sy + -1 * cr * cy);
521526 right.z = -1 * sr * cp;
522527
528+ // finding wishdir
529+ Vector wishdir;
530+ if (inputSystem->IsKeyDown (ButtonCode_t::KEY_W)) wishdir += forward;
531+ if (inputSystem->IsKeyDown (ButtonCode_t::KEY_S)) wishdir += (forward * -1 );
532+ if (inputSystem->IsKeyDown (ButtonCode_t::KEY_A)) wishdir += (right * -1 );
533+ if (inputSystem->IsKeyDown (ButtonCode_t::KEY_D)) wishdir += right;
534+
535+ if (wishdir.Length () > 0 .0f ) {
536+ driveMovementTime += real_frame_time;
537+ } else {
538+ driveMovementTime = 0 .0f ;
539+ }
540+
523541 // applying movement
524542 bool shiftdown = inputSystem->IsKeyDown (KEY_LSHIFT) || inputSystem->IsKeyDown (KEY_RSHIFT);
525543 bool controldown = inputSystem->IsKeyDown (KEY_LCONTROL) || inputSystem->IsKeyDown (KEY_RCONTROL);
526- float speed = shiftdown ? 525 .0f : (controldown ? 60 .0f : 175 .0f );
544+ float speedMultiplier = shiftdown ? 3 .0f : (controldown ? 0 .333f : 1 .0f );
545+ float speed = sar_cam_drive_base_speed.GetFloat () * speedMultiplier;
546+ float buildupMultiplier = 1 .0f + (driveMovementTime * sar_cam_drive_buildup_scale.GetFloat ());
547+ speed *= buildupMultiplier;
527548 speed *= engine->IsAdvancing () ? real_frame_time : engine->GetHostFrameTime ();
528549
529- if (inputSystem->IsKeyDown (ButtonCode_t::KEY_W)) {
530- currentState.origin = currentState.origin + (forward * speed);
531- }
532- if (inputSystem->IsKeyDown (ButtonCode_t::KEY_S)) {
533- currentState.origin = currentState.origin + (forward * -speed);
534- }
535- if (inputSystem->IsKeyDown (ButtonCode_t::KEY_A)) {
536- currentState.origin = currentState.origin + (right * -speed);
537- }
538- if (inputSystem->IsKeyDown (ButtonCode_t::KEY_D)) {
539- currentState.origin = currentState.origin + (right * speed);
540- }
550+ currentState.origin += wishdir * speed;
541551 }
542552 }
543553 // cinematic camera - move it along predefined path
0 commit comments