Even more changes...

- Removed 3DoF mode from multiplayer (it would never be used)
- Prevent player clipping though solid objects/walls in Multiplayer
- vr_weaponPitch - Allows adjustment of weapon pitch - default: -20
- vr_heightAdjust - Additional height adjustment in metres: default: 0.0
- vr_twoHandedWeapons - Allows disabling of two handed weapon mode, set to 0 to disable
This commit is contained in:
Simon 2022-02-15 23:03:29 +00:00
parent 4f14c4547c
commit 9cce7d8d6a
6 changed files with 51 additions and 45 deletions

View file

@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.ioq3quest"
android:installLocation="preferExternal"
android:versionCode="16"
android:versionName="0.11.0">
android:versionCode="17"
android:versionName="0.12.0">
<uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />
<uses-feature android:glEsVersion="0x00030001" />

View file

@ -2685,20 +2685,28 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
cg.refdef.vieworg[2] -= PLAYER_HEIGHT;
cg.refdef.vieworg[2] += vr->hmdposition[1] * worldscale;
}
else if (trap_Cvar_VariableValue("vr_mp6DoF") == 1.0f)
else
{
//If connected to external server, allow some amount of faked positional tracking
cg.refdef.vieworg[2] -= PLAYER_HEIGHT;
cg.refdef.vieworg[2] += vr->hmdposition[1] * worldscale;
if (cg.snap->ps.stats[STAT_HEALTH] > 0)
{
vec3_t pos, hmdposition;
vec3_t pos, hmdposition, vieworg;
VectorClear(pos);
VectorSubtract(vr->hmdposition, vr->hmdorigin, hmdposition);
rotateAboutOrigin(hmdposition[2], hmdposition[0],
cg.refdefViewAngles[YAW] - vr->weaponangles[YAW], pos);
VectorScale(pos, worldscale, pos);
VectorSubtract(cg.refdef.vieworg, pos, cg.refdef.vieworg);
VectorSubtract(cg.refdef.vieworg, pos, vieworg);
//Prevent player clipping through solid objects
trace_t trace;
vec3_t mins = {-8, -8, -8};
vec3_t maxs = {8, 8, 8};
CG_Trace(&trace, cg.refdef.vieworg, mins, maxs, vieworg, cg.snap->ps.clientNum, CONTENTS_SOLID|CONTENTS_BODY);
VectorCopy(trace.endpos, cg.refdef.vieworg);
}
}

View file

@ -259,8 +259,7 @@ void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles, qboolean crossh
if (!cgs.localServer)
{
if (trap_Cvar_VariableValue("vr_mp6DoF") == 1.0f &&
!crosshair)
if (!crosshair)
{
//Use absolute position for the faked 6DoF for multiplayer
vec3_t offset, weaponposition;
@ -275,14 +274,6 @@ void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles, qboolean crossh
{
vec3_t weaponoffset;
VectorSet(weaponoffset, 0.0f, 0.0f, 0.0f);
//Fixed point
if (!crosshair) {
vec2_t temp;
rotateAboutOrigin(0.25f, -0.25f, -vr->hmdorientation[YAW], temp);
VectorSet(weaponoffset, temp[0], -0.3f, temp[1]);
}
CG_ConvertFromVR(weaponoffset, cg.refdef.vieworg, origin);
}
}

View file

@ -20,6 +20,13 @@ static engine_t vr_engine;
cvar_t *vr_worldscale = NULL;
cvar_t *vr_hudDepth = NULL;
cvar_t *vr_righthanded = NULL;
cvar_t *vr_snapturn = NULL;
cvar_t *vr_heightAdjust = NULL;
cvar_t *vr_extralatencymode = NULL;
cvar_t *vr_directionMode = NULL;
cvar_t *vr_weaponPitch = NULL;
cvar_t *vr_twoHandedWeapons = NULL;
engine_t* VR_Init( ovrJava java )
{
@ -41,6 +48,13 @@ void VR_InitCvars( void )
{
vr_worldscale = Cvar_Get ("vr_worldscale", "32.0", CVAR_ARCHIVE);
vr_hudDepth = Cvar_Get ("vr_hudDepth", "3", CVAR_ARCHIVE);
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
vr_weaponPitch = Cvar_Get ("vr_weaponPitch", "-20", CVAR_ARCHIVE);
vr_heightAdjust = Cvar_Get ("vr_heightAdjust", "0.0", CVAR_ARCHIVE);
vr_twoHandedWeapons = Cvar_Get ("vr_twoHandedWeapons", "1", CVAR_ARCHIVE);
// Values are: scale,right,up,forward,pitch,yaw,roll
// VALUES PROVIDED BY SkillFur - Thank-you!

View file

@ -48,10 +48,6 @@ extern cvar_t *cl_sensitivity;
extern cvar_t *m_pitch;
extern cvar_t *m_yaw;
cvar_t *vr_righthanded;
cvar_t *vr_snapturn;
float radians(float deg) {
return (deg * M_PI) / 180.0;
}
@ -65,9 +61,13 @@ float degrees(float rad) {
#define EPSILON 0.001f
#endif
cvar_t *vr_extralatencymode = NULL;
cvar_t *vr_directionMode = NULL;
cvar_t *vr_mp6DoF = NULL;
extern cvar_t *vr_righthanded;
extern cvar_t *vr_snapturn;
extern cvar_t *vr_extralatencymode;
extern cvar_t *vr_directionMode;
extern cvar_t *vr_weaponPitch;
extern cvar_t *vr_heightAdjust;
extern cvar_t *vr_twoHandedWeapons;
void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
{
@ -193,12 +193,6 @@ static float length(float x, float y)
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
vr_mp6DoF = Cvar_Get ("vr_mp6DoF", "1", CVAR_ARCHIVE); // if 0 then multiplayer will use only 3DoF for headset
memset(&vr, 0, sizeof(vr));
}
@ -208,7 +202,7 @@ static void IN_VRController( qboolean isRightController, ovrTracking remoteTrack
{
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
vec3_t rotation = {0};
rotation[PITCH] =-20.0f;
rotation[PITCH] = vr_weaponPitch->value;
QuatToYawPitchRoll(remoteTracking.HeadPose.Pose.Orientation, rotation, vr.weaponangles);
VectorSubtract(vr.weaponangles_last, vr.weaponangles, vr.weaponangles_delta);
@ -216,28 +210,28 @@ static void IN_VRController( qboolean isRightController, ovrTracking remoteTrack
///Weapon location relative to view
vr.weaponposition[0] = remoteTracking.HeadPose.Pose.Position.x;
vr.weaponposition[1] = remoteTracking.HeadPose.Pose.Position.y;
vr.weaponposition[1] = remoteTracking.HeadPose.Pose.Position.y + vr_heightAdjust->value;
vr.weaponposition[2] = remoteTracking.HeadPose.Pose.Position.z;
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];
vr.weaponoffset[0] = vr.weaponposition[0] - vr.hmdposition[0];
vr.weaponoffset[1] = vr.weaponposition[1] - vr.hmdposition[1];
vr.weaponoffset[2] = vr.weaponposition[2] - vr.hmdposition[2];
} else {
vec3_t rotation = {0};
rotation[PITCH] =-20.0f;
rotation[PITCH] = vr_weaponPitch->value;
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[1] = remoteTracking.HeadPose.Pose.Position.y + vr_heightAdjust->value;
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];
vr.offhandoffset[0] = vr.offhandposition[0] - vr.hmdposition[0];
vr.offhandoffset[1] = vr.offhandposition[1] - vr.hmdposition[1];
vr.offhandoffset[2] = vr.offhandposition[2] - vr.hmdposition[2];
}
if (vr.weapon_stabilised)
if (vr_twoHandedWeapons->integer && vr.weapon_stabilised)
{
float x = vr.offhandoffset[0] - vr.weaponoffset[0];
float y = vr.offhandoffset[1] - vr.weaponoffset[1];
@ -462,12 +456,11 @@ static void IN_VRButtonsChanged( qboolean isRightController, uint32_t buttons )
//Com_QueueEvent(in_vrEventTime, SE_KEY, K_PAD0_X, qfalse, 0, NULL);
}
// Y button - unassigned right now
if ((buttons & ovrButton_Y) && !(controller->buttons & ovrButton_Y)) {
int thirdPerson = Cvar_VariableIntegerValue("cg_thirdPerson");
Cvar_SetValue("cg_thirdPerson", 1-thirdPerson);
//Com_QueueEvent(in_vrEventTime, SE_KEY, K_PAD0_Y, qtrue, 0, NULL);
Com_QueueEvent(in_vrEventTime, SE_KEY, K_PAD0_Y, qtrue, 0, NULL);
} else if (!(buttons & ovrButton_Y) && (controller->buttons & ovrButton_Y)) {
//Com_QueueEvent(in_vrEventTime, SE_KEY, K_PAD0_Y, qfalse, 0, NULL);
Com_QueueEvent(in_vrEventTime, SE_KEY, K_PAD0_Y, qfalse, 0, NULL);
}
controller->buttons = buttons;
@ -505,7 +498,7 @@ void IN_VRInputFrame( void )
const ovrVector3f positionHmd = VR_GetEngine()->tracking.HeadPose.Pose.Position;
vec3_t rotation = {0, 0, 0};
QuatToYawPitchRoll(quatHmd, rotation, vr.hmdorientation);
VectorSet(vr.hmdposition, positionHmd.x, positionHmd.y, positionHmd.z);
VectorSet(vr.hmdposition, positionHmd.x, positionHmd.y + vr_heightAdjust->value, positionHmd.z);
//Position
VectorSubtract(vr.hmdposition_last, vr.hmdposition, vr.hmdposition_delta);

View file

@ -244,7 +244,7 @@ void VR_DrawFrame( engine_t* engine ) {
const ovrMatrix4f projectionMatrix = ovrMatrix4f_CreateProjectionFov(
fov_x, fov_y, 0.0f, 0.0f, 1.0f, 0.0f );
static int playerYaw = 0;
static float playerYaw = 0;
int eyeW, eyeH;
VR_GetResolution(engine, &eyeW, &eyeH);