Skip to content

Commit

Permalink
CalcSurfaceExtents: more info in extents error message
Browse files Browse the repository at this point in the history
s1lentq committed Dec 7, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent df862d9 commit 6e6368d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion rehlds/engine/model.cpp
Original file line number Diff line number Diff line change
@@ -854,6 +854,7 @@ void CalcSurfaceExtents(msurface_t *s)
int i, j, e;
mvertex_t *v;
mtexinfo_t *tex;
vec3_t middle{};
int bmins[2], bmaxs[2];

mins[0] = mins[1] = 999999;
@@ -869,6 +870,8 @@ void CalcSurfaceExtents(msurface_t *s)
else
v = &loadmodel->vertexes[loadmodel->edges[-e].v[1]];

VectorAdd(middle, v->position, middle);

for (j = 0; j < 2; j++)
{
// FIXED: loss of floating point
@@ -884,15 +887,25 @@ void CalcSurfaceExtents(msurface_t *s)
}
}

VectorScale(middle, 1.0f / s->numedges, middle);

for (i = 0; i < 2; i++)
{
bmins[i] = (int) floor(mins[i] / 16);
bmaxs[i] = (int) ceil(maxs[i] / 16);

s->texturemins[i] = bmins[i] * 16;
s->extents[i] = (bmaxs[i] - bmins[i]) * 16;

if (!(tex->flags & TEX_SPECIAL) && s->extents[i] > MAX_SURFACE_TEXTURE_SIZE)
Sys_Error("%s: Bad surface extents", __func__);
{
int surfID = s - loadmodel->surfaces;
Sys_Error("%s: Bad #%d surface extents %d/%d on %s at position (%d,%d,%d)",
__func__, surfID, s->extents[0], s->extents[1],
tex->texture->name,
(int)middle[0], (int)middle[1], (int)middle[2]
);
}
}
}

0 comments on commit 6e6368d

Please sign in to comment.