Lots of change going on...

This commit is contained in:
Simon 2020-07-01 23:49:41 +01:00
parent 1f5a068b27
commit 8a4ad32dd1
19 changed files with 203 additions and 475 deletions

View file

@ -80,8 +80,6 @@ int GPU_LEVEL = 4;
int NUM_MULTI_SAMPLES = 1;
float SS_MULTIPLIER = 1.25f;
vec2_t cylinderSize = {1280, 720};
jclass clazz;
float radians(float deg) {
@ -133,12 +131,15 @@ LAMBDA1VR Stuff
================================================================================
*/
void Qcommon_Init (int argc, char **argv);
qboolean RTCWVR_useScreenLayer()
{
//TODO
return qtrue;//(showingScreenLayer || (cls.state != ca_connected && cls.state != ca_active) || cls.key_dest != key_game) || cl.cinematictime != 0;
return (qboolean)(showingScreenLayer ||
(cls.state == CA_CINEMATIC) ||
(cls.state == CA_LOADING) ||
(clc.demoplaying) ||
( Key_GetCatcher( ) & KEYCATCH_UI ) ||
( Key_GetCatcher( ) & KEYCATCH_CONSOLE ));
}
int runStatus = -1;
@ -582,6 +583,32 @@ void ovrFramebuffer_SetNone()
GL( gles_glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 ) );
}
GLsync syncBuff = NULL;
void GPUDropSync()
{
if (syncBuff != NULL)
{
glDeleteSync(syncBuff);
}
syncBuff = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
}
void GPUWaitSync()
{
if( syncBuff )
{
GLenum status = glClientWaitSync(syncBuff, GL_SYNC_FLUSH_COMMANDS_BIT, 1000 * 1000 * 50); // Wait for a max of 50ms...
if (status != GL_ALREADY_SIGNALED && status != GL_CONDITION_SATISFIED)
{
LOGE("Error on glClientWaitSync: %d\n", status);
}
glDeleteSync(syncBuff);
syncBuff = NULL;
}
}
void ovrFramebuffer_Resolve( ovrFramebuffer * frameBuffer )
{
// Discard the depth buffer, so the tiler won't need to write it back out to memory.
@ -590,6 +617,8 @@ void ovrFramebuffer_Resolve( ovrFramebuffer * frameBuffer )
// Flush this frame worth of commands.
glFlush();
GPUDropSync();
}
void ovrFramebuffer_Advance( ovrFramebuffer * frameBuffer )
@ -854,7 +883,7 @@ qboolean isMultiplayer()
/*
========================
Android_Vibrate
RTCWVR_Vibrate
========================
*/
@ -862,7 +891,7 @@ Android_Vibrate
float vibration_channel_duration[2] = {0.0f, 0.0f};
float vibration_channel_intensity[2] = {0.0f, 0.0f};
void Android_Vibrate( float duration, int channel, float intensity )
void RTCWVR_Vibrate( float duration, int channel, float intensity )
{
if (vibration_channel_duration[channel] > 0.0f)
return;
@ -1254,16 +1283,10 @@ int m_height;
qboolean R_SetMode( void );
void Android_GetScreenRes(int *width, int *height)
void RTCWVR_GetScreenRes(int *width, int *height)
{
if (RTCWVR_useScreenLayer())
{
*width = cylinderSize[0];
*height = cylinderSize[1];
} else {
*width = m_width;
*height = m_height;
}
*width = m_width;
*height = m_height;
}
void Android_MessageBox(const char *title, const char *text)
@ -1277,7 +1300,7 @@ void VR_Init()
{
//Initialise all our variables
playerYaw = 0.0f;
showingScreenLayer = qtrue;
showingScreenLayer = qfalse;
remote_movementSideways = 0.0f;
remote_movementForward = 0.0f;
remote_movementUp = 0.0f;
@ -1291,7 +1314,8 @@ void VR_Init()
//Create Cvars
vr_snapturn_angle = Cvar_Get( "vr_snapturn_angle", "45", CVAR_ARCHIVE);
vr_positional_factor = Cvar_Get( "vr_positional_factor", "2000", CVAR_ARCHIVE);
vr_reloadtimeoutms = Cvar_Get( "vr_reloadtimeoutms", "200", CVAR_ARCHIVE);
vr_positional_factor = Cvar_Get( "vr_positional_factor", "10", CVAR_ARCHIVE);
vr_walkdirection = Cvar_Get( "vr_walkdirection", "0", CVAR_ARCHIVE);
vr_weapon_pitchadjust = Cvar_Get( "vr_weapon_pitchadjust", "-20.0", CVAR_ARCHIVE);
vr_control_scheme = Cvar_Get( "vr_control_scheme", "0", CVAR_ARCHIVE);
@ -1300,13 +1324,6 @@ void VR_Init()
vr_weapon_stabilised = Cvar_Get( "vr_weapon_stabilised", "0.0", CVAR_LATCH);
vr_lasersight = Cvar_Get( "vr_lasersight", "0", CVAR_LATCH);
vr_comfort_mask = Cvar_Get( "vr_comfort_mask", "0.0", CVAR_ARCHIVE);
//The Engine (which is a derivative of Quake) uses a very specific unit size:
//Wolfenstein 3D, DOOM and QUAKE use the same coordinate/unit system:
//8 foot (96 inch) height wall == 64 units, 1.5 inches per pixel unit
//1.0 pixel unit / 1.5 inch == 0.666666 pixel units per inch
//This make a world scale of: 26.2467
vr_worldscale = Cvar_Get( "vr_worldscale", "26.2467", CVAR_ARCHIVE);
}

View file

@ -68,7 +68,7 @@ void interactWithTouchScreen(ovrTracking *tracking, ovrInputStateTrackedRemote *
//Called from engine code
qboolean RTCWVR_useScreenLayer();
void RTCWVR_GetScreenRes(uint32_t *width, uint32_t *height);
void RTCWVR_GetScreenRes(int *width, int *height);
void RTCWVR_Vibrate(float duration, int channel, float intensity );
qboolean RTCWVR_processMessageQueue();
void RTCWVR_FrameSetup();
@ -83,4 +83,7 @@ void RTCWVR_prepareEyeBuffer(int eye );
void RTCWVR_finishEyeBuffer(int eye );
void RTCWVR_submitFrame();
void GPUDropSync();
void GPUWaitSync();
#endif //vrcommon_h

View file

@ -59,321 +59,6 @@ void restoreRenderState( renderState * state )
}
/*
================================================================================
ovrGeometry
================================================================================
*/
enum VertexAttributeLocation
{
VERTEX_ATTRIBUTE_LOCATION_POSITION,
VERTEX_ATTRIBUTE_LOCATION_COLOR,
VERTEX_ATTRIBUTE_LOCATION_UV,
};
typedef struct
{
enum VertexAttributeLocation location;
const char * name;
} ovrVertexAttribute;
static ovrVertexAttribute ProgramVertexAttributes[] =
{
{ VERTEX_ATTRIBUTE_LOCATION_POSITION, "vertexPosition" },
{ VERTEX_ATTRIBUTE_LOCATION_COLOR, "vertexColor" },
{ VERTEX_ATTRIBUTE_LOCATION_UV, "vertexUv" },
};
static void ovrGeometry_Clear( ovrGeometry * geometry )
{
geometry->VertexBuffer = 0;
geometry->IndexBuffer = 0;
geometry->VertexArrayObject = 0;
geometry->VertexCount = 0;
geometry->IndexCount = 0;
for ( int i = 0; i < MAX_VERTEX_ATTRIB_POINTERS; i++ )
{
memset( &geometry->VertexAttribs[i], 0, sizeof( geometry->VertexAttribs[i] ) );
geometry->VertexAttribs[i].Index = -1;
}
}
static void ovrGeometry_CreateGroundPlane( ovrGeometry * geometry )
{
typedef struct
{
float positions[4][4];
unsigned char colors[4][4];
} ovrCubeVertices;
static const ovrCubeVertices cubeVertices =
{
// positions
{
{ 4.5f, -1.2f, 4.5f, 1.0f },
{ 4.5f, -1.2f, -4.5f, 1.0f },
{ -4.5f, -1.2f, -4.5f, 1.0f },
{ -4.5f, -1.2f, 4.5f, 1.0f }
},
// colors
{
{ 255, 0, 0, 255 },
{ 0, 255, 0, 255 },
{ 0, 0, 255, 255 },
{ 255, 255, 0, 255 },
},
};
static const unsigned short cubeIndices[6] =
{
0, 1, 2,
0, 2, 3,
};
geometry->VertexCount = 4;
geometry->IndexCount = 6;
geometry->VertexAttribs[0].Index = VERTEX_ATTRIBUTE_LOCATION_POSITION;
geometry->VertexAttribs[0].Size = 4;
geometry->VertexAttribs[0].Type = GL_FLOAT;
geometry->VertexAttribs[0].Normalized = false;
geometry->VertexAttribs[0].Stride = sizeof( cubeVertices.positions[0] );
geometry->VertexAttribs[0].Pointer = (const GLvoid *)offsetof( ovrCubeVertices, positions );
geometry->VertexAttribs[1].Index = VERTEX_ATTRIBUTE_LOCATION_COLOR;
geometry->VertexAttribs[1].Size = 4;
geometry->VertexAttribs[1].Type = GL_UNSIGNED_BYTE;
geometry->VertexAttribs[1].Normalized = true;
geometry->VertexAttribs[1].Stride = sizeof( cubeVertices.colors[0] );
geometry->VertexAttribs[1].Pointer = (const GLvoid *)offsetof( ovrCubeVertices, colors );
renderState state;
getCurrentRenderState(&state);
GL( glGenBuffers( 1, &geometry->VertexBuffer ) );
GL( glBindBuffer( GL_ARRAY_BUFFER, geometry->VertexBuffer ) );
GL( glBufferData( GL_ARRAY_BUFFER, sizeof( cubeVertices ), &cubeVertices, GL_STATIC_DRAW ) );
GL( glGenBuffers( 1, &geometry->IndexBuffer ) );
GL( glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, geometry->IndexBuffer ) );
GL( glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( cubeIndices ), cubeIndices, GL_STATIC_DRAW ) );
restoreRenderState(&state);
}
static void ovrGeometry_Destroy( ovrGeometry * geometry )
{
GL( glDeleteBuffers( 1, &geometry->IndexBuffer ) );
GL( glDeleteBuffers( 1, &geometry->VertexBuffer ) );
ovrGeometry_Clear( geometry );
}
static void ovrGeometry_CreateVAO( ovrGeometry * geometry )
{
renderState state;
getCurrentRenderState(&state);
GL( glGenVertexArrays( 1, &geometry->VertexArrayObject ) );
GL( glBindVertexArray( geometry->VertexArrayObject ) );
GL( glBindBuffer( GL_ARRAY_BUFFER, geometry->VertexBuffer ) );
for ( int i = 0; i < MAX_VERTEX_ATTRIB_POINTERS; i++ )
{
if ( geometry->VertexAttribs[i].Index != -1 )
{
GL( glEnableVertexAttribArray( geometry->VertexAttribs[i].Index ) );
GL( glVertexAttribPointer( geometry->VertexAttribs[i].Index, geometry->VertexAttribs[i].Size,
geometry->VertexAttribs[i].Type, geometry->VertexAttribs[i].Normalized,
geometry->VertexAttribs[i].Stride, geometry->VertexAttribs[i].Pointer ) );
}
}
GL( glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, geometry->IndexBuffer ) );
restoreRenderState(&state);
}
static void ovrGeometry_DestroyVAO( ovrGeometry * geometry )
{
GL( glDeleteVertexArrays( 1, &geometry->VertexArrayObject ) );
}
/*
================================================================================
ovrProgram
================================================================================
*/
typedef struct
{
enum
{
UNIFORM_VIEW_PROJ_MATRIX,
} index;
enum
{
UNIFORM_TYPE_VECTOR4,
UNIFORM_TYPE_MATRIX4X4,
UNIFORM_TYPE_INT,
UNIFORM_TYPE_BUFFER,
} type;
const char * name;
} ovrUniform;
static ovrUniform ProgramUniforms[] =
{
{ UNIFORM_VIEW_PROJ_MATRIX, UNIFORM_TYPE_MATRIX4X4, "viewProjectionMatrix" },
};
static void ovrProgram_Clear( ovrProgram * program )
{
program->Program = 0;
program->VertexShader = 0;
program->FragmentShader = 0;
memset( program->UniformLocation, 0, sizeof( program->UniformLocation ) );
memset( program->UniformBinding, 0, sizeof( program->UniformBinding ) );
memset( program->Textures, 0, sizeof( program->Textures ) );
}
static bool ovrProgram_Create( ovrProgram * program, const char * vertexSource, const char * fragmentSource )
{
GLint r;
GL( program->VertexShader = glCreateShader( GL_VERTEX_SHADER ) );
GL( glShaderSource( program->VertexShader, 1, &vertexSource, 0 ) );
GL( glCompileShader( program->VertexShader ) );
GL( glGetShaderiv( program->VertexShader, GL_COMPILE_STATUS, &r ) );
if ( r == GL_FALSE )
{
GLchar msg[4096];
GL( glGetShaderInfoLog( program->VertexShader, sizeof( msg ), 0, msg ) );
ALOGE( "%s\n%s\n", vertexSource, msg );
return false;
}
GL( program->FragmentShader = glCreateShader( GL_FRAGMENT_SHADER ) );
GL( glShaderSource( program->FragmentShader, 1, &fragmentSource, 0 ) );
GL( glCompileShader( program->FragmentShader ) );
GL( glGetShaderiv( program->FragmentShader, GL_COMPILE_STATUS, &r ) );
if ( r == GL_FALSE )
{
GLchar msg[4096];
GL( glGetShaderInfoLog( program->FragmentShader, sizeof( msg ), 0, msg ) );
ALOGE( "%s\n%s\n", fragmentSource, msg );
return false;
}
GL( program->Program = glCreateProgram() );
GL( glAttachShader( program->Program, program->VertexShader ) );
GL( glAttachShader( program->Program, program->FragmentShader ) );
// Bind the vertex attribute locations.
for ( int i = 0; i < sizeof( ProgramVertexAttributes ) / sizeof( ProgramVertexAttributes[0] ); i++ )
{
GL( glBindAttribLocation( program->Program, ProgramVertexAttributes[i].location, ProgramVertexAttributes[i].name ) );
}
GL( glLinkProgram( program->Program ) );
GL( glGetProgramiv( program->Program, GL_LINK_STATUS, &r ) );
if ( r == GL_FALSE )
{
GLchar msg[4096];
GL( glGetProgramInfoLog( program->Program, sizeof( msg ), 0, msg ) );
ALOGE( "Linking program failed: %s\n", msg );
return false;
}
int numBufferBindings = 0;
// Get the uniform locations.
memset( program->UniformLocation, -1, sizeof( program->UniformLocation ) );
for ( int i = 0; i < sizeof( ProgramUniforms ) / sizeof( ProgramUniforms[0] ); i++ )
{
const int uniformIndex = ProgramUniforms[i].index;
if ( ProgramUniforms[i].type == UNIFORM_TYPE_BUFFER )
{
GL( program->UniformLocation[uniformIndex] = glGetUniformBlockIndex( program->Program, ProgramUniforms[i].name ) );
program->UniformBinding[uniformIndex] = numBufferBindings++;
GL( glUniformBlockBinding( program->Program, program->UniformLocation[uniformIndex], program->UniformBinding[uniformIndex] ) );
}
else
{
GL( program->UniformLocation[uniformIndex] = glGetUniformLocation( program->Program, ProgramUniforms[i].name ) );
program->UniformBinding[uniformIndex] = program->UniformLocation[uniformIndex];
}
}
renderState state;
getCurrentRenderState(&state);
GL( glUseProgram( program->Program ) );
// Get the texture locations.
for ( int i = 0; i < MAX_PROGRAM_TEXTURES; i++ )
{
char name[32];
sprintf( name, "Texture%i", i );
program->Textures[i] = glGetUniformLocation( program->Program, name );
if ( program->Textures[i] != -1 )
{
GL( glUniform1i( program->Textures[i], i ) );
}
}
restoreRenderState(&state);
return true;
}
static void ovrProgram_Destroy( ovrProgram * program )
{
if ( program->Program != 0 )
{
GL( glDeleteProgram( program->Program ) );
program->Program = 0;
}
if ( program->VertexShader != 0 )
{
GL( glDeleteShader( program->VertexShader ) );
program->VertexShader = 0;
}
if ( program->FragmentShader != 0 )
{
GL( glDeleteShader( program->FragmentShader ) );
program->FragmentShader = 0;
}
}
static const char VERTEX_SHADER[] =
"#version 300 es\n"
"in vec3 vertexPosition;\n"
"in vec4 vertexColor;\n"
"uniform mat4 viewProjectionMatrix;\n"
"out vec4 fragmentColor;\n"
"void main()\n"
"{\n"
" gl_Position = viewProjectionMatrix * vec4( vertexPosition, 1.0 );\n"
" fragmentColor = vertexColor;\n"
"}\n";
static const char FRAGMENT_SHADER[] =
"#version 300 es\n"
"in lowp vec4 fragmentColor;\n"
"out lowp vec4 outColor;\n"
"void main()\n"
"{\n"
" outColor = fragmentColor;\n"
"}\n";
/*
================================================================================
@ -385,9 +70,6 @@ ovrScene
void ovrScene_Clear( ovrScene * scene )
{
scene->CreatedScene = false;
scene->CreatedVAOs = false;
ovrProgram_Clear( &scene->Program );
ovrGeometry_Clear( &scene->GroundPlane );
ovrRenderer_Clear( &scene->CylinderRenderer );
scene->CylinderWidth = 0;
@ -399,33 +81,8 @@ bool ovrScene_IsCreated( ovrScene * scene )
return scene->CreatedScene;
}
void ovrScene_CreateVAOs( ovrScene * scene )
{
if ( !scene->CreatedVAOs )
{
ovrGeometry_CreateVAO( &scene->GroundPlane );
scene->CreatedVAOs = true;
}
}
void ovrScene_DestroyVAOs( ovrScene * scene )
{
if ( scene->CreatedVAOs )
{
ovrGeometry_DestroyVAO( &scene->GroundPlane );
scene->CreatedVAOs = false;
}
}
void ovrScene_Create( int width, int height, ovrScene * scene, const ovrJava * java )
{
// Simple ground plane geometry.
{
ovrProgram_Create( &scene->Program, VERTEX_SHADER, FRAGMENT_SHADER );
ovrGeometry_CreateGroundPlane( &scene->GroundPlane );
ovrScene_CreateVAOs( scene );
}
// Create Cylinder renderer
{
scene->CylinderWidth = width;
@ -440,9 +97,6 @@ void ovrScene_Create( int width, int height, ovrScene * scene, const ovrJava * j
void ovrScene_Destroy( ovrScene * scene )
{
ovrScene_DestroyVAOs( scene );
ovrProgram_Destroy( &scene->Program );
ovrGeometry_Destroy( &scene->GroundPlane );
ovrRenderer_Destroy( &scene->CylinderRenderer );
scene->CreatedScene = false;
@ -497,8 +151,8 @@ ovrLayerCylinder2 BuildCylinderLayer( ovrRenderer * cylinderRenderer,
const float density = 4500.0f;
const float rotateYaw = 0.0f;
const float radius = 2.0f;
const ovrVector3f translation = { 0.0f, playerHeight, -0.5f };
const float radius = 3.0f;
const ovrVector3f translation = { 0.0f, playerHeight/2, -5.0f };
ovrMatrix4f cylinderTransform =
CylinderModelMatrix( textureWidth, textureHeight, translation,

View file

@ -178,9 +178,6 @@ ovrScene
typedef struct
{
bool CreatedScene;
bool CreatedVAOs;
ovrProgram Program;
ovrGeometry GroundPlane;
//Proper renderer for stereo rendering to the cylinder layer
ovrRenderer CylinderRenderer;
@ -189,11 +186,8 @@ typedef struct
int CylinderHeight;
} ovrScene;
bool ovrScene_IsCreated( ovrScene * scene );
void ovrScene_Clear( ovrScene * scene );
void ovrScene_Create( int width, int height, ovrScene * scene, const ovrJava * java );
void ovrScene_CreateVAOs( ovrScene * scene );
void ovrScene_DestroyVAOs( ovrScene * scene );
void ovrScene_Destroy( ovrScene * scene );
/*

View file

@ -1,11 +1,11 @@
cvar_t *vr_snapturn_angle;
cvar_t *vr_reloadtimeoutms;
cvar_t *vr_positional_factor;
cvar_t *vr_walkdirection;
cvar_t *vr_weapon_pitchadjust;
cvar_t *vr_lasersight;
cvar_t *vr_control_scheme;
cvar_t *vr_height_adjust;
cvar_t *vr_worldscale;
cvar_t *vr_weaponscale;
cvar_t *vr_weapon_stabilised;
cvar_t *vr_comfort_mask;

View file

@ -156,18 +156,14 @@ void interactWithTouchScreen(ovrTracking *tracking, ovrInputStateTrackedRemote *
if (yaw >= 180.0f) yaw -= 180.0f;
if (yaw <= -180.0f) yaw += 180.0f;
if (yaw > -40.0f && yaw < 40.0f &&
remoteAngles[PITCH] > -22.5f && remoteAngles[PITCH] < 22.5f) {
if (yaw > -45.0f && yaw < 45.0f &&
remoteAngles[PITCH] > -15.0f && remoteAngles[PITCH] < 75.0f) {
int newRemoteTrigState = (newState->Buttons & ovrButton_Trigger) != 0;
int prevRemoteTrigState = (oldState->Buttons & ovrButton_Trigger) != 0;
float touchX = (-yaw + 40.0f) / 80.0f;
float touchY = (remoteAngles[PITCH] + 22.5f) / 45.0f;
if (newRemoteTrigState != prevRemoteTrigState)
{
}
float touchX = (-yaw + 45.0f) / 90.0f;
float touchY = (remoteAngles[PITCH] + 15.0f) / 90.0f;
PortableMouseAbs(touchX, touchY);
}
}

View file

@ -32,16 +32,25 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
Cvar_Set("hand", vr_control_scheme->value < 10 ? "0" : "1");
//Get the cvar
sv_cheats = Cvar_Get("cheats", "0", CVAR_ARCHIVE);
sv_cheats = Cvar_Get("cheats", "1", CVAR_ARCHIVE);
static qboolean dominantGripPushed = false;
static float dominantGripPushTime = 0.0f;
static qboolean inventoryManagementMode = false;
static int grabMeleeWeapon = 0;
static bool canUseBackpack = false;
//Menu button
//switch to screen layer override
if ((pOffTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
(pOffTrackedRemoteOld->Buttons & ovrButton_Joystick)) {
showingScreenLayer = !showingScreenLayer;
}
//Menu button
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old, ovrButton_Enter, K_ESCAPE);
if ( Key_GetCatcher( ) & KEYCATCH_UI )
if ( RTCWVR_useScreenLayer() )
{
interactWithTouchScreen(pDominantTracking, pDominantTrackedRemoteNew, pDominantTrackedRemoteOld);
@ -87,10 +96,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
const ovrQuatf quatRemote = pDominantTracking->HeadPose.Pose.Orientation;
vec3_t rotation = {0};
rotation[PITCH] = vr_weapon_pitchadjust->value;
QuatToYawPitchRoll(quatRemote, rotation, weaponangles);
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, weaponangles);
weaponangles[YAW] += (cl.viewangles[YAW] - hmdorientation[YAW]);
weaponangles[ROLL] *= -1.0f;
@ -107,11 +115,57 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
}
}
static bool finishReloadNextFrame = false;
if (finishReloadNextFrame)
{
sendButtonActionSimple("-reload");
finishReloadNextFrame = false;
}
if (pDominantTracking->Status & (VRAPI_TRACKING_STATUS_POSITION_TRACKED | VRAPI_TRACKING_STATUS_POSITION_VALID)) {
canUseBackpack = false;
}
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
canUseBackpack = true;
}
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_GripTrigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_GripTrigger)) {
sendButtonActionSimple("inven");
inventoryManagementMode = (pDominantTrackedRemoteNew->Buttons & ovrButton_GripTrigger) > 0;
dominantGripPushed = (pDominantTrackedRemoteNew->Buttons &
ovrButton_GripTrigger) != 0;
if (grabMeleeWeapon == 0)
{
if (pDominantTracking->Status & (VRAPI_TRACKING_STATUS_POSITION_TRACKED | VRAPI_TRACKING_STATUS_POSITION_VALID)) {
if (dominantGripPushed) {
dominantGripPushTime = GetTimeInMilliSeconds();
} else {
if ((GetTimeInMilliSeconds() - dominantGripPushTime) <
vr_reloadtimeoutms->integer) {
sendButtonActionSimple("+reload");
finishReloadNextFrame = true;
}
}
} else{
if (dominantGripPushed) {
//Initiate crowbar from backpack mode
sendButtonActionSimple("weapon0");
int channel = (vr_control_scheme->integer >= 10) ? 0 : 1;
RTCWVR_Vibrate(80, channel, 0.8); // vibrate to let user know they switched
grabMeleeWeapon = 1;
}
}
} else if (grabMeleeWeapon == 1 && !dominantGripPushed) {
//Restores last used weapon
sendButtonActionSimple("lastinv");
grabMeleeWeapon = 0;
}
}
}
@ -150,12 +204,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
//This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the
//player is facing for positional tracking
float multiplier = 1.0;//(vr_positional_factor->value) /
//((pOffTrackedRemoteNew->Buttons & ovrButton_Trigger) ? 1.5f : 1.0f);
vec2_t v;
rotateAboutOrigin(-positionDeltaThisFrame[0] * multiplier,
positionDeltaThisFrame[2] * multiplier, /*cl.viewangles[YAW]*/ - hmdorientation[YAW], v);
rotateAboutOrigin(-positionDeltaThisFrame[0] * vr_positional_factor->value,
positionDeltaThisFrame[2] * vr_positional_factor->value, - hmdorientation[YAW], v);
positional_movementSideways = v[0];
positional_movementForward = v[1];
@ -167,27 +218,37 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
handleTrackedControllerButton(pDominantTrackedRemoteNew,
pDominantTrackedRemoteOld, domButton2, K_SPACE);
//We need to record if we have started firing primary so that releasing trigger will stop firing, if user has pushed grip
//in meantime, then it wouldn't stop the gun firing and it would get stuck
static bool firingPrimary = false;
{
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) {
if (!firingPrimary && dominantGripPushed && (GetTimeInMilliSeconds() - dominantGripPushTime) > vr_reloadtimeoutms->integer)
{
//Fire Secondary
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) {
firingPrimary = (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger);
sendButtonAction("+attack2", (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger));
}
}
else
{
//Fire Primary
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) {
if (inventoryManagementMode)
{
if (firingPrimary)
sendButtonActionSimple("invuse");
}
else
{
sendButtonAction("+attack", firingPrimary ? 1 : 0);
}
}
}
firingPrimary = (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger);
sendButtonAction("+attack", firingPrimary);
}
// we need to release secondary fire if dominantGripPushed has been released before releasing trigger -> should fix the gun jamming and non stop firing secondary attack bug
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger) &&
(pDominantTrackedRemoteNew->Buttons& ovrButton_Trigger) == false)
{
sendButtonAction("+attack2", false);
}
}
//Duck with A
if ((pDominantTrackedRemoteNew->Buttons & domButton1) !=
@ -206,26 +267,11 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
if (!itemSwitched) {
if (between(0.8f, pDominantTrackedRemoteNew->Joystick.y, 1.0f))
{
if (inventoryManagementMode)
{
sendButtonActionSimple("invprev");
}
else
{
sendButtonActionSimple("weapprev");
}
sendButtonActionSimple("weapprev");
}
else
{
if (inventoryManagementMode)
{
sendButtonActionSimple("invnext");
}
else
{
sendButtonActionSimple("weapnext");
}
sendButtonActionSimple("weapnext");
}
itemSwitched = true;
}
@ -241,7 +287,15 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
pOffTracking->HeadPose.Pose.Position.y,
pOffTracking->HeadPose.Pose.Position.z);
//Laser-sight
//"Use" (open doors etc)
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Joystick)) {
sendButtonAction("+activate", (pDominantTrackedRemoteNew->Buttons & ovrButton_Joystick) ? 1 : 0);
}
//Laser-sight - not implemented
/*
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Joystick)
&& (pDominantTrackedRemoteNew->Buttons & ovrButton_Joystick)) {
@ -253,6 +307,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
// Cvar_ForceSet("vr_lasersight", "1.0");
}
}
*/
//Apply a filter and quadratic scaler so small movements are easier to make
float dist = length(pOffTrackedRemoteNew->Joystick.x, pOffTrackedRemoteNew->Joystick.y);
@ -272,24 +327,27 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
remote_movementSideways,
remote_movementForward);
//show help computer while X/A pressed
//Kick!
if ((pOffTrackedRemoteNew->Buttons & offButton1) !=
(pOffTrackedRemoteOld->Buttons & offButton1)) {
sendButtonActionSimple("cmd help");
sendButtonAction("+kick", (pOffTrackedRemoteNew->Buttons & offButton1));
}
//notebook
if ((pOffTrackedRemoteNew->Buttons & offButton2) !=
(pOffTrackedRemoteOld->Buttons & offButton2)) {
sendButtonActionSimple("notebook");
}
//Use (Action)
if ((pOffTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
(pOffTrackedRemoteOld->Buttons & ovrButton_Joystick)
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");
}
}
//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

