MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / LineIntersectsLine

Function LineIntersectsLine

Descent3/render.cpp:372–385  ·  view source on GitHub ↗

Returns true if a line intersects another line

Source from the content-addressed store, hash-verified

370
371// Returns true if a line intersects another line
372static inline bool LineIntersectsLine(g3Point *ls, g3Point *le, float x1, float y1, float x2, float y2) {
373 float num, denom;
374 num = ((ls->p3_sy - y1) * (x2 - x1)) - ((ls->p3_sx - x1) * (y2 - y1));
375 denom = ((le->p3_sx - ls->p3_sx) * (y2 - y1)) - ((le->p3_sy - ls->p3_sy) * (x2 - x1));
376 float r = num / denom;
377 if (r >= 0.0 && r <= 1.0)
378 return true;
379 num = ((ls->p3_sy - y1) * (le->p3_sx - ls->p3_sx)) - ((ls->p3_sx - x1) * (le->p3_sy - ls->p3_sy));
380 denom = ((le->p3_sx - ls->p3_sx) * (y2 - y1)) - ((le->p3_sy - ls->p3_sy) * (x2 - x1));
381 float s = num / denom;
382 if (s >= 0.0 && s <= 1.0)
383 return true;
384 return false;
385}
386// Returns true if a face intersects the passed in portal in any way
387static inline bool FaceIntersectsPortal(room *rp, face *fp, clip_wnd *wnd) {
388 g3Codes cc;

Callers 1

FaceIntersectsPortalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected