mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-24 21:11:03 +00:00
Use calculated projection matrix
sorts out weird warping on the Pico. Allows for FOV to be overridden still for some effects (force speed)
This commit is contained in:
parent
7d99f83ae9
commit
4b1e010ca0
15 changed files with 40 additions and 7 deletions
|
@ -2130,6 +2130,20 @@ void JKVR_prepareEyeBuffer(int eye )
|
|||
VR_ClearFrameBuffer(frameBuffer->ColorSwapChain.Width, frameBuffer->ColorSwapChain.Height);
|
||||
}
|
||||
|
||||
bool JKVR_GetVRProjection(int eye, float zNear, float zFar, float* projection)
|
||||
{
|
||||
if (!vr.cgzoommode)
|
||||
{
|
||||
XrMatrix4x4f_CreateProjectionFov(
|
||||
&(gAppState.ProjectionMatrices[eye]), GRAPHICS_OPENGL_ES,
|
||||
gAppState.Projections[eye].fov, zNear, zFar);
|
||||
memcpy(projection, gAppState.ProjectionMatrices[eye].m, 16 * sizeof(float));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void JKVR_finishEyeBuffer(int eye )
|
||||
{
|
||||
ovrRenderer *renderer = &gAppState.Renderer;
|
||||
|
@ -2366,7 +2380,6 @@ void JKVR_submitFrame()
|
|||
XrPosef xfHeadFromEye = gAppState.Projections[eye].pose;
|
||||
XrPosef xfStageFromEye = XrPosef_Multiply(gAppState.xfStageFromHead, xfHeadFromEye);
|
||||
viewTransform[eye] = XrPosef_Inverse(xfStageFromEye);
|
||||
|
||||
fov.angleLeft += gAppState.Projections[eye].fov.angleLeft / 2.0f;
|
||||
fov.angleRight += gAppState.Projections[eye].fov.angleRight / 2.0f;
|
||||
fov.angleUp += gAppState.Projections[eye].fov.angleUp / 2.0f;
|
||||
|
|
|
@ -194,6 +194,8 @@ typedef struct
|
|||
GLboolean SessionActive;
|
||||
XrPosef xfStageFromHead;
|
||||
XrView* Projections;
|
||||
XrMatrix4x4f ProjectionMatrices[2];
|
||||
|
||||
|
||||
float currentDisplayRefreshRate;
|
||||
float* SupportedDisplayRefreshRates;
|
||||
|
@ -246,6 +248,7 @@ void VR_Recenter();
|
|||
|
||||
//Called from engine code
|
||||
bool JKVR_useScreenLayer();
|
||||
bool JKVR_GetVRProjection(int eye, float zNear, float zFar, float* projection);
|
||||
void JKVR_GetScreenRes(int *width, int *height);
|
||||
void JKVR_InitActions( void );
|
||||
void JKVR_Vibrate(int duration, int channel, float intensity );
|
||||
|
|
|
@ -5,7 +5,7 @@ LOCAL_PATH := $(call my-dir)
|
|||
#OPENXR_HMD = -DMETA_QUEST
|
||||
OPENXR_HMD = -DPICO_XR
|
||||
|
||||
JK3_BASE_CFLAGS = $(OPENXR_HMD) -DHAVE_GLES -DFINAL_BUILD -fexceptions -Wall -Wno-write-strings -Wno-comment -fno-caller-saves -fno-tree-vectorize -Wno-unused-but-set-variable -fvisibility=hidden
|
||||
JK3_BASE_CFLAGS = $(OPENXR_HMD) -O1 -DHAVE_GLES -DFINAL_BUILD -fexceptions -Wall -Wno-write-strings -Wno-comment -fno-caller-saves -fno-tree-vectorize -Wno-unused-but-set-variable -fvisibility=hidden
|
||||
JK3_BASE_CPPFLAGS = -fvisibility-inlines-hidden -Wno-invalid-offsetof -fvisibility=hidden
|
||||
|
||||
JK3_BASE_LDLIBS =
|
||||
|
|
|
@ -1317,6 +1317,7 @@ qboolean CG_CalcFOVFromX( float fov_x )
|
|||
}
|
||||
|
||||
// set it
|
||||
cg.refdef.override_fov = true;
|
||||
cg.refdef.fov_x = fov_x;
|
||||
cg.refdef.fov_y = fov_y;
|
||||
|
||||
|
|
|
@ -1612,6 +1612,7 @@ static void CIN_AddTextCrawl()
|
|||
refdef.rdflags = RDF_NOWORLDMODEL;
|
||||
AxisClear( refdef.viewaxis );
|
||||
|
||||
refdef.override_fov = true;
|
||||
refdef.fov_x = 130;
|
||||
refdef.fov_y = 130;
|
||||
|
||||
|
@ -2035,6 +2036,7 @@ void SCR_AddCreditTextCrawl()
|
|||
refdef.rdflags = RDF_NOWORLDMODEL;
|
||||
AxisClear( refdef.viewaxis );
|
||||
|
||||
refdef.override_fov = true;
|
||||
refdef.fov_x = 150;
|
||||
refdef.fov_y = 150;
|
||||
|
||||
|
|
|
@ -1192,6 +1192,7 @@ void CL_InitRef( void ) {
|
|||
rit.saved_game = &ojk::SavedGame::get_instance();
|
||||
|
||||
rit.JKVR_useScreenLayer = JKVR_useScreenLayer;
|
||||
rit.JKVR_GetVRProjection = JKVR_GetVRProjection;
|
||||
|
||||
ret = GetRefAPI( REF_API_VERSION, &rit );
|
||||
|
||||
|
|
|
@ -129,6 +129,7 @@ typedef struct {
|
|||
|
||||
//JKVR Functions
|
||||
bool (*JKVR_useScreenLayer) ( void );
|
||||
bool (*JKVR_GetVRProjection) (int eye, float zNear, float zFar, float* projection);
|
||||
|
||||
} refimport_t;
|
||||
|
||||
|
|
|
@ -195,6 +195,7 @@ typedef enum {
|
|||
|
||||
typedef struct {
|
||||
int x, y, width, height;
|
||||
bool override_fov;
|
||||
float fov_x, fov_y;
|
||||
vec3_t vieworg;
|
||||
vec3_t viewaxis[3]; // transformation matrix
|
||||
|
|
|
@ -1430,11 +1430,9 @@ const void *RB_DrawBuffer( const void *data ) {
|
|||
const drawBufferCommand_t *cmd;
|
||||
|
||||
cmd = (const drawBufferCommand_t *)data;
|
||||
/*
|
||||
#ifndef HAVE_GLES
|
||||
qglDrawBuffer( cmd->buffer );
|
||||
#endif
|
||||
*/
|
||||
|
||||
tr.stereoFrame = (stereoFrame_t )cmd->buffer;
|
||||
|
||||
// clear screen for debugging
|
||||
if ( r_clear->integer ) {
|
||||
qglClearColor( 0, 0, 0, 1 );
|
||||
|
|
|
@ -79,6 +79,7 @@ typedef struct {
|
|||
// as well as the locally generated scene information
|
||||
typedef struct {
|
||||
int x, y, width, height;
|
||||
bool override_fov;
|
||||
float fov_x, fov_y;
|
||||
vec3_t vieworg;
|
||||
vec3_t viewaxis[3]; // transformation matrix
|
||||
|
@ -1017,6 +1018,7 @@ typedef struct {
|
|||
model_t *currentModel;
|
||||
|
||||
viewParms_t viewParms;
|
||||
stereoFrame_t stereoFrame;
|
||||
|
||||
float identityLight; // 1.0 / ( 1 << overbrightBits )
|
||||
int identityLightByte; // identityLight * 255
|
||||
|
|
|
@ -539,6 +539,13 @@ void R_SetupProjection( void ) {
|
|||
zNear = r_znear->value;
|
||||
zFar = tr.viewParms.zFar;
|
||||
|
||||
if (!tr.refdef.override_fov &&
|
||||
ri.JKVR_GetVRProjection((int)tr.stereoFrame, zNear, zFar, tr.viewParms.projectionMatrix))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ymax = zNear * tan( tr.refdef.fov_y * M_PI / 360.0f );
|
||||
ymin = -ymax;
|
||||
|
||||
|
|
|
@ -295,6 +295,7 @@ void RE_RenderScene( const refdef_t *fd ) {
|
|||
tr.refdef.y = fd->y;
|
||||
tr.refdef.width = fd->width;
|
||||
tr.refdef.height = fd->height;
|
||||
tr.refdef.override_fov = fd->override_fov;
|
||||
tr.refdef.fov_x = fd->fov_x;
|
||||
tr.refdef.fov_y = fd->fov_y;
|
||||
|
||||
|
|
|
@ -7164,6 +7164,7 @@ void Item_Model_Paint(itemDef_t *item)
|
|||
//refdef.fov_x = (modelPtr->fov_x) ? modelPtr->fov_x : w;
|
||||
//refdef.fov_y = (modelPtr->fov_y) ? modelPtr->fov_y : h;
|
||||
|
||||
refdef.override_fov = true;
|
||||
refdef.fov_x = 45;
|
||||
refdef.fov_y = 45;
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ static void CG_Draw3DModel( float x, float y, float w, float h, qhandle_t model,
|
|||
|
||||
AxisClear( refdef.viewaxis );
|
||||
|
||||
refdef.override_fov = true;
|
||||
refdef.fov_x = 30;
|
||||
refdef.fov_y = 30;
|
||||
|
||||
|
|
|
@ -1335,6 +1335,7 @@ float CG_ForceSpeedFOV( float infov )
|
|||
fov = infov;//+amt;
|
||||
}
|
||||
|
||||
cg.refdef.override_fov = true;
|
||||
return fov;
|
||||
}
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue