diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 28184fdb..96b89f44 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="42" + android:versionName="0.29.3"> diff --git a/android/app/src/main/assets/pakQ3Q.pk3 b/android/app/src/main/assets/pakQ3Q.pk3 index ded8a313..b8346b47 100644 Binary files a/android/app/src/main/assets/pakQ3Q.pk3 and b/android/app/src/main/assets/pakQ3Q.pk3 differ diff --git a/android/app/src/main/cpp/code/cgame/cg_draw.c b/android/app/src/main/cpp/code/cgame/cg_draw.c index c1d3a668..4af3137b 100644 --- a/android/app/src/main/cpp/code/cgame/cg_draw.c +++ b/android/app/src/main/cpp/code/cgame/cg_draw.c @@ -539,7 +539,7 @@ static void CG_DrawStatusBar( void ) { { 0.5f, 0.5f, 0.5f, 1.0f }, // weapon firing { 1.0f, 1.0f, 1.0f, 1.0f } }; // health > 100 - if ( cg_drawStatus.integer == 0 ) { + if ( trap_Cvar_VariableValue( "vr_hudDrawStatus" ) == 0 ) { return; } @@ -2662,10 +2662,6 @@ static void CG_DrawHUD2D() return; } - if ( cg_draw2D.integer == 0 ) { - return; - } - if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { CG_DrawIntermission(); return; @@ -2685,7 +2681,7 @@ static void CG_DrawHUD2D() } #ifdef MISSIONPACK - if ( cg_drawStatus.integer ) { + if ( trap_Cvar_VariableValue( "vr_hudDrawStatus" ) != 0.0f ) { Menu_PaintAll(); CG_DrawTimedMenus(); } @@ -2758,10 +2754,6 @@ static void CG_DrawScreen2D() return; } - if ( cg_draw2D.integer == 0 ) { - return; - } - if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { return; } @@ -2898,6 +2890,7 @@ void CG_DrawActive( void ) { } //Now draw the HUD shader in the world + if (trap_Cvar_VariableValue("vr_hudDrawStatus") == 1.0f) { refEntity_t ent; trace_t trace; @@ -2917,13 +2910,15 @@ void CG_DrawActive( void ) { static float hmd_yaw_x = 0.0f; static float hmd_yaw_y = 1.0f; + static float prevPitch = 0.0f; { - hmd_yaw_x = 0.97f * hmd_yaw_x + 0.03f * cosf(DEG2RAD(vr->hmdorientation[YAW])); - hmd_yaw_y = 0.97f * hmd_yaw_y + 0.03f * sinf(DEG2RAD(vr->hmdorientation[YAW])); + hmd_yaw_x = 0.98f * hmd_yaw_x + 0.02f * cosf(DEG2RAD(vr->hmdorientation[YAW])); + hmd_yaw_y = 0.98f * hmd_yaw_y + 0.02f * sinf(DEG2RAD(vr->hmdorientation[YAW])); } angles[YAW] = viewYaw + RAD2DEG(atan2(hmd_yaw_y, hmd_yaw_x)); - angles[PITCH] = 0; + angles[PITCH] = 0.98f * prevPitch + 0.02f * vr->hmdorientation[PITCH]; + prevPitch = angles[PITCH]; angles[ROLL] = 0; AngleVectors(angles, forward, right, up); @@ -2955,6 +2950,8 @@ void CG_DrawActive( void ) { VectorCopy( baseOrg, cg.refdef.vieworg ); { + cg.drawingHUD = qtrue; + //Tell renderer we want to draw to the HUD buffer trap_R_HUDBufferStart(); @@ -2963,6 +2960,8 @@ void CG_DrawActive( void ) { trap_R_HUDBufferEnd(); + cg.drawingHUD = qfalse; + //Now draw the screen 2D stuff CG_DrawScreen2D(); } diff --git a/android/app/src/main/cpp/code/cgame/cg_drawtools.c b/android/app/src/main/cpp/code/cgame/cg_drawtools.c index 1d8aa2ea..15d5ee7a 100644 --- a/android/app/src/main/cpp/code/cgame/cg_drawtools.c +++ b/android/app/src/main/cpp/code/cgame/cg_drawtools.c @@ -46,8 +46,8 @@ Adjusted for resolution and screen aspect ratio */ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) { -/* if ( cg.snap == NULL || - cg.snap->ps.pm_type != PM_INTERMISSION)*/ + if ( trap_Cvar_VariableValue("vr_hudDrawStatus") != 2.0f || + !cg.drawingHUD) { // scale for screen sizes *x *= cgs.screenXScale; @@ -65,11 +65,10 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) *h *= cgs.screenYScale; } } - /* else // scale to clearly visible portion of VR screen { - float screenXScale = cgs.screenXScale / 2.75f; - float screenYScale = cgs.screenYScale / 2.25f; + float screenXScale = cgs.screenXScale / 2.8f; + float screenYScale = cgs.screenYScale / 2.3f; *x *= screenXScale; *y *= screenYScale; @@ -90,7 +89,6 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) *y += (cg.refdef.height - (480 * screenYScale)) / 2.0f - trap_Cvar_VariableValue("vr_hudYOffset"); } - */ } /* diff --git a/android/app/src/main/cpp/code/cgame/cg_local.h b/android/app/src/main/cpp/code/cgame/cg_local.h index 1922473c..7e995881 100644 --- a/android/app/src/main/cpp/code/cgame/cg_local.h +++ b/android/app/src/main/cpp/code/cgame/cg_local.h @@ -499,6 +499,8 @@ typedef struct { qboolean renderingThirdPerson; // during deaths, chasecams, etc + qboolean drawingHUD; + // prediction state qboolean hyperspace; // true if prediction has hit a trigger_teleport playerState_t predictedPlayerState; @@ -1145,8 +1147,6 @@ extern vmCvar_t cg_crosshairX; extern vmCvar_t cg_crosshairY; extern vmCvar_t cg_crosshairSize; extern vmCvar_t cg_crosshairHealth; -extern vmCvar_t cg_drawStatus; -extern vmCvar_t cg_draw2D; extern vmCvar_t cg_animSpeed; extern vmCvar_t cg_debugAnim; extern vmCvar_t cg_debugPosition; diff --git a/android/app/src/main/cpp/code/cgame/cg_main.c b/android/app/src/main/cpp/code/cgame/cg_main.c index 2e64dc3f..0cf045af 100644 --- a/android/app/src/main/cpp/code/cgame/cg_main.c +++ b/android/app/src/main/cpp/code/cgame/cg_main.c @@ -125,8 +125,6 @@ vmCvar_t cg_crosshairSize; vmCvar_t cg_crosshairX; vmCvar_t cg_crosshairY; vmCvar_t cg_crosshairHealth; -vmCvar_t cg_draw2D; -vmCvar_t cg_drawStatus; vmCvar_t cg_animSpeed; vmCvar_t cg_debugAnim; vmCvar_t cg_debugPosition; @@ -232,12 +230,10 @@ static cvarTable_t cvarTable[] = { { &cg_playerShadow, "cg_playerShadow", "1", CVAR_ARCHIVE }, { &cg_gibs, "cg_gibs", "1", CVAR_ARCHIVE }, { &cg_megagibs, "cg_megagibs", "0", CVAR_ARCHIVE }, - { &cg_draw2D, "cg_draw2D", "1", CVAR_ARCHIVE }, - { &cg_drawStatus, "cg_drawStatus", "1", CVAR_ARCHIVE }, { &cg_drawTimer, "cg_drawTimer", "0", CVAR_ARCHIVE }, { &cg_drawFPS, "cg_drawFPS", "0", CVAR_ARCHIVE }, { &cg_drawSnapshot, "cg_drawSnapshot", "0", CVAR_ARCHIVE }, - { &cg_draw3dIcons, "cg_draw3dIcons", "1", CVAR_ARCHIVE }, + { &cg_draw3dIcons, "cg_draw3dIcons", "0", CVAR_ARCHIVE }, { &cg_debugWeaponAiming, "cg_debugWeaponAiming", "0", CVAR_ARCHIVE }, { &cg_weaponSelectorSimple2DIcons, "cg_weaponSelectorSimple2DIcons", "0", CVAR_ARCHIVE }, { &cg_drawIcons, "cg_drawIcons", "1", CVAR_ARCHIVE }, diff --git a/android/app/src/main/cpp/code/cgame/cg_newdraw.c b/android/app/src/main/cpp/code/cgame/cg_newdraw.c index bd75cf23..69021f0a 100644 --- a/android/app/src/main/cpp/code/cgame/cg_newdraw.c +++ b/android/app/src/main/cpp/code/cgame/cg_newdraw.c @@ -165,7 +165,7 @@ static void CG_DrawPlayerArmorIcon( rectDef_t *rect, qboolean draw2D ) { vec3_t angles; vec3_t origin; - if ( cg_drawStatus.integer == 0 ) { + if ( trap_Cvar_VariableValue( "vr_hudDrawStatus" ) == 0 ) { return; } @@ -1501,7 +1501,7 @@ void CG_DrawMedal(int ownerDraw, rectDef_t *rect, float scale, vec4_t color, qha void CG_OwnerDraw(float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle) { rectDef_t rect; - if ( cg_drawStatus.integer == 0 ) { + if ( trap_Cvar_VariableValue( "vr_hudDrawStatus" ) == 0 ) { return; } diff --git a/android/app/src/main/cpp/code/client/cl_main.c b/android/app/src/main/cpp/code/client/cl_main.c index 6ae76597..fb5c3901 100644 --- a/android/app/src/main/cpp/code/client/cl_main.c +++ b/android/app/src/main/cpp/code/client/cl_main.c @@ -3580,7 +3580,6 @@ void CL_Init( void ) { // init autoswitch and hud toggle so the ui will have it correctly even // if the cgame hasn't been started Cvar_Get ("cg_autoswitch", "1", CVAR_ARCHIVE); - Cvar_Get ("cg_drawStatus", "1", CVAR_ARCHIVE); m_pitch = Cvar_Get ("m_pitch", "0.022", CVAR_ARCHIVE); m_yaw = Cvar_Get ("m_yaw", "0.022", CVAR_ARCHIVE); diff --git a/android/app/src/main/cpp/code/q3_ui/ui_preferences.c b/android/app/src/main/cpp/code/q3_ui/ui_preferences.c index a2ac4b46..02546076 100644 --- a/android/app/src/main/cpp/code/q3_ui/ui_preferences.c +++ b/android/app/src/main/cpp/code/q3_ui/ui_preferences.c @@ -80,7 +80,7 @@ typedef struct { menuradiobutton_s synceveryframe; menuradiobutton_s forcemodel; menulist_s drawteamoverlay; - menuradiobutton_s drawhud; + menulist_s drawhud; menuradiobutton_s allowdownload; menuradiobutton_s holster2d; menulist_s gore; @@ -93,6 +93,14 @@ typedef struct { static preferences_t s_preferences; +static const char *hud_names[] = +{ + "off", + "floating", + "static (performance)", + NULL +}; + static const char *teamoverlay_names[] = { "off", @@ -123,7 +131,7 @@ static void Preferences_SetMenuItems( void ) { // s_preferences.synceveryframe.curvalue = trap_Cvar_VariableValue( "r_finish" ) != 0; s_preferences.forcemodel.curvalue = trap_Cvar_VariableValue( "cg_forcemodel" ) != 0; s_preferences.drawteamoverlay.curvalue = Com_Clamp( 0, 3, trap_Cvar_VariableValue( "cg_drawTeamOverlay" ) ); - s_preferences.drawhud.curvalue = trap_Cvar_VariableValue( "cg_drawStatus" ) != 0; + s_preferences.drawhud.curvalue = trap_Cvar_VariableValue( "vr_hudDrawStatus" ); // s_preferences.allowdownload.curvalue = trap_Cvar_VariableValue( "cl_allowDownload" ) != 0; s_preferences.holster2d.curvalue = trap_Cvar_VariableValue( "cg_weaponSelectorSimple2DIcons" ) != 0; s_preferences.gore.curvalue = trap_Cvar_VariableValue( "vr_goreLevel" ); @@ -191,7 +199,8 @@ static void Preferences_Event( void* ptr, int notification ) { break; case ID_DRAWHUD: - trap_Cvar_SetValue( "cg_drawStatus", s_preferences.drawhud.curvalue ); + trap_Cvar_SetValue( "vr_hudDrawStatus", s_preferences.drawhud.curvalue ); + trap_Cvar_SetValue("cg_draw3dIcons", (s_preferences.drawhud.curvalue == 2) ? 0 : 1); break; case ID_HOLSTER2D: @@ -446,13 +455,14 @@ static void Preferences_MenuInit( void ) { s_preferences.drawteamoverlay.itemnames = teamoverlay_names; y += BIGCHAR_HEIGHT+2; - s_preferences.drawhud.generic.type = MTYPE_RADIOBUTTON; - s_preferences.drawhud.generic.name = "Draw HUD:"; + s_preferences.drawhud.generic.type = MTYPE_SPINCONTROL; + s_preferences.drawhud.generic.name = "HUD Mode:"; s_preferences.drawhud.generic.flags = QMF_PULSEIFFOCUS|QMF_SMALLFONT; s_preferences.drawhud.generic.callback = Preferences_Event; s_preferences.drawhud.generic.id = ID_DRAWHUD; s_preferences.drawhud.generic.x = PREFERENCES_X_POS; s_preferences.drawhud.generic.y = y; + s_preferences.drawhud.itemnames = hud_names; y += BIGCHAR_HEIGHT+2; s_preferences.selectorwithhud.generic.type = MTYPE_RADIOBUTTON; diff --git a/android/app/src/main/cpp/code/q3_ui/ui_vr.c b/android/app/src/main/cpp/code/q3_ui/ui_vr.c index 60bdeb05..88fb2139 100644 --- a/android/app/src/main/cpp/code/q3_ui/ui_vr.c +++ b/android/app/src/main/cpp/code/q3_ui/ui_vr.c @@ -101,7 +101,7 @@ static VR_t s_VR; static void VR_SetMenuItems( void ) { - s_VR.drawhud.curvalue = trap_Cvar_VariableValue( "cg_drawStatus" ) != 0; + s_VR.drawhud.curvalue = (int)trap_Cvar_VariableValue( "vr_hudDrawStatus" ) % 2; s_VR.huddepth.curvalue = (int)trap_Cvar_VariableValue( "vr_hudDepth" ) % NUM_HUDDEPTH; s_VR.righthanded.curvalue = trap_Cvar_VariableValue( "vr_righthanded" ) != 0; s_VR.autoswitch.curvalue = trap_Cvar_VariableValue( "cg_autoswitch" ) != 0; @@ -209,7 +209,7 @@ static void VR_Event( void* ptr, int notification ) { break; case ID_DRAWHUD: - trap_Cvar_SetValue( "cg_drawStatus", s_VR.drawhud.curvalue ); + trap_Cvar_SetValue( "vr_hudDrawStatus", s_VR.drawhud.curvalue ); break; case ID_ROLLHIT: diff --git a/android/app/src/main/cpp/code/renderergles3/tr_backend.c b/android/app/src/main/cpp/code/renderergles3/tr_backend.c index 152363cb..0ab9f269 100644 --- a/android/app/src/main/cpp/code/renderergles3/tr_backend.c +++ b/android/app/src/main/cpp/code/renderergles3/tr_backend.c @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA backEndData_t *backEndData; backEndState_t backEnd; +extern cvar_t *vr_hudDrawStatus; static float s_flipMatrix[16] = { // convert from our coordinate system (looking down X) @@ -1772,34 +1773,47 @@ const void* RB_HUDBuffer( const void* data ) { if (cmd->start && tr.renderFbo->frameBuffer != tr.hudFbo->frameBuffer) { glState.isDrawingHUD = qtrue; - //keep record of current render fbo and switch to the hud buffer - tr.backupFrameBuffer = tr.renderFbo->frameBuffer; - tr.renderFbo->frameBuffer = tr.hudFbo->frameBuffer; - // Render to framebuffer - GL_BindFramebuffer(GL_FRAMEBUFFER, tr.hudFbo->frameBuffer); - qglBindRenderbuffer(GL_RENDERBUFFER, 0); - qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tr.hudImage->texnum, 0); + //Only set the HUD buffer if we are using the in-world HUD otherwise + //just flag we are drawing the hud + if (vr_hudDrawStatus->integer == 1) + { + //keep record of current render fbo and switch to the hud buffer + tr.backupFrameBuffer = tr.renderFbo->frameBuffer; + tr.renderFbo->frameBuffer = tr.hudFbo->frameBuffer; - // Attach combined depth+stencil - qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, tr.hudDepthImage->texnum); - qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, tr.hudDepthImage->texnum); + // Render to framebuffer + GL_BindFramebuffer(GL_FRAMEBUFFER, tr.hudFbo->frameBuffer); + qglBindRenderbuffer(GL_RENDERBUFFER, 0); + qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + tr.hudImage->texnum, 0); - GLenum result = qglCheckFramebufferStatus(GL_FRAMEBUFFER); - if(result != GL_FRAMEBUFFER_COMPLETE) - { - ri.Error( "Error binding Framebuffer: %i\n", result ); - } + // Attach combined depth+stencil + qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, + tr.hudDepthImage->texnum); + qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, + tr.hudDepthImage->texnum); - qglClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); - qglClear( GL_COLOR_BUFFER_BIT ); + GLenum result = qglCheckFramebufferStatus(GL_FRAMEBUFFER); + if (result != GL_FRAMEBUFFER_COMPLETE) + { + ri.Error("Error binding Framebuffer: %i\n", result); + } + + qglClearColor(0.0f, 0.0f, 0.0f, 0.0f); + qglClear(GL_COLOR_BUFFER_BIT); + } } - else if (tr.renderFbo->frameBuffer == tr.hudFbo->frameBuffer) + else if (glState.isDrawingHUD) { glState.isDrawingHUD = qfalse; - //restore the true render fbo - tr.renderFbo->frameBuffer = tr.backupFrameBuffer; - GL_BindFramebuffer(GL_FRAMEBUFFER, tr.renderFbo->frameBuffer); + + if (vr_hudDrawStatus->integer == 1) + { + //restore the true render fbo + tr.renderFbo->frameBuffer = tr.backupFrameBuffer; + GL_BindFramebuffer(GL_FRAMEBUFFER, tr.renderFbo->frameBuffer); + } } glState.currentFBO = tr.renderFbo; diff --git a/android/app/src/main/cpp/code/renderergles3/tr_glsl.c b/android/app/src/main/cpp/code/renderergles3/tr_glsl.c index f56141b0..e435c9c9 100644 --- a/android/app/src/main/cpp/code/renderergles3/tr_glsl.c +++ b/android/app/src/main/cpp/code/renderergles3/tr_glsl.c @@ -57,6 +57,7 @@ extern const char *fallbackShader_tonemap_vp; extern const char *fallbackShader_tonemap_fp; extern cvar_t *vr_hudDepth; +extern cvar_t *vr_hudDrawStatus; extern vr_clientinfo_t vr; typedef struct uniformInfo_s @@ -68,6 +69,7 @@ uniformInfo_t; typedef enum { HUD_ORTHO_PROJECTION, // Orthographic projection and no stereo view + STEREO_ORTHO_PROJECTION, // Orthographic projection with a slight stereo offset per eye VR_PROJECTION, MONO_VR_PROJECTION, @@ -211,6 +213,17 @@ static void GLSL_ViewMatricesUniformBuffer(const float eyeView[32], const float Mat4Identity( viewMatrices + 16 ); } break; + case STEREO_ORTHO_PROJECTION: + { + const auto depth = (6-vr_hudDepth->integer) * 16; + vec3_t translate; + VectorSet(translate, depth, 0, 0); + Mat4Translation( translate, viewMatrices ); + + VectorSet(translate, -depth, 0, 0); + Mat4Translation( translate, viewMatrices + 16 ); + } + break; case VR_PROJECTION: { Mat4Copy(eyeView, viewMatrices); @@ -1673,9 +1686,11 @@ void GLSL_PrepareUniformBuffers(void) Mat4Ortho(0, width, height, 0, 0, 1, orthoProjectionMatrix); - //ortho projection matrix + //ortho projection matrices GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[HUD_ORTHO_PROJECTION], orthoProjectionMatrix); + GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[STEREO_ORTHO_PROJECTION], + orthoProjectionMatrix); //VR projection matrix GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[VR_PROJECTION], @@ -1709,7 +1724,14 @@ static GLuint GLSL_CalculateProjection() { //as we aren't drawing models to the HUD if (Mat4Compare(&orthoProjectionMatrix, glState.projection)) { - result = HUD_ORTHO_PROJECTION; + if (glState.isDrawingHUD && vr_hudDrawStatus->integer == 2) + { + result = STEREO_ORTHO_PROJECTION; + } + else + { + result = HUD_ORTHO_PROJECTION; + } } return result; diff --git a/android/app/src/main/cpp/code/vr/vr_base.c b/android/app/src/main/cpp/code/vr/vr_base.c index f234a99c..5d70cdaa 100644 --- a/android/app/src/main/cpp/code/vr/vr_base.c +++ b/android/app/src/main/cpp/code/vr/vr_base.c @@ -41,6 +41,7 @@ cvar_t *vr_comfortVignette = NULL; cvar_t *vr_weaponSelectorMode = NULL; cvar_t *vr_weaponSelectorWithHud = NULL; cvar_t *vr_goreLevel = NULL; +cvar_t *vr_hudDrawStatus = NULL; engine_t* VR_Init( ovrJava java ) { @@ -84,6 +85,7 @@ void VR_InitCvars( void ) vr_weaponSelectorMode = Cvar_Get ("vr_weaponSelectorMode", "0", CVAR_ARCHIVE); vr_weaponSelectorWithHud = Cvar_Get ("vr_weaponSelectorWithHud", "0", CVAR_ARCHIVE); vr_goreLevel = Cvar_Get ("vr_goreLevel", "2", CVAR_ARCHIVE); + vr_hudDrawStatus = Cvar_Get ("vr_hudDrawStatus", "2", CVAR_ARCHIVE); // 0 - no hud, 1 - in-world hud, 2 - performance (static HUD) // Values are: scale,right,up,forward,pitch,yaw,roll // VALUES PROVIDED BY SkillFur - Thank-you! diff --git a/android/run.bat b/android/run.bat index 49d93565..92980f50 100644 --- a/android/run.bat +++ b/android/run.bat @@ -3,7 +3,7 @@ setlocal set BUILD_TYPE=release -set VERSION=0.29.2-multiview +set VERSION=0.29.3-multiview @REM Define the following environment variables to sign a release build @REM set KEYSTORE=