NOTE: Previously DoProperDetection().
| 1292 | |
| 1293 | // NOTE: Previously DoProperDetection(). |
| 1294 | void DoProjectileDynamics(short itemNumber, int x, int y, int z, int xv, int yv, int zv) |
| 1295 | { |
| 1296 | auto* item = &g_Level.Items[itemNumber]; |
| 1297 | |
| 1298 | auto prevPointColl = GetPointCollision(Vector3i(x, y, z), item->RoomNumber); |
| 1299 | auto pointColl = GetPointCollision(*item); |
| 1300 | |
| 1301 | // TODO: Use floor normal directly. |
| 1302 | auto floorTilt = GetSurfaceTilt(pointColl.GetFloorNormal(), true); |
| 1303 | |
| 1304 | auto bounds = GameBoundingBox(item); |
| 1305 | int radius = bounds.GetHeight(); |
| 1306 | |
| 1307 | item->Pose.Position.y += radius; |
| 1308 | |
| 1309 | if (item->Pose.Position.y >= pointColl.GetFloorHeight()) |
| 1310 | { |
| 1311 | int bs = 0; |
| 1312 | |
| 1313 | if (pointColl.IsSteepFloor() && prevPointColl.GetFloorHeight() < pointColl.GetFloorHeight()) |
| 1314 | { |
| 1315 | int yAngle = (long)((unsigned short)item->Pose.Orientation.y); |
| 1316 | |
| 1317 | if (floorTilt.x < 0) |
| 1318 | { |
| 1319 | if (yAngle >= ANGLE(180.0f)) |
| 1320 | bs = 1; |
| 1321 | } |
| 1322 | else if (floorTilt.x > 0) |
| 1323 | { |
| 1324 | if (yAngle <= ANGLE(180.0f)) |
| 1325 | bs = 1; |
| 1326 | } |
| 1327 | |
| 1328 | if (floorTilt.y < 0) |
| 1329 | { |
| 1330 | if (yAngle >= ANGLE(90.0f) && yAngle <= ANGLE(270.0f)) |
| 1331 | bs = 1; |
| 1332 | } |
| 1333 | else if (floorTilt.y > 0) |
| 1334 | { |
| 1335 | if (yAngle <= ANGLE(90.0f) || yAngle >= ANGLE(270.0f)) |
| 1336 | bs = 1; |
| 1337 | } |
| 1338 | } |
| 1339 | |
| 1340 | // If last position of item was also below this floor height, we've hit a wall, else we've hit a floor. |
| 1341 | |
| 1342 | if (y > (pointColl.GetFloorHeight() + 32) && bs == 0 && |
| 1343 | (((x / BLOCK(1)) != (item->Pose.Position.x / BLOCK(1))) || |
| 1344 | ((z / BLOCK(1)) != (item->Pose.Position.z / BLOCK(1))))) |
| 1345 | { |
| 1346 | // Need to know which direction the wall is. |
| 1347 | |
| 1348 | long xs; |
| 1349 | |
| 1350 | if ((x & (~WALL_MASK)) != (item->Pose.Position.x & (~WALL_MASK)) && // X crossed boundary? |
| 1351 | (z & (~WALL_MASK)) != (item->Pose.Position.z & (~WALL_MASK))) // Z crossed boundary as well? |
no test coverage detected