Decouple view angles from 3rd person saber

Feels a lot cleaner, also made the turn mode have 3 options:
0 = Snap turn
1 = Snap turn (1st Person) & Smooth turn (3rd person)
2 = Smooth turn
This commit is contained in:
Simon 2022-10-31 22:17:09 +00:00
parent 89f925c373
commit 5c09153f67
11 changed files with 109 additions and 63 deletions

View file

@ -30,8 +30,8 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
if (cg.drawingHUD && !vr->cin_camera && !vr->using_screen_layer && !vr->scopeengaged)
{
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.25f);
float screenXScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
float screenYScale = 1.0f / (cg.drawingHUD == CG_HUD_SCALED ? 2.5f : 1.2f);
float xoffset = cg.drawingHUD == CG_HUD_SCALED ? -20 : 0;
if (cg.refdef.stereoView == STEREO_LEFT) {

View file

@ -1968,6 +1968,7 @@ void CG_RunEmplacedWeapon()
// don't let the player try and change this
cg.renderingThirdPerson = qtrue;
vr->third_person = false; // don't treat this as a true 3rd person scenario
// cg.refdefViewAngles[PITCH] += cg.overrides.thirdPersonPitchOffset? cg.overrides.thirdPersonPitchOffset: cg_thirdPersonPitchOffset.value;
// cg.refdefViewAngles[YAW] += cg.overrides.thirdPersonAngle ? cg.overrides.thirdPersonAngle : cg_thirdPersonAngle.value;;
@ -2114,10 +2115,13 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) {
)
);
vr->third_person = cg.renderingThirdPerson;
if ( cg.zoomMode )
{
// zoomed characters should never do third person stuff??
cg.renderingThirdPerson = qfalse;
vr->third_person = false;
}
vr->cin_camera = in_camera;

View file

@ -712,13 +712,22 @@ void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
}
float getHMDYawForCalc()
{
if (!vr->third_person) {
return vr->hmdorientation[YAW];
}
return 0.0f;
}
void BG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
{
vec3_t vrSpace;
VectorSet(vrSpace, in[2], in[0], in[1] );
vec2_t r;
rotateAboutOrigin(vrSpace[0], vrSpace[1], cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW], r);
rotateAboutOrigin(vrSpace[0], vrSpace[1],
cg.refdefViewAngles[YAW] - getHMDYawForCalc(), r);
vrSpace[0] = -r[0];
vrSpace[1] = -r[1];
@ -743,7 +752,7 @@ void BG_CalculateVRPositionInWorld( const vec3_t in_position, vec3_t in_offset,
origin[2] += (in_position[1] + cg_heightAdjust.value) * cg_worldScale.value;
VectorCopy(in_orientation, angles);
angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]);
angles[YAW] += (cg.refdefViewAngles[YAW] - getHMDYawForCalc());
}
void BG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles )