MCPcopy Create free account
hub / github.com/demoth/jake2 / BoxTrace

Method BoxTrace

qcommon/src/main/java/jake2/qcommon/CM.java:1391–1476  ·  view source on GitHub ↗
(float[] start, float[] end, float[] mins, float[] maxs, int headnode, int brushmask)

Source from the content-addressed store, hash-verified

1389 * ================== CM_BoxTrace ==================
1390 */
1391 public trace_t BoxTrace(float[] start, float[] end, float[] mins, float[] maxs, int headnode, int brushmask) {
1392
1393 // for multi-check avoidance
1394 checkcount++;
1395
1396 // for statistics, may be zeroed
1397 Globals.c_traces++;
1398
1399 // fill in a default trace
1400 //was: memset(& trace_trace, 0, sizeof(trace_trace));
1401 trace_trace = new trace_t();
1402
1403 trace_trace.fraction = 1;
1404 trace_trace.surface = nullsurface.c;
1405
1406 if (numnodes == 0) {
1407 // map not loaded
1408 return trace_trace;
1409 }
1410
1411 trace_contents = brushmask;
1412 Math3D.VectorCopy(start, trace_start);
1413 Math3D.VectorCopy(end, trace_end);
1414 Math3D.VectorCopy(mins, trace_mins);
1415 Math3D.VectorCopy(maxs, trace_maxs);
1416
1417 //
1418 // check for position test special case
1419 //
1420 if (start[0] == end[0] && start[1] == end[1] && start[2] == end[2]) {
1421
1422 int leafs[] = new int[1024];
1423 int i, numleafs;
1424 float[] c1 = { 0, 0, 0 }, c2 = { 0, 0, 0 };
1425 int topnode = 0;
1426
1427 Math3D.VectorAdd(start, mins, c1);
1428 Math3D.VectorAdd(start, maxs, c2);
1429
1430 for (i = 0; i < 3; i++) {
1431 c1[i] -= 1;
1432 c2[i] += 1;
1433 }
1434
1435 int tn[] = { topnode };
1436
1437 numleafs = CM_BoxLeafnums_headnode(c1, c2, leafs, 1024, headnode,
1438 tn);
1439 topnode = tn[0];
1440 for (i = 0; i < numleafs; i++) {
1441 CM_TestInLeaf(leafs[i]);
1442 if (trace_trace.allsolid)
1443 break;
1444 }
1445 Math3D.VectorCopy(start, trace_trace.endpos);
1446 return trace_trace;
1447 }
1448

Callers 4

TransformedBoxTraceMethod · 0.95
CL_TraceMethod · 0.80
PMTraceMethod · 0.80
SV_TraceMethod · 0.80

Calls 6

VectorCopyMethod · 0.95
VectorAddMethod · 0.95
CM_TestInLeafMethod · 0.95
VectorClearMethod · 0.95
CM_RecursiveHullCheckMethod · 0.95

Tested by

no test coverage detected