mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-27 22:31:07 +00:00
Cull walls
This commit is contained in:
parent
27eb8e36ae
commit
c914a7a7fe
2 changed files with 19 additions and 6 deletions
|
@ -46,10 +46,7 @@ void RenderPolyBsp::Render()
|
||||||
|
|
||||||
// Setup working buffers
|
// Setup working buffers
|
||||||
PolyVertexBuffer::Clear();
|
PolyVertexBuffer::Clear();
|
||||||
SolidSegments.clear();
|
ClearSolidSegments();
|
||||||
SolidSegments.reserve(SolidCullScale + 2);
|
|
||||||
SolidSegments.push_back({ -0x7fff, -SolidCullScale });
|
|
||||||
SolidSegments.push_back({ SolidCullScale , 0x7fff });
|
|
||||||
SectorSpriteRanges.clear();
|
SectorSpriteRanges.clear();
|
||||||
SectorSpriteRanges.resize(numsectors);
|
SectorSpriteRanges.resize(numsectors);
|
||||||
SortedSprites.clear();
|
SortedSprites.clear();
|
||||||
|
@ -92,6 +89,7 @@ void RenderPolyBsp::Render()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render front to back
|
// Render front to back
|
||||||
|
ClearSolidSegments();
|
||||||
if (r_debug_cull)
|
if (r_debug_cull)
|
||||||
{
|
{
|
||||||
for (auto it = PvsSectors.rbegin(); it != PvsSectors.rend(); ++it)
|
for (auto it = PvsSectors.rbegin(); it != PvsSectors.rend(); ++it)
|
||||||
|
@ -363,6 +361,12 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector, uint32_t subsect
|
||||||
if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0)
|
if (pt1.Y * (pt1.X - pt2.X) + pt1.X * (pt2.Y - pt1.Y) >= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Cull wall if not visible
|
||||||
|
int sx1, sx2;
|
||||||
|
bool hasSegmentRange = GetSegmentRangeForLine(line->v1->fX(), line->v1->fY(), line->v2->fX(), line->v2->fY(), sx1, sx2);
|
||||||
|
if (hasSegmentRange && IsSegmentCulled(sx1, sx2))
|
||||||
|
return;
|
||||||
|
|
||||||
double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1);
|
double frontceilz1 = frontsector->ceilingplane.ZatPoint(line->v1);
|
||||||
double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1);
|
double frontfloorz1 = frontsector->floorplane.ZatPoint(line->v1);
|
||||||
double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2);
|
double frontceilz2 = frontsector->ceilingplane.ZatPoint(line->v2);
|
||||||
|
@ -384,6 +388,8 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector, uint32_t subsect
|
||||||
wall.UnpeggedCeil = frontceilz1;
|
wall.UnpeggedCeil = frontceilz1;
|
||||||
wall.Texpart = side_t::mid;
|
wall.Texpart = side_t::mid;
|
||||||
wall.Render(worldToClip);
|
wall.Render(worldToClip);
|
||||||
|
if (hasSegmentRange)
|
||||||
|
MarkSegmentCulled(sx1, sx2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -972,6 +978,14 @@ void RenderPolyBsp::RenderPlayerSprite(DPSprite *sprite, AActor *owner, float bo
|
||||||
//R_DrawVisSprite(vis);
|
//R_DrawVisSprite(vis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RenderPolyBsp::ClearSolidSegments()
|
||||||
|
{
|
||||||
|
SolidSegments.clear();
|
||||||
|
SolidSegments.reserve(SolidCullScale + 2);
|
||||||
|
SolidSegments.push_back({ -0x7fff, -SolidCullScale });
|
||||||
|
SolidSegments.push_back({ SolidCullScale , 0x7fff });
|
||||||
|
}
|
||||||
|
|
||||||
bool RenderPolyBsp::IsSegmentCulled(int x1, int x2) const
|
bool RenderPolyBsp::IsSegmentCulled(int x1, int x2) const
|
||||||
{
|
{
|
||||||
int next = 0;
|
int next = 0;
|
||||||
|
|
|
@ -132,11 +132,10 @@ private:
|
||||||
// Checks BSP node/subtree bounding box.
|
// Checks BSP node/subtree bounding box.
|
||||||
// Returns true if some part of the bbox might be visible.
|
// Returns true if some part of the bbox might be visible.
|
||||||
bool CheckBBox(float *bspcoord);
|
bool CheckBBox(float *bspcoord);
|
||||||
|
|
||||||
bool GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const;
|
bool GetSegmentRangeForLine(double x1, double y1, double x2, double y2, int &sx1, int &sx2) const;
|
||||||
|
|
||||||
void MarkSegmentCulled(int x1, int x2);
|
void MarkSegmentCulled(int x1, int x2);
|
||||||
bool IsSegmentCulled(int x1, int x2) const;
|
bool IsSegmentCulled(int x1, int x2) const;
|
||||||
|
void ClearSolidSegments();
|
||||||
|
|
||||||
std::vector<subsector_t *> PvsSectors;
|
std::vector<subsector_t *> PvsSectors;
|
||||||
uint32_t NextSubsectorDepth = 0;
|
uint32_t NextSubsectorDepth = 0;
|
||||||
|
|
Loading…
Reference in a new issue