Fully hook up sprite clipping by subsector

This commit is contained in:
Magnus Norddahl 2016-12-02 13:24:53 +01:00
parent 01008f0daa
commit ce6e1e1e47
3 changed files with 18 additions and 21 deletions

View file

@ -150,18 +150,9 @@ void RenderPolyPortal::RenderSprite(AActor *thing, double sortDistance, DVector2
DVector2 mid = left * (1.0 - t) + right * t;
double tmid = t1 * (1.0 - t) + t2 * t;
if (sideLeft == 0)
{
RenderSprite(thing, sortDistance, mid, right, tmid, t2, bsp->children[sideRight]);
right = mid;
t2 = tmid;
}
else
{
RenderSprite(thing, sortDistance, left, mid, t1, tmid, bsp->children[sideRight]);
left = mid;
t1 = tmid;
}
RenderSprite(thing, sortDistance, mid, right, tmid, t2, bsp->children[sideRight]);
right = mid;
t2 = tmid;
}
node = bsp->children[sideLeft];
}
@ -346,7 +337,7 @@ void RenderPolyPortal::RenderTranslucent(int portalDepth)
else
{
RenderPolySprite spr;
spr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1);
spr.Render(WorldToClip, PortalPlane, obj.thing, obj.sub, obj.subsectorDepth, StencilValue + 1, obj.SpriteLeft, obj.SpriteRight);
}
}
}

View file

@ -63,10 +63,10 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
return true;
}
void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue)
void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2)
{
DVector2 points[2];
if (!GetLine(thing, points[0], points[1]))
DVector2 line[2];
if (!GetLine(thing, line[0], line[1]))
return;
DVector3 pos = thing->InterpolatedPosition(r_TicFracF);
@ -108,10 +108,16 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla
std::pair<float, float> offsets[4] =
{
{ 0.0f, 1.0f },
{ 1.0f, 1.0f },
{ 1.0f, 0.0f },
{ 0.0f, 0.0f },
{ t1, 1.0f },
{ t2, 1.0f },
{ t2, 0.0f },
{ t1, 0.0f },
};
DVector2 points[2] =
{
line[0] * (1.0 - t1) + line[1] * t1,
line[0] * (1.0 - t2) + line[1] * t2
};
for (int i = 0; i < 4; i++)

View file

@ -29,7 +29,7 @@ class Vec4f;
class RenderPolySprite
{
public:
void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue);
void Render(const TriMatrix &worldToClip, const Vec4f &clipPlane, AActor *thing, subsector_t *sub, uint32_t subsectorDepth, uint32_t stencilValue, float t1, float t2);
static bool GetLine(AActor *thing, DVector2 &left, DVector2 &right);
static bool IsThingCulled(AActor *thing);