Improvements to the crosshair

This commit is contained in:
Simon 2022-10-08 17:28:59 +01:00
parent ab03fc7c6d
commit 7328046b32
6 changed files with 45 additions and 35 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.jk2quest"
android:versionCode="10"
android:versionName="0.0.10" android:installLocation="auto" >
android:versionCode="11"
android:versionName="0.0.11" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>

View File

@ -2972,26 +2972,31 @@ static void CG_DrawCrosshair3D(void)
}
hShader = cgs.media.crosshairShader[ ca % NUM_CROSSHAIRS ];
float xmax = 64.0f * tan(cg.refdef.fov_x * M_PI / 360.0f);
float maxdist = (cgs.glconfig.vidWidth * 64.0f / (2 * xmax)) * 1.5f;
vec3_t forward, weaponangles, origin;
BG_CalculateVRWeaponPosition(origin, weaponangles);
AngleVectors(weaponangles, forward, NULL, NULL);
VectorMA(origin, 1024, forward, endpos);
VectorMA(origin, maxdist, forward, endpos);
CG_Trace(&trace, origin, NULL, NULL, endpos, 0, MASK_SHOT);
memset(&ent, 0, sizeof(ent));
ent.reType = RT_SPRITE;
ent.renderfx = RF_FIRST_PERSON;
if (trace.fraction != 1.0f) {
memset(&ent, 0, sizeof(ent));
ent.reType = RT_SPRITE;
ent.renderfx = RF_FIRST_PERSON;
VectorCopy(trace.endpos, ent.origin);
VectorCopy(trace.endpos, ent.origin);
ent.radius = 2.0f;
ent.customShader = hShader;
ent.shaderRGBA[0] = 255;
ent.shaderRGBA[1] = 255;
ent.shaderRGBA[2] = 255;
ent.shaderRGBA[3] = 255;
ent.radius = w / 640 * xmax * trace.fraction * maxdist / 64.0f;
ent.customShader = hShader;
ent.shaderRGBA[0] = 255;
ent.shaderRGBA[1] = 255;
ent.shaderRGBA[2] = 255;
ent.shaderRGBA[3] = 255;
cgi_R_AddRefEntityToScene(&ent);
cgi_R_AddRefEntityToScene(&ent);
}
}
/*
@ -4352,6 +4357,8 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
return;
}
CG_DrawCrosshair3D();
//FIXME: these globals done once at start of frame for various funcs
AngleVectors (cg.refdefViewAngles, vfwd, vright, vup);
VectorCopy( vfwd, vfwd_n );
@ -4412,8 +4419,6 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
cg.refdef.rdflags |= RDF_DRAWSKYBOX;
CG_DrawCrosshair3D();
// draw 3D view
cgi_R_RenderScene( &cg.refdef );

View File

@ -33,8 +33,8 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
float screenXScale = 1.0f / 2.5f;
float screenYScale = 1.0f / 2.5f;
float xoffset = -24;
if (cg.refdef.stereoView == 1) {
float xoffset = -20;
if (cg.refdef.stereoView == STEREO_LEFT) {
xoffset *= -1;
}

View File

@ -1735,26 +1735,31 @@ static void CG_DrawCrosshair3D(void)
}
hShader = cgs.media.crosshairShader[ ca % NUM_CROSSHAIRS ];
float xmax = 64.0f * tan(cg.refdef.fov_x * M_PI / 360.0f);
float maxdist = (cgs.glconfig.vidWidth * 64.0f / (2 * xmax)) * 1.5f;
vec3_t forward, weaponangles, origin;
BG_CalculateVRWeaponPosition(origin, weaponangles);
AngleVectors(weaponangles, forward, NULL, NULL);
VectorMA(origin, 1024, forward, endpos);
VectorMA(origin, maxdist, forward, endpos);
CG_Trace(&trace, origin, NULL, NULL, endpos, 0, MASK_SHOT);
memset(&ent, 0, sizeof(ent));
ent.reType = RT_SPRITE;
ent.renderfx = RF_FIRST_PERSON;
if (trace.fraction != 1.0f) {
memset(&ent, 0, sizeof(ent));
ent.reType = RT_SPRITE;
ent.renderfx = RF_FIRST_PERSON;
VectorCopy(trace.endpos, ent.origin);
VectorCopy(trace.endpos, ent.origin);
ent.radius = 2.0f;
ent.customShader = hShader;
ent.shaderRGBA[0] = 255;
ent.shaderRGBA[1] = 255;
ent.shaderRGBA[2] = 255;
ent.shaderRGBA[3] = 255;
ent.radius = w / 640 * xmax * trace.fraction * maxdist / 64.0f;
ent.customShader = hShader;
ent.shaderRGBA[0] = 255;
ent.shaderRGBA[1] = 255;
ent.shaderRGBA[2] = 255;
ent.shaderRGBA[3] = 255;
cgi_R_AddRefEntityToScene(&ent);
cgi_R_AddRefEntityToScene(&ent);
}
}
/*
@ -2578,6 +2583,8 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
return;
}
CG_DrawCrosshair3D();
//FIXME: these globals done once at start of frame for various funcs
AngleVectors (cg.refdefViewAngles, vfwd, vright, vup);
VectorCopy( vfwd, vfwd_n );
@ -2625,8 +2632,6 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
cgi_R_LAGoggles();
}
CG_DrawCrosshair3D();
if (!in_camera || vr->immersive_cinematics) {
//Vertical Positional Movement
cg.refdef.vieworg[2] -= DEFAULT_PLAYER_HEIGHT;

View File

@ -32,7 +32,7 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
float screenXScale = 1.0f / 2.5f;
float screenYScale = 1.0f / 2.5f;
float xoffset = -24;
float xoffset = -20;
if (cg.refdef.stereoView == STEREO_LEFT) {
xoffset *= -1;
}

View File

@ -149,7 +149,7 @@ void CG_MissionFailed(void)
tempY = y+30;
CG_AdjustFrom640Int( &tempX, &tempY, NULL, NULL );
cgi_R_Font_DrawString(tempX, tempY, text, colorTable[CT_HUD_RED], cgs.media.qhFontSmall, -1, 1.2f * FONT_SCALE);
/*
cgi_SP_GetStringTextString( "INGAME_RELOADMISSION", text, sizeof(text) );
w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, FONT_SCALE);
@ -157,7 +157,7 @@ void CG_MissionFailed(void)
tempY = 450;
CG_AdjustFrom640Int( &tempX, &tempY, NULL, NULL );
cgi_R_Font_DrawString(tempX, tempY, text, colorTable[CT_CYAN], cgs.media.qhFontSmall, -1, FONT_SCALE);
*/
}