Tweaks and full model wepon location correct

Code taken from the OpenVR port
This commit is contained in:
Simon 2020-03-15 23:16:38 +00:00
parent c4c2ffbb7a
commit 6e5a4488a4
9 changed files with 60 additions and 51 deletions

View file

@ -63,8 +63,6 @@ vec3_t offhandangles;
vec3_t offhandoffset;
bool player_moving;
bool disable_clock_gettime;
#if !defined( EGL_OPENGL_ES3_BIT_KHR )
#define EGL_OPENGL_ES3_BIT_KHR 0x0040
@ -153,6 +151,7 @@ LAMBDA1VR Stuff
//This is now controlled by the engine
static bool useVirtualScreen = true;
bool forceVirtualScreen = false;
extern bool automapactive;
void setUseScreenLayer(bool use)
{
@ -161,7 +160,7 @@ void setUseScreenLayer(bool use)
bool useScreenLayer()
{
return useVirtualScreen || forceVirtualScreen;
return useVirtualScreen || forceVirtualScreen || automapactive;
}
static void UnEscapeQuotes( char *arg )
@ -1269,8 +1268,6 @@ void VR_Init()
positional_movementForward = 0.0f;
snapTurn = 90.0f; // start partly turned
disable_clock_gettime = false;
//init randomiser
srand(time(NULL));

View file

@ -12,6 +12,7 @@ Authors : Simon Brown
#include <VrApi_SystemUtils.h>
#include <VrApi_Input.h>
#include <VrApi_Types.h>
#include <android/keycodes.h>
#include "VrInput.h"
@ -22,13 +23,13 @@ int isMenuActive();
void Joy_GenerateButtonEvents(int oldbuttons, int newbuttons, int numbuttons, int base);
extern bool forceVirtualScreen;
extern bool disable_clock_gettime;
void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, ovrInputStateTrackedRemote *pDominantTrackedRemoteOld, ovrTracking* pDominantTracking,
ovrInputStateTrackedRemote *pOffTrackedRemoteNew, ovrInputStateTrackedRemote *pOffTrackedRemoteOld, ovrTracking* pOffTracking,
int domButton1, int domButton2, int offButton1, int offButton2 )
{
#ifdef _DEBUG
//Show screen view - for testing
if (((pOffTrackedRemoteNew->Buttons & offButton2) !=
(pOffTrackedRemoteOld->Buttons & offButton2)) &&
@ -36,14 +37,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
forceVirtualScreen = !forceVirtualScreen;
}
//Toggle the get time function for testing
if (((pOffTrackedRemoteNew->Buttons & offButton1) !=
(pOffTrackedRemoteOld->Buttons & offButton1)) &&
(pOffTrackedRemoteNew->Buttons & offButton1)) {
disable_clock_gettime = !disable_clock_gettime;
}
#endif
//Menu button - invoke menu
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, KEY_ESCAPE);
@ -268,16 +262,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
itemSwitched = 2;
}
}
else if (itemSwitched == 1)
{
Joy_GenerateButtonEvents(1, 0, 1, KEY_MWHEELDOWN);
itemSwitched = 0;
}
else if (itemSwitched == 2)
{
Joy_GenerateButtonEvents(1, 0, 1, KEY_MWHEELUP);
itemSwitched = 0;
}
} else {
if (itemSwitched == 1)
{
@ -290,58 +274,72 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
itemSwitched = 0;
}
//Dominant Hand - Primary keys (no grip pushed)
//Dominant Hand - Primary keys (no grip pushed) - All keys are remappable, default bindngs are shown below
//Fire
Joy_GenerateButtonEvents(((pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger) != 0) && !dominantGripPushedOld ? 1 : 0,
((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) != 0) && !dominantGripPushedNew ? 1 : 0,
1, KEY_RCTRL);
1, KEY_PAD_RTRIGGER);
//"Use" (open door, toggle switch etc)
Joy_GenerateButtonEvents(((pDominantTrackedRemoteOld->Buttons & domButton1) != 0) && !dominantGripPushedOld ? 1 : 0,
((pDominantTrackedRemoteNew->Buttons & domButton1) != 0) && !dominantGripPushedNew ? 1 : 0,
1, KEY_SPACE);
1, KEY_PAD_A);
//No Binding
Joy_GenerateButtonEvents(((pDominantTrackedRemoteOld->Buttons & domButton2) != 0) && !dominantGripPushedOld ? 1 : 0,
((pDominantTrackedRemoteNew->Buttons & domButton2) != 0) && !dominantGripPushedNew ? 1 : 0,
1, KEY_PAD_B);
// Inv Use
Joy_GenerateButtonEvents(((pDominantTrackedRemoteOld->Buttons & ovrButton_Joystick) != 0) && !dominantGripPushedOld ? 1 : 0,
((pDominantTrackedRemoteNew->Buttons & ovrButton_Joystick) != 0) && !dominantGripPushedNew ? 1 : 0,
1, KEY_MWHEELDOWN);
1, KEY_ENTER);
//Dominant Hand - Secondary keys (grip pushed)
//Alt-Fire
Joy_GenerateButtonEvents(((pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger) != 0) && dominantGripPushedOld ? 1 : 0,
((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) != 0) && dominantGripPushedNew ? 1 : 0,
1, KEY_PAD_RSHOULDER);
1, KEY_PAD_LTRIGGER);
//Crouch
Joy_GenerateButtonEvents(((pDominantTrackedRemoteOld->Buttons & domButton1) != 0) && dominantGripPushedOld ? 1 : 0,
((pDominantTrackedRemoteNew->Buttons & domButton1) != 0) && dominantGripPushedNew ? 1 : 0,
1, KEY_RSHIFT);
1, KEY_PAD_LTHUMB);
//No Binding
Joy_GenerateButtonEvents(((pDominantTrackedRemoteOld->Buttons & domButton2) != 0) && dominantGripPushedOld ? 1 : 0,
((pDominantTrackedRemoteNew->Buttons & domButton2) != 0) && dominantGripPushedNew ? 1 : 0,
1, KEY_RCTRL);
1, KEY_RSHIFT);
//Toggle Map
Joy_GenerateButtonEvents(((pDominantTrackedRemoteOld->Buttons & ovrButton_Joystick) != 0) && dominantGripPushedOld ? 1 : 0,
((pDominantTrackedRemoteNew->Buttons & ovrButton_Joystick) != 0) && dominantGripPushedNew ? 1 : 0,
1, KEY_ENTER);
1, KEY_TAB);
//Off Hand - Primary keys (no grip pushed)
//No Default Binding
Joy_GenerateButtonEvents(((pOffTrackedRemoteOld->Buttons & ovrButton_Trigger) != 0) && !dominantGripPushedOld ? 1 : 0,
((pOffTrackedRemoteNew->Buttons & ovrButton_Trigger) != 0) && !dominantGripPushedNew ? 1 : 0,
1, KEY_LSHIFT);
//No Default Binding
Joy_GenerateButtonEvents(((pOffTrackedRemoteOld->Buttons & offButton1) != 0) && !dominantGripPushedOld ? 1 : 0,
((pOffTrackedRemoteNew->Buttons & offButton1) != 0) && !dominantGripPushedNew ? 1 : 0,
1, KEY_PAD_X);
//Jump
Joy_GenerateButtonEvents(((pOffTrackedRemoteOld->Buttons & offButton2) != 0) && !dominantGripPushedOld ? 1 : 0,
((pOffTrackedRemoteNew->Buttons & offButton2) != 0) && !dominantGripPushedNew ? 1 : 0,
1, KEY_PAD_Y);
//"Use" (open door, toggle switch etc) - Can be rebound for other uses
Joy_GenerateButtonEvents(((pOffTrackedRemoteOld->Buttons & ovrButton_Joystick) != 0) && !dominantGripPushedOld ? 1 : 0,
((pOffTrackedRemoteNew->Buttons & ovrButton_Joystick) != 0) && !dominantGripPushedNew ? 1 : 0,
1, KEY_SPACE);
@ -349,21 +347,26 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//Off Hand - Secondary keys (grip pushed)
//Toggle Run
Joy_GenerateButtonEvents(((pOffTrackedRemoteOld->Buttons & ovrButton_Trigger) != 0) && dominantGripPushedOld ? 1 : 0,
((pOffTrackedRemoteNew->Buttons & ovrButton_Trigger) != 0) && dominantGripPushedNew ? 1 : 0,
1, KEY_PAD_LSHOULDER);
1, AKEYCODE_CAPS_LOCK);
//Move Down
Joy_GenerateButtonEvents(((pOffTrackedRemoteOld->Buttons & offButton1) != 0) && dominantGripPushedOld ? 1 : 0,
((pOffTrackedRemoteNew->Buttons & offButton1) != 0) && dominantGripPushedNew ? 1 : 0,
1, KEY_LSHIFT);
1, KEY_PGDN);
//Move Up
Joy_GenerateButtonEvents(((pOffTrackedRemoteOld->Buttons & offButton2) != 0) && dominantGripPushedOld ? 1 : 0,
((pOffTrackedRemoteNew->Buttons & offButton2) != 0) && dominantGripPushedNew ? 1 : 0,
1, KEY_LCTRL);
1, KEY_PGUP);
//Land
Joy_GenerateButtonEvents(((pOffTrackedRemoteOld->Buttons & ovrButton_Joystick) != 0) && dominantGripPushedOld ? 1 : 0,
((pOffTrackedRemoteNew->Buttons & ovrButton_Joystick) != 0) && dominantGripPushedNew ? 1 : 0,
1, KEY_DEL);
1, KEY_HOME);
}
}

View file

@ -303,7 +303,7 @@ unsigned int *FModelVertexBuffer::LockIndexBuffer(unsigned int size)
ibo_mem = (char*)realloc(ibo_mem,ibo_size);
}
}
return (unsigned int*)ibo_mem;
}
else
@ -316,7 +316,7 @@ unsigned int *FModelVertexBuffer::LockIndexBuffer(unsigned int size)
else
return (unsigned int*)glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
#ifdef __MOBILE__
}
}
#endif
}
else

View file

@ -357,7 +357,6 @@ namespace s3d
long oculusquest_rightHanded = vr_control_scheme < 10;
if (GetHandTransform(oculusquest_rightHanded ? 1 : 0, out))
{
//out->rotate(vr_weaponRotate, 1, 0, 0); - not needed, done in the C
if (!oculusquest_rightHanded)
out->scale(-1.0f, 1.0f, 1.0f);
return true;
@ -382,6 +381,7 @@ namespace s3d
}
//Fishbiter's Function.. Thank-you!!
static DVector3 MapAttackDir(AActor* actor, DAngle yaw, DAngle pitch)
{
LSMatrix44 mat;

View file

@ -56,7 +56,7 @@ CVAR(Float, vr_ipd, 0.064f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // METERS
CVAR(Float, vr_screendist, 0.80f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
// default conversion between (vertical) DOOM units and meters
CVAR(Float, vr_vunits_per_meter, 34.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
CVAR(Float, vr_vunits_per_meter, 30.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
CVAR(Float, vr_floor_offset, 0.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) // METERS
@ -64,8 +64,6 @@ CVAR(Int, vr_control_scheme, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_moveFollowsOffHand, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Bool, vr_drawControllers, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_weaponRotate, -30, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
CVAR(Float, vr_weaponScale, 1.0f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)

View file

@ -43,6 +43,7 @@
#include "r_data/models/models_ue1.h"
#include "r_data/models/models_obj.h"
#include "i_time.h"
#include "gl/stereo3d/gl_stereo3d.h"
#ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data
@ -192,6 +193,18 @@ void FModelRenderer::RenderHUDModel(DPSprite *psp, float ofsX, float ofsY)
// The model position and orientation has to be drawn independently from the position of the player,
// but we need to position it correctly in the world for light to work properly.
VSMatrix objectToWorldMatrix = GetViewToWorldMatrix();
if (s3d::Stereo3DMode::getCurrentMode().GetHandTransform(1, &objectToWorldMatrix))
{
float scale = 0.01f;
objectToWorldMatrix.scale(scale, scale, scale);
objectToWorldMatrix.translate(0, 5, 30);
}
else
{
DVector3 pos = playermo->Pos();
objectToWorldMatrix.translate(pos.X, pos.Z + 40, pos.Y);
objectToWorldMatrix.rotate(-playermo->Angles.Yaw.Degrees - 90, 0, 1, 0);
}
// Scaling model (y scale for a sprite means height, i.e. z in the world!).
objectToWorldMatrix.scale(smf->xscale, smf->zscale, smf->yscale);

View file

@ -40,8 +40,6 @@
#include <time.h>
extern bool disable_clock_gettime;
class cycle_t
{
public:
@ -52,21 +50,21 @@ public:
void Clock()
{
if (!disable_clock_gettime) {
#if 0
timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
Sec -= ts.tv_sec + ts.tv_nsec * 1e-9;
}
#endif
}
void Unclock() {
if (!disable_clock_gettime) {
#if 0
timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
Sec += ts.tv_sec + ts.tv_nsec * 1e-9;
}
#endif
}
double Time()

View file

@ -60,9 +60,9 @@ mwheelup weapprev
// Originally just for Heretic, Hexen, and Strife.
// I can't see why they shouldn't be for Doom or Chex either.
pgup +moveup
ins +movedown
pgdn +movedown
home land
pgdn +lookup
ins +lookup
del +lookdown
end centerview
@ -74,7 +74,7 @@ joy4 +use
// Xbox 360 / PS2 controllers
pad_a +use
pad_y +jump
pad_b +jump
rtrigger +attack
ltrigger +altattack
lshoulder weapprev

Binary file not shown.