Differences From Artifact [504811d94d]:
- File
src/worldocull.m
— part of check-in
[6b85eefc85]
at
2025-03-23 02:47:40
on branch trunk
— Remove loop[ijkl]
They confused clang-format a lot. (user: js, size: 4556) [annotate] [blame] [check-ins using]
To Artifact [1dcc5bb2a7]:
- File src/worldocull.m — part of check-in [51fb59fc93] at 2025-03-23 17:45:28 on branch trunk — Remove fast_f2nat (user: js, size: 4454) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
31 32 33 34 35 36 37 | float apitch = (float)fabs(player1.pitch); float af = getvar(@"fov") / 2 + apitch / 1.5f + 3; float byaw = (player1.yaw - 90 + af) / 360 * PI2; float syaw = (player1.yaw - 90 - af) / 360 * PI2; for (int i = 0; i < NUMRAYS; i++) { float angle = i * PI2 / NUMRAYS; | > | | | < < < < | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | float apitch = (float)fabs(player1.pitch); float af = getvar(@"fov") / 2 + apitch / 1.5f + 3; float byaw = (player1.yaw - 90 + af) / 360 * PI2; float syaw = (player1.yaw - 90 - af) / 360 * PI2; for (int i = 0; i < NUMRAYS; i++) { float angle = i * PI2 / NUMRAYS; // try to avoid tracing ray if outside of frustrum // apitch must be bigger if fov > 120 if ((apitch > 45 || (angle < byaw && angle > syaw) || (angle < byaw - PI2 && angle > syaw - PI2) || (angle < byaw + PI2 && angle > syaw + PI2)) && !OUTBORD(vx, vy) && !SOLID(S((int)vx, (int)vy))) { float ray = i * 8 / (float)NUMRAYS; float dx, dy; if (ray > 1 && ray < 3) { dx = -(ray - 2); dy = 1; } else if (ray >= 3 && ray < 5) { dx = -1; |
︙ | ︙ | |||
62 63 64 65 66 67 68 | float sx = vx; float sy = vy; for (;;) { sx += dx; sy += dy; // 90% of time spend in this function is on this // line | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | float sx = vx; float sy = vy; for (;;) { sx += dx; sy += dy; // 90% of time spend in this function is on this // line if (SOLID(S((int)sx, (int)sy))) { rdist[i] = (float)(fabs(sx - vx) + fabs(sy - vy)); break; } } } else rdist[i] = 2; |
︙ | ︙ | |||
179 180 181 182 183 184 185 | l = ma(cx - vx, cy + csize - vy); } // E } else { h = ca(cx + csize - vx, cy - vy); l = ca(cx - vx, cy + csize - vy); } // H } | < | > | | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | l = ma(cx - vx, cy + csize - vy); } // E } else { h = ca(cx + csize - vx, cy - vy); l = ca(cx - vx, cy + csize - vy); } // H } // get indexes into occlusion map from angles int si = h * (NUMRAYS / 8) + NUMRAYS; int ei = l * (NUMRAYS / 8) + NUMRAYS + 1; if (ei <= si) ei += NUMRAYS; for (int i = si; i <= ei; i++) { if (dist < rdist[i & (NUMRAYS - 1)]) // if any value in this segment of the occlusion map is // further away then cube is not occluded return 0; } return 1; // cube is entirely occluded } |