1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-16 18:29:59 +00:00

fixed numerical artifacts in Nil

This commit is contained in:
Zeno Rogue 2019-08-08 00:09:06 +02:00
parent 6ab7535088
commit 5a3a408831

View File

@ -408,7 +408,8 @@ namespace nilv {
"for(int it=0; it<50; it++) {" "for(int it=0; it<50; it++) {"
"float w = (wmin + wmax) / 2.;" "float w = (wmin + wmax) / 2.;"
"float z = b * b * (s + (sin(w) - w)/(cos(w) - 1.)) + w;" // the formula after ':' produces visible numerical artifacts for w~0
"float z = b * b * (s + (abs(w) < .1 ? w/3. + w*w*w/90. + w*w*w*w*w/2520.: (sin(w) - w)/(cos(w) - 1.))) + w;"
"if(h[2] > z) wmin = w;" "if(h[2] > z) wmin = w;"
"else wmax = w;" "else wmax = w;"
"}" "}"