Browse Source

Fixed a silly mistake in the primitive buffer allocation space check

unrollquadloop
Nico de Poel 3 years ago
parent
commit
a478a7c1ed
  1. 14
      world.c

14
world.c

@ -54,7 +54,7 @@ static INLINE void drawface_triangle_fan(const ps1bsp_face_t *face, SVECTOR *vec
{ {
int p; int p;
if (!mem_checkprim(sizeof(POLY_G3), face->numFaceVertices))
if (!mem_checkprim(sizeof(POLY_G3), face->numFaceVertices - 2))
return; return;
// Draw the face as a triangle fan // Draw the face as a triangle fan
@ -94,7 +94,8 @@ static INLINE void drawface_triangle_strip(const ps1bsp_face_t *face, SVECTOR *v
{ {
int p; int p;
if (!mem_checkprim(sizeof(POLY_G3), face->numFaceVertices))
u_char numTris = face->numFaceVertices - 2;
if (!mem_checkprim(sizeof(POLY_G3), numTris))
return; return;
// Draw the face as a triangle strip // Draw the face as a triangle strip
@ -105,7 +106,6 @@ static INLINE void drawface_triangle_strip(const ps1bsp_face_t *face, SVECTOR *v
v2 = head++; // Initialize first vertex to index 0 and set head to index 1 v2 = head++; // Initialize first vertex to index 0 and set head to index 1
u_char numTris = face->numFaceVertices - 2;
for (u_char triIdx = 0; triIdx < numTris; ++triIdx) for (u_char triIdx = 0; triIdx < numTris; ++triIdx)
{ {
if (reverse ^= 1) if (reverse ^= 1)
@ -150,7 +150,8 @@ static INLINE void drawface_quad_strip(const ps1bsp_face_t *face, SVECTOR *vecs)
{ {
int p; int p;
if (!mem_checkprim(sizeof(POLY_G4), face->numFaceVertices))
u_char numQuads = (face->numFaceVertices - 1) / 2;
if (!mem_checkprim(sizeof(POLY_G4), numQuads))
return; return;
// Draw the face as a quad strip // Draw the face as a quad strip
@ -163,7 +164,6 @@ static INLINE void drawface_quad_strip(const ps1bsp_face_t *face, SVECTOR *vecs)
v3 = head++; v3 = head++;
// Normally a quad strip would have (N-2)/2 quads, but we might end up with a sole triangle at the end which will be drawn as a collapsed quad // Normally a quad strip would have (N-2)/2 quads, but we might end up with a sole triangle at the end which will be drawn as a collapsed quad
u_char numQuads = (face->numFaceVertices - 1) / 2;
for (u_char quadIdx = 0; quadIdx < numQuads; ++quadIdx) for (u_char quadIdx = 0; quadIdx < numQuads; ++quadIdx)
{ {
v0 = v2; v0 = v2;
@ -208,7 +208,8 @@ static INLINE void drawface_quad_strip_tex(const ps1bsp_face_t *face, STVECTOR *
{ {
int p; int p;
if (!mem_checkprim(sizeof(POLY_GT4), face->numFaceVertices))
u_char numQuads = (face->numFaceVertices - 1) / 2;
if (!mem_checkprim(sizeof(POLY_GT4), numQuads))
return; return;
// Draw the face as a quad strip // Draw the face as a quad strip
@ -221,7 +222,6 @@ static INLINE void drawface_quad_strip_tex(const ps1bsp_face_t *face, STVECTOR *
v3 = head++; v3 = head++;
// Normally a quad strip would have (N-2)/2 quads, but we might end up with a sole triangle at the end which will be drawn as a collapsed quad // Normally a quad strip would have (N-2)/2 quads, but we might end up with a sole triangle at the end which will be drawn as a collapsed quad
u_char numQuads = (face->numFaceVertices - 1) / 2;
for (u_char quadIdx = 0; quadIdx < numQuads; ++quadIdx) for (u_char quadIdx = 0; quadIdx < numQuads; ++quadIdx)
{ {
v0 = v2; v0 = v2;

Loading…
Cancel
Save