Differences From Artifact [0149f2d0e3]:
- File
src/physics.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: 12141) [annotate] [blame] [check-ins using]
To Artifact [bf839677bd]:
- File src/physics.m — part of check-in [85566b261d] at 2025-03-23 14:17:30 on branch trunk — Adjust to ObjFW changes (user: js, size: 12148) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
204 205 206 207 208 209 210 | if (space < 0) { if (space > -0.01) // stick on step d.origin = OFMakeVector3D( d.origin.x, d.origin.y, lo + d.eyeHeight); else if (space > -1.26f) // rise thru stair | | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | if (space < 0) { if (space > -0.01) // stick on step d.origin = OFMakeVector3D( d.origin.x, d.origin.y, lo + d.eyeHeight); else if (space > -1.26f) // rise thru stair d.origin = OFAddVectors3D( d.origin, OFMakeVector3D(0, 0, rise)); else return false; } else // gravity d.origin = OFSubtractVectors3D(d.origin, OFMakeVector3D( 0, 0, min(min(drop, space), headspace))); const float space2 = hi - (d.origin.z + d.aboveEye); if (space2 < 0) { if (space2 < -0.1) return false; // hack alert! |
︙ | ︙ | |||
357 358 359 360 361 362 363 | const float drop = dropf * curtime / gravity / 100 / moveres; // extra smoothness when lifting up stairs const float rise = speed / moveres / 1.2f; // discrete steps collision detection & sliding for (int i = 0; i < moveres; i++) { // try move forward | | | | | | | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | const float drop = dropf * curtime / gravity / 100 / moveres; // extra smoothness when lifting up stairs const float rise = speed / moveres / 1.2f; // discrete steps collision detection & sliding for (int i = 0; i < moveres; i++) { // try move forward pl.origin = OFAddVectors3D(pl.origin, OFMakeVector3D(f * d.x, f * d.y, f * d.z)); if (collide(pl, false, drop, rise)) continue; // player stuck, try slide along y axis pl.blocked = true; pl.origin = OFSubtractVectors3D( pl.origin, OFMakeVector3D(f * d.x, 0, 0)); if (collide(pl, false, drop, rise)) { d.x = 0; continue; } // still stuck, try x axis pl.origin = OFAddVectors3D( pl.origin, OFMakeVector3D(f * d.x, -f * d.y, 0)); if (collide(pl, false, drop, rise)) { d.y = 0; continue; } // try just dropping down pl.moving = false; pl.origin = OFSubtractVectors3D( pl.origin, OFMakeVector3D(f * d.x, 0, 0)); if (collide(pl, false, drop, rise)) { d.y = d.x = 0; continue; } pl.origin = OFSubtractVectors3D( pl.origin, OFMakeVector3D(0, 0, f * d.z)); break; } } // detect wether player is outside map, used for skipping zbuffer clear // mostly |
︙ | ︙ |