mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-13 07:21:31 +00:00
gl_model.c (CalcSurfaceExtents): fix a lighting glitch due to floating point precision. patch from Eric Wasylishen.
git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@908 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
908ecf84a0
commit
5e6683608d
1 changed files with 20 additions and 4 deletions
|
@ -943,10 +943,26 @@ void CalcSurfaceExtents (msurface_t *s)
|
||||||
|
|
||||||
for (j=0 ; j<2 ; j++)
|
for (j=0 ; j<2 ; j++)
|
||||||
{
|
{
|
||||||
val = v->position[0] * tex->vecs[j][0] +
|
/* The following calculation is sensitive to floating-point
|
||||||
v->position[1] * tex->vecs[j][1] +
|
* precision. It needs to produce the same result that the
|
||||||
v->position[2] * tex->vecs[j][2] +
|
* light compiler does, because R_BuildLightMap uses surf->
|
||||||
tex->vecs[j][3];
|
* extents to know the width/height of a surface's lightmap,
|
||||||
|
* and incorrect rounding here manifests itself as patches
|
||||||
|
* of "corrupted" looking lightmaps.
|
||||||
|
* Most light compilers are win32 executables, so they use
|
||||||
|
* x87 floating point. This means the multiplies and adds
|
||||||
|
* are done at 80-bit precision, and the result is rounded
|
||||||
|
* down to 32-bits and stored in val.
|
||||||
|
* Adding the casts to double seems to be good enough to fix
|
||||||
|
* lighting glitches when Quakespasm is compiled as x86_64
|
||||||
|
* and using SSE2 floating-point. A potential trouble spot
|
||||||
|
* is the hallway at the beginning of mfxsp17. -- ericw
|
||||||
|
*/
|
||||||
|
val = ((double)v->position[0] * (double)tex->vecs[j][0]) +
|
||||||
|
((double)v->position[1] * (double)tex->vecs[j][1]) +
|
||||||
|
((double)v->position[2] * (double)tex->vecs[j][2]) +
|
||||||
|
(double)tex->vecs[j][3];
|
||||||
|
|
||||||
if (val < mins[j])
|
if (val < mins[j])
|
||||||
mins[j] = val;
|
mins[j] = val;
|
||||||
if (val > maxs[j])
|
if (val > maxs[j])
|
||||||
|
|
Loading…
Reference in a new issue