- trace_t trace;
- vec3_t offset;
- vec3_t start_l, end_l;
- hull_t *hull;
-
-// fill in a default trace
- memset (&trace, 0, sizeof(trace_t));
- trace.fraction = 1;
- trace.allsolid = true;
- VectorCopy (end, trace.endpos);
-
-// get the clipping hull
- hull = SV_HullForEntity (ent, mins, maxs, offset);
-
- VectorSubtract (start, offset, start_l);
- VectorSubtract (end, offset, end_l);
-
-// LordHavoc: enabling rotating bmodels
- // rotate start and end into the models frame of reference
- if (ent->v.solid == SOLID_BSP &&
- (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
- {
- vec3_t forward, right, up;
- vec3_t temp;
-
- AngleVectors (ent->v.angles, forward, right, up);
-
- VectorCopy (start_l, temp);
- start_l[0] = DotProduct (temp, forward);
- start_l[1] = -DotProduct (temp, right);
- start_l[2] = DotProduct (temp, up);
-
- VectorCopy (end_l, temp);
- end_l[0] = DotProduct (temp, forward);
- end_l[1] = -DotProduct (temp, right);
- end_l[2] = DotProduct (temp, up);
- }
-
-// trace a line through the apropriate clipping hull
- SV_RecursiveHullCheck (hull, hull->firstclipnode, 0, 1, start_l, end_l, &trace);
-
-// LordHavoc: enabling rotating bmodels
- // rotate endpos back to world frame of reference
- if (ent->v.solid == SOLID_BSP &&
- (ent->v.angles[0] || ent->v.angles[1] || ent->v.angles[2]) )
- {
- vec3_t a;
- vec3_t forward, right, up;
- vec3_t temp;
-
- if (trace.fraction != 1)
- {
- VectorSubtract (vec3_origin, ent->v.angles, a);
- AngleVectors (a, forward, right, up);
-
- VectorCopy (trace.endpos, temp);
- trace.endpos[0] = DotProduct (temp, forward);
- trace.endpos[1] = -DotProduct (temp, right);
- trace.endpos[2] = DotProduct (temp, up);
-
- VectorCopy (trace.plane.normal, temp);
- trace.plane.normal[0] = DotProduct (temp, forward);
- trace.plane.normal[1] = -DotProduct (temp, right);
- trace.plane.normal[2] = DotProduct (temp, up);
- }
- }
-
-// fix trace up by the offset
- if (trace.fraction != 1)
- VectorAdd (trace.endpos, offset, trace.endpos);
-
-// did we clip the move?
- if (trace.fraction < 1 || trace.startsolid )
- trace.ent = ent;
-
+ trace_t trace;
+ memset(&trace, 0, sizeof(trace));
+ trace.fraction = trace.realfraction = 1;
+ sv.worldmodel->TraceBox(sv.worldmodel, 0, &trace, start, mins, maxs, end, hitsupercontents);
+ trace.fraction = bound(0, trace.fraction, 1);
+ trace.realfraction = bound(0, trace.realfraction, 1);
+ VectorLerp(start, trace.fraction, end, trace.endpos);