Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ================
- idPlayer::UpdateViewAngles
- ================
- */
- void idPlayer::UpdateViewAngles( void ) {
- int i;
- idAngles delta;
- if ( !noclip && ( gameLocal.inCinematic || privateCameraView || gameLocal.GetCamera() || influenceActive == INFLUENCE_LEVEL2 ) ) {
- // no view changes at all, but we still want to update the deltas or else when
- // we get out of this mode, our view will snap to a kind of random angle
- UpdateDeltaViewAngles( viewAngles );
- return;
- }
- // if dead
- if ( health <= 0 ) {
- if ( pm_thirdPersonDeath.GetBool() ) {
- viewAngles.roll = 0.0f;
- viewAngles.pitch = 30.0f;
- } else {
- viewAngles.roll = 40.0f;
- viewAngles.pitch = -15.0f;
- }
- return;
- }
- // circularly clamp the angles with deltas
- // if( gameLocal.localClientNum == entityNumber ) {
- // gameLocal.Printf( "BEFORE VIEWANGLES: %s\n", viewAngles.ToString() );
- // gameLocal.Printf( "\tUSERCMD: <%d, %d, %d>\n", usercmd.angles[ 0 ], usercmd.angles[ 1 ], usercmd.angles[ 2 ] );
- // gameLocal.Printf( "\tDELTAVIEW: %s\n", deltaViewAngles.ToString() );
- // }
- for ( i = 0; i < 3; i++ ) {
- cmdAngles[i] = SHORT2ANGLE( usercmd.angles[i] );
- if ( influenceActive == INFLUENCE_LEVEL3 ) {
- viewAngles[i] += idMath::ClampFloat( -1.0f, 1.0f, idMath::AngleDelta( idMath::AngleNormalize180( SHORT2ANGLE( usercmd.angles[i]) + deltaViewAngles[i] ) , viewAngles[i] ) );
- } else {
- viewAngles[i] = idMath::AngleNormalize180( SHORT2ANGLE( usercmd.angles[i] ) + deltaViewAngles[i] );
- }
- }
- if ( !centerView.IsDone( gameLocal.time ) ) {
- viewAngles.pitch = centerView.GetCurrentValue( gameLocal.time );
- }
- // if( gameLocal.localClientNum == entityNumber ) {
- // gameLocal.Printf( "AFTER VIEWANGLES: %s\n", viewAngles.ToString() );
- // }
- // clamp the pitch
- if ( noclip ) {
- if ( viewAngles.pitch > 89.0f ) {
- // don't let the player look down more than 89 degrees while noclipping
- viewAngles.pitch = 89.0f;
- } else if ( viewAngles.pitch < -89.0f ) {
- // don't let the player look up more than 89 degrees while noclipping
- viewAngles.pitch = -89.0f;
- }
- } else {
- if ( viewAngles.pitch > pm_maxviewpitch.GetFloat() ) {
- // don't let the player look down enough to see the shadow of his (non-existant) feet
- viewAngles.pitch = pm_maxviewpitch.GetFloat();
- } else if ( viewAngles.pitch < pm_minviewpitch.GetFloat() ) {
- // don't let the player look up more than 89 degrees
- viewAngles.pitch = pm_minviewpitch.GetFloat();
- }
- }
- UpdateDeltaViewAngles( viewAngles );
- // orient the model towards the direction we're looking
- SetAngles( idAngles( 0, viewAngles.yaw, 0 ) );
- // save in the log for analyzing weapon angle offsets
- loggedViewAngles[ gameLocal.framenum & (NUM_LOGGED_VIEW_ANGLES-1) ] = viewAngles;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement