| 1226 | } |
| 1227 | |
| 1228 | void xEntCollide(xEnt* ent, xScene* sc, F32 dt) |
| 1229 | { |
| 1230 | if (ent->model) |
| 1231 | { |
| 1232 | if (ent->collis->chk & 0x2E) |
| 1233 | { |
| 1234 | xEntBeginCollide(ent, sc, dt); |
| 1235 | } |
| 1236 | |
| 1237 | if (ent->collis->chk & 0x8) |
| 1238 | { |
| 1239 | xEntCollCheckNPCsByGrid(ent, sc, xEntCollCheckOneEntNoDepen); |
| 1240 | } |
| 1241 | |
| 1242 | if (ent->collis->chk & 0x6) |
| 1243 | { |
| 1244 | xEntCollCheckByGrid(ent, sc, xEntCollCheckOneEntNoDepen); |
| 1245 | } |
| 1246 | |
| 1247 | if (ent->collis->chk & 0x20) |
| 1248 | { |
| 1249 | xEntCollCheckEnv(ent, sc); |
| 1250 | } |
| 1251 | |
| 1252 | xCollis* coll = &ent->collis->colls[0]; |
| 1253 | |
| 1254 | if (ent->collis->chk & 0x2E) |
| 1255 | { |
| 1256 | F32 h_dot_n; |
| 1257 | |
| 1258 | if (ent->bound.type == XBOUND_TYPE_SPHERE) |
| 1259 | { |
| 1260 | h_dot_n = ent->bound.sph.r; |
| 1261 | } |
| 1262 | else |
| 1263 | { |
| 1264 | h_dot_n = 0.7f; |
| 1265 | } |
| 1266 | |
| 1267 | if (ent->pflags & 0x80 && coll->flags & 0x1) |
| 1268 | { |
| 1269 | F32 depen_len = xVec3Dot(&coll->hdng, &coll->norm); |
| 1270 | |
| 1271 | if (depen_len > 0.0f) |
| 1272 | { |
| 1273 | xVec3Inv(&coll->norm, &coll->norm); |
| 1274 | depen_len = -depen_len; |
| 1275 | } |
| 1276 | |
| 1277 | depen_len = depen_len * coll->dist + h_dot_n; |
| 1278 | |
| 1279 | if (depen_len < 0.0f || depen_len > h_dot_n) |
| 1280 | { |
| 1281 | depen_len = CLAMP(depen_len, 0.0f, h_dot_n); |
| 1282 | } |
| 1283 | |
| 1284 | xVec3SMul(&coll->depen, &coll->norm, depen_len); |
| 1285 | } |
no test coverage detected