| 385 | } |
| 386 | |
| 387 | int ObjectOnLOS2(GameVector* origin, GameVector* target, Vector3i* vec, StaticMesh** staticObj, GAME_OBJECT_ID priorityObjectID) |
| 388 | { |
| 389 | ClosestItem = NO_LOS_ITEM; |
| 390 | ClosestDist = (int)Vector3i::Distance(origin->ToVector3i(), target->ToVector3i()); |
| 391 | |
| 392 | for (int roomNumber : LosRoomNumbers) |
| 393 | { |
| 394 | auto& room = g_Level.Rooms[roomNumber]; |
| 395 | |
| 396 | auto pose = Pose::Zero; |
| 397 | |
| 398 | if (staticObj != nullptr) |
| 399 | { |
| 400 | for (int m = 0; m < room.mesh.size(); m++) |
| 401 | { |
| 402 | auto& meshp = room.mesh[m]; |
| 403 | |
| 404 | if (meshp.Flags & StaticMeshFlags::SM_VISIBLE) |
| 405 | { |
| 406 | auto bounds = GetBoundsAccurate(meshp, false); |
| 407 | pose = Pose(meshp.Pose.Position, EulerAngles(0, meshp.Pose.Orientation.y, 0)); |
| 408 | |
| 409 | if (DoRayBox(*origin, *target, bounds, pose, *vec, -1 - meshp.Slot)) |
| 410 | { |
| 411 | *staticObj = &meshp; |
| 412 | target->RoomNumber = roomNumber; |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | for (int linkNumber = room.itemNumber; linkNumber != NO_VALUE; linkNumber = g_Level.Items[linkNumber].NextItem) |
| 419 | { |
| 420 | const auto& item = g_Level.Items[linkNumber]; |
| 421 | |
| 422 | if (item.Status == ITEM_DEACTIVATED || item.Status == ITEM_INVISIBLE) |
| 423 | continue; |
| 424 | |
| 425 | if (priorityObjectID != GAME_OBJECT_ID::ID_NO_OBJECT && item.ObjectNumber != priorityObjectID) |
| 426 | continue; |
| 427 | |
| 428 | if (item.ObjectNumber != ID_LARA && (Objects[item.ObjectNumber].collision == nullptr || Objects[item.ObjectNumber].Hidden || !item.Collidable)) |
| 429 | continue; |
| 430 | |
| 431 | if (item.ObjectNumber == ID_LARA && priorityObjectID != ID_LARA) |
| 432 | continue; |
| 433 | |
| 434 | auto bounds = GameBoundingBox(&item); |
| 435 | pose = Pose(item.Pose.Position, EulerAngles(0, item.Pose.Orientation.y, 0)); |
| 436 | |
| 437 | if (DoRayBox(*origin, *target, bounds, pose, *vec, linkNumber)) |
| 438 | target->RoomNumber = roomNumber; |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | vec->x = ClosestCoord.x; |
| 443 | vec->y = ClosestCoord.y; |
| 444 | vec->z = ClosestCoord.z; |
no test coverage detected