| 941 | //========================================================================== |
| 942 | |
| 943 | void getzrange(const DVector3& pos, sectortype* sect, double* ceilz, CollisionBase& ceilhit, double* florz, CollisionBase& florhit, double maxdist, uint32_t cliptype) |
| 944 | { |
| 945 | if (sect == nullptr) |
| 946 | { |
| 947 | *ceilz = -FLT_MAX; ceilhit.setVoid(); |
| 948 | *florz = FLT_MAX; florhit.setVoid(); |
| 949 | return; |
| 950 | } |
| 951 | |
| 952 | const EWallFlags dawalclipmask = EWallFlags::FromInt(cliptype & 65535); |
| 953 | const ESpriteFlags dasprclipmask = ESpriteFlags::FromInt(cliptype >> 16); |
| 954 | |
| 955 | auto closest = pos.XY(); |
| 956 | if (enginecompatibility_mode == ENGINECOMPATIBILITY_NONE) |
| 957 | SquareDistToSector(closest.X, closest.Y, sect, &closest); |
| 958 | |
| 959 | calcSlope(sect, closest, ceilz, florz); |
| 960 | ceilhit.setSector(sect); |
| 961 | florhit.setSector(sect); |
| 962 | |
| 963 | double theZs[2]; |
| 964 | |
| 965 | BFSSectorSearch search(sect); |
| 966 | while (auto sec = search.GetNext()) |
| 967 | { |
| 968 | for (auto& wal : sec->walls) |
| 969 | { |
| 970 | if (checkRangeOfWall(&wal, EWallFlags::FromInt(dawalclipmask), pos, maxdist + 1 / 16., theZs)) |
| 971 | { |
| 972 | auto nsec = wal.nextSector(); |
| 973 | search.Add(nsec); |
| 974 | if (/*(pos.Z > theZs[0]) &&*/ (theZs[0] > *ceilz)) |
| 975 | { |
| 976 | *ceilz = theZs[0]; |
| 977 | ceilhit.setSector(nsec); |
| 978 | } |
| 979 | |
| 980 | if (/*(pos.Z < theZs[1]) &&*/ (theZs[1] < *florz)) |
| 981 | { |
| 982 | *florz = theZs[1]; |
| 983 | florhit.setSector(nsec); |
| 984 | } |
| 985 | } |
| 986 | else if (checkRangeOfWall(&wal, EWallFlags::FromInt(dawalclipmask), pos, maxdist + 64., theZs)) |
| 987 | { |
| 988 | // extend the search distance for neighboring sectors a bit further so that we can find sprites outside the search range extending to our position. |
| 989 | auto nsec = wal.nextSector(); |
| 990 | search.Add(nsec); |
| 991 | } |
| 992 | } |
| 993 | } |
| 994 | |
| 995 | if (dasprclipmask) |
| 996 | { |
| 997 | search.Rewind(); |
| 998 | while (auto sec = search.GetNext()) |
| 999 | { |
| 1000 | TSectIterator<DCoreActor> it(sec); |
no test coverage detected