MCPcopy Create free account
hub / github.com/ZDoom/Raze / getzrange

Function getzrange

source/core/gamefuncs.cpp:943–1041  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

941//==========================================================================
942
943void 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);

Callers 9

fakedomovethingsFunction · 0.85
processinput_rFunction · 0.85
getglobalzFunction · 0.85
makeitfallFunction · 0.85
processinput_dFunction · 0.85
FAFgetzrangeFunction · 0.85
movespritezFunction · 0.85
GetZRangeFunction · 0.85
GetZRangeAtXYZFunction · 0.85

Calls 14

SquareDistToSectorFunction · 0.85
checkRangeOfWallFunction · 0.85
checkRangeOfFaceSpriteFunction · 0.85
checkRangeOfWallSpriteFunction · 0.85
checkRangeOfFloorSpriteFunction · 0.85
setVoidMethod · 0.80
setSectorMethod · 0.80
nextSectorMethod · 0.80
RewindMethod · 0.80
setSpriteMethod · 0.80
calcSlopeFunction · 0.70
GetNextMethod · 0.45

Tested by

no test coverage detected