mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-09 01:01:07 +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++)
|
||||
{
|
||||
val = v->position[0] * tex->vecs[j][0] +
|
||||
v->position[1] * tex->vecs[j][1] +
|
||||
v->position[2] * tex->vecs[j][2] +
|
||||
tex->vecs[j][3];
|
||||
/* The following calculation is sensitive to floating-point
|
||||
* precision. It needs to produce the same result that the
|
||||
* light compiler does, because R_BuildLightMap uses surf->
|
||||
* 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])
|
||||
mins[j] = val;
|
||||
if (val > maxs[j])
|
||||
|
|
Loading…
Reference in a new issue