mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-27 21:51:00 +00:00
Crash fixes
This commit is contained in:
parent
6c52e1e52b
commit
b94096ffe1
5 changed files with 24 additions and 17 deletions
|
@ -129,7 +129,7 @@ void RenderPolyBsp::RenderSubsector(subsector_t *sub)
|
||||||
for (uint32_t i = 0; i < sub->numlines; i++)
|
for (uint32_t i = 0; i < sub->numlines; i++)
|
||||||
{
|
{
|
||||||
seg_t *line = &sub->firstline[i];
|
seg_t *line = &sub->firstline[i];
|
||||||
if (line->sidedef == NULL || !(line->sidedef->Flags & WALLF_POLYOBJ))
|
if (line->sidedef == nullptr || !(line->sidedef->Flags & WALLF_POLYOBJ))
|
||||||
AddLine(line, frontsector);
|
AddLine(line, frontsector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,12 +237,15 @@ void RenderPolyBsp::AddLine(seg_t *line, sector_t *frontsector)
|
||||||
|
|
||||||
if (line->backsector == nullptr)
|
if (line->backsector == nullptr)
|
||||||
{
|
{
|
||||||
wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2);
|
if (line->sidedef)
|
||||||
wall.TopZ = frontceilz1;
|
{
|
||||||
wall.BottomZ = frontfloorz1;
|
wall.SetCoords(line->v1->fPos(), line->v2->fPos(), frontceilz1, frontfloorz1, frontceilz2, frontfloorz2);
|
||||||
wall.UnpeggedCeil = frontceilz1;
|
wall.TopZ = frontceilz1;
|
||||||
wall.Texpart = side_t::mid;
|
wall.BottomZ = frontfloorz1;
|
||||||
wall.Render(worldToClip);
|
wall.UnpeggedCeil = frontceilz1;
|
||||||
|
wall.Texpart = side_t::mid;
|
||||||
|
wall.Render(worldToClip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -469,7 +472,7 @@ visstyle_t RenderPolyBsp::GetSpriteVisStyle(AActor *thing, double z)
|
||||||
}
|
}
|
||||||
|
|
||||||
// get light level
|
// get light level
|
||||||
if (fixedcolormap != NULL)
|
if (fixedcolormap != nullptr)
|
||||||
{ // fixed map
|
{ // fixed map
|
||||||
visstyle.BaseColormap = fixedcolormap;
|
visstyle.BaseColormap = fixedcolormap;
|
||||||
visstyle.ColormapNum = 0;
|
visstyle.ColormapNum = 0;
|
||||||
|
@ -1268,7 +1271,7 @@ void PolyScreenSprite::Render()
|
||||||
DTA_FillColor, FillColor,
|
DTA_FillColor, FillColor,
|
||||||
DTA_SpecialColormap, special,
|
DTA_SpecialColormap, special,
|
||||||
DTA_ColorOverlay, overlay.d,
|
DTA_ColorOverlay, overlay.d,
|
||||||
DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : NULL,
|
DTA_ColormapStyle, usecolormapstyle ? &colormapstyle : nullptr,
|
||||||
TAG_DONE);
|
TAG_DONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ TriVertex PolyTriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVerte
|
||||||
void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *))
|
void PolyTriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenPolyTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenPolyTriangleDrawerArgs *, DrawerThread *))
|
||||||
{
|
{
|
||||||
// Cull, clip and generate additional vertices as needed
|
// Cull, clip and generate additional vertices as needed
|
||||||
TriVertex clippedvert[12];
|
TriVertex clippedvert[max_additional_vertices];
|
||||||
int numclipvert;
|
int numclipvert;
|
||||||
clipedge(vert, clippedvert, numclipvert);
|
clipedge(vert, clippedvert, numclipvert);
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert
|
||||||
// -v.w <= v.z <= v.w
|
// -v.w <= v.z <= v.w
|
||||||
|
|
||||||
// use barycentric weights while clipping vertices
|
// use barycentric weights while clipping vertices
|
||||||
float weights[12 * 3 * 2];
|
float weights[max_additional_vertices * 3 * 2];
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
weights[i * 3 + 0] = 0.0f;
|
weights[i * 3 + 0] = 0.0f;
|
||||||
|
@ -220,7 +220,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert
|
||||||
|
|
||||||
// Clip against each halfspace
|
// Clip against each halfspace
|
||||||
float *input = weights;
|
float *input = weights;
|
||||||
float *output = weights + 12 * 3;
|
float *output = weights + max_additional_vertices * 3;
|
||||||
int inputverts = 3;
|
int inputverts = 3;
|
||||||
int outputverts = 0;
|
int outputverts = 0;
|
||||||
for (int p = 0; p < 6; p++)
|
for (int p = 0; p < 6; p++)
|
||||||
|
@ -241,7 +241,7 @@ void PolyTriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert
|
||||||
clipdistance[2 * 6 + p] * input[j * 3 + 2];
|
clipdistance[2 * 6 + p] * input[j * 3 + 2];
|
||||||
|
|
||||||
float t1, t2;
|
float t1, t2;
|
||||||
if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2))
|
if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2) && outputverts + 1 < max_additional_vertices)
|
||||||
{
|
{
|
||||||
// add t1 vertex
|
// add t1 vertex
|
||||||
for (int k = 0; k < 3; k++)
|
for (int k = 0; k < 3; k++)
|
||||||
|
|
|
@ -43,6 +43,8 @@ private:
|
||||||
|
|
||||||
static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor);
|
static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, int cliptop, int clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor);
|
||||||
|
|
||||||
|
enum { max_additional_vertices = 16 };
|
||||||
|
|
||||||
friend class DrawPolyTrianglesCommand;
|
friend class DrawPolyTrianglesCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ TriVertex TriangleDrawer::shade_vertex(const TriUniforms &uniforms, TriVertex v)
|
||||||
void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *))
|
void TriangleDrawer::draw_shaded_triangle(const TriVertex *vert, bool ccw, ScreenTriangleDrawerArgs *args, DrawerThread *thread, void(*drawfunc)(const ScreenTriangleDrawerArgs *, DrawerThread *))
|
||||||
{
|
{
|
||||||
// Cull, clip and generate additional vertices as needed
|
// Cull, clip and generate additional vertices as needed
|
||||||
TriVertex clippedvert[12];
|
TriVertex clippedvert[max_additional_vertices];
|
||||||
int numclipvert;
|
int numclipvert;
|
||||||
clipedge(vert, clippedvert, numclipvert);
|
clipedge(vert, clippedvert, numclipvert);
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, in
|
||||||
// -v.w <= v.z <= v.w
|
// -v.w <= v.z <= v.w
|
||||||
|
|
||||||
// use barycentric weights while clipping vertices
|
// use barycentric weights while clipping vertices
|
||||||
float weights[12 * 3 * 2];
|
float weights[max_additional_vertices * 3 * 2];
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
weights[i * 3 + 0] = 0.0f;
|
weights[i * 3 + 0] = 0.0f;
|
||||||
|
@ -231,7 +231,7 @@ void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, in
|
||||||
|
|
||||||
// Clip against each halfspace
|
// Clip against each halfspace
|
||||||
float *input = weights;
|
float *input = weights;
|
||||||
float *output = weights + 12 * 3;
|
float *output = weights + max_additional_vertices * 3;
|
||||||
int inputverts = 3;
|
int inputverts = 3;
|
||||||
int outputverts = 0;
|
int outputverts = 0;
|
||||||
for (int p = 0; p < 6; p++)
|
for (int p = 0; p < 6; p++)
|
||||||
|
@ -252,7 +252,7 @@ void TriangleDrawer::clipedge(const TriVertex *verts, TriVertex *clippedvert, in
|
||||||
clipdistance[2 * 6 + p] * input[j * 3 + 2];
|
clipdistance[2 * 6 + p] * input[j * 3 + 2];
|
||||||
|
|
||||||
float t1, t2;
|
float t1, t2;
|
||||||
if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2))
|
if (!cullhalfspace(clipdistance1, clipdistance2, t1, t2) && outputverts + 1 < max_additional_vertices)
|
||||||
{
|
{
|
||||||
// add t1 vertex
|
// add t1 vertex
|
||||||
for (int k = 0; k < 3; k++)
|
for (int k = 0; k < 3; k++)
|
||||||
|
|
|
@ -106,6 +106,8 @@ private:
|
||||||
|
|
||||||
static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor);
|
static void queue_arrays(const TriUniforms &uniforms, const TriVertex *vinput, int vcount, TriangleDrawMode mode, bool ccw, int clipleft, int clipright, const short *cliptop, const short *clipbottom, const uint8_t *texturePixels, int textureWidth, int textureHeight, int solidcolor);
|
||||||
|
|
||||||
|
enum { max_additional_vertices = 16 };
|
||||||
|
|
||||||
friend class DrawTrianglesCommand;
|
friend class DrawTrianglesCommand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue