| 921 | } |
| 922 | |
| 923 | bool IsTargetOccludedByObjects(ItemInfo& playerItem, Vector3 origin, Vector3 target, float distance) |
| 924 | { |
| 925 | constexpr auto playerSize = LARA_RADIUS * 2.0f; |
| 926 | |
| 927 | if (!g_GameFlow->GetSettings()->Gameplay.TargetObjectOcclusion) |
| 928 | return false; |
| 929 | |
| 930 | auto dir = target - origin; |
| 931 | dir.Normalize(); |
| 932 | |
| 933 | // We need to subtract Lara's radius from distance to avoid near plane false negatives. |
| 934 | distance -= playerSize; |
| 935 | |
| 936 | // Get raw LOS data. |
| 937 | auto los = GetLosCollision(origin, playerItem.RoomNumber, dir, distance, true, true, true); |
| 938 | |
| 939 | // Assess static mesh line of sight. |
| 940 | if (!los.Statics.empty() && los.Statics.front().Distance < distance) |
| 941 | { |
| 942 | auto& staticLos = los.Statics.front(); |
| 943 | |
| 944 | // Don't filter out shatterables. |
| 945 | if (Statics[staticLos.Static->Slot].shatterType == ShatterType::None) |
| 946 | { |
| 947 | // Filter out statics that are too small. |
| 948 | auto extents = staticLos.Static->GetCollisionAabb().GetExtents(); |
| 949 | auto radius = Vector2(extents.x, extents.z).Length(); |
| 950 | |
| 951 | if (radius > playerSize && extents.y > playerSize) |
| 952 | return true; |
| 953 | } |
| 954 | } |
| 955 | |
| 956 | // Assess moveable line of sight. |
| 957 | if (!los.Items.empty() && los.Items.front().Distance < distance) |
| 958 | { |
| 959 | auto& moveableLos = los.Items.front(); |
| 960 | |
| 961 | // Don't filter out creatures. |
| 962 | if (!Objects[moveableLos.Item->ObjectNumber].intelligent) |
| 963 | { |
| 964 | // Filter out moveables that are too small. |
| 965 | auto extents = moveableLos.Item->GetAabb().Extents; |
| 966 | auto radius = Vector2(extents.x, extents.z).Length(); |
| 967 | |
| 968 | if (radius > playerSize && extents.y > playerSize) |
| 969 | return true; |
| 970 | } |
| 971 | } |
| 972 | |
| 973 | return false; |
| 974 | } |
| 975 | |
| 976 | void FindNewTarget(ItemInfo& laraItem, const WeaponInfo& weaponInfo) |
| 977 | { |
no test coverage detected