MCPcopy Create free account
hub / github.com/Meridian59/Meridian59 / IsLineDefInside

Function IsLineDefInside

roomedit/source/objects.cpp:1008–1064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1006*/
1007
1008BOOL IsLineDefInside (SHORT ldnum, SHORT x0, SHORT y0, SHORT x1, SHORT y1)
1009{
1010 LineDef *pLD = &LineDefs[ldnum];
1011 SHORT start = pLD->start;
1012 SHORT end = pLD->end;
1013
1014 Vertex *pVStart = &Vertexes[start];
1015 Vertex *pVEnd = &Vertexes[end];
1016 SHORT lx0 = pVStart->x;
1017 SHORT ly0 = pVStart->y;
1018 SHORT lx1 = pVEnd->x;
1019 SHORT ly1 = pVEnd->y;
1020 SHORT i;
1021
1022 // The LineDef start is entirely inside the square ?
1023 if (lx0 >= x0 && lx0 <= x1 && ly0 >= y0 && ly0 <= y1)
1024 return TRUE;
1025
1026 // The LineDef end is entirely inside the square ?
1027 if (lx1 >= x0 && lx1 <= x1 && ly1 >= y0 && ly1 <= y1)
1028 return TRUE;
1029
1030
1031 // The LineDef crosses the y0 side (left) ?
1032 if ((ly0 > y0) != (ly1 > y0))
1033 {
1034 i = lx0 + (SHORT) ( (long) (y0 - ly0) * (long) (lx1 - lx0) / (long) (ly1 - ly0));
1035 if (i >= x0 && i <= x1)
1036 return TRUE;
1037 }
1038
1039 // The LineDef crosses the y1 side (right) ?
1040 if ((ly0 > y1) != (ly1 > y1))
1041 {
1042 i = lx0 + (SHORT) ( (long) (y1 - ly0) * (long) (lx1 - lx0) / (long) (ly1 - ly0));
1043 if (i >= x0 && i <= x1)
1044 return TRUE;
1045 }
1046
1047 // The LineDef crosses the x0 side (down) ?
1048 if ((lx0 > x0) != (lx1 > x0))
1049 {
1050 i = ly0 + (SHORT) ( (long) (x0 - lx0) * (long) (ly1 - ly0) / (long) (lx1 - lx0));
1051 if (i >= y0 && i <= y1)
1052 return TRUE;
1053 }
1054
1055 // The LineDef crosses the x1 side (up) ?
1056 if ((lx0 > x1) != (lx1 > x1))
1057 {
1058 i = ly0 + (SHORT) ( (long) (x1 - lx0) * (long) (ly1 - ly0) / (long) (lx1 - lx0));
1059 if (i >= y0 && i <= y1)
1060 return TRUE;
1061 }
1062
1063 return FALSE;
1064}
1065

Callers 2

GetCurObjectFunction · 0.85
AutoMergeVerticesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected