mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-14 16:40:46 +00:00
Fixed couple of 6DoF issues...
- Duke: Fixed issue where for some sectors the weapon wouldn't appear to fire any projectiles - Blood: Fixed 6DoF Pitch being based on headset angle - Blood: Fixed 6DoF Z position being based on headset - All games use 6DoF Z position as an offset from view position
This commit is contained in:
parent
c9dc3c628f
commit
8ad59c7e43
6 changed files with 66 additions and 48 deletions
|
@ -52,7 +52,7 @@ float RazeXR_GetFOV();
|
||||||
void VR_GetMove(float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up,
|
void VR_GetMove(float *joy_forward, float *joy_side, float *hmd_forward, float *hmd_side, float *up,
|
||||||
float *yaw, float *pitch, float *roll);
|
float *yaw, float *pitch, float *roll);
|
||||||
|
|
||||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
|
||||||
|
|
||||||
// Set up 3D-specific console variables:
|
// Set up 3D-specific console variables:
|
||||||
CVAR(Int, vr_mode, 15, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
CVAR(Int, vr_mode, 15, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
||||||
|
@ -336,15 +336,14 @@ VSMatrix VREyeInfo::GetPlayerSpriteProjection(int width, int height) const
|
||||||
new_projection.rotate(-hmdorientation[PITCH], 1, 0, 0);
|
new_projection.rotate(-hmdorientation[PITCH], 1, 0, 0);
|
||||||
new_projection.rotate(-hmdorientation[ROLL], 0, 0, 1);
|
new_projection.rotate(-hmdorientation[ROLL], 0, 0, 1);
|
||||||
|
|
||||||
float x, y, z1, z2, pitch, yaw;
|
float x, y, z, pitch, yaw;
|
||||||
get_weapon_pos_and_angle(x, y, z1, z2, pitch, yaw);
|
get_weapon_pos_and_angle(x, y, z, pitch, yaw);
|
||||||
new_projection.translate(-x * weapon_stereo_effect, z2 * weapon_stereo_effect, -y * weapon_stereo_effect);
|
new_projection.translate(-x * weapon_stereo_effect, (z-hmdPosition[1]) * weapon_stereo_effect, -y * weapon_stereo_effect);
|
||||||
|
|
||||||
new_projection.rotate(weaponangles[YAW] - hmdorientation[YAW], 0, 1, 0);
|
new_projection.rotate(weaponangles[YAW] - hmdorientation[YAW], 0, 1, 0);
|
||||||
new_projection.rotate(weaponangles[PITCH], 1, 0, 0);
|
new_projection.rotate(weaponangles[PITCH], 1, 0, 0);
|
||||||
new_projection.rotate(weaponangles[ROLL], 0, 0, 1);
|
new_projection.rotate(weaponangles[ROLL], 0, 0, 1);
|
||||||
|
|
||||||
|
|
||||||
float weapon_scale = 0.6f;
|
float weapon_scale = 0.6f;
|
||||||
new_projection.scale(-weapon_scale, weapon_scale, -weapon_scale);
|
new_projection.scale(-weapon_scale, weapon_scale, -weapon_scale);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "gamestate.h"
|
#include "gamestate.h"
|
||||||
#include "automap.h"
|
#include "automap.h"
|
||||||
|
|
||||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
|
||||||
float vr_hunits_per_meter();
|
float vr_hunits_per_meter();
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||||
|
@ -1543,21 +1543,31 @@ void ProcessInput(PLAYER* pPlayer)
|
||||||
pPlayer->restTime += 4;
|
pPlayer->restTime += 4;
|
||||||
|
|
||||||
|
|
||||||
float px, py, pz1, pz2, pitch, yaw;
|
float px, py, pz, pitch, yaw;
|
||||||
|
double slope = pPlayer->slope;
|
||||||
|
double zWeapon = pPlayer->zWeapon;
|
||||||
|
|
||||||
DVector2 posXY;
|
DVector2 posXY;
|
||||||
sectortype* sect;
|
sectortype* sect;
|
||||||
bool crosshairActive = false;
|
bool crosshairActive = false;
|
||||||
if (vr_6dof_weapons)
|
if (vr_6dof_weapons)
|
||||||
{
|
{
|
||||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
get_weapon_pos_and_angle(px, py, pz, pitch, yaw);
|
||||||
|
|
||||||
|
//Position for crosshair calculation
|
||||||
|
DVector3 spos = actor->spr.pos.plusZ(-(pz * vr_hunits_per_meter()) - actor->viewzoffset);
|
||||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + actor->spr.Angles.Yaw);
|
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + actor->spr.Angles.Yaw);
|
||||||
|
spos.X -= posXY.X;
|
||||||
|
spos.Y -= posXY.Y;
|
||||||
|
|
||||||
|
//Update player angles and position for shooting
|
||||||
actor->spr.pos.X -= posXY.X;
|
actor->spr.pos.X -= posXY.X;
|
||||||
actor->spr.pos.Y -= posXY.Y;
|
actor->spr.pos.Y -= posXY.Y;
|
||||||
actor->spr.pos.Z -= (pz2 * vr_hunits_per_meter()) - actor->viewzoffset;
|
actor->spr.pos.Z -= (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||||
|
pPlayer->zWeapon = actor->spr.pos.Z;
|
||||||
actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||||
actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||||
|
pPlayer->slope = actor->spr.Angles.Pitch.Tan();
|
||||||
|
|
||||||
sect = actor->sector();
|
sect = actor->sector();
|
||||||
sectortype* newsect = actor->sector();
|
sectortype* newsect = actor->sector();
|
||||||
|
@ -1572,7 +1582,7 @@ void ProcessInput(PLAYER* pPlayer)
|
||||||
setFreeAimVelocity(vel, zvel, actor->spr.Angles.Pitch, 16.);
|
setFreeAimVelocity(vel, zvel, actor->spr.Angles.Pitch, 16.);
|
||||||
|
|
||||||
actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||||
hitscan(actor->spr.pos, actor->sector(),
|
hitscan(spos, actor->sector(),
|
||||||
DVector3(actor->spr.Angles.Yaw.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
DVector3(actor->spr.Angles.Yaw.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
||||||
actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
|
actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
|
||||||
|
|
||||||
|
@ -1622,9 +1632,11 @@ void ProcessInput(PLAYER* pPlayer)
|
||||||
{
|
{
|
||||||
actor->spr.pos.X += posXY.X;
|
actor->spr.pos.X += posXY.X;
|
||||||
actor->spr.pos.Y += posXY.Y;
|
actor->spr.pos.Y += posXY.Y;
|
||||||
actor->spr.pos.Z += (pz2 * vr_hunits_per_meter()) - actor->viewzoffset;
|
actor->spr.pos.Z += (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||||
actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||||
actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||||
|
pPlayer->slope = actor->spr.Angles.Pitch.Tan();
|
||||||
|
pPlayer->zWeapon = zWeapon;
|
||||||
actor->setsector(sect);
|
actor->setsector(sect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ source as it is released.
|
||||||
#include "names_d.h"
|
#include "names_d.h"
|
||||||
#include "dukeactor.h"
|
#include "dukeactor.h"
|
||||||
|
|
||||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
|
||||||
float vr_hunits_per_meter();
|
float vr_hunits_per_meter();
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||||
|
@ -949,23 +949,23 @@ void shoot_d_override(DDukeActor* actor, int atwith, PClass *cls)
|
||||||
int l, j;
|
int l, j;
|
||||||
int sx, sy, sz, sa, p, vel, zvel, x, dal;
|
int sx, sy, sz, sa, p, vel, zvel, x, dal;
|
||||||
|
|
||||||
float px, py, pz1, pz2, pitch, yaw;
|
float px, py, pz, pitch, yaw;
|
||||||
|
|
||||||
DVector2 posXY;
|
DVector2 posXY;
|
||||||
sectortype* sectp;
|
sectortype* sectp;
|
||||||
if (actor->isPlayer() && vr_6dof_weapons)
|
if (actor->isPlayer() && vr_6dof_weapons)
|
||||||
{
|
{
|
||||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
get_weapon_pos_and_angle(px, py, pz, pitch, yaw);
|
||||||
|
|
||||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + actor->spr.Angles.Yaw);
|
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + actor->spr.Angles.Yaw);
|
||||||
actor->spr.pos.X -= posXY.X;
|
actor->spr.pos.X -= posXY.X;
|
||||||
actor->spr.pos.Y -= posXY.Y;
|
actor->spr.pos.Y -= posXY.Y;
|
||||||
actor->spr.pos.Z -= (pz1 * vr_hunits_per_meter()) + actor->viewzoffset;
|
actor->spr.pos.Z -= (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||||
actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||||
actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||||
|
|
||||||
sectp = actor->sector();
|
sectp = actor->sector();
|
||||||
sectortype* sectpnew;
|
sectortype* sectpnew = sectp;
|
||||||
updatesector(actor->spr.pos.XY(), §pnew);
|
updatesector(actor->spr.pos.XY(), §pnew);
|
||||||
actor->setsector(sectpnew);
|
actor->setsector(sectpnew);
|
||||||
}
|
}
|
||||||
|
@ -976,7 +976,7 @@ void shoot_d_override(DDukeActor* actor, int atwith, PClass *cls)
|
||||||
{
|
{
|
||||||
actor->spr.pos.X += posXY.X;
|
actor->spr.pos.X += posXY.X;
|
||||||
actor->spr.pos.Y += posXY.Y;
|
actor->spr.pos.Y += posXY.Y;
|
||||||
actor->spr.pos.Z += (pz1 * vr_hunits_per_meter()) + actor->viewzoffset;
|
actor->spr.pos.Z += (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||||
actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||||
actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||||
actor->setsector(sectp);
|
actor->setsector(sectp);
|
||||||
|
@ -2567,12 +2567,12 @@ static void processweapon(int snum, ESyncBits actions)
|
||||||
{
|
{
|
||||||
if (vr_6dof_weapons && vr_6dof_crosshair)
|
if (vr_6dof_weapons && vr_6dof_crosshair)
|
||||||
{
|
{
|
||||||
float x, y, z1, z2, pitch, yaw;
|
float x, y, z, pitch, yaw;
|
||||||
get_weapon_pos_and_angle(x, y, z1, z2, pitch, yaw);
|
get_weapon_pos_and_angle(x, y, z, pitch, yaw);
|
||||||
|
|
||||||
DAngle sang = pact->spr.Angles.Yaw + DAngle::fromDeg(yaw);
|
DAngle sang = pact->spr.Angles.Yaw + DAngle::fromDeg(yaw);
|
||||||
|
|
||||||
DVector3 spos = pact->spr.pos.plusZ(-(z1 * vr_hunits_per_meter()));
|
DVector3 spos = pact->spr.pos.plusZ(-(z * vr_hunits_per_meter()));
|
||||||
DVector2 posXY(x * vr_hunits_per_meter(), y * vr_hunits_per_meter());
|
DVector2 posXY(x * vr_hunits_per_meter(), y * vr_hunits_per_meter());
|
||||||
posXY = posXY.Rotated(-DAngle90 + pact->spr.Angles.Yaw);
|
posXY = posXY.Rotated(-DAngle90 + pact->spr.Angles.Yaw);
|
||||||
spos.X -= posXY.X;
|
spos.X -= posXY.X;
|
||||||
|
@ -2584,7 +2584,7 @@ static void processweapon(int snum, ESyncBits actions)
|
||||||
updatesector(spos.XY(), §p);
|
updatesector(spos.XY(), §p);
|
||||||
|
|
||||||
double vel = 1024, zvel = 0;
|
double vel = 1024, zvel = 0;
|
||||||
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView() - DAngle::fromDeg(pitch), 16.);
|
setFreeAimVelocity(vel, zvel, pact->spr.Angles.Pitch - DAngle::fromDeg(pitch), 16.);
|
||||||
|
|
||||||
pact->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
pact->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||||
hitscan(spos, sectp, DVector3(sang.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
hitscan(spos, sectp, DVector3(sang.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
||||||
|
|
|
@ -33,7 +33,7 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
|
||||||
#include "dukeactor.h"
|
#include "dukeactor.h"
|
||||||
#include "names_d.h"
|
#include "names_d.h"
|
||||||
|
|
||||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
|
||||||
float vr_hunits_per_meter();
|
float vr_hunits_per_meter();
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||||
|
@ -773,23 +773,23 @@ void shoot_r_override(DDukeActor* actor, int atwith, PClass *cls)
|
||||||
int l, j;
|
int l, j;
|
||||||
int sx, sy, sz, sa, p, vel, zvel, x, dal;
|
int sx, sy, sz, sa, p, vel, zvel, x, dal;
|
||||||
|
|
||||||
float px, py, pz1, pz2, pitch, yaw;
|
float px, py, pz, pitch, yaw;
|
||||||
|
|
||||||
DVector2 posXY;
|
DVector2 posXY;
|
||||||
sectortype* sectp;
|
sectortype* sectp;
|
||||||
if (actor->isPlayer() && vr_6dof_weapons)
|
if (actor->isPlayer() && vr_6dof_weapons)
|
||||||
{
|
{
|
||||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
get_weapon_pos_and_angle(px, py, pz, pitch, yaw);
|
||||||
|
|
||||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + actor->spr.Angles.Yaw);
|
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + actor->spr.Angles.Yaw);
|
||||||
actor->spr.pos.X -= posXY.X;
|
actor->spr.pos.X -= posXY.X;
|
||||||
actor->spr.pos.Y -= posXY.Y;
|
actor->spr.pos.Y -= posXY.Y;
|
||||||
actor->spr.pos.Z -= (pz1 * vr_hunits_per_meter()) + actor->viewzoffset;
|
actor->spr.pos.Z -= (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||||
actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||||
actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||||
|
|
||||||
sectp = actor->sector();
|
sectp = actor->sector();
|
||||||
sectortype* sectpnew;
|
sectortype* sectpnew = sectp;
|
||||||
updatesector(actor->spr.pos.XY(), §pnew);
|
updatesector(actor->spr.pos.XY(), §pnew);
|
||||||
actor->setsector(sectpnew);
|
actor->setsector(sectpnew);
|
||||||
}
|
}
|
||||||
|
@ -800,7 +800,7 @@ void shoot_r_override(DDukeActor* actor, int atwith, PClass *cls)
|
||||||
{
|
{
|
||||||
actor->spr.pos.X += posXY.X;
|
actor->spr.pos.X += posXY.X;
|
||||||
actor->spr.pos.Y += posXY.Y;
|
actor->spr.pos.Y += posXY.Y;
|
||||||
actor->spr.pos.Z += (pz1 * vr_hunits_per_meter()) + actor->viewzoffset;
|
actor->spr.pos.Z += (pz * vr_hunits_per_meter()) + actor->viewzoffset;
|
||||||
actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||||
actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||||
actor->setsector(sectp);
|
actor->setsector(sectp);
|
||||||
|
@ -3181,12 +3181,12 @@ static void processweapon(int snum, ESyncBits actions, sectortype* psectp)
|
||||||
{
|
{
|
||||||
if (vr_6dof_weapons && vr_6dof_crosshair)
|
if (vr_6dof_weapons && vr_6dof_crosshair)
|
||||||
{
|
{
|
||||||
float x, y, z1, z2, pitch, yaw;
|
float x, y, z, pitch, yaw;
|
||||||
get_weapon_pos_and_angle(x, y, z1, z2, pitch, yaw);
|
get_weapon_pos_and_angle(x, y, z, pitch, yaw);
|
||||||
|
|
||||||
DAngle sang = pact->spr.Angles.Yaw + DAngle::fromDeg(yaw);
|
DAngle sang = pact->spr.Angles.Yaw + DAngle::fromDeg(yaw);
|
||||||
|
|
||||||
DVector3 spos = pact->spr.pos.plusZ(-(z1 * vr_hunits_per_meter()));
|
DVector3 spos = pact->spr.pos.plusZ(-(z * vr_hunits_per_meter()));
|
||||||
DVector2 posXY(x * vr_hunits_per_meter(), y * vr_hunits_per_meter());
|
DVector2 posXY(x * vr_hunits_per_meter(), y * vr_hunits_per_meter());
|
||||||
posXY = posXY.Rotated(-DAngle90 + pact->spr.Angles.Yaw);
|
posXY = posXY.Rotated(-DAngle90 + pact->spr.Angles.Yaw);
|
||||||
spos.X -= posXY.X;
|
spos.X -= posXY.X;
|
||||||
|
@ -3197,7 +3197,7 @@ static void processweapon(int snum, ESyncBits actions, sectortype* psectp)
|
||||||
auto sectp = pact->sector();
|
auto sectp = pact->sector();
|
||||||
updatesector(spos.XY(), §p);
|
updatesector(spos.XY(), §p);
|
||||||
double vel = 1024, zvel = 0;
|
double vel = 1024, zvel = 0;
|
||||||
setFreeAimVelocity(vel, zvel, p->Angles.getPitchWithView() - DAngle::fromDeg(pitch), 16.);
|
setFreeAimVelocity(vel, zvel, pact->spr.Angles.Pitch - DAngle::fromDeg(pitch), 16.);
|
||||||
|
|
||||||
pact->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
pact->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||||
hitscan(spos, sectp, DVector3(sang.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
hitscan(spos, sectp, DVector3(sang.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
||||||
|
|
|
@ -38,7 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
|
||||||
float vr_hunits_per_meter();
|
float vr_hunits_per_meter();
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||||
|
@ -2660,19 +2660,25 @@ sectdone:
|
||||||
pDopple->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
pDopple->spr.cstat = CSTAT_SPRITE_INVISIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
float px, py, pz1, pz2, pitch, yaw;
|
float px, py, pz, pitch, yaw;
|
||||||
|
|
||||||
DVector2 posXY;
|
DVector2 posXY;
|
||||||
sectortype* sect;
|
sectortype* sect;
|
||||||
bool crosshairActive = false;
|
bool crosshairActive = false;
|
||||||
if (vr_6dof_weapons && nPlayer == 0)
|
if (vr_6dof_weapons && nPlayer == 0)
|
||||||
{
|
{
|
||||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
get_weapon_pos_and_angle(px, py, pz, pitch, yaw);
|
||||||
|
|
||||||
|
//Position for crosshair calculation
|
||||||
|
DVector3 spos = pPlayerActor->spr.pos.plusZ(-(pz * vr_hunits_per_meter()));
|
||||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + pPlayerActor->spr.Angles.Yaw);
|
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + pPlayerActor->spr.Angles.Yaw);
|
||||||
|
spos.X -= posXY.X;
|
||||||
|
spos.Y -= posXY.Y;
|
||||||
|
|
||||||
|
//Update player angles and position for shooting
|
||||||
pPlayerActor->spr.pos.X -= posXY.X;
|
pPlayerActor->spr.pos.X -= posXY.X;
|
||||||
pPlayerActor->spr.pos.Y -= posXY.Y;
|
pPlayerActor->spr.pos.Y -= posXY.Y;
|
||||||
pPlayerActor->spr.pos.Z -= (pz2 * vr_hunits_per_meter()) - pPlayerActor->viewzoffset;
|
pPlayerActor->spr.pos.Z -= (pz * vr_hunits_per_meter()) + pPlayerActor->viewzoffset;
|
||||||
pPlayerActor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
pPlayerActor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||||
pPlayerActor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
pPlayerActor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||||
|
|
||||||
|
@ -2689,7 +2695,7 @@ sectdone:
|
||||||
setFreeAimVelocity(vel, zvel, pPlayerActor->spr.Angles.Pitch, 16.);
|
setFreeAimVelocity(vel, zvel, pPlayerActor->spr.Angles.Pitch, 16.);
|
||||||
|
|
||||||
pPlayerActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
pPlayerActor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||||
hitscan(pPlayerActor->spr.pos, pPlayerActor->sector(),
|
hitscan(spos, pPlayerActor->sector(),
|
||||||
DVector3(pPlayerActor->spr.Angles.Yaw.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
DVector3(pPlayerActor->spr.Angles.Yaw.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
||||||
pPlayerActor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
|
pPlayerActor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
|
||||||
|
|
||||||
|
@ -2721,8 +2727,6 @@ sectdone:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pPlayerActor->spr.pos.Z += -pPlayerActor->viewzoffset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!crosshairActive)
|
if (!crosshairActive)
|
||||||
|
@ -2741,7 +2745,7 @@ sectdone:
|
||||||
{
|
{
|
||||||
pPlayerActor->spr.pos.X += posXY.X;
|
pPlayerActor->spr.pos.X += posXY.X;
|
||||||
pPlayerActor->spr.pos.Y += posXY.Y;
|
pPlayerActor->spr.pos.Y += posXY.Y;
|
||||||
pPlayerActor->spr.pos.Z += (pz2 * vr_hunits_per_meter());
|
pPlayerActor->spr.pos.Z += (pz * vr_hunits_per_meter()) + pPlayerActor->viewzoffset;
|
||||||
pPlayerActor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
pPlayerActor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||||
pPlayerActor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
pPlayerActor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||||
pPlayerActor->setsector(sect);
|
pPlayerActor->setsector(sect);
|
||||||
|
|
|
@ -56,7 +56,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
||||||
#include "gamestate.h"
|
#include "gamestate.h"
|
||||||
#include "vm.h"
|
#include "vm.h"
|
||||||
|
|
||||||
void get_weapon_pos_and_angle(float &x, float &y, float &z1, float &z2, float &pitch, float &yaw);
|
void get_weapon_pos_and_angle(float &x, float &y, float &z, float &pitch, float &yaw);
|
||||||
float vr_hunits_per_meter();
|
float vr_hunits_per_meter();
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
EXTERN_CVAR(Bool, vr_6dof_weapons);
|
||||||
|
@ -7032,19 +7032,25 @@ void domovethings(void)
|
||||||
UpdatePlayerSprite(pp);
|
UpdatePlayerSprite(pp);
|
||||||
|
|
||||||
|
|
||||||
float px, py, pz1, pz2, pitch, yaw;
|
float px, py, pz, pitch, yaw;
|
||||||
|
|
||||||
DVector2 posXY;
|
DVector2 posXY;
|
||||||
sectortype* sect;
|
sectortype* sect;
|
||||||
bool crosshairActive = false;
|
bool crosshairActive = false;
|
||||||
if (vr_6dof_weapons)
|
if (vr_6dof_weapons)
|
||||||
{
|
{
|
||||||
get_weapon_pos_and_angle(px, py, pz1, pz2, pitch, yaw);
|
get_weapon_pos_and_angle(px, py, pz, pitch, yaw);
|
||||||
|
|
||||||
|
//Position for crosshair calculation
|
||||||
|
DVector3 spos = pp->actor->spr.pos.plusZ(-(pz * vr_hunits_per_meter()));
|
||||||
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + pp->actor->spr.Angles.Yaw);
|
posXY = DVector2(px * vr_hunits_per_meter(), py * vr_hunits_per_meter()).Rotated(-DAngle90 + pp->actor->spr.Angles.Yaw);
|
||||||
|
spos.X -= posXY.X;
|
||||||
|
spos.Y -= posXY.Y;
|
||||||
|
|
||||||
|
//Update player angles and position for shooting
|
||||||
pp->actor->spr.pos.X -= posXY.X;
|
pp->actor->spr.pos.X -= posXY.X;
|
||||||
pp->actor->spr.pos.Y -= posXY.Y;
|
pp->actor->spr.pos.Y -= posXY.Y;
|
||||||
pp->actor->spr.pos.Z -= (pz1 * vr_hunits_per_meter());
|
pp->actor->spr.pos.Z -= (pz * vr_hunits_per_meter()) + pp->actor->viewzoffset;
|
||||||
pp->actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
pp->actor->spr.Angles.Yaw += DAngle::fromDeg(yaw);
|
||||||
pp->actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
pp->actor->spr.Angles.Pitch -= DAngle::fromDeg(pitch);
|
||||||
|
|
||||||
|
@ -7061,7 +7067,7 @@ void domovethings(void)
|
||||||
setFreeAimVelocity(vel, zvel, pp->actor->spr.Angles.Pitch, 16.);
|
setFreeAimVelocity(vel, zvel, pp->actor->spr.Angles.Pitch, 16.);
|
||||||
|
|
||||||
pp->actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
pp->actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL;
|
||||||
hitscan(pp->actor->spr.pos, pp->actor->sector(), DVector3(pp->actor->spr.Angles.Yaw.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
hitscan(spos, pp->actor->sector(), DVector3(pp->actor->spr.Angles.Yaw.ToVector() * vel, zvel * 64), hit, CLIPMASK1);
|
||||||
pp->actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
|
pp->actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL;
|
||||||
|
|
||||||
if (hit.hitSector != nullptr)
|
if (hit.hitSector != nullptr)
|
||||||
|
@ -7089,9 +7095,6 @@ void domovethings(void)
|
||||||
crosshair->spr.shade = -40;
|
crosshair->spr.shade = -40;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Now adjust Z for weapon origin
|
|
||||||
pp->actor->spr.pos.Z -= pp->actor->viewzoffset;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7111,7 +7114,7 @@ void domovethings(void)
|
||||||
{
|
{
|
||||||
pp->actor->spr.pos.X += posXY.X;
|
pp->actor->spr.pos.X += posXY.X;
|
||||||
pp->actor->spr.pos.Y += posXY.Y;
|
pp->actor->spr.pos.Y += posXY.Y;
|
||||||
pp->actor->spr.pos.Z += (pz1 * vr_hunits_per_meter()) + pp->actor->viewzoffset;
|
pp->actor->spr.pos.Z += (pz * vr_hunits_per_meter()) + pp->actor->viewzoffset;
|
||||||
pp->actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
pp->actor->spr.Angles.Yaw -= DAngle::fromDeg(yaw);
|
||||||
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
pp->actor->spr.Angles.Pitch += DAngle::fromDeg(pitch);
|
||||||
pp->actor->setsector(sect);
|
pp->actor->setsector(sect);
|
||||||
|
|
Loading…
Reference in a new issue