- // try center
- VectorCopy(eye, start);
- VectorMAM(0.5f, boxmins, 0.5f, boxmaxs, end);
- if (model->brush.TraceLineOfSight(model, start, end))
+ // try specific positions in the box first - note that these can be cached
+ if (r_cullentities_trace_entityocclusion.integer)
+ {
+ for (i = 0; i < sizeof(positions) / sizeof(positions[0]); i++)
+ {
+ VectorCopy(eye, start);
+ end[0] = boxmins[0] + (boxmaxs[0] - boxmins[0]) * positions[i][0];
+ end[1] = boxmins[1] + (boxmaxs[1] - boxmins[1]) * positions[i][1];
+ end[2] = boxmins[2] + (boxmaxs[2] - boxmins[2]) * positions[i][2];
+ //trace_t trace = CL_TraceLine(start, end, MOVE_NOMONSTERS, NULL, SUPERCONTENTS_SOLID, SUPERCONTENTS_SKY, 0.0f, true, false, NULL, true, true);
+ trace_t trace = CL_Cache_TraceLineSurfaces(start, end, MOVE_NORMAL, SUPERCONTENTS_SOLID, 0, MATERIALFLAGMASK_TRANSLUCENT);
+ // not picky - if the trace ended anywhere in the box we're good
+ if (BoxesOverlap(trace.endpos, trace.endpos, boxmins, boxmaxs))
+ return true;
+ }
+ }
+ else if (model->brush.TraceLineOfSight(model, start, end, boxmins, boxmaxs))