Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
tyrquake
Commits
20a9181c
Commit
20a9181c
authored
Jan 12, 2020
by
Libretro-Admin
Browse files
Backport
https://disenchant.net/git/tyrquake.git/commit/?id=0ca7766d0fed7e73284b55dd9c6d559c1944c84e
parent
74c9b7f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
common/model.c
View file @
20a9181c
...
...
@@ -996,10 +996,27 @@ CalcSurfaceExtents(msurface_t *s)
else
v
=
&
loadmodel
->
vertexes
[
loadmodel
->
edges
[
-
e
].
v
[
1
]];
/*
* The (long double) casts below are important: The original code was
* written for x87 floating-point which uses 80-bit floats for
* intermediate calculations. But if you compile it without the casts
* for modern x86_64, the compiler will round each intermediate result
* to a 32-bit float, which introduces extra rounding error.
*
* This becomes a problem if the rounding error causes the light
* utilities and the engine to disagree about the lightmap size for
* some surfaces.
*
* Casting to (long double) keeps the intermediate values at at least
* 64 bits of precision, probably 128.
*/
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
];
val
=
(
long
double
)
v
->
position
[
0
]
*
tex
->
vecs
[
j
][
0
]
+
(
long
double
)
v
->
position
[
1
]
*
tex
->
vecs
[
j
][
1
]
+
(
long
double
)
v
->
position
[
2
]
*
tex
->
vecs
[
j
][
2
]
+
tex
->
vecs
[
j
][
3
];
if
(
val
<
mins
[
j
])
mins
[
j
]
=
val
;
if
(
val
>
maxs
[
j
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment