From 860b7d37562b1e61385ea2f92e36ffda457bdb35 Mon Sep 17 00:00:00 2001 From: XProger Date: Tue, 27 Aug 2019 01:50:28 +0300 Subject: [PATCH] fix shadow for split-screen mode, minor fixes --- src/lara.h | 2 +- src/level.h | 11 +++++++++-- src/platform/win/main.cpp | 4 +++- src/utils.h | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/lara.h b/src/lara.h index 91f89be..cf3b70e 100644 --- a/src/lara.h +++ b/src/lara.h @@ -1422,7 +1422,7 @@ struct Lara : Character { // flip left and right by relative target direction if (count > 1) { - int side[2] = { 0, 0 }; + float side[2] = { 0, 0 }; vec3 dir = getDir(); dir.y = 0.0f; diff --git a/src/level.h b/src/level.h index a486659..d06e51f 100644 --- a/src/level.h +++ b/src/level.h @@ -80,6 +80,8 @@ struct Level : IGame { vec4 underwaterFogParams; vec4 levelFogParams; + mat4 mLightProj[2]; + // IGame implementation ======== virtual void loadLevel(TR::LevelID id) { sndWater = sndTrack = NULL; @@ -2538,7 +2540,8 @@ struct Level : IGame { Core::mView = Core::mViewInv.inverseOrtho(); Core::mProj = GAPI::perspective(90.0f, 1.0f, znear, zfar, 0.0f); - Core::mLightProj = Core::mProj * Core::mView; + mat4 &m = mLightProj[player->camera->cameraIndex]; + m = Core::mProj * Core::mView; mat4 bias; bias.identity(); @@ -2546,7 +2549,9 @@ struct Level : IGame { #if defined(_GAPI_D3D9) || defined(_GAPI_GXM) bias.e11 = -bias.e11; #endif - Core::mLightProj = bias * Core::mLightProj; + m = bias * m; + + Core::mLightProj = m; camera->frustum->pos = Core::viewPos.xyz(); camera->frustum->calcPlanes(Core::mViewProj); @@ -3033,6 +3038,8 @@ struct Level : IGame { player = players[view]; camera = player->camera; + Core::mLightProj = mLightProj[view]; + Core::pass = Core::passCompose; setDefaultTarget(eye, view, invBG); diff --git a/src/platform/win/main.cpp b/src/platform/win/main.cpp index c33b292..5469ef9 100644 --- a/src/platform/win/main.cpp +++ b/src/platform/win/main.cpp @@ -661,7 +661,9 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara } //VR Support -#define VR_SUPPORT +#ifdef _GAPI_GL + #define VR_SUPPORT +#endif #ifdef VR_SUPPORT // TODO: fix depth precision diff --git a/src/utils.h b/src/utils.h index 65cfe04..2533729 100644 --- a/src/utils.h +++ b/src/utils.h @@ -129,8 +129,8 @@ inline const T& clamp(const T &x, const T &a, const T &b) { } template -inline const int sign(const T &x) { - return x > 0 ? 1 : (x < 0 ? -1 : 0); +inline const T sign(const T &x) { + return (T)(x > 0 ? 1 : (x < 0 ? -1 : 0)); } template