Differences From Artifact [95d4c13f64]:
- File
src/physics.m
— part of check-in
[75e920ae30]
at
2025-03-29 14:25:43
on branch trunk
— Switch from clang-format to manual formatting
clang-format does too many weird things. (user: js, size: 12270) [annotate] [blame] [check-ins using]
To Artifact [775d6c79ad]:
- File src/physics.m — part of check-in [c634a689e7] at 2025-03-29 17:13:40 on branch trunk — More style fixes (user: js, size: 12050) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
11 12 13 14 15 16 17 | #import "MapModelInfo.h" #import "Monster.h" #import "Player.h" #import "Variable.h" // collide with player or monster static bool | < | > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #import "MapModelInfo.h" #import "Monster.h" #import "Player.h" #import "Variable.h" // collide with player or monster static bool plcollide(DynamicEntity *d, DynamicEntity *o, float *headspace, float *hi, float *lo) { if (o.state != CS_ALIVE) return true; const float r = o.radius + d.radius; if (fabs(o.origin.x - d.origin.x) < r && fabs(o.origin.y - d.origin.y) < r) { |
︙ | ︙ | |||
121 122 123 124 125 126 127 | float floor = s->floor; switch (s->type) { case SOLID: return false; case CORNER: { int bx = x, by = y, bs = 1; | | < | < | < | | < < | | < < | | | | < | | < | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | float floor = s->floor; switch (s->type) { case SOLID: return false; case CORNER: { int bx = x, by = y, bs = 1; if ((x == x1 && y == y1 && cornertest(0, x, y, -1, -1, &bx, &by, &bs) && fx1 - bx + fy1 - by <= bs) || (x == x2 && y == y1 && cornertest(0, x, y, 1, -1, &bx, &by, &bs) && fx2 - bx >= fy1 - by) || (x == x1 && y == y2 && cornertest(0, x, y, -1, 1, &bx, &by, &bs) && fx1 - bx <= fy2 - by) || (x == x2 && y == y2 && cornertest(0, x, y, 1, 1, &bx, &by, &bs) && fx2 - bx + fy2 - by >= bs)) return false; break; } // FIXME: too simplistic collision with slopes, makes // it feels like tiny stairs case FHF: floor -= (s->vdelta + S(x + 1, y)->vdelta + S(x, y + 1)->vdelta + S(x + 1, y + 1)->vdelta) / 16.0f; break; case CHF: ceil += (s->vdelta + S(x + 1, y)->vdelta + S(x, y + 1)->vdelta + S(x + 1, y + 1)->vdelta) / 16.0f; } if (ceil < hi) hi = ceil; if (floor > lo) lo = floor; if (floor < minfloor) |
︙ | ︙ | |||
210 211 212 213 214 215 216 | // rise thru stair d.origin = OFAddVectors3D( d.origin, OFMakeVector3D(0, 0, rise)); else return false; } else // gravity | | < | | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | // 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! // glue to ceiling d.origin = OFMakeVector3D( |
︙ | ︙ | |||
403 404 405 406 407 408 409 | // mostly if (pl.origin.x < 0 || pl.origin.x >= ssize || pl.origin.y < 0 || pl.origin.y > ssize) pl.outsideMap = true; else { struct sqr *s = S((int)pl.origin.x, (int)pl.origin.y); | | < | | | | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | // mostly if (pl.origin.x < 0 || pl.origin.x >= ssize || pl.origin.y < 0 || pl.origin.y > ssize) pl.outsideMap = true; else { struct sqr *s = S((int)pl.origin.x, (int)pl.origin.y); pl.outsideMap = (SOLID(s) || pl.origin.z < s->floor - (s->type == FHF ? s->vdelta / 4 : 0) || pl.origin.z > s->ceil + (s->type == CHF ? s->vdelta / 4 : 0)); } // automatically apply smooth roll when strafing if (pl.strafe == 0) pl.roll = pl.roll / (1 + (float)sqrt((float)curtime) / 25); else { |
︙ | ︙ | |||
439 440 441 442 443 444 445 | pl.inWater = water; } void moveplayer(DynamicEntity *pl, int moveres, bool local) { for (int i = 0; i < physicsrepeat; i++) | | < < | | 428 429 430 431 432 433 434 435 436 437 | pl.inWater = water; } void moveplayer(DynamicEntity *pl, int moveres, bool local) { for (int i = 0; i < physicsrepeat; i++) moveplayer4(pl, moveres, local, i ? curtime / physicsrepeat : curtime - curtime / physicsrepeat * (physicsrepeat - 1)); } |