mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-29 23:32:23 +00:00
Multiple fixes
- Only use dark crimson background in death cam - vr_directionMode - 0 = HMD, 1 = off-hand - use a faked positional tracking approach for multiplayer.. in game player location won't change tho, as it is only view translation - Use the interpolated position for the weapon in a remote server situation, mades weapon movement MUCH smoother
This commit is contained in:
parent
2926e73185
commit
49b8ba1f43
16 changed files with 151 additions and 84 deletions
|
@ -2,8 +2,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.drbeef.ioq3quest"
|
||||
android:installLocation="preferExternal"
|
||||
android:versionCode="12"
|
||||
android:versionName="0.8.0">
|
||||
android:versionCode="13"
|
||||
android:versionName="0.8.1">
|
||||
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
|
||||
<uses-feature android:glEsVersion="0x00030001" />
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ int drawTeamOverlayModificationCount = -1;
|
|||
int sortedTeamPlayers[TEAM_MAXOVERLAY];
|
||||
int numSortedTeamPlayers;
|
||||
|
||||
extern vr_clientinfo_t* cgVR;
|
||||
extern vr_clientinfo_t* vr;
|
||||
extern stereoFrame_t hudStereoView;
|
||||
|
||||
char systemChat[256];
|
||||
|
@ -2684,7 +2684,18 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
|
|||
worldscale * (ipd / 2); // right
|
||||
|
||||
cg.refdef.vieworg[2] -= PLAYER_HEIGHT;
|
||||
cg.refdef.vieworg[2] += cgVR->hmdposition[1] * worldscale;
|
||||
cg.refdef.vieworg[2] += vr->hmdposition[1] * worldscale;
|
||||
|
||||
//If connected to external server, allow some amount of faked positional tracking
|
||||
float sv_running = trap_Cvar_VariableValue("sv_running");
|
||||
if ( sv_running == 0.0f && ( cg.snap->ps.stats[STAT_HEALTH] > 0 )) {
|
||||
vec3_t pos;
|
||||
VectorClear(pos);
|
||||
rotateAboutOrigin(vr->hmdposition[2], vr->hmdposition[0], cg.refdefViewAngles[YAW] - vr->weaponangles[YAW], pos);
|
||||
VectorScale(pos, worldscale, pos);
|
||||
VectorSubtract(cg.refdef.vieworg, pos, cg.refdef.vieworg);
|
||||
}
|
||||
|
||||
VectorMA(cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg);
|
||||
|
||||
// draw 3D view
|
||||
|
|
|
@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
int hudflags = 0;
|
||||
stereoFrame_t hudStereoView = STEREO_CENTER;
|
||||
extern vr_clientinfo_t* cgVR;
|
||||
extern vr_clientinfo_t* vr;
|
||||
|
||||
void CG_SetHUDFlags(int flags)
|
||||
{
|
||||
|
@ -47,7 +47,7 @@ Adjusted for resolution and screen aspect ratio
|
|||
*/
|
||||
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
||||
|
||||
if (cgVR->virtual_screen)
|
||||
if (vr->virtual_screen)
|
||||
{
|
||||
// scale for screen sizes
|
||||
*x *= cgs.screenXScale;
|
||||
|
|
|
@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
displayContextDef_t cgDC;
|
||||
#endif
|
||||
|
||||
vr_clientinfo_t *cgVR;
|
||||
vr_clientinfo_t *vr;
|
||||
|
||||
int forceModelModificationCount = -1;
|
||||
|
||||
|
@ -52,7 +52,7 @@ Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, i
|
|||
switch ( command ) {
|
||||
case CG_INIT: {
|
||||
int ptr[2] = {arg3, arg4};
|
||||
cgVR = (vr_clientinfo_t *) (*(long *) (ptr));
|
||||
vr = (vr_clientinfo_t *) (*(long *) (ptr));
|
||||
CG_Init(arg0, arg1, arg2);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "cg_local.h"
|
||||
#include "../vr/vr_clientinfo.h"
|
||||
|
||||
extern vr_clientinfo_t* cgVR;
|
||||
extern vr_clientinfo_t* vr;
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
@ -227,7 +227,7 @@ CG_OffsetDeathView
|
|||
static void CG_OffsetDeathView( void ) {
|
||||
|
||||
vec3_t position_delta;
|
||||
VectorNegate(cgVR->hmdposition_delta, position_delta);
|
||||
VectorNegate(vr->hmdposition_delta, position_delta);
|
||||
CG_ConvertFromVR(position_delta, NULL, position_delta);
|
||||
position_delta[2] = 0;
|
||||
VectorScale(position_delta, (DEATH_WORLDSCALE_MULTIPLIER / 2), position_delta);
|
||||
|
@ -636,7 +636,7 @@ static int CG_CalcViewValues( void ) {
|
|||
|
||||
//HACK!! - should change this to a renderer function call
|
||||
//Indicate to renderer whether we are in deathcam mode, We don't want sky in death cam mode
|
||||
trap_Cvar_Set( "r_deathCam", ((ps->stats[STAT_HEALTH] <= 0) &&
|
||||
trap_Cvar_Set( "vr_deathCam", ((ps->stats[STAT_HEALTH] <= 0) &&
|
||||
( ps->pm_type != PM_INTERMISSION )) ? "1" : "0" );
|
||||
|
||||
// intermission view
|
||||
|
@ -654,14 +654,14 @@ static int CG_CalcViewValues( void ) {
|
|||
CG_Trace( &trace, ps->origin, mins, maxs, end, cg.predictedPlayerState.clientNum, MASK_SOLID );
|
||||
VectorCopy(trace.endpos, cg.refdef.vieworg);
|
||||
|
||||
VectorCopy(cgVR->hmdorientation, cg.refdefViewAngles);
|
||||
VectorCopy(vr->hmdorientation, cg.refdefViewAngles);
|
||||
cg.refdefViewAngles[YAW] += (ps->viewangles[YAW] - hmdYaw);
|
||||
AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
|
||||
|
||||
return CG_CalcFov();
|
||||
}
|
||||
|
||||
hmdYaw = cgVR->hmdorientation[YAW];
|
||||
hmdYaw = vr->hmdorientation[YAW];
|
||||
|
||||
cg.bobcycle = ( ps->bobCycle & 128 ) >> 7;
|
||||
cg.bobfracsin = fabs( sin( ( ps->bobCycle & 127 ) / 127.0 * M_PI ) );
|
||||
|
@ -710,8 +710,8 @@ static int CG_CalcViewValues( void ) {
|
|||
//We are connected to a multiplayer server, so make the appropriate adjustment to the view
|
||||
//angles as we send orientation to the server that includes the weapon angles
|
||||
vec3_t angles;
|
||||
VectorCopy(cgVR->hmdorientation, angles);
|
||||
angles[YAW] = (cg.refdefViewAngles[YAW] + cgVR->hmdorientation[YAW]) - cgVR->weaponangles[YAW];
|
||||
VectorCopy(vr->hmdorientation, angles);
|
||||
angles[YAW] = (cg.refdefViewAngles[YAW] + vr->hmdorientation[YAW]) - vr->weaponangles[YAW];
|
||||
AnglesToAxis( angles, cg.refdef.viewaxis );
|
||||
} else {
|
||||
AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis );
|
||||
|
|
|
@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "cg_local.h"
|
||||
#include "../vr/vr_clientinfo.h"
|
||||
|
||||
extern vr_clientinfo_t *cgVR;
|
||||
extern vr_clientinfo_t *vr;
|
||||
|
||||
|
||||
#define M_PI2 (float)6.28318530717958647692
|
||||
|
@ -235,9 +235,9 @@ void CG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
|
|||
{
|
||||
//We are connected to a multiplayer server, so make the appropriate adjustment to the view
|
||||
//angles as we send orientation to the server that includes the weapon angles
|
||||
rotateAboutOrigin(vrSpace[0], vrSpace[1], cg.refdefViewAngles[YAW] - cgVR->weaponangles[YAW], r);
|
||||
rotateAboutOrigin(vrSpace[0], vrSpace[1], cg.refdefViewAngles[YAW] - vr->weaponangles[YAW], r);
|
||||
} else {
|
||||
rotateAboutOrigin(vrSpace[0], vrSpace[1], cg.refdefViewAngles[YAW] - cgVR->hmdorientation[YAW], r);
|
||||
rotateAboutOrigin(vrSpace[0], vrSpace[1], cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW], r);
|
||||
}
|
||||
|
||||
vrSpace[0] = -r[0];
|
||||
|
@ -256,23 +256,34 @@ void CG_ConvertFromVR(vec3_t in, vec3_t offset, vec3_t out)
|
|||
|
||||
void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles )
|
||||
{
|
||||
CG_ConvertFromVR(cgVR->calculated_weaponoffset, cg.refdef.vieworg, origin);
|
||||
qboolean localServer = trap_Cvar_VariableValue("sv_running") != 0;
|
||||
|
||||
if (!localServer)
|
||||
{
|
||||
vec3_t offset;
|
||||
VectorCopy(vr->weaponposition, offset);
|
||||
offset[1] = vr->weaponoffset[1]; // up/down is index 1 in this case
|
||||
CG_ConvertFromVR(offset, cg.refdef.vieworg, origin);
|
||||
}
|
||||
else
|
||||
{
|
||||
CG_ConvertFromVR(vr->weaponoffset, cg.refdef.vieworg, origin);
|
||||
}
|
||||
|
||||
float worldscale = trap_Cvar_VariableValue("vr_worldscale");
|
||||
origin[2] -= PLAYER_HEIGHT;
|
||||
origin[2] += cgVR->hmdposition[1] * worldscale;
|
||||
origin[2] += vr->hmdposition[1] * worldscale;
|
||||
|
||||
VectorCopy(cgVR->weaponangles, angles);
|
||||
VectorCopy(vr->weaponangles, angles);
|
||||
|
||||
float sv_running = trap_Cvar_VariableValue("sv_running");
|
||||
if (sv_running == 0.0f )
|
||||
if ( !localServer )
|
||||
{
|
||||
//take player state angles provided by server
|
||||
angles[YAW] = cg.snap->ps.viewangles[YAW];
|
||||
angles[PITCH] = cg.snap->ps.viewangles[PITCH];
|
||||
angles[YAW] = cg.predictedPlayerState.viewangles[YAW]; //cg.snap->ps.viewangles[YAW];
|
||||
angles[PITCH] = cg.predictedPlayerState.viewangles[PITCH]; //cg.snap->ps.viewangles[PITCH];
|
||||
} else
|
||||
{
|
||||
angles[YAW] += (cg.refdefViewAngles[YAW] - cgVR->hmdorientation[YAW]);
|
||||
angles[YAW] += (cg.refdefViewAngles[YAW] - vr->hmdorientation[YAW]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1712,7 +1723,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
|||
&(adjust[PITCH]), &(adjust[YAW]), &(adjust[ROLL]));
|
||||
VectorScale(temp_offset, scale, offset);
|
||||
|
||||
if (!cgVR->right_handed)
|
||||
if (!vr->right_handed)
|
||||
{
|
||||
//yaw needs to go in the other direction as left handed model is reversed
|
||||
adjust[YAW] *= -1.0f;
|
||||
|
@ -1732,7 +1743,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
|||
AngleVectors( angles, forward, right, up );
|
||||
VectorMA( hand.origin, offset[2], forward, hand.origin );
|
||||
VectorMA( hand.origin, offset[1], up, hand.origin );
|
||||
if (cgVR->right_handed) {
|
||||
if (vr->right_handed) {
|
||||
VectorMA(hand.origin, offset[0], right, hand.origin);
|
||||
} else {
|
||||
VectorMA(hand.origin, -offset[0], right, hand.origin);
|
||||
|
@ -1765,7 +1776,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
|||
|
||||
//scale the whole model
|
||||
for ( int i = 0; i < 3; i++ ) {
|
||||
VectorScale( hand.axis[i], cgVR->right_handed || i != 1 ? scale : -scale, hand.axis[i] );
|
||||
VectorScale( hand.axis[i], vr->right_handed || i != 1 ? scale : -scale, hand.axis[i] );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -596,8 +596,12 @@ void CL_FinishMove( usercmd_t *cmd ) {
|
|||
//and adjust the move values accordingly, to "fake" a 3DoF weapon but keeping the movement correct
|
||||
if ( !com_sv_running || !com_sv_running->integer )
|
||||
{
|
||||
vr.localServer = qfalse;
|
||||
vr.clientNum = -1;
|
||||
|
||||
vec3_t angles;
|
||||
VectorCopy(vr.weaponangles, angles);
|
||||
angles[ROLL] = 0; // suppress roll
|
||||
angles[YAW] += (cl.viewangles[YAW] - vr.hmdorientation[YAW]);
|
||||
for (i = 0; i < 3; i++) {
|
||||
cmd->angles[i] = ANGLE2SHORT(angles[i]);
|
||||
|
@ -609,6 +613,12 @@ void CL_FinishMove( usercmd_t *cmd ) {
|
|||
cmd->forwardmove = out[1];
|
||||
}
|
||||
else {
|
||||
vr.localServer = qtrue;
|
||||
|
||||
//Record client number - local server uses this to know we can use absolute angles
|
||||
//rather than deltas
|
||||
vr.clientNum = cl.snap.ps.clientNum;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
cmd->angles[i] = ANGLE2SHORT(cl.viewangles[i]);
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "../qcommon/q_shared.h"
|
||||
#include "bg_public.h"
|
||||
#include "bg_local.h"
|
||||
#include "../vr/vr_clientinfo.h"
|
||||
|
||||
pmove_t *pm;
|
||||
pml_t pml;
|
||||
|
@ -47,6 +48,7 @@ float pm_spectatorfriction = 5.0f;
|
|||
|
||||
int c_pmove = 0;
|
||||
|
||||
extern vr_clientinfo_t *vr;
|
||||
|
||||
/*
|
||||
===============
|
||||
|
@ -1810,8 +1812,18 @@ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) {
|
|||
|
||||
// circularly clamp the angles with deltas
|
||||
for (i=0 ; i<3 ; i++) {
|
||||
//temp = cmd->angles[i] + ps->delta_angles[i];
|
||||
if (vr != NULL && vr->clientNum == ps->clientNum && vr->localServer)
|
||||
{
|
||||
//Client is the VR player on the "local" server
|
||||
temp = cmd->angles[i] + (i == YAW ? ps->delta_angles[i] : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Client is either a BOT or a remote/connected player, or
|
||||
//the vr player playing on a remote server (since this is shared code by game and cgame)
|
||||
temp = cmd->angles[i] + ps->delta_angles[i];
|
||||
}
|
||||
|
||||
if ( i == PITCH ) {
|
||||
// don't let the player look up or down more than 90 degrees
|
||||
if ( temp > 16000 ) {
|
||||
|
|
|
@ -39,7 +39,7 @@ typedef struct {
|
|||
gentity_t g_entities[MAX_GENTITIES];
|
||||
gclient_t g_clients[MAX_CLIENTS];
|
||||
|
||||
vr_clientinfo_t* gVR;
|
||||
vr_clientinfo_t* vr;
|
||||
|
||||
vmCvar_t g_gametype;
|
||||
vmCvar_t g_dmflags;
|
||||
|
@ -206,7 +206,7 @@ Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, i
|
|||
switch ( command ) {
|
||||
case GAME_INIT: {
|
||||
int ptr[2] = {arg3, arg4};
|
||||
gVR = (vr_clientinfo_t *) (*(long *) (ptr));
|
||||
vr = (vr_clientinfo_t *) (*(long *) (ptr));
|
||||
G_InitGame(arg0, arg1, arg2);
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -31,7 +31,7 @@ static float s_quadFactor;
|
|||
static vec3_t forward, right, up;
|
||||
static vec3_t muzzle;
|
||||
|
||||
extern vr_clientinfo_t* gVR;
|
||||
extern vr_clientinfo_t* vr;
|
||||
|
||||
#define NUM_NAILSHOTS 15
|
||||
|
||||
|
@ -48,7 +48,7 @@ void convertFromVR(gentity_t *ent, vec3_t in, vec3_t offset, vec3_t out)
|
|||
VectorSet(vrSpace, in[2], in[0], in[1] );
|
||||
|
||||
vec2_t r;
|
||||
rotateAboutOrigin(vrSpace[0], vrSpace[1], ent->client->ps.viewangles[YAW] - gVR->hmdorientation[YAW], r);
|
||||
rotateAboutOrigin(vrSpace[0], vrSpace[1], ent->client->ps.viewangles[YAW] - vr->hmdorientation[YAW], r);
|
||||
vrSpace[0] = -r[0];
|
||||
vrSpace[1] = -r[1];
|
||||
|
||||
|
@ -107,8 +107,8 @@ qboolean CheckGauntletAttack( gentity_t *ent ) {
|
|||
|
||||
// set aiming directions
|
||||
vec3_t angles;
|
||||
VectorCopy(gVR->weaponangles, angles);
|
||||
angles[YAW] += (ent->client->ps.viewangles[YAW] - gVR->hmdorientation[YAW]);
|
||||
VectorCopy(vr->weaponangles, angles);
|
||||
angles[YAW] += (ent->client->ps.viewangles[YAW] - vr->hmdorientation[YAW]);
|
||||
AngleVectors (angles, forward, right, up);
|
||||
|
||||
CalcMuzzlePoint ( ent, forward, right, up, muzzle );
|
||||
|
@ -811,12 +811,12 @@ void CalcMuzzlePoint ( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up,
|
|||
muzzlePoint[2] += ent->client->ps.viewheight;
|
||||
VectorMA( muzzlePoint, 14, forward, muzzlePoint );
|
||||
}
|
||||
else if (gVR != NULL)
|
||||
else if (vr != NULL)
|
||||
{
|
||||
float worldscale = trap_Cvar_VariableValue("vr_worldscale");
|
||||
convertFromVR(ent, gVR->calculated_weaponoffset, ent->r.currentOrigin, muzzlePoint);
|
||||
convertFromVR(ent, vr->weaponoffset, ent->r.currentOrigin, muzzlePoint);
|
||||
muzzlePoint[2] -= ent->client->ps.viewheight;
|
||||
muzzlePoint[2] += gVR->hmdposition[1] * worldscale;
|
||||
muzzlePoint[2] += vr->hmdposition[1] * worldscale;
|
||||
}
|
||||
|
||||
// snap to integer coordinates for more efficient network bandwidth usage
|
||||
|
@ -867,10 +867,10 @@ void FireWeapon( gentity_t *ent ) {
|
|||
}
|
||||
|
||||
vec3_t viewang;
|
||||
if ( !( ent->r.svFlags & SVF_BOT ) && gVR != NULL)
|
||||
if ( !( ent->r.svFlags & SVF_BOT ) && vr != NULL)
|
||||
{
|
||||
VectorCopy(gVR->weaponangles, viewang);
|
||||
viewang[YAW] += ent->client->ps.viewangles[YAW] - gVR->hmdorientation[YAW];
|
||||
VectorCopy(vr->weaponangles, viewang);
|
||||
viewang[YAW] += ent->client->ps.viewangles[YAW] - vr->hmdorientation[YAW];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ cvar_t *r_measureOverdraw;
|
|||
|
||||
cvar_t *r_inGameVideo;
|
||||
cvar_t *r_fastsky;
|
||||
cvar_t *r_deathCam;
|
||||
cvar_t *vr_deathCam;
|
||||
cvar_t *r_drawSun;
|
||||
cvar_t *r_dynamiclight;
|
||||
cvar_t *r_dlightBacks;
|
||||
|
@ -1306,7 +1306,7 @@ void R_Register( void )
|
|||
r_stereoSeparation = ri.Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE );
|
||||
r_ignoreGLErrors = ri.Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE );
|
||||
r_fastsky = ri.Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE );
|
||||
r_deathCam = ri.Cvar_Get( "r_deathCam", "0", CVAR_ARCHIVE );
|
||||
vr_deathCam = ri.Cvar_Get( "vr_deathCam", "0", CVAR_TEMP );
|
||||
r_inGameVideo = ri.Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE );
|
||||
r_drawSun = ri.Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE );
|
||||
r_dynamiclight = ri.Cvar_Get( "r_dynamiclight", "0", CVAR_ARCHIVE );
|
||||
|
|
|
@ -1699,7 +1699,7 @@ extern cvar_t *r_lodscale;
|
|||
|
||||
extern cvar_t *r_inGameVideo; // controls whether in game video should be draw
|
||||
extern cvar_t *r_fastsky; // controls whether sky should be cleared or drawn
|
||||
extern cvar_t *r_deathCam; //
|
||||
extern cvar_t *vr_deathCam; //
|
||||
extern cvar_t *r_drawSun; // controls drawing of sun quad
|
||||
extern cvar_t *r_dynamiclight; // dynamic lights enabled/disabled
|
||||
extern cvar_t *r_dlightBacks; // dlight non-facing surfaces for continuity
|
||||
|
|
|
@ -843,7 +843,7 @@ Other things could be stuck in here, like birds in the sky, etc
|
|||
================
|
||||
*/
|
||||
void RB_StageIteratorSky( void ) {
|
||||
if ( r_fastsky->integer || r_deathCam->integer ) {
|
||||
if ( r_fastsky->integer || vr_deathCam->integer ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@ typedef struct {
|
|||
qboolean right_handed;
|
||||
qboolean virtual_screen;
|
||||
|
||||
qboolean localServer;
|
||||
int clientNum;
|
||||
|
||||
vec3_t hmdposition;
|
||||
vec3_t hmdposition_last; // Don't use this, it is just for calculating delta!
|
||||
vec3_t hmdposition_delta;
|
||||
|
@ -22,14 +25,12 @@ typedef struct {
|
|||
vec3_t weaponangles_last; // Don't use this, it is just for calculating delta!
|
||||
vec3_t weaponangles_delta;
|
||||
|
||||
vec3_t current_weaponoffset;
|
||||
vec3_t calculated_weaponoffset;
|
||||
float current_weaponoffset_timestamp;
|
||||
vec3_t weaponoffset_history[NUM_WEAPON_SAMPLES];
|
||||
float weaponoffset_history_timestamp[NUM_WEAPON_SAMPLES];
|
||||
vec3_t weaponoffset;
|
||||
vec3_t weaponposition;
|
||||
|
||||
vec3_t offhandangles;
|
||||
vec3_t offhandoffset;
|
||||
vec3_t offhandposition;
|
||||
|
||||
//////////////////////////////////////
|
||||
// Test stuff for weapon alignment
|
||||
|
|
|
@ -66,6 +66,7 @@ float degrees(float rad) {
|
|||
#endif
|
||||
|
||||
cvar_t *vr_extralatencymode = NULL;
|
||||
cvar_t *vr_directionMode = NULL;
|
||||
|
||||
void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
|
||||
{
|
||||
|
@ -194,6 +195,7 @@ void IN_VRInit( void )
|
|||
vr_righthanded = Cvar_Get ("vr_righthanded", "1", CVAR_ARCHIVE);
|
||||
vr_snapturn = Cvar_Get ("vr_snapturn", "45", CVAR_ARCHIVE);
|
||||
vr_extralatencymode = Cvar_Get ("vr_extralatencymode", "1", CVAR_ARCHIVE);
|
||||
vr_directionMode = Cvar_Get ("vr_directionMode", "0", CVAR_ARCHIVE); // 0 = HMD, 1 = Off-hand
|
||||
}
|
||||
|
||||
static void IN_VRController( qboolean isRightController, ovrTracking remoteTracking )
|
||||
|
@ -208,29 +210,24 @@ static void IN_VRController( qboolean isRightController, ovrTracking remoteTrack
|
|||
VectorSubtract(vr.weaponangles_last, vr.weaponangles, vr.weaponangles_delta);
|
||||
VectorCopy(vr.weaponangles, vr.weaponangles_last);
|
||||
|
||||
//Record recent weapon position for trajectory based stuff
|
||||
for (int i = (NUM_WEAPON_SAMPLES-1); i != 0; --i)
|
||||
{
|
||||
VectorCopy(vr.weaponoffset_history[i-1], vr.weaponoffset_history[i]);
|
||||
vr.weaponoffset_history_timestamp[i] = vr.weaponoffset_history_timestamp[i-1];
|
||||
}
|
||||
VectorCopy(vr.current_weaponoffset, vr.weaponoffset_history[0]);
|
||||
vr.weaponoffset_history_timestamp[0] = vr.current_weaponoffset_timestamp;
|
||||
|
||||
///Weapon location relative to view
|
||||
vr.current_weaponoffset[0] = remoteTracking.HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
vr.current_weaponoffset[1] = remoteTracking.HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
vr.current_weaponoffset[2] = remoteTracking.HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
vr.current_weaponoffset_timestamp = Sys_Milliseconds( );
|
||||
vr.weaponposition[0] = remoteTracking.HeadPose.Pose.Position.x;
|
||||
vr.weaponposition[1] = remoteTracking.HeadPose.Pose.Position.y;
|
||||
vr.weaponposition[2] = remoteTracking.HeadPose.Pose.Position.z;
|
||||
|
||||
//Just copy to calculated offset, used to use this in case we wanted to apply any modifiers, but don't any more
|
||||
VectorCopy(vr.current_weaponoffset, vr.calculated_weaponoffset);
|
||||
vr.weaponoffset[0] = remoteTracking.HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
vr.weaponoffset[1] = remoteTracking.HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
vr.weaponoffset[2] = remoteTracking.HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
} else {
|
||||
vec3_t rotation = {0};
|
||||
rotation[PITCH] =-20.0f;
|
||||
QuatToYawPitchRoll(remoteTracking.HeadPose.Pose.Orientation, rotation, vr.offhandangles);
|
||||
|
||||
///location relative to view
|
||||
vr.offhandposition[0] = remoteTracking.HeadPose.Pose.Position.x;
|
||||
vr.offhandposition[1] = remoteTracking.HeadPose.Pose.Position.y;
|
||||
vr.offhandposition[2] = remoteTracking.HeadPose.Pose.Position.z;
|
||||
|
||||
vr.offhandoffset[0] = remoteTracking.HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
vr.offhandoffset[1] = remoteTracking.HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
vr.offhandoffset[2] = remoteTracking.HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
|
@ -238,9 +235,9 @@ static void IN_VRController( qboolean isRightController, ovrTracking remoteTrack
|
|||
|
||||
if (vr.weapon_stabilised)
|
||||
{
|
||||
float x = vr.offhandoffset[0] - vr.calculated_weaponoffset[0];
|
||||
float y = vr.offhandoffset[1] - vr.calculated_weaponoffset[1];
|
||||
float z = vr.offhandoffset[2] - vr.calculated_weaponoffset[2];
|
||||
float x = vr.offhandoffset[0] - vr.weaponoffset[0];
|
||||
float y = vr.offhandoffset[1] - vr.weaponoffset[1];
|
||||
float z = vr.offhandoffset[2] - vr.weaponoffset[2];
|
||||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
|
@ -264,24 +261,39 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
|
|||
} else
|
||||
{
|
||||
if (isRightController == qfalse) {
|
||||
//Positional movement speed correction for when we are not hitting target framerate
|
||||
int refresh = vrapi_GetSystemPropertyInt(&(VR_GetEngine()->java), VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE);
|
||||
float multiplier = (float)((1000.0 / refresh) / (in_vrEventTime - lastframetime));
|
||||
|
||||
vec2_t positional;
|
||||
float factor = (refresh / 72.0F) * 10.0f; // adjust positional factor based on refresh rate
|
||||
rotateAboutOrigin(-vr.hmdposition_delta[0] * factor * multiplier,
|
||||
vr.hmdposition_delta[2] * factor * multiplier, - vr.hmdorientation[YAW], positional);
|
||||
vec3_t positional;
|
||||
VectorClear(positional);
|
||||
|
||||
vec2_t joystick;
|
||||
if ( !com_sv_running || !com_sv_running->integer )
|
||||
{
|
||||
//multiplayer server
|
||||
if (!vr_directionMode->integer) {
|
||||
//HMD Based
|
||||
rotateAboutOrigin(joystickX, joystickY, vr.hmdorientation[YAW], joystick);
|
||||
} else
|
||||
} else {
|
||||
//Off-hand based
|
||||
rotateAboutOrigin(joystickX, joystickY, vr.offhandangles[YAW], joystick);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Positional movement speed correction for when we are not hitting target framerate
|
||||
int refresh = vrapi_GetSystemPropertyInt(&(VR_GetEngine()->java), VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE);
|
||||
float multiplier = (float)((1000.0 / refresh) / (in_vrEventTime - lastframetime));
|
||||
|
||||
float factor = (refresh / 72.0F) * 10.0f; // adjust positional factor based on refresh rate
|
||||
rotateAboutOrigin(-vr.hmdposition_delta[0] * factor * multiplier,
|
||||
vr.hmdposition_delta[2] * factor * multiplier, -vr.hmdorientation[YAW], positional);
|
||||
|
||||
if (!vr_directionMode->integer) {
|
||||
//HMD Based
|
||||
joystick[0] = joystickX;
|
||||
joystick[1] = joystickY;
|
||||
} else {
|
||||
//Off-hand based
|
||||
rotateAboutOrigin(joystickX, joystickY, vr.offhandangles[YAW] - vr.hmdorientation[YAW], joystick);
|
||||
}
|
||||
}
|
||||
|
||||
//sideways
|
||||
|
|
|
@ -208,7 +208,17 @@ void VR_ClearFrameBuffer( GLuint frameBuffer, int width, int height)
|
|||
glEnable( GL_SCISSOR_TEST );
|
||||
glViewport( 0, 0, width, height );
|
||||
|
||||
glClearColor( 0.2f, 0.0f, 0.05f, 1.0f );
|
||||
if (Cvar_VariableIntegerValue("vr_deathCam"))
|
||||
{
|
||||
//Blood red.. ish
|
||||
glClearColor( 0.12f, 0.0f, 0.05f, 1.0f );
|
||||
}
|
||||
else
|
||||
{
|
||||
//Black
|
||||
glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
}
|
||||
|
||||
glScissor( 0, 0, width, height );
|
||||
glClear( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
|
|
Loading…
Reference in a new issue