Hardware mode y-shearing matches software mode mouselook

This commit is contained in:
Jaime Passos 2019-05-17 17:49:04 -03:00
parent 315f941573
commit d3dfd77ae7
6 changed files with 48 additions and 37 deletions

View file

@ -415,6 +415,9 @@ extern INT32 cv_debug;
extern UINT8 shiftdown, ctrldown, altdown;
extern boolean capslock;
// WARNING: a should be unsigned but to add with 2048, it isn't!
#define AIMINGTODY(a) (FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)
// if we ever make our alloc stuff...
#define ZZ_Alloc(x) Z_Malloc(x, PU_STATIC, NULL)

View file

@ -158,6 +158,7 @@ typedef struct
boolean mirror; // SRB2Kart: Encore Mode
#endif
boolean shearing; // 14042019
angle_t viewaiming; // 17052019
} FTransform;
// Transformed vector, as passed to HWR API

View file

@ -48,7 +48,7 @@ EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value);
//Hurdler: added for new development
EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, FSurfaceInfo *Surface);
EXPORT void HWRAPI(CreateModelVBOs) (model_t *model);
EXPORT void HWRAPI(SetTransform) (FTransform *ptransform, angle_t viewaiming);
EXPORT void HWRAPI(SetTransform) (FTransform *stransform);
EXPORT INT32 HWRAPI(GetTextureUsed) (void);
EXPORT void HWRAPI(FlushScreenTextures) (void);

View file

@ -3938,7 +3938,7 @@ void HWR_RenderDrawNodes(void)
} // loop++
// Okay! Let's draw it all! Woo!
HWD.pfnSetTransform(&atransform, aimingangle);
HWD.pfnSetTransform(&atransform);
HWD.pfnSetShader(0);
for (i = 0; i < p; i++)
@ -4459,6 +4459,15 @@ void HWR_DrawSkyBackground(void)
angleturn = (((float)ANGLE_45-1.0f)*aspectratio)*dimensionmultiply;
if (cv_grshearing.value)
{
// Doesn't really make sense, but what can I do?
angle_t dy = FixedAngle(FixedMul(360*FRACUNIT, FixedDiv(AIMINGTODY(aimingangle), 900*FRACUNIT)));
v[3].t = v[2].t -= ((float) dy / angleturn);
v[0].t = v[1].t -= ((float) dy / angleturn);
}
else
{
if (angle > ANGLE_180) // Do this because we don't want the sky to suddenly teleport when crossing over 0 to 360 and vice versa
{
angle = InvAngle(angle);
@ -4470,6 +4479,7 @@ void HWR_DrawSkyBackground(void)
v[3].t = v[2].t -= ((float) angle / angleturn);
v[0].t = v[1].t -= ((float) angle / angleturn);
}
}
HWD.pfnSetShader(7); // sky shader
HWD.pfnDrawPolygon(NULL, v, 4, 0);
@ -4560,12 +4570,11 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
atransform.scalez = 1;
// 14042019
if (!cv_grshearing.value)
{
gr_aimingangle = aimingangle;
atransform.shearing = false;
}
else
atransform.viewaiming = aimingangle;
if (cv_grshearing.value)
{
gr_aimingangle = 0;
atransform.shearing = true;
@ -4609,14 +4618,14 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
gld_FrustrumSetup();
#endif
// Set transform and shader
HWD.pfnSetTransform(&atransform, aimingangle);
// Set transform.
HWD.pfnSetTransform(&atransform);
// Reset the shader state.
HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_grshaders.value);
HWD.pfnSetShader(0);
// Check for shaders
HWD.pfnSetSpecialState(HWD_SET_SHADERS, cv_grshaders.value);
// Check for fog (shader)
// Check if fog is enabled.
if (cv_grfog.value)
HWR_FoggingOn(); // First of all, turn it on, set the default user settings too
else
@ -4639,7 +4648,7 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox)
HWR_RenderDrawNodes();
// Unset transform and shader
HWD.pfnSetTransform(NULL, 0.0f);
HWD.pfnSetTransform(NULL);
HWD.pfnUnSetShader();
// Disable fog

View file

@ -2186,7 +2186,7 @@ EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration,
// -----------------+
// SetTransform :
// -----------------+
EXPORT void HWRAPI(SetTransform) (FTransform *stransform, angle_t viewaiming)
EXPORT void HWRAPI(SetTransform) (FTransform *stransform)
{
static boolean special_splitscreen;
GLdouble used_fov;
@ -2232,12 +2232,8 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform, angle_t viewaiming)
// https://zdoom.org/wiki/Y-shearing
if (shearing)
{
float tilt = (float)(viewaiming>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES);
if (tilt >= 270.0f)
tilt = -(90.0f - (tilt - 270.0f));
tilt /= 24.0f; // ?????????
pglTranslatef(0.0f, -tilt, 0.0f);
float dy = FIXED_TO_FLOAT(AIMINGTODY(stransform->viewaiming)) * 2; //screen_width/BASEVIDWIDTH;
pglTranslatef(0.0f, -dy/BASEVIDHEIGHT, 0.0f);
}
if (special_splitscreen)

View file

@ -738,29 +738,31 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
static mobj_t *viewmobj;
// WARNING: a should be unsigned but to add with 2048, it isn't!
#define AIMINGTODY(a) ((FINETANGENT((2048+(((INT32)a)>>ANGLETOFINESHIFT)) & FINEMASK)*160)>>FRACBITS)
// recalc necessary stuff for mouseaiming
// slopes are already calculated for the full possible view (which is 4*viewheight).
// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out)
static void R_SetupFreelook(void)
{
INT32 dy = 0;
if (rendermode == render_soft)
{
// clip it in the case we are looking a hardware 90 degrees full aiming
// (lmps, network and use F12...)
if (rendermode == render_soft
#ifdef HWRENDER
|| cv_grshearing.value
#endif
)
G_SoftwareClipAimingPitch((INT32 *)&aimingangle);
dy = AIMINGTODY(aimingangle) * viewwidth/BASEVIDWIDTH;
if (rendermode == render_soft)
{
dy = (AIMINGTODY(aimingangle)>>FRACBITS) * viewwidth/BASEVIDWIDTH;
yslope = &yslopetab[viewheight*8 - (viewheight/2 + dy)];
}
centery = (viewheight/2) + dy;
centeryfrac = centery<<FRACBITS;
}
#undef AIMINGTODY
void R_SetupFrame(player_t *player, boolean skybox)
{
camera_t *thiscam;