Huge improvement to immersive cutscene camera control

This commit is contained in:
Simon 2023-01-24 18:52:10 +00:00
parent 93f18988d4
commit 3d22e95737
3 changed files with 63 additions and 13 deletions

View file

@ -182,6 +182,12 @@ void VR_SetHMDPosition(float x, float y, float z )
//Record player position on transition
VectorSet(vr.hmdposition_snap, x, y, z);
VectorCopy(vr.hmdorientation, vr.hmdorientation_snap);
if (vr.cin_camera)
{
//Reset snap turn too if in a cinematic
vr.snapTurn = 0;
}
vr.take_snap = false;
}

View file

@ -32,6 +32,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
bool in_camera = false;
bool in_misccamera = false; // if we are viewing a misc_camera
camera_t client_camera={};
camera_t previous_client_camera={};
extern qboolean player_locked;
extern gentity_t *G_Find (gentity_t *from, int fieldofs, const char *match);
@ -93,10 +94,14 @@ void CGCam_Enable( void )
client_camera.FOV = CAMERA_DEFAULT_FOV;
client_camera.FOV2 = CAMERA_DEFAULT_FOV;
client_camera.has_stored_angles = false;
in_camera = true;
client_camera.next_roff_time = 0;
previous_client_camera = client_camera;
if ( &g_entities[0] && g_entities[0].client )
{
//Player zero not allowed to do anything
@ -562,7 +567,6 @@ void CGCam_Track( const char *trackName, float speed, float initLerp )
else
{
client_camera.trackInitLerp = qfalse;
vr->take_snap = true;
}
/*
if ( client_camera.info_state & CAMERA_FOLLOWING )
@ -802,12 +806,6 @@ void CGCam_FollowUpdate ( void )
//So tracker doesn't move right away thinking the first angle change
//is the subject moving... FIXME: shouldn't set this until lerp done OR snapped?
client_camera.subjectSpeed = 0;
//Store initial point, let player do the follow from here themselves
if (vr->immersive_cinematics)
{
vr->take_snap = true;
}
}
//Point camera to lerp angles
@ -1104,10 +1102,6 @@ void CGCam_Update( void )
cg.refdefViewAngles[i] = client_camera.angles[i] + ( client_camera.angles2[i] / client_camera.pan_duration ) * ( cg.time - client_camera.pan_time );
}
}
else
{
VectorCopy(client_camera.angles, cg.refdefViewAngles);
}
}
else if ( client_camera.info_state & CAMERA_PANNING )
{
@ -1171,11 +1165,15 @@ void CGCam_Update( void )
if ( checkFollow )
{
//Don't follow if immersive
if (( client_camera.info_state & CAMERA_FOLLOWING ) && !vr->immersive_cinematics )
if ( client_camera.info_state & CAMERA_FOLLOWING )
{//This needs to be done after camera movement
CGCam_FollowUpdate();
}
VectorCopy(client_camera.angles, cg.refdefViewAngles );
if (!vr->immersive_cinematics)
{
VectorCopy(client_camera.angles, cg.refdefViewAngles);
}
}
if ( checkTrack )
@ -1188,6 +1186,48 @@ void CGCam_Update( void )
VectorCopy( client_camera.origin, cg.refdef.vieworg );
}
if (vr->immersive_cinematics)
{
//If no stored angles yet, store them
if (!client_camera.has_stored_angles)
{
client_camera.has_stored_angles = true;
vr->take_snap = true;
}
//if camera state has changed, store the angles and reset user's snap orientation
if (((client_camera.info_state & CAMERA_FOLLOWING) != (previous_client_camera.info_state & CAMERA_FOLLOWING)) ||
((client_camera.info_state & CAMERA_ROFFING) != (previous_client_camera.info_state & CAMERA_ROFFING)) ||
((client_camera.info_state & CAMERA_MOVING) != (previous_client_camera.info_state & CAMERA_MOVING)) ||
((client_camera.info_state & CAMERA_PANNING) != (previous_client_camera.info_state & CAMERA_PANNING)))
{
vr->take_snap = true;
}
//If the camera has changed position (by over half an in-game metre), but is not in moving mode (last frame)
//then it is a keyframe that requires a new snap
if (!(previous_client_camera.info_state & CAMERA_MOVING))
{
vec3_t delta;
VectorSubtract(client_camera.origin, previous_client_camera.origin, delta);
if (VectorLength(delta) > (0.5f * cg_worldScale.value))
{
vr->take_snap = true;
}
}
if (vr->take_snap)
{
VectorCopy(client_camera.angles, client_camera.stored_angles);
}
//Copy stored angles to refdef whether they have changed or not
VectorCopy(client_camera.stored_angles, cg.refdefViewAngles);
//store previous state
previous_client_camera = client_camera;
}
//Bar fading
if ( client_camera.info_state & CAMERA_BAR_FADING )
{

View file

@ -54,6 +54,10 @@ typedef struct camera_s
vec3_t origin2;
vec3_t angles2;
//Stored angles/origin used in immersive cinematic mode
bool has_stored_angles;
vec3_t stored_angles;
//Movement information
float move_duration;
float move_time;