float CL_SelectTraceLine(const vec3_t start, const vec3_t end, vec3_t impact, vec3_t normal, int *hitent, entity_render_t *ignoreent)
{
- float maxfrac, maxrealfrac;
+ float maxfrac;
int n;
entity_render_t *ent;
vec_t tracemins[3], tracemaxs[3];
memset (&trace, 0 , sizeof(trace_t));
trace.fraction = 1;
- trace.realfraction = 1;
VectorCopy (end, trace.endpos);
if (hitent)
if (normal)
VectorCopy(trace.plane.normal, normal);
maxfrac = trace.fraction;
- maxrealfrac = trace.realfraction;
tracemins[0] = min(start[0], end[0]);
tracemaxs[0] = max(start[0], end[0]);
Matrix4x4_Transform(&ent->inversematrix, start, starttransformed);
Matrix4x4_Transform(&ent->inversematrix, end, endtransformed);
Collision_ClipTrace_Box(&trace, ent->model->normalmins, ent->model->normalmaxs, starttransformed, vec3_origin, vec3_origin, endtransformed, SUPERCONTENTS_SOLID, SUPERCONTENTS_SOLID, 0, NULL);
- if (maxrealfrac < trace.realfraction)
+ if (maxfrac < trace.fraction)
continue;
ent->model->TraceLine(ent->model, ent->frameblend, ent->skeleton, &trace, starttransformed, endtransformed, SUPERCONTENTS_SOLID);
- if (maxrealfrac > trace.realfraction)
+ if (maxfrac > trace.fraction)
{
if (hitent)
*hitent = n;
maxfrac = trace.fraction;
- maxrealfrac = trace.realfraction;
if (normal)
{
VectorCopy(trace.plane.normal, tempnormal);
if (!BoxesOverlap(clipboxmins, clipboxmaxs, ent->mins, ent->maxs))
continue;
Collision_ClipPointToGenericEntity(&trace, ent->model, ent->frameblend, ent->skeleton, vec3_origin, vec3_origin, 0, &ent->matrix, &ent->inversematrix, start, hitsupercontentsmask);
- if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
+ if (cliptrace.fraction > trace.fraction && hitnetworkentity)
*hitnetworkentity = cl.brushmodel_entities[i];
Collision_CombineTraces(&cliptrace, &trace, NULL, true);
}
Matrix4x4_CreateTranslate(&entmatrix, origin[0], origin[1], origin[2]);
Matrix4x4_CreateTranslate(&entinversematrix, -origin[0], -origin[1], -origin[2]);
Collision_ClipPointToGenericEntity(&trace, NULL, NULL, NULL, cl.playerstandmins, cl.playerstandmaxs, SUPERCONTENTS_BODY, &entmatrix, &entinversematrix, start, hitsupercontentsmask);
- if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
+ if (cliptrace.fraction > trace.fraction && hitnetworkentity)
*hitnetworkentity = i;
Collision_CombineTraces(&cliptrace, &trace, NULL, false);
}
else
Collision_ClipPointToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, hitsupercontentsmask);
- if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
+ if (cliptrace.fraction > trace.fraction && hitnetworkentity)
*hitnetworkentity = 0;
Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_clientedictfloat(touch, solid) == SOLID_BSP);
}
if (!BoxesOverlap(clipboxmins, clipboxmaxs, ent->mins, ent->maxs))
continue;
Collision_ClipLineToGenericEntity(&trace, ent->model, ent->frameblend, ent->skeleton, vec3_origin, vec3_origin, 0, &ent->matrix, &ent->inversematrix, start, end, hitsupercontentsmask, extend, hitsurfaces);
- if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
+ if (cliptrace.fraction > trace.fraction && hitnetworkentity)
*hitnetworkentity = cl.brushmodel_entities[i];
Collision_CombineTraces(&cliptrace, &trace, NULL, true);
}
Matrix4x4_CreateTranslate(&entmatrix, origin[0], origin[1], origin[2]);
Matrix4x4_CreateTranslate(&entinversematrix, -origin[0], -origin[1], -origin[2]);
Collision_ClipLineToGenericEntity(&trace, NULL, NULL, NULL, cl.playerstandmins, cl.playerstandmaxs, SUPERCONTENTS_BODY, &entmatrix, &entinversematrix, start, end, hitsupercontentsmask, extend, hitsurfaces);
- if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
+ if (cliptrace.fraction > trace.fraction && hitnetworkentity)
*hitnetworkentity = i;
Collision_CombineTraces(&cliptrace, &trace, NULL, false);
}
else
Collision_ClipLineToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipend, hitsupercontentsmask, extend, hitsurfaces);
- if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
+ if (cliptrace.fraction > trace.fraction && hitnetworkentity)
*hitnetworkentity = 0;
Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_clientedictfloat(touch, solid) == SOLID_BSP);
}
if (!BoxesOverlap(clipboxmins, clipboxmaxs, ent->mins, ent->maxs))
continue;
Collision_ClipToGenericEntity(&trace, ent->model, ent->frameblend, ent->skeleton, vec3_origin, vec3_origin, 0, &ent->matrix, &ent->inversematrix, start, mins, maxs, end, hitsupercontentsmask, extend);
- if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
+ if (cliptrace.fraction > trace.fraction && hitnetworkentity)
*hitnetworkentity = cl.brushmodel_entities[i];
Collision_CombineTraces(&cliptrace, &trace, NULL, true);
}
Matrix4x4_CreateTranslate(&entmatrix, origin[0], origin[1], origin[2]);
Matrix4x4_CreateTranslate(&entinversematrix, -origin[0], -origin[1], -origin[2]);
Collision_ClipToGenericEntity(&trace, NULL, NULL, NULL, cl.playerstandmins, cl.playerstandmaxs, SUPERCONTENTS_BODY, &entmatrix, &entinversematrix, start, mins, maxs, end, hitsupercontentsmask, extend);
- if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
+ if (cliptrace.fraction > trace.fraction && hitnetworkentity)
*hitnetworkentity = i;
Collision_CombineTraces(&cliptrace, &trace, NULL, false);
}
else
Collision_ClipToGenericEntity(&trace, model, touch->priv.server->frameblend, &touch->priv.server->skeleton, touchmins, touchmaxs, bodysupercontents, &matrix, &imatrix, clipstart, clipmins, clipmaxs, clipend, hitsupercontentsmask, extend);
- if (cliptrace.realfraction > trace.realfraction && hitnetworkentity)
+ if (cliptrace.fraction > trace.fraction && hitnetworkentity)
*hitnetworkentity = 0;
Collision_CombineTraces(&cliptrace, &trace, (void *)touch, PRVM_clientedictfloat(touch, solid) == SOLID_BSP);
}
cvar_t collision_endnudge = {0, "collision_endnudge", "0", "how much to bias collision trace end"};
cvar_t collision_enternudge = {0, "collision_enternudge", "0", "how much to bias collision entry fraction"};
cvar_t collision_leavenudge = {0, "collision_leavenudge", "0", "how much to bias collision exit fraction"};
-cvar_t collision_prefernudgedfraction = {0, "collision_prefernudgedfraction", "1", "whether to sort collision events by nudged fraction (1) or real fraction (0)"};
cvar_t collision_extendmovelength = {0, "collision_extendmovelength", "16", "internal bias on trace length to ensure detection of collisions within the collision_impactnudge/collision_enternudge/collision_leavenudge distance so that short moves do not degrade across frames (this does not alter the final trace length)"};
cvar_t collision_extendtraceboxlength = {0, "collision_extendtraceboxlength", "1", "internal bias for tracebox() qc builtin to account for collision_impactnudge/collision_enternudge/collision_leavenudge (this does not alter the final trace length)"};
cvar_t collision_extendtracelinelength = {0, "collision_extendtracelinelength", "1", "internal bias for traceline() qc builtin to account for collision_impactnudge/collision_enternudge/collision_leavenudge (this does not alter the final trace length)"};
Cvar_RegisterVariable(&collision_endnudge);
Cvar_RegisterVariable(&collision_enternudge);
Cvar_RegisterVariable(&collision_leavenudge);
- Cvar_RegisterVariable(&collision_prefernudgedfraction);
Cvar_RegisterVariable(&collision_extendmovelength);
Cvar_RegisterVariable(&collision_extendtracelinelength);
Cvar_RegisterVariable(&collision_extendtraceboxlength);
// if the collision time range is now empty, no collision
if (enterfrac > leavefrac)
return;
+ // calculate the nudged fraction and impact normal we'll
+ // need if we accept this collision later
+ enterfrac2 = (startdist - collision_impactnudge.value) * imove;
// if the collision would be further away than the trace's
// existing collision data, we don't care about this
// collision
- if (enterfrac > trace->realfraction)
+ if (enterfrac2 >= trace->fraction)
return;
- // calculate the nudged fraction and impact normal we'll
- // need if we accept this collision later
- enterfrac2 = (startdist - collision_impactnudge.value) * imove;
ie = 1.0f - enterfrac;
newimpactplane[0] = startplane[0] * ie + endplane[0] * enterfrac;
newimpactplane[1] = startplane[1] * ie + endplane[1] * enterfrac;
trace->hitsupercontents = other_start->supercontents;
trace->hitq3surfaceflags = hitq3surfaceflags;
trace->hittexture = hittexture;
- trace->realfraction = bound(0, enterfrac, 1);
trace->fraction = bound(0, enterfrac2, 1);
- if (collision_prefernudgedfraction.integer)
- trace->realfraction = trace->fraction;
VectorCopy(newimpactplane, trace->plane.normal);
trace->plane.dist = newimpactplane[3];
}
// if the collision time range is now empty, no collision
if (enterfrac > leavefrac)
return;
+ // calculate the nudged fraction and impact normal we'll
+ // need if we accept this collision later
+ enterfrac2 = (startdist - collision_impactnudge.value) * imove;
// if the collision would be further away than the trace's
// existing collision data, we don't care about this
// collision
- if (enterfrac > trace->realfraction)
+ if (enterfrac2 >= trace->fraction)
return;
- // calculate the nudged fraction and impact normal we'll
- // need if we accept this collision later
- enterfrac2 = (startdist - collision_impactnudge.value) * imove;
ie = 1.0f - enterfrac;
newimpactplane[0] = startplane[0] * ie + endplane[0] * enterfrac;
newimpactplane[1] = startplane[1] * ie + endplane[1] * enterfrac;
trace->hitsupercontents = other_start->supercontents;
trace->hitq3surfaceflags = hitq3surfaceflags;
trace->hittexture = hittexture;
- trace->realfraction = bound(0, enterfrac, 1);
trace->fraction = bound(0, enterfrac2, 1);
- if (collision_prefernudgedfraction.integer)
- trace->realfraction = trace->fraction;
VectorCopy(newimpactplane, trace->plane.normal);
trace->plane.dist = newimpactplane[3];
}
void Collision_TraceLineTriangleFloat(trace_t *trace, const vec3_t linestart, const vec3_t lineend, const float *point0, const float *point1, const float *point2, int supercontents, int q3surfaceflags, const texture_t *texture)
{
-#if 1
- // more optimized
- float d1, d2, d, f, impact[3], edgenormal[3], faceplanenormal[3], faceplanedist, faceplanenormallength2, edge01[3], edge21[3], edge02[3];
+ float d1, d2, d, f, f2, impact[3], edgenormal[3], faceplanenormal[3], faceplanedist, faceplanenormallength2, edge01[3], edge21[3], edge02[3];
// this function executes:
// 32 ops when line starts behind triangle
// and subtracting the face plane distance (this is the distance of the
// triangle along that same normal)
// then multiply by the recipricol distance delta
- // 2 ops
+ // 4 ops
f = (d1 - faceplanedist) * d;
+ f2 = f - collision_impactnudge.value * d;
// skip out if this impact is further away than previous ones
// 1 ops
- if (f > trace->realfraction)
+ if (f2 >= trace->fraction)
return;
// calculate the perfect impact point for classification of insidedness
// 9 ops
// 8 ops (rare)
// store the new trace fraction
- trace->realfraction = f;
-
- // calculate a nudged fraction to keep it out of the surface
- // (the main fraction remains perfect)
- trace->fraction = f - collision_impactnudge.value * d;
-
- if (collision_prefernudgedfraction.integer)
- trace->realfraction = trace->fraction;
+ trace->fraction = f2;
// store the new trace plane (because collisions only happen from
// the front this is always simply the triangle normal, never flipped)
trace->hitsupercontents = supercontents;
trace->hitq3surfaceflags = q3surfaceflags;
trace->hittexture = texture;
-#else
- float d1, d2, d, f, fnudged, impact[3], edgenormal[3], faceplanenormal[3], faceplanedist, edge[3];
-
- // this code is designed for clockwise triangles, conversion to
- // counterclockwise would require swapping some things around...
- // it is easier to simply swap the point0 and point2 parameters to this
- // function when calling it than it is to rewire the internals.
-
- // calculate the unnormalized faceplanenormal of the triangle,
- // this represents the front side
- TriangleNormal(point0, point1, point2, faceplanenormal);
- // there's no point in processing a degenerate triangle
- // (GIGO - Garbage In, Garbage Out)
- if (DotProduct(faceplanenormal, faceplanenormal) < 0.0001f)
- return;
- // calculate the unnormalized distance
- faceplanedist = DotProduct(point0, faceplanenormal);
-
- // calculate the unnormalized start distance
- d1 = DotProduct(faceplanenormal, linestart) - faceplanedist;
- // if start point is on the back side there is no collision
- // (we don't care about traces going through the triangle the wrong way)
- if (d1 <= 0)
- return;
-
- // calculate the unnormalized end distance
- d2 = DotProduct(faceplanenormal, lineend) - faceplanedist;
- // if both are in front, there is no collision
- if (d2 >= 0)
- return;
-
- // from here on we know d1 is >= 0 and d2 is < 0
- // this means the line starts infront and ends behind, passing through it
-
- // calculate the recipricol of the distance delta,
- // so we can use it multiple times cheaply (instead of division)
- d = 1.0f / (d1 - d2);
- // calculate the impact fraction by taking the start distance (> 0)
- // and subtracting the face plane distance (this is the distance of the
- // triangle along that same normal)
- // then multiply by the recipricol distance delta
- f = d1 * d;
- // skip out if this impact is further away than previous ones
- if (f > trace->realfraction)
- return;
- // calculate the perfect impact point for classification of insidedness
- impact[0] = linestart[0] + f * (lineend[0] - linestart[0]);
- impact[1] = linestart[1] + f * (lineend[1] - linestart[1]);
- impact[2] = linestart[2] + f * (lineend[2] - linestart[2]);
-
- // calculate the edge normal and reject if impact is outside triangle
- // (an edge normal faces away from the triangle, to get the desired normal
- // a crossproduct with the faceplanenormal is used, and because of the way
- // the insidedness comparison is written it does not need to be normalized)
-
- VectorSubtract(point2, point0, edge);
- CrossProduct(edge, faceplanenormal, edgenormal);
- if (DotProduct(impact, edgenormal) > DotProduct(point0, edgenormal))
- return;
-
- VectorSubtract(point0, point1, edge);
- CrossProduct(edge, faceplanenormal, edgenormal);
- if (DotProduct(impact, edgenormal) > DotProduct(point1, edgenormal))
- return;
-
- VectorSubtract(point1, point2, edge);
- CrossProduct(edge, faceplanenormal, edgenormal);
- if (DotProduct(impact, edgenormal) > DotProduct(point2, edgenormal))
- return;
-
- // store the new trace fraction
- trace->realfraction = bound(0, f, 1);
-
- // store the new trace plane (because collisions only happen from
- // the front this is always simply the triangle normal, never flipped)
- VectorNormalize(faceplanenormal);
- VectorCopy(faceplanenormal, trace->plane.normal);
- trace->plane.dist = DotProduct(point0, faceplanenormal);
-
- // calculate the normalized start and end distances
- d1 = DotProduct(trace->plane.normal, linestart) - trace->plane.dist;
- d2 = DotProduct(trace->plane.normal, lineend) - trace->plane.dist;
-
- // calculate a nudged fraction to keep it out of the surface
- // (the main fraction remains perfect)
- fnudged = (d1 - collision_impactnudge.value) / (d1 - d2);
- trace->fraction = bound(0, fnudged, 1);
-
- // store the new trace endpos
- // not needed, it's calculated later when the trace is finished
- //trace->endpos[0] = linestart[0] + fnudged * (lineend[0] - linestart[0]);
- //trace->endpos[1] = linestart[1] + fnudged * (lineend[1] - linestart[1]);
- //trace->endpos[2] = linestart[2] + fnudged * (lineend[2] - linestart[2]);
- trace->hitsupercontents = supercontents;
- trace->hitq3surfaceflags = q3surfaceflags;
- trace->hittexture = texture;
-#endif
}
void Collision_BoundingBoxOfBrushTraceSegment(const colbrushf_t *start, const colbrushf_t *end, vec3_t mins, vec3_t maxs, float startfrac, float endfrac)
static void Collision_ClipExtendPrepare(extendtraceinfo_t *extendtraceinfo, trace_t *trace, const vec3_t tstart, const vec3_t tend, float textend)
{
memset(trace, 0, sizeof(*trace));
- trace->fraction = trace->realfraction = 1;
+ trace->fraction = 1;
extendtraceinfo->trace = trace;
VectorCopy(tstart, extendtraceinfo->realstart);
{
// undo the extended trace length
trace->fraction *= extendtraceinfo->scaletoextend;
- trace->realfraction *= extendtraceinfo->scaletoextend;
// if the extended trace hit something that the unextended trace did not hit (even considering the collision_impactnudge), then we have to clear the hit information
if (trace->fraction > 1.0f)
// clamp things
trace->fraction = bound(0, trace->fraction, 1);
- trace->realfraction = bound(0, trace->realfraction, 1);
// calculate the end position
VectorMA(extendtraceinfo->realstart, trace->fraction, extendtraceinfo->realdelta, trace->endpos);
{
float starttransformed[3];
memset(trace, 0, sizeof(*trace));
- trace->fraction = trace->realfraction = 1;
+ trace->fraction = 1;
Matrix4x4_Transform(inversematrix, start, starttransformed);
#if COLLISIONPARANOID >= 3
void Collision_ClipPointToWorld(trace_t *trace, dp_model_t *model, const vec3_t start, int hitsupercontents)
{
memset(trace, 0, sizeof(*trace));
- trace->fraction = trace->realfraction = 1;
+ trace->fraction = 1;
if (model && model->TracePoint)
model->TracePoint(model, NULL, NULL, trace, start, hitsupercontents);
VectorCopy(start, trace->endpos);
if (isbmodel)
cliptrace->bmodelstartsolid = true;
cliptrace->startsolid = true;
- if (cliptrace->realfraction == 1)
+ if (cliptrace->fraction == 1)
cliptrace->ent = touch;
if (cliptrace->startdepth > trace->startdepth)
{
// cliptrace->inopen = true;
if (trace->inwater)
cliptrace->inwater = true;
- if ((trace->realfraction < cliptrace->realfraction) && (VectorLength2(trace->plane.normal) > 0))
+ if ((trace->fraction < cliptrace->fraction) && (VectorLength2(trace->plane.normal) > 0))
{
cliptrace->fraction = trace->fraction;
- cliptrace->realfraction = trace->realfraction;
VectorCopy(trace->endpos, cliptrace->endpos);
cliptrace->plane = trace->plane;
cliptrace->ent = touch;
}
cliptrace->startsupercontents |= trace->startsupercontents;
}
-
-void Collision_ShortenTrace(trace_t *trace, float shorten_factor, const vec3_t end)
-{
- // now undo our moving end 1 qu farther...
- trace->fraction = bound(trace->fraction, trace->fraction / shorten_factor - 1e-6, 1); // we subtract 1e-6 to guard for roundoff errors
- trace->realfraction = bound(trace->realfraction, trace->realfraction / shorten_factor - 1e-6, 1); // we subtract 1e-6 to guard for roundoff errors
- if(trace->fraction >= 1) // trace would NOT hit if not expanded!
- {
- trace->fraction = 1;
- trace->realfraction = 1;
- VectorCopy(end, trace->endpos);
- memset(&trace->plane, 0, sizeof(trace->plane));
- trace->ent = NULL;
- trace->hitsupercontentsmask = 0;
- trace->hitsupercontents = 0;
- trace->hitq3surfaceflags = 0;
- trace->hittexture = NULL;
- }
-}
// (set only by Q1BSP tracing)
int inwater;
// fraction of the total distance that was traveled before impact
+ // in case of impact this is actually nudged a bit off the surface
// (1.0 = did not hit anything)
double fraction;
- // like fraction but is not nudged away from the surface (better for
- // comparisons between two trace structs, as only one nudge for the final
- // result is ever needed)
- double realfraction;
// final position of the trace (simply a point between start and end)
double endpos[3];
// surface normal at impact (not really correct for edge collisions)
extern cvar_t collision_extendtracelinelength;
extern cvar_t collision_extendtraceboxlength;
extern cvar_t collision_extendmovelength;
-extern cvar_t collision_prefernudgedfraction;
#endif
float *vertex3f = vertex3fbuf;
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
if (model->surfmesh.num_vertices > 1024)
vertex3f = (float *)Mem_Alloc(tempmempool, model->surfmesh.num_vertices * sizeof(float[3]));
// box trace, performed as brush trace
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
if (model->surfmesh.num_vertices > 1024)
vertex3f = (float *)Mem_Alloc(tempmempool, model->surfmesh.num_vertices * sizeof(float[3]));
VectorCopy (plane->normal, t->trace->plane.normal);
}
- // calculate the true fraction
+ // calculate the return fraction which is nudged off the surface a bit
t1 = DotProduct(t->trace->plane.normal, t->start) - t->trace->plane.dist;
t2 = DotProduct(t->trace->plane.normal, t->end) - t->trace->plane.dist;
- midf = t1 / (t1 - t2);
- t->trace->realfraction = bound(0, midf, 1);
-
- // calculate the return fraction which is nudged off the surface a bit
midf = (t1 - collision_impactnudge.value) / (t1 - t2);
t->trace->fraction = bound(0, midf, 1);
- if (collision_prefernudgedfraction.integer)
- t->trace->realfraction = t->trace->fraction;
-
#if COLLISIONPARANOID >= 3
Con_Print("D");
#endif
memset(trace, 0, sizeof(trace_t));
rhc.trace = trace;
rhc.trace->fraction = 1;
- rhc.trace->realfraction = 1;
rhc.trace->allsolid = true;
rhc.hull = &model->brushq1.hulls[0]; // 0x0x0
VectorCopy(start, rhc.start);
rhc.trace = trace;
rhc.trace->hitsupercontentsmask = hitsupercontentsmask;
rhc.trace->fraction = 1;
- rhc.trace->realfraction = 1;
rhc.trace->allsolid = true;
rhc.hull = &model->brushq1.hulls[0]; // 0x0x0
VectorCopy(start, rhc.start);
rhc.trace = &testtrace;
rhc.trace->hitsupercontentsmask = hitsupercontentsmask;
rhc.trace->fraction = 1;
- rhc.trace->realfraction = 1;
rhc.trace->allsolid = true;
VectorCopy(test, rhc.start);
VectorCopy(test, rhc.end);
rhc.trace = trace;
rhc.trace->hitsupercontentsmask = hitsupercontentsmask;
rhc.trace->fraction = 1;
- rhc.trace->realfraction = 1;
rhc.trace->allsolid = true;
VectorSubtract(boxmaxs, boxmins, boxsize);
if (boxsize[0] < 3)
rhc.trace = &testtrace;
rhc.trace->hitsupercontentsmask = hitsupercontentsmask;
rhc.trace->fraction = 1;
- rhc.trace->realfraction = 1;
rhc.trace->allsolid = true;
VectorCopy(test, rhc.start);
VectorCopy(test, rhc.end);
memset(trace, 0, sizeof(trace_t));
trace->hitsupercontentsmask = hitsupercontentsmask;
trace->fraction = 1;
- trace->realfraction = 1;
Collision_TraceLineBrushFloat(trace, start, end, &cbox, &cbox);
#else
RecursiveHullCheckTraceInfo_t rhc;
rhc.trace = trace;
rhc.trace->hitsupercontentsmask = hitsupercontentsmask;
rhc.trace->fraction = 1;
- rhc.trace->realfraction = 1;
rhc.trace->allsolid = true;
VectorCopy(start, rhc.start);
VectorCopy(end, rhc.end);
{
memset(trace, 0, sizeof(trace_t));
trace->fraction = 1;
- trace->realfraction = 1;
if (BoxesOverlap(start, start, cmins, cmaxs))
{
trace->startsupercontents |= boxsupercontents;
VectorCopy(normal, t->trace->plane.normal);
t->trace->plane.dist = DotProduct(normal, p);
- // calculate the true fraction
+ // calculate the return fraction which is nudged off the surface a bit
t1 = DotProduct(t->start, t->trace->plane.normal) - t->trace->plane.dist;
t2 = DotProduct(t->end, t->trace->plane.normal) - t->trace->plane.dist;
- midf = t1 / (t1 - t2);
- t->trace->realfraction = midf;
-
- // calculate the return fraction which is nudged off the surface a bit
midf = (t1 - collision_impactnudge.value) / (t1 - t2);
t->trace->fraction = bound(0, midf, 1);
- if (collision_prefernudgedfraction.integer)
- t->trace->realfraction = t->trace->fraction;
-
t->trace->hittexture = surface->texture->currentframe;
t->trace->hitq3surfaceflags = t->trace->hittexture->surfaceflags;
t->trace->hitsupercontents = t->trace->hittexture->supercontents;
rhc.trace = trace;
rhc.trace->hitsupercontentsmask = hitsupercontentsmask;
rhc.trace->fraction = 1;
- rhc.trace->realfraction = 1;
rhc.trace->allsolid = true;
rhc.hull = &model->brushq1.hulls[0]; // 0x0x0
VectorCopy(start, rhc.start);
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
bih = &model->collision_bih;
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
// push first node
// box trace, performed as brush trace
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
// calculate tracebox-like parameters for efficient culling
#endif
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
#if 0
Mod_CollisionBIH_TraceLine(model, frameblend, skeleton, trace, start, end, hitsupercontentsmask);
hitsupercontents = trace->hitsupercontents;
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
trace->startsupercontents = hitsupercontents;
#endif
VectorSet(end, start[0], start[1], model->normalmins[2]);
memset(&trace, 0, sizeof(trace));
trace.fraction = 1;
- trace.realfraction = 1;
trace.hitsupercontentsmask = 0;
Mod_CollisionBIH_TraceLine(model, frameblend, skeleton, trace, start, end, hitsupercontentsmask);
return trace.hitsupercontents;
Mod_Q3BSP_TraceLine_RecursiveBSPNode(trace, model, node->children[startside], start, mid, startfrac, midfrac, linestart, lineend, markframe, segmentmins, segmentmaxs);
// if we found an impact on the front side, don't waste time
// exploring the far side
- if (midfrac <= trace->realfraction)
+ if (midfrac <= trace->fraction)
Mod_Q3BSP_TraceLine_RecursiveBSPNode(trace, model, node->children[endside], mid, end, midfrac, endfrac, linestart, lineend, markframe, segmentmins, segmentmaxs);
return;
}
q3mbrush_t *brush;
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
if (mod_collision_bih.integer)
Mod_CollisionBIH_TracePoint(model, frameblend, skeleton, trace, start, hitsupercontentsmask);
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
segmentmins[0] = min(start[0], end[0]) - 1;
segmentmins[1] = min(start[1], end[1]) - 1;
// box trace, performed as brush trace
memset(trace, 0, sizeof(*trace));
trace->fraction = 1;
- trace->realfraction = 1;
trace->hitsupercontentsmask = hitsupercontentsmask;
segmentmins[0] = min(start->mins[0], end->mins[0]) - 1;
segmentmins[1] = min(start->mins[1], end->mins[1]) - 1;