Many fixes

- Weapon 6DoF is now pretty good, apart from correcting the relative location to the controller, it now feels right
- If you have the binoculars you can activate them pressing X
- Pressing X whilst holding down the right grip button gives you ALL WEAPONS!
- Fixed crash when you die (I'd introduced it)
- Off-hand joystick click to Kick
- Weapon scale cvar that doesn't really work
This commit is contained in:
Simon 2020-07-06 23:09:20 +01:00
parent 062682addd
commit 076392b618
7 changed files with 81 additions and 78 deletions

View file

@ -1277,7 +1277,7 @@ void initialize_gl4es();
void RTCWVR_ResyncClientYawWithGameYaw()
{
//Allow 3 frames for the yaw to sync, first is this frame which is the old yaw
//Allow several frames for the yaw to sync, first is this frame which is the old yaw
//second is the next frame which _should_ be the new yaw, but just in case it isn't
//we resync on the 3rd frame as well
resyncClientYawWithGameYaw = 5;

View file

@ -28,31 +28,10 @@ void handleTrackedControllerButton(ovrInputStateTrackedRemote * trackedRemoteSta
}
}
static void Matrix4x4_Transform (const matrix4x4 *in, const float v[3], float out[3])
void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
{
out[0] = v[0] * (*in)[0][0] + v[1] * (*in)[0][1] + v[2] * (*in)[0][2] + (*in)[0][3];
out[1] = v[0] * (*in)[1][0] + v[1] * (*in)[1][1] + v[2] * (*in)[1][2] + (*in)[1][3];
out[2] = v[0] * (*in)[2][0] + v[1] * (*in)[2][1] + v[2] * (*in)[2][2] + (*in)[2][3];
}
void Matrix4x4_CreateFromEntity( matrix4x4 out, const vec3_t angles, const vec3_t origin, float scale );
void rotateAboutOrigin(float v1, float v2, float rotation, vec2_t out)
{
vec3_t temp = {0.0f, 0.0f, 0.0f};
temp[0] = v1;
temp[1] = v2;
vec3_t v = {0.0f, 0.0f, 0.0f};
matrix4x4 matrix;
vec3_t angles = {0.0f, rotation, 0.0f};
vec3_t origin = {0.0f, 0.0f, 0.0f};
Matrix4x4_CreateFromEntity(matrix, angles, origin, 1.0f);
Matrix4x4_Transform(&matrix, temp, v);
out[0] = v[0];
out[1] = v[1];
out[0] = cosf(DEG2RAD(-rotation)) * x + sinf(DEG2RAD(-rotation)) * y;
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
}
float length(float x, float y)

View file

@ -20,7 +20,7 @@ Authors : Simon Brown
cvar_t *sv_cheats;
void CG_CenterPrint( const char *str, int y, int charWidth );
void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
@ -40,10 +40,10 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//switch to screen layer override
if ((pOffTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
(pOffTrackedRemoteOld->Buttons & ovrButton_Joystick)) {
showingScreenLayer = !showingScreenLayer;
}
// if ((pOffTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
// (pOffTrackedRemoteOld->Buttons & ovrButton_Joystick)) {
// showingScreenLayer = !showingScreenLayer;
// }
//Need this for the touch screen
{
@ -134,13 +134,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
vr.weaponoffset[1] = pDominantTracking->HeadPose.Pose.Position.y - vr.hmdposition[1];
vr.weaponoffset[2] = pDominantTracking->HeadPose.Pose.Position.z - vr.hmdposition[2];
{
vec2_t v;
rotateAboutOrigin(vr.weaponoffset[0], vr.weaponoffset[2], -snapTurn, v);
vr.weaponoffset[0] = v[0];
vr.weaponoffset[2] = v[1];
}
if (vr.weapon_stabilised)
{
float z = pOffTracking->HeadPose.Pose.Position.z - pDominantTracking->HeadPose.Pose.Position.z;
@ -149,7 +142,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
float zxDist = length(x, z);
if (zxDist != 0.0f && z != 0.0f) {
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)), -snapTurn - degrees(atan2f(x, -z)), vr.weaponangles[ROLL]);
VectorSet(vr.weaponangles, -degrees(atanf(y / zxDist)), -degrees(atan2f(x, -z)), vr.weaponangles[ROLL]);
}
}
@ -165,8 +158,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
else if (!canUseBackpack && grabMeleeWeapon == 0) {
int channel = (vr_control_scheme->integer >= 10) ? 0 : 1;
RTCWVR_Vibrate(40, channel,
0.5); // vibrate to let user know they can switch
RTCWVR_Vibrate(40, channel, 0.5); // vibrate to let user know they can switch
canUseBackpack = true;
}
@ -214,11 +206,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
vr.flashlightoffset[1] = pOffTracking->HeadPose.Pose.Position.y - vr.hmdposition[1];
vr.flashlightoffset[2] = pOffTracking->HeadPose.Pose.Position.z - vr.hmdposition[2];
vec2_t v;
rotateAboutOrigin(-vr.flashlightoffset[0], vr.flashlightoffset[2], (cl.viewangles[YAW] - vr.hmdorientation[YAW]), v);
vr.flashlightoffset[0] = v[0];
vr.flashlightoffset[2] = v[1];
vec3_t rotation = {0};
QuatToYawPitchRoll(pOffTracking->HeadPose.Pose.Orientation, rotation, vr.flashlightangles);
@ -365,11 +352,17 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
remote_movementSideways,
remote_movementForward);
//Kick!
if (!canUseQuickSave) {
if ((pOffTrackedRemoteNew->Buttons & offButton1) !=
(pOffTrackedRemoteOld->Buttons & offButton1)) {
sendButtonAction("+kick", (pOffTrackedRemoteNew->Buttons & offButton1));
if (dominantGripPushed) {
//If cheats enabled, give all weapons/pickups to player
Cbuf_AddText("give all\n");
} else {
sendButtonAction("+zoom", (pOffTrackedRemoteNew->Buttons & offButton1));
}
}
}
@ -382,14 +375,10 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
if (((pOffTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
(pOffTrackedRemoteOld->Buttons & ovrButton_Joystick))
&& (pOffTrackedRemoteNew->Buttons & ovrButton_Joystick)) {
//If cheats enabled, give all weapons/pickups to player
if (sv_cheats->value == 1.0f) {
Cbuf_AddText("give all\n");
}
//Kick!
if ((pOffTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
(pOffTrackedRemoteOld->Buttons & ovrButton_Joystick)) {
sendButtonAction("+kick", (pOffTrackedRemoteNew->Buttons & ovrButton_Joystick));
}
//We need to record if we have started firing primary so that releasing trigger will stop definitely firing, if user has pushed grip

View file

@ -312,8 +312,8 @@ cvarTable_t cvarTable[] = {
{ &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE },
{ &cg_letterbox, "cg_letterbox", "0", CVAR_TEMP }, //----(SA) added
{ &cg_stereoSeparation, "cg_stereoSeparation", "0.065", CVAR_ARCHIVE },
{ &cg_worldScale, "cg_worldScale", "35.0", CVAR_ARCHIVE },
{ &cg_weaponScale, "cg_weaponScale", "0.5", CVAR_ARCHIVE },
{ &cg_worldScale, "cg_worldScale", "37.5", CVAR_ARCHIVE },
{ &cg_weaponScale, "cg_weaponScale", "1.0", CVAR_ARCHIVE },
{ &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE },
{ &cg_gibs, "cg_gibs", "1", CVAR_ARCHIVE },
{ &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE },

View file

@ -1755,11 +1755,22 @@ static void CG_WeaponAnimation( playerState_t *ps, weaponInfo_t *weapon, int *we
// (SA) it wasn't used anyway
void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
{
out[0] = cosf(DEG2RAD(-rotation)) * x + sinf(DEG2RAD(-rotation)) * y;
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
}
void 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] - cgVR->hmdorientation[YAW], r);
vrSpace[0] = -r[0];
vrSpace[1] = -r[1];
vec3_t temp;
VectorScale(vrSpace, cg_worldScale.value, temp);
@ -1780,8 +1791,8 @@ CG_CalculateWeaponPosition
static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) {
convertFromVR(cgVR->weaponoffset, cg.refdef.vieworg, origin);
origin[2] -= 64;
origin[2] += (cgVR->hmdposition[1] /*+ vr_height_adjust->value*/) * cg_worldScale.value;
origin[2] -= 64;
origin[2] += (cgVR->hmdposition[1] /*+ vr_height_adjust->value*/) * cg_worldScale.value;
VectorCopy(cgVR->weaponangles, angles);
angles[YAW] = cg.refdefViewAngles[YAW] + (cgVR->weaponangles[YAW] - cgVR->hmdorientation[YAW]);
@ -1789,9 +1800,9 @@ static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) {
//Now move weapon closer to proper origin
vec3_t forward, right, up;
AngleVectors( angles, forward, right, up );
VectorMA( origin, -16, forward, origin );
VectorMA( origin, 9, up, origin );
VectorMA( origin, -4.5, right, origin );
VectorMA( origin, -18, forward, origin );
VectorMA( origin, 8, up, origin );
VectorMA( origin, -8, right, origin );
return;
float scale;
@ -2672,6 +2683,11 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
}
}
for ( i = 0; i < 3; i++ ) { // scale weapon back up so it doesn't pick up the adjusted scale of the character models.
// this will affect any parts attached to the gun as well (barrel/bolt/flash/brass/etc.)
VectorScale( gun.axis[i], cg_weaponScale.value, gun.axis[i] );
}
// characters that draw their own special weapon model will not draw the standard ones
if ( CG_DrawRealWeapons( cent ) ) {
drawrealweap = qtrue;
@ -6074,8 +6090,9 @@ static qboolean CG_CalcMuzzlePoint( int entityNum, vec3_t muzzle ) {
int anim;
if ( entityNum == cg.snap->ps.clientNum ) {
convertFromVR(cgVR->weaponoffset, cg.snap->ps.origin, muzzle);
muzzle[2] += cg.snap->ps.viewheight;
convertFromVR(cgVR->weaponoffset, cg.refdef.vieworg, muzzle);
muzzle[2] -= 64;
muzzle[2] += (cgVR->hmdposition[1] /*+ vr_height_adjust->value*/) * cg_worldScale.value;
vec3_t angles;
VectorCopy(cgVR->weaponangles, angles);

View file

@ -55,12 +55,24 @@ int G_GetWeaponDamage( int weapon ); // JPW
#define NUM_NAILSHOTS 10
void convertFromVR(float worldscale, vec3_t in, vec3_t offset, vec3_t out)
void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
{
out[0] = cosf(DEG2RAD(-rotation)) * x + sinf(DEG2RAD(-rotation)) * y;
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
}
void convertFromVR(float worldscale, gentity_t *ent, vec3_t in, vec3_t offset, vec3_t out)
{
vec3_t vrSpace;
VectorSet(vrSpace, in[2], in[0], in[1]);
vec3_t temp;
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);
vrSpace[0] = -r[0];
vrSpace[1] = -r[1];
vec3_t temp;
VectorScale(vrSpace, worldscale, temp);
if (offset) {
@ -70,8 +82,6 @@ void convertFromVR(float worldscale, vec3_t in, vec3_t offset, vec3_t out)
}
}
/*
======================================================================
@ -99,8 +109,11 @@ void Weapon_Knife( gentity_t *ent ) {
vec3_t angles;
VectorCopy(gVR->weaponangles_unadjusted, angles);
angles[YAW] = ent->client->ps.viewangles[YAW] + (gVR->weaponangles[YAW] - gVR->hmdorientation[YAW]);
if (gVR != NULL) {
VectorCopy(gVR->weaponangles_unadjusted, angles);
angles[YAW] = ent->client->ps.viewangles[YAW] +
(gVR->weaponangles[YAW] - gVR->hmdorientation[YAW]);
}
AngleVectors( angles, forward, right, up );
CalcMuzzlePoint( ent, ent->s.weapon, forward, right, up, muzzleTrace );
@ -1666,11 +1679,11 @@ void CalcMuzzlePoint( gentity_t *ent, int weapon, vec3_t forward, vec3_t right,
VectorCopy(ent->r.currentOrigin, muzzlePoint);
muzzlePoint[2] += ent->client->ps.viewheight;
}
else
else if (gVR != NULL)
{
float worldscale = trap_Cvar_VariableIntegerValue("cg_worldScale");
convertFromVR(worldscale, gVR->weaponoffset, ent->r.currentOrigin, muzzlePoint);
muzzlePoint[2] += ent->client->ps.viewheight;
convertFromVR(worldscale, ent, gVR->weaponoffset, ent->r.currentOrigin, muzzlePoint);
muzzlePoint[2] += (gVR->hmdposition[1] /*+ vr_height_adjust->value*/) * worldscale;
return;
}
@ -1724,11 +1737,11 @@ void CalcMuzzlePointForActivate( gentity_t *ent, vec3_t forward, vec3_t right, v
muzzlePoint[2] += ent->client->ps.viewheight;
AddLean( ent, muzzlePoint );
}
else
else if (gVR != NULL)
{
float worldscale = trap_Cvar_VariableIntegerValue("cg_worldScale");
convertFromVR(worldscale, gVR->weaponoffset, ent->r.currentOrigin, muzzlePoint);
muzzlePoint[2] += ent->client->ps.viewheight;
convertFromVR(worldscale, ent, gVR->weaponoffset, ent->r.currentOrigin, muzzlePoint);
muzzlePoint[2] += (gVR->hmdposition[1] /*+ vr_height_adjust->value*/) * worldscale;
return;
}
}
@ -1739,7 +1752,8 @@ void CalcMuzzlePointForActivate( gentity_t *ent, vec3_t forward, vec3_t right, v
void CalcMuzzlePoints( gentity_t *ent, int weapon ) {
vec3_t viewang;
if ( !( ent->r.svFlags & SVF_CASTAI ) ) {
if ( !( ent->r.svFlags & SVF_CASTAI ) &&
gVR != NULL) {
/*
// non ai's take into account scoped weapon 'sway' (just another way aimspread is visualized/utilized)

View file

@ -301,6 +301,8 @@ Completely restarts a level, but doesn't send a new gamestate to the clients.
This allows fair starts with variable load times.
================
*/
void RTCWVR_ResyncClientYawWithGameYaw();
static void SV_MapRestart_f( void ) {
int i;
client_t *client;
@ -323,6 +325,8 @@ static void SV_MapRestart_f( void ) {
return;
}
RTCWVR_ResyncClientYawWithGameYaw();
if ( Cmd_Argc() > 1 ) {
delay = atoi( Cmd_Argv( 1 ) );
} else {