Merge branch 'master' into next

This commit is contained in:
Monster Iestyn 2018-11-02 11:02:35 +00:00
commit f37a573834
2 changed files with 62 additions and 42 deletions

View file

@ -112,10 +112,10 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option)
if (option & V_NOSCALESTART)
sdupx = sdupy = 2.0f;
v[0].x = v[3].x = (x*sdupx-gpatch->leftoffset*pdupx)/vid.width - 1;
v[2].x = v[1].x = (x*sdupx+(gpatch->width-gpatch->leftoffset)*pdupx)/vid.width - 1;
v[0].y = v[1].y = 1-(y*sdupy-gpatch->topoffset*pdupy)/vid.height;
v[2].y = v[3].y = 1-(y*sdupy+(gpatch->height-gpatch->topoffset)*pdupy)/vid.height;
v[0].x = v[3].x = (x*sdupx-SHORT(gpatch->leftoffset)*pdupx)/vid.width - 1;
v[2].x = v[1].x = (x*sdupx+(SHORT(gpatch->width)-SHORT(gpatch->leftoffset))*pdupx)/vid.width - 1;
v[0].y = v[1].y = 1-(y*sdupy-SHORT(gpatch->topoffset)*pdupy)/vid.height;
v[2].y = v[3].y = 1-(y*sdupy+(SHORT(gpatch->height)-SHORT(gpatch->topoffset))*pdupy)/vid.height;
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
@ -179,18 +179,29 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
dupx = dupy = (dupx < dupy ? dupx : dupy);
fscale = FIXED_TO_FLOAT(pscale);
if (option & V_OFFSET)
// See my comments in v_video.c's V_DrawFixedPatch
// -- Monster Iestyn 29/10/18
{
cx -= (float)gpatch->leftoffset * dupx * fscale;
cy -= (float)gpatch->topoffset * dupy * fscale;
}
else
{
cy -= (float)gpatch->topoffset * fscale;
float offsetx = 0.0f, offsety = 0.0f;
// left offset
if (option & V_FLIP)
cx -= ((float)gpatch->width - (float)gpatch->leftoffset) * fscale;
offsetx = (float)(SHORT(gpatch->width) - SHORT(gpatch->leftoffset)) * fscale;
else
cx -= (float)gpatch->leftoffset * fscale;
offsetx = (float)SHORT(gpatch->leftoffset) * fscale;
// top offset
// TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!?
offsety = (float)SHORT(gpatch->topoffset) * fscale;
if ((option & (V_NOSCALESTART|V_OFFSET)) == (V_NOSCALESTART|V_OFFSET)) // Multiply by dupx/dupy for crosshairs
{
offsetx *= dupx;
offsety *= dupy;
}
cx -= offsetx;
cy -= offsety;
}
if (option & V_SPLITSCREEN)
@ -237,13 +248,13 @@ void HWR_DrawFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
if (pscale != FRACUNIT)
{
fwidth = (float)gpatch->width * fscale * dupx;
fheight = (float)gpatch->height * fscale * dupy;
fwidth = (float)SHORT(gpatch->width) * fscale * dupx;
fheight = (float)SHORT(gpatch->height) * fscale * dupy;
}
else
{
fwidth = (float)gpatch->width * dupx;
fheight = (float)gpatch->height * dupy;
fwidth = (float)SHORT(gpatch->width) * dupx;
fheight = (float)SHORT(gpatch->height) * dupy;
}
// positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1
@ -341,8 +352,8 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
dupx = dupy = (dupx < dupy ? dupx : dupy);
fscale = FIXED_TO_FLOAT(pscale);
cy -= (float)gpatch->topoffset * fscale;
cx -= (float)gpatch->leftoffset * fscale;
cy -= (float)SHORT(gpatch->topoffset) * fscale;
cx -= (float)SHORT(gpatch->leftoffset) * fscale;
if (!(option & V_NOSCALESTART))
{
@ -392,11 +403,11 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
if (fheight > h - sy)
fheight = h - sy;
if (fwidth > gpatch->width)
fwidth = gpatch->width;
if (fwidth > SHORT(gpatch->width))
fwidth = SHORT(gpatch->width);
if (fheight > gpatch->height)
fheight = gpatch->height;
if (fheight > SHORT(gpatch->height))
fheight = SHORT(gpatch->height);
if (pscale != FRACUNIT)
{
@ -426,10 +437,10 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
v[0].sow = v[3].sow = ((sx)/(float)gpatch->width )*gpatch->max_s;
v[2].sow = v[1].sow = ((w )/(float)gpatch->width )*gpatch->max_s;
v[0].tow = v[1].tow = ((sy)/(float)gpatch->height)*gpatch->max_t;
v[2].tow = v[3].tow = ((h )/(float)gpatch->height)*gpatch->max_t;
v[0].sow = v[3].sow = ((sx)/(float)SHORT(gpatch->width) )*gpatch->max_s;
v[2].sow = v[1].sow = ((w )/(float)SHORT(gpatch->width) )*gpatch->max_s;
v[0].tow = v[1].tow = ((sy)/(float)SHORT(gpatch->height))*gpatch->max_t;
v[2].tow = v[3].tow = ((h )/(float)SHORT(gpatch->height))*gpatch->max_t;
flags = BLENDMODE|PF_Clip|PF_NoZClip|PF_NoDepthTest;

View file

@ -331,7 +331,6 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
{
UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t);
UINT32 alphalevel = 0;
boolean flip = false;
fixed_t col, ofs, colfrac, rowfrac, fdup;
INT32 dupx, dupy;
@ -406,22 +405,32 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
colfrac = FixedDiv(FRACUNIT, fdup);
rowfrac = FixedDiv(FRACUNIT, fdup);
if (scrn & V_OFFSET) // Crosshair shit
// So it turns out offsets aren't scaled in V_NOSCALESTART unless V_OFFSET is applied ...poo, that's terrible
// For now let's just at least give V_OFFSET the ability to support V_FLIP
// I'll probably make a better fix for 2.2 where I don't have to worry about breaking existing support for stuff
// -- Monster Iestyn 29/10/18
{
y -= FixedMul((SHORT(patch->topoffset)*dupy)<<FRACBITS, pscale);
x -= FixedMul((SHORT(patch->leftoffset)*dupx)<<FRACBITS, pscale);
}
else
{
y -= FixedMul(SHORT(patch->topoffset)<<FRACBITS, pscale);
fixed_t offsetx = 0, offsety = 0;
// left offset
if (scrn & V_FLIP)
{
flip = true;
x -= FixedMul((SHORT(patch->width) - SHORT(patch->leftoffset))<<FRACBITS, pscale) + 1;
}
offsetx = FixedMul((SHORT(patch->width) - SHORT(patch->leftoffset))<<FRACBITS, pscale) + 1;
else
x -= FixedMul(SHORT(patch->leftoffset)<<FRACBITS, pscale);
offsetx = FixedMul(SHORT(patch->leftoffset)<<FRACBITS, pscale);
// top offset
// TODO: make some kind of vertical version of V_FLIP, maybe by deprecating V_OFFSET in future?!?
offsety = FixedMul(SHORT(patch->topoffset)<<FRACBITS, pscale);
if ((scrn & (V_NOSCALESTART|V_OFFSET)) == (V_NOSCALESTART|V_OFFSET)) // Multiply by dupx/dupy for crosshairs
{
offsetx = FixedMul(offsetx, dupx<<FRACBITS);
offsety = FixedMul(offsety, dupy<<FRACBITS);
}
// Subtract the offsets from x/y positions
x -= offsetx;
y -= offsety;
}
if (scrn & V_SPLITSCREEN)
@ -497,7 +506,7 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
for (col = 0; (col>>FRACBITS) < SHORT(patch->width); col += colfrac, ++offx, desttop++)
{
INT32 topdelta, prevdelta = -1;
if (flip) // offx is measured from right edge instead of left
if (scrn & V_FLIP) // offx is measured from right edge instead of left
{
if (x+pwidth-offx < 0) // don't draw off the left of the screen (WRAP PREVENTION)
break;
@ -521,7 +530,7 @@ void V_DrawFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_t
prevdelta = topdelta;
source = (const UINT8 *)(column) + 3;
dest = desttop;
if (flip)
if (scrn & V_FLIP)
dest = deststart + (destend - desttop);
dest += FixedInt(FixedMul(topdelta<<FRACBITS,fdup))*vid.width;