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

Function SquareDistToSector

source/core/gamefuncs.cpp:171–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169//==========================================================================
170
171double SquareDistToSector(double px, double py, const sectortype* sect, DVector2* point)
172{
173 if (inside(px, py, sect))
174 {
175 if (point)
176 *point = { px, py };
177 return 0;
178 }
179
180 double bestdist = DBL_MAX;
181 DVector2 bestpt = { px, py };
182 for (auto& wal : sect->walls)
183 {
184 DVector2 pt;
185 auto dist = SquareDistToWall(px, py, &wal, &pt);
186 if (dist < bestdist)
187 {
188 bestdist = dist;
189 bestpt = pt;
190 }
191 }
192 if (point) *point = bestpt;
193 return bestdist;
194}
195
196//==========================================================================
197//

Callers 3

checkRangeOfWallFunction · 0.85
getzrangeFunction · 0.85
checkOpeningFunction · 0.85

Calls 2

insideFunction · 0.85
SquareDistToWallFunction · 0.85

Tested by

no test coverage detected