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

Function checkforinside

source/core/gamefuncs.cpp:370–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368//==========================================================================
369
370int64_t checkforinside(double x, double y, const DVector2& pt1, const DVector2& pt2)
371{
372 // Perform the checks here in 48.16 fixed point.
373 // Doing it directly with floats and multiplications does not work reliably due to underflows.
374 // Unfortunately, due to the conversions, this is a bit slower. :(
375 int64_t xs = int64_t(0x10000 * (pt1.X - x));
376 int64_t ys = int64_t(0x10000 * (pt1.Y - y));
377 int64_t xe = int64_t(0x10000 * (pt2.X - x));
378 int64_t ye = int64_t(0x10000 * (pt2.Y - y));
379
380 if ((ys ^ ye) < 0)
381 {
382 int64_t val;
383
384 if ((xs ^ xe) >= 0) val = xs;
385 else val = ((xs * ye) - xe * ys) ^ ye;
386 return val;
387 }
388 return 0;
389}
390
391//==========================================================================
392//

Callers 2

insideFunction · 0.85
insidePolyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected