mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-01 00:21:35 +00:00
Fix dancing sprites regression
This commit is contained in:
parent
e0e0fb0d8f
commit
d7924d6e9d
3 changed files with 32 additions and 17 deletions
|
@ -54,6 +54,8 @@ namespace swrenderer
|
|||
auto viewport = thread->Viewport.get();
|
||||
RenderPortal* renderportal = thread->Portal.get();
|
||||
|
||||
// Rotate to view direction:
|
||||
|
||||
tleft.X = float(pt1.X * viewport->viewpoint.Sin - pt1.Y * viewport->viewpoint.Cos);
|
||||
tright.X = float(pt2.X * viewport->viewpoint.Sin - pt2.Y * viewport->viewpoint.Cos);
|
||||
|
||||
|
@ -68,6 +70,8 @@ namespace swrenderer
|
|||
std::swap(tleft.Y, tright.Y);
|
||||
}
|
||||
|
||||
// Edge clip:
|
||||
|
||||
float fsx1, fsz1, fsx2, fsz2;
|
||||
|
||||
if (tleft.X >= -tleft.Y)
|
||||
|
@ -112,23 +116,20 @@ namespace swrenderer
|
|||
if (fsz2 < TOO_CLOSE_Z)
|
||||
return true;
|
||||
|
||||
// Find screen range covered by the line:
|
||||
|
||||
sx1 = xs_RoundToInt(fsx1);
|
||||
sx2 = xs_RoundToInt(fsx2);
|
||||
|
||||
float delta = fsx2 - fsx1;
|
||||
float t1 = (sx1 + 0.5f - fsx1) / delta;
|
||||
float t2 = (sx2 + 0.5f - fsx1) / delta;
|
||||
float invZ1 = 1.0f / fsz1;
|
||||
float invZ2 = 1.0f / fsz2;
|
||||
sz1 = 1.0f / (invZ1 * (1.0f - t1) + invZ2 * t1);
|
||||
sz2 = 1.0f / (invZ1 * (1.0f - t2) + invZ2 * t2);
|
||||
|
||||
if (sx2 <= sx1)
|
||||
return true;
|
||||
|
||||
// Remap texture coordinates to the part covered by the line segment:
|
||||
|
||||
if (lineseg && lineseg->linedef)
|
||||
{
|
||||
line_t* line = lineseg->linedef;
|
||||
float t1, t2;
|
||||
if (fabs(line->delta.X) > fabs(line->delta.Y))
|
||||
{
|
||||
t1 = (lineseg->v1->fX() - line->v1->fX()) / line->delta.X;
|
||||
|
@ -150,6 +151,23 @@ namespace swrenderer
|
|||
tx2 = t1 + tx2 * (t2 - t1);
|
||||
}
|
||||
|
||||
// Calculate screen depths for the start and end points (resulting values are at the pixel center):
|
||||
|
||||
float delta = fsx2 - fsx1;
|
||||
float t1 = (sx1 + 0.5f - fsx1) / delta;
|
||||
float t2 = (sx2 + 0.5f - fsx1) / delta;
|
||||
float invZ1 = 1.0f / fsz1;
|
||||
float invZ2 = 1.0f / fsz2;
|
||||
sz1 = 1.0f / (invZ1 * (1.0f - t1) + invZ2 * t1);
|
||||
sz2 = 1.0f / (invZ1 * (1.0f - t2) + invZ2 * t2);
|
||||
|
||||
// Adjust texture coordinates to also be at the pixel centers:
|
||||
|
||||
float ftx1 = tx1 * invZ1;
|
||||
float ftx2 = tx2 * invZ2;
|
||||
tx1 = (ftx1 * (1.0f - t1) + ftx2 * t1) * sz1;
|
||||
tx2 = (ftx1 * (1.0f - t2) + ftx2 * t2) * sz2;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,9 +70,6 @@ namespace swrenderer
|
|||
iscale = -iscale;
|
||||
float vstepY = iscale / WallC.sz1 / (viewport->InvZtoScale / WallC.sz1);
|
||||
|
||||
wpos += wstepX * 0.5f;
|
||||
upos += ustepX * 0.5f;
|
||||
|
||||
int x1 = MAX<int>(WallC.sx1, clipx1);
|
||||
int x2 = MIN<int>(WallC.sx2, clipx2);
|
||||
if (x1 >= x2)
|
||||
|
@ -165,7 +162,7 @@ namespace swrenderer
|
|||
}
|
||||
}
|
||||
|
||||
void SpriteDrawerArgs::DrawMaskedColumn(RenderThread* thread, int x, int y1, int cliptop, int clipbottom, uint32_t texelX, uint32_t texelStepX, uint32_t texelStepY, float scaleV, bool flipY, FSoftwareTexture* tex, int texwidth, int texheight, bool bgra, FRenderStyle style)
|
||||
void SpriteDrawerArgs::DrawMaskedColumn(RenderThread* thread, int x, float y1, int cliptop, int clipbottom, uint32_t texelX, uint32_t texelStepX, uint32_t texelStepY, float scaleV, bool flipY, FSoftwareTexture* tex, int texwidth, int texheight, bool bgra, FRenderStyle style)
|
||||
{
|
||||
const FSoftwareTextureSpan* span;
|
||||
if (bgra)
|
||||
|
@ -230,8 +227,8 @@ namespace swrenderer
|
|||
const int top = span->TopOffset;
|
||||
|
||||
// calculate unclipped screen coordinates for post
|
||||
dc_yl = (int)(y1 + top / scaleV + 0.5f);
|
||||
dc_yh = (int)(y1 + (top + length) / scaleV + 0.5f);
|
||||
dc_yl = xs_RoundToInt(y1 + top / scaleV);
|
||||
dc_yh = xs_RoundToInt(y1 + (top + length) / scaleV);
|
||||
|
||||
if (flipY)
|
||||
std::swap(dc_yl, dc_yh);
|
||||
|
@ -268,8 +265,8 @@ namespace swrenderer
|
|||
const int top = span->TopOffset;
|
||||
|
||||
// calculate unclipped screen coordinates for post
|
||||
dc_yl = (int)(y1 + top / scaleV + 0.5f);
|
||||
dc_yh = (int)(y1 + (top + length) / scaleV + 0.5f);
|
||||
dc_yl = xs_RoundToInt(y1 + top / scaleV);
|
||||
dc_yh = xs_RoundToInt(y1 + (top + length) / scaleV);
|
||||
|
||||
if (flipY)
|
||||
std::swap(dc_yl, dc_yh);
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace swrenderer
|
|||
RenderViewport *Viewport() const { return dc_viewport; }
|
||||
|
||||
private:
|
||||
void DrawMaskedColumn(RenderThread* thread, int x, int y1, int cliptop, int clipbottom, uint32_t texelX, uint32_t texelStepX, uint32_t texelStepY, float scaleV, bool flipY, FSoftwareTexture* tex, int texwidth, int texheight, bool bgra, FRenderStyle style);
|
||||
void DrawMaskedColumn(RenderThread* thread, int x, float y1, int cliptop, int clipbottom, uint32_t texelX, uint32_t texelStepX, uint32_t texelStepY, float scaleV, bool flipY, FSoftwareTexture* tex, int texwidth, int texheight, bool bgra, FRenderStyle style);
|
||||
|
||||
void SetDest(RenderViewport* viewport, int x, int y);
|
||||
void SetCount(int count) { dc_count = count; }
|
||||
|
|
Loading…
Reference in a new issue