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

Function BSPRayOccluded

Descent3/bsp.cpp:1149–1197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1147static int si;
1148
1149int BSPRayOccluded(vector *line_start, vector *line_end, bspnode *start_node) {
1150 si = 0;
1151 vector start, end;
1152 bspnode *node;
1153
1154 PUSH_BSP_RAY(*line_start, *line_end, start_node);
1155
1156 while (si > 0) {
1157 POP_BSP_RAY();
1158 while (node->type == BSP_NODE) {
1159 float dist1 = node->plane.a * start.x + node->plane.b * start.y + node->plane.c * start.z + node->plane.d;
1160 float dist2 = node->plane.a * end.x + node->plane.b * end.y + node->plane.c * end.z + node->plane.d;
1161
1162 if (dist1 >= 0 && dist2 >= 0) {
1163 node = (bspnode *)node->front;
1164 } else if (dist1 < 0 && dist2 < 0) {
1165 node = (bspnode *)node->back;
1166 } else {
1167 vector mid, delta;
1168 float t;
1169
1170 // Generate split point
1171 t = dist1 / (dist1 - dist2);
1172 delta = end - start;
1173 mid = start + (t * delta);
1174 if (BSPPointInPolygon(&mid, node))
1175 return 1;
1176
1177 // vm_NormalizeVectorFast (&delta);
1178
1179 vector mid1 = mid; //-(delta*BSP_EPSILON);
1180 vector mid2 = mid; //+(delta*BSP_EPSILON);
1181
1182 if (dist1 >= 0.0) {
1183 PUSH_BSP_RAY(mid1, end, (bspnode *)node->back);
1184 PUSH_BSP_RAY(start, mid2, (bspnode *)node->front);
1185 } else {
1186 PUSH_BSP_RAY(mid2, end, (bspnode *)node->front);
1187 PUSH_BSP_RAY(start, mid1, (bspnode *)node->back);
1188 }
1189
1190 goto break_out;
1191 }
1192 }
1193 break_out:;
1194 }
1195
1196 return 0;
1197}
1198
1199// Initializes some variables for the indoor bsp tree
1200void InitDefaultBSP() {

Callers 3

ShootRayToVolumePointFunction · 0.85
ShootRayFromPointFunction · 0.85
ProcessTestKeysFunction · 0.85

Calls 1

BSPPointInPolygonFunction · 0.85

Tested by

no test coverage detected