@ -247,7 +247,7 @@ static qboolean GLW_StartDriverAndSetMode( const char *drivername,
}
void Android_GetScreenRes(int *width, int *height);
void RTCWVR_GetScreenRes(int *width, int *height);
/*
** GLW_InitExtensions
@ -478,7 +478,7 @@ void GLimp_Init( void ) {
int android_screen_width;
int android_screen_height;
Android_GetScreenRes(&android_screen_width, &android_screen_height);
RTCWVR_GetScreenRes(&android_screen_width, &android_screen_height);
glConfig.vidWidth = android_screen_width;
glConfig.vidHeight = android_screen_height;
glConfig.colorBits = 32;

View file

@ -225,12 +225,12 @@ void PortableMouse(float dx,float dy)
}
int absx=0,absy=0;
Android_GetScreenRes(int *width, int *height);
RTCWVR_GetScreenRes(int *width, int *height);
void PortableMouseAbs(float x,float y)
{
int width;
int height;
Android_GetScreenRes(&width, &height);
RTCWVR_GetScreenRes(&width, &height);
absx = x * width;
absy = y * height;
}

View file

@ -3535,7 +3535,7 @@ CG_DrawActive
Perform all drawing needed to completely fill the screen
=====================
*/
void CG_DrawActive( stereoFrame_t stereoView ) {
void CG_DrawActive( int stereoView ) {
float separation;
vec3_t baseOrg;
@ -3561,22 +3561,13 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
return;
}
switch ( stereoView ) {
case STEREO_CENTER:
separation = 0;
break;
case STEREO_LEFT:
separation = -cg_stereoSeparation.value / 2;
break;
case STEREO_RIGHT:
separation = cg_stereoSeparation.value / 2;
break;
default:
separation = 0;
CG_Error( "CG_DrawActive: Undefined stereoView" );
}
separation = stereoView == 1 ?
cg_worldScale.value * (-cg_stereoSeparation.value / 2) : //left
cg_worldScale.value * (cg_stereoSeparation.value / 2); // right
cg.refdef.worldscale = cg_worldScale.value;
// clear around the rendered view if sized down
// CG_TileClear(); // (SA) moved down
@ -3586,6 +3577,10 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg );
}
cg.refdef.vieworg[2] -= cg.predictedPlayerState.viewheight;
cg.refdef.glfog.registered = 0; // make sure it doesn't use fog from another scene
/*
// NERVE - SMF - activate limbo menu and draw small 3d window

View file

@ -1703,6 +1703,7 @@ extern vmCvar_t cg_thirdPersonRange;
extern vmCvar_t cg_thirdPersonAngle;
extern vmCvar_t cg_thirdPerson;
extern vmCvar_t cg_stereoSeparation;
extern vmCvar_t cg_worldScale;
extern vmCvar_t cg_lagometer;
extern vmCvar_t cg_drawAttacker;
extern vmCvar_t cg_synchronousClients;
@ -1893,7 +1894,7 @@ void CG_AddLagometerSnapshotInfo( snapshot_t *snap );
void CG_CenterPrint( const char *str, int y, int charWidth );
void CG_ObjectivePrint( const char *str, int charWidth, int team ); // NERVE - SMF
void CG_DrawHead( float x, float y, float w, float h, int clientNum, vec3_t headAngles );
void CG_DrawActive( stereoFrame_t stereoView );
void CG_DrawActive( int stereoView );
void CG_DrawFlagModel( float x, float y, float w, float h, int team );
void CG_DrawTeamBackground( int x, int y, int w, int h, float alpha, int team );

View file

@ -185,6 +185,7 @@ vmCvar_t cg_thirdPerson;
vmCvar_t cg_thirdPersonRange;
vmCvar_t cg_thirdPersonAngle;
vmCvar_t cg_stereoSeparation;
vmCvar_t cg_worldScale;
vmCvar_t cg_lagometer;
vmCvar_t cg_drawAttacker;
vmCvar_t cg_synchronousClients;
@ -301,10 +302,11 @@ cvarTable_t cvarTable[] = {
{ &cg_zoomStepSniper, "cg_zoomStepSniper", "2", CVAR_ARCHIVE },
{ &cg_zoomStepSnooper, "cg_zoomStepSnooper", "5", CVAR_ARCHIVE },
{ &cg_zoomStepFG, "cg_zoomStepFG", "10", CVAR_ARCHIVE }, //----(SA) added
{ &cg_fov, "cg_fov", "104", CVAR_ARCHIVE | CVAR_CHEAT }, // JPW NERVE added cheat protect NOTE: there is already a dmflag (DF_FIXED_FOV) to allow server control of this cheat
{ &cg_fov, "cg_fov", "104", CVAR_ARCHIVE }, // JPW NERVE added cheat protect NOTE: there is already a dmflag (DF_FIXED_FOV) to allow server control of this cheat
{ &cg_viewsize, "cg_viewsize", "100", CVAR_ARCHIVE },
{ &cg_letterbox, "cg_letterbox", "0", CVAR_TEMP }, //----(SA) added
{ &cg_stereoSeparation, "cg_stereoSeparation", "0.4", CVAR_ARCHIVE },
{ &cg_stereoSeparation, "cg_stereoSeparation", "0.065", CVAR_ARCHIVE },
{ &cg_worldScale, "cg_worldScale", "35.0", CVAR_ARCHIVE },
{ &cg_shadows, "cg_shadows", "1", CVAR_ARCHIVE },
{ &cg_gibs, "cg_gibs", "1", CVAR_ARCHIVE },
{ &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE },
@ -334,7 +336,7 @@ cvarTable_t cvarTable[] = {
{ &cg_crosshairY, "cg_crosshairY", "0", CVAR_ARCHIVE },
{ &cg_brassTime, "cg_brassTime", "1250", CVAR_ARCHIVE },
{ &cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE },
{ &cg_reticles, "cg_reticles", "1", CVAR_CHEAT },
{ &cg_reticles, "cg_reticles", "0", CVAR_CHEAT },
{ &cg_reticleBrightness, "cg_reticleBrightness", "0.7", CVAR_ARCHIVE },
{ &cg_markTime, "cg_marktime", "20000", CVAR_ARCHIVE },
{ &cg_lagometer, "cg_lagometer", "1", CVAR_ARCHIVE },

View file

@ -565,8 +565,8 @@ static void CG_OffsetFirstPersonView( void ) {
// if dead, fix the angle and don't add any kick
if ( cg.snap->ps.stats[STAT_HEALTH] <= 0 ) {
angles[ROLL] = 40;
angles[PITCH] = -15;
//angles[ROLL] = 40;
//angles[PITCH] = -15;
angles[YAW] = cg.snap->ps.stats[STAT_DEAD_YAW];
origin[2] += cg.predictedPlayerState.viewheight;
return;
@ -1070,7 +1070,7 @@ static int CG_CalcViewValues( void ) {
if ( cg.cameraMode ) {
vec3_t origin, angles;
float fov = 90;
float fov = 104;
float x;
if ( trap_getCameraInfo( CAM_PRIMARY, cg.time, &origin, &angles, &fov ) ) {

View file

@ -215,6 +215,7 @@ typedef struct {
float fov_x, fov_y;
vec3_t vieworg;
vec3_t viewaxis[3]; // transformation matrix
float worldscale;
int time; // time in milliseconds for shader effects and other time dependent rendering issues
int rdflags; // RDF_NOWORLDMODEL, etc

View file

@ -540,6 +540,7 @@ void RTCWVR_processHaptics();
void RTCWVR_getHMDOrientation();
qboolean RTCWVR_processMessageQueue();
void RTCWVR_getTrackedRemotesOrientation();
void GPUWaitSync();
void SCR_UpdateScreen( void ) {
static int recursive;
@ -571,6 +572,8 @@ void SCR_UpdateScreen( void ) {
RTCWVR_processHaptics();
GPUWaitSync();
//Draw twice for Quest
SCR_DrawScreenField( STEREO_LEFT );
RTCWVR_finishEyeBuffer(0);

View file

@ -80,7 +80,7 @@ float pm_waterWadeScale = 0.70;
float pm_slagSwimScale = 0.30;
float pm_slagWadeScale = 0.70;
float pm_accelerate = 10;
float pm_accelerate = 10000; // Boosted for VR
float pm_airaccelerate = 1;
float pm_wateraccelerate = 4;
float pm_slagaccelerate = 2;
@ -3732,7 +3732,7 @@ void PM_UpdateViewAngles( playerState_t *ps, usercmd_t *cmd, void( trace ) ( tra
// circularly clamp the angles with deltas
for ( i = 0 ; i < 3 ; i++ ) {
temp = cmd->angles[i] + ps->delta_angles[i];
temp = cmd->angles[i] + (i == YAW ? ps->delta_angles[i] : 0);
if ( i == PITCH ) {
// don't let the player look up or down more than 90 degrees
if ( temp > 16000 ) {

View file

@ -27,6 +27,7 @@ If you have questions concerning this license or the applicable additional terms
*/
#include <src/client/client.h>
#include "tr_local.h"
int r_firstSceneDrawSurf;
@ -405,6 +406,8 @@ Rendering a scene may require multiple views to be rendered
to handle mirrors,
@@@@@@@@@@@@@@@@@@@@@
*/
extern vec3_t hmdPosition;
extern cvar_t *vr_worldscale;
void RE_RenderScene( const refdef_t *fd ) {
viewParms_t parms;
int startTime;
@ -524,6 +527,7 @@ void RE_RenderScene( const refdef_t *fd ) {
parms.fovY = tr.refdef.fov_y;
VectorCopy( fd->vieworg, parms.or.origin );
//AnglesToAxis( cl.viewangles, parms.or.axis ); // Just use our known client view angles
VectorCopy( fd->viewaxis[0], parms.or.axis[0] );
VectorCopy( fd->viewaxis[1], parms.or.axis[1] );
VectorCopy( fd->viewaxis[2], parms.or.axis[2] );

View file

@ -285,11 +285,11 @@ static void SV_Map_f( void ) {
// if the level was started with "map <levelname>", then
// cheats will not be allowed. If started with "devmap <levelname>"
// then cheats will be allowed
if ( cheat ) {
// if ( cheat ) {
Cvar_Set( "sv_cheats", "1" );
} else {
Cvar_Set( "sv_cheats", "0" );
}
// } else {
// Cvar_Set( "sv_cheats", "0" );
// }
}

View file

@ -919,7 +919,7 @@ void SV_Init( void ) {
// systeminfo
#ifdef PANDORA
// allow easy cheating by aving sv_cheats R/W
Cvar_Get( "sv_cheats", "0", CVAR_SYSTEMINFO );
Cvar_Get( "sv_cheats", "1", CVAR_SYSTEMINFO );
#else
Cvar_Get( "sv_cheats", "0", CVAR_SYSTEMINFO | CVAR_ROM );
#endif