mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-02-14 16:10:55 +00:00
FInished "6"DoF and removed need for weapon alignment logic
This commit is contained in:
parent
62f54f8986
commit
f2b9eaee60
8 changed files with 32 additions and 55 deletions
|
@ -1991,7 +1991,7 @@ static void CG_DrawCrosshair3D(void)
|
|||
vec3_t viewaxis[3];
|
||||
vec3_t weaponangles;
|
||||
vec3_t origin;
|
||||
CG_CalculateVRWeaponPosition(origin, weaponangles, qfalse);
|
||||
CG_CalculateVRWeaponPosition(origin, weaponangles);
|
||||
AnglesToAxis(weaponangles, viewaxis);
|
||||
maxdist = (cgs.glconfig.vidWidth * stereoSep * zProj / (2 * xmax)) * 1.5f;
|
||||
VectorMA(origin, maxdist, viewaxis[0], endpos);
|
||||
|
|
|
@ -1026,7 +1026,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
|
|||
if(es->clientNum == cg.snap->ps.clientNum && !cg.renderingThirdPerson)
|
||||
{
|
||||
vec3_t angles;
|
||||
CG_CalculateVRWeaponPosition(es->origin2, angles, qfalse);
|
||||
CG_CalculateVRWeaponPosition(es->origin2, angles);
|
||||
/*
|
||||
if(cg_drawGun.integer == 2)
|
||||
VectorMA(es->origin2, 8, cg.refdef.viewaxis[1], es->origin2);
|
||||
|
|
|
@ -1379,7 +1379,7 @@ void CG_PrevWeapon_f( void );
|
|||
void CG_Weapon_f( void );
|
||||
|
||||
void rotateAboutOrigin(float x, float y, float rotation, vec2_t out);
|
||||
void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles, qboolean crosshair );
|
||||
void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles );
|
||||
void CG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out);
|
||||
|
||||
void CG_RegisterWeapon( int weaponNum );
|
||||
|
|
|
@ -1646,17 +1646,14 @@ void CG_CalculateVROffHandPosition( vec3_t origin, vec3_t angles )
|
|||
origin[2] += vr->hmdposition[1] * worldscale;
|
||||
}
|
||||
|
||||
VectorCopy(vr->offhandangles, angles);
|
||||
if ( !cgs.localServer )
|
||||
{
|
||||
//Calculate the offhand angles from "first principles"
|
||||
float deltaYaw = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[YAW]);
|
||||
angles[YAW] = deltaYaw + (vr->clientviewangles[YAW] - vr->hmdorientation[YAW]) + vr->offhandangles[YAW];
|
||||
float deltaPitch = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[PITCH]);
|
||||
angles[PITCH] = vr->realign_pitch + deltaPitch + (vr->clientviewangles[PITCH] - vr->hmdorientation[PITCH]) + vr->offhandangles[PITCH];
|
||||
angles[ROLL] = vr->offhandangles[ROLL];
|
||||
} else
|
||||
{
|
||||
VectorCopy(vr->offhandangles, angles);
|
||||
angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -707,18 +707,10 @@ static int CG_CalcViewValues( stereoFrame_t stereoView ) {
|
|||
|
||||
if (stereoView == STEREO_LEFT)
|
||||
{
|
||||
//Have to do this here so we can use the predicted player state
|
||||
if (--vr->realign == 0)
|
||||
{
|
||||
VectorCopy(vr->hmdposition, vr->hmdorigin);
|
||||
vr->realign_pitch -= (cg.predictedPlayerState.viewangles[PITCH]-vr->calculated_weaponangles[PITCH]) ;
|
||||
vr->realign_pitch = AngleNormalize180(vr->realign_pitch);
|
||||
}
|
||||
|
||||
VectorCopy(vr->calculated_weaponangles, vr->last_calculated_weaponangles);
|
||||
|
||||
vec3_t weaponorigin, weaponangles;
|
||||
CG_CalculateVRWeaponPosition(weaponorigin, weaponangles, qfalse);
|
||||
CG_CalculateVRWeaponPosition(weaponorigin, weaponangles);
|
||||
|
||||
vec3_t forward, end, dir;
|
||||
AngleVectors(weaponangles, forward, NULL, NULL);
|
||||
|
|
|
@ -255,28 +255,25 @@ void CG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
|
|||
}
|
||||
}
|
||||
|
||||
void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles, qboolean crosshair )
|
||||
void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles )
|
||||
{
|
||||
float worldscale = trap_Cvar_VariableValue("vr_worldscale");
|
||||
|
||||
if (!cgs.localServer)
|
||||
{
|
||||
if (!crosshair)
|
||||
{
|
||||
//Use absolute position for the faked 6DoF for multiplayer
|
||||
vec3_t weaponoffset;
|
||||
VectorSubtract(vr->weaponposition, vr->hmdorigin, weaponoffset);
|
||||
weaponoffset[1] = vr->weaponoffset[1]; // up/down is index 1 in this case
|
||||
CG_ConvertFromVR(weaponoffset, cg.refdef.vieworg, origin);
|
||||
origin[2] -= PLAYER_HEIGHT;
|
||||
origin[2] += vr->hmdposition[1] * worldscale;
|
||||
}
|
||||
else
|
||||
{
|
||||
vec3_t weaponoffset;
|
||||
VectorSet(weaponoffset, 0.0f, 0.0f, 0.0f);
|
||||
CG_ConvertFromVR(weaponoffset, cg.refdef.vieworg, origin);
|
||||
}
|
||||
//Use absolute position for the faked 6DoF for multiplayer
|
||||
vec3_t weaponoffset;
|
||||
VectorSubtract(vr->weaponposition, vr->hmdorigin, weaponoffset);
|
||||
weaponoffset[1] = vr->weaponoffset[1]; // up/down is index 1 in this case
|
||||
CG_ConvertFromVR(weaponoffset, cg.refdef.vieworg, origin);
|
||||
origin[2] -= PLAYER_HEIGHT;
|
||||
origin[2] += vr->hmdposition[1] * worldscale;
|
||||
|
||||
//Calculate the weapon angles from "first principles"
|
||||
float deltaYaw = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[YAW]);
|
||||
angles[YAW] = deltaYaw + (vr->clientviewangles[YAW] - vr->hmdorientation[YAW]) + vr->weaponangles[YAW];
|
||||
angles[PITCH] = vr->weaponangles[PITCH];
|
||||
angles[ROLL] = vr->weaponangles[ROLL];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -284,22 +281,9 @@ void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles, qboolean crossh
|
|||
CG_ConvertFromVR(vr->weaponoffset, cg.refdef.vieworg, origin);
|
||||
origin[2] -= PLAYER_HEIGHT;
|
||||
origin[2] += vr->hmdposition[1] * worldscale;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( !cgs.localServer )
|
||||
{
|
||||
//Calculate the weapon angles from "first principles"
|
||||
float deltaYaw = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[YAW]);
|
||||
angles[YAW] = deltaYaw + (vr->clientviewangles[YAW] - vr->hmdorientation[YAW]) + vr->weaponangles[YAW];
|
||||
float deltaPitch = SHORT2ANGLE(cg.predictedPlayerState.delta_angles[PITCH]);
|
||||
angles[PITCH] = vr->realign_pitch + deltaPitch + vr->weaponangles[PITCH];
|
||||
angles[ROLL] = vr->weaponangles[ROLL];
|
||||
} else
|
||||
{
|
||||
VectorCopy(vr->weaponangles, angles);
|
||||
angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]);
|
||||
angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1307,7 +1291,7 @@ static void CG_LightningBolt( centity_t *cent, vec3_t origin ) {
|
|||
if (cent->currentState.number == cg.predictedPlayerState.clientNum)// && (cg_trueLightning.value != 0))
|
||||
{
|
||||
vec3_t angle;
|
||||
CG_CalculateVRWeaponPosition(muzzlePoint, angle, qfalse);
|
||||
CG_CalculateVRWeaponPosition(muzzlePoint, angle);
|
||||
AngleVectors(angle, forward, NULL, NULL );
|
||||
} else {
|
||||
// !CPMA
|
||||
|
@ -1717,7 +1701,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
|||
memset (&hand, 0, sizeof(hand));
|
||||
|
||||
// set up gun position
|
||||
CG_CalculateVRWeaponPosition( hand.origin, angles, qfalse );
|
||||
CG_CalculateVRWeaponPosition( hand.origin, angles );
|
||||
|
||||
//Scale / Move gun etc
|
||||
float scale = 1.0f;
|
||||
|
|
|
@ -604,13 +604,18 @@ void CL_FinishMove( usercmd_t *cmd ) {
|
|||
{
|
||||
vr.local_server = qfalse;
|
||||
|
||||
vec3_t angles;
|
||||
//Realign in playspace
|
||||
if (--vr.realign == 0)
|
||||
{
|
||||
VectorCopy(vr.hmdposition, vr.hmdorigin);
|
||||
}
|
||||
|
||||
vec3_t angles;
|
||||
VectorCopy(vr.calculated_weaponangles, angles);
|
||||
|
||||
//Adjust for difference in server angles
|
||||
float deltaPitch = SHORT2ANGLE(cl.snap.ps.delta_angles[PITCH]);
|
||||
Com_Printf("realign_pitch: %f, delta pitch: %f", vr.realign_pitch, deltaPitch);
|
||||
|
||||
angles[PITCH] += vr.realign_pitch;
|
||||
angles[PITCH] -= deltaPitch;
|
||||
angles[YAW] += (cl.viewangles[YAW] - vr.hmdorientation[YAW]);
|
||||
angles[ROLL] = 0; // suppress roll
|
||||
|
||||
|
|
|
@ -13,8 +13,7 @@ typedef struct {
|
|||
qboolean virtual_screen;
|
||||
qboolean local_server; // used in bg_pmove.c
|
||||
|
||||
int realign; // used to realign the weapon/playspace in a multiplayer game
|
||||
float realign_pitch; // used to realign the weapon pitch in a multiplayer game
|
||||
int realign; // used to realign the fake 6DoF playspace in a multiplayer game
|
||||
|
||||
int clientNum;
|
||||
vec3_t clientviewangles; //orientation in the client - we use this in the cgame
|
||||
|
|
Loading…
Reference in a new issue