vec3_t end;
vec_t len = 0;
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
{
// TRICK: make the trace 1 qu longer!
VectorSubtract(pEnd, start, end);
len = VectorNormalizeLength(end);
- VectorAdd(pEnd, end, end);
+ VectorMA(pEnd, collision_endposnudge.value, end, end);
}
else
VectorCopy(pEnd, end);
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);
#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
Collision_ShortenTrace(&trace, len / (len + 1), pEnd);
#endif
if (maxrealfrac < trace.realfraction)
vec3_t end;
vec_t len = 0;
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
{
// TRICK: make the trace 1 qu longer!
VectorSubtract(pEnd, start, end);
len = VectorNormalizeLength(end);
- VectorAdd(pEnd, end, end);
+ VectorMA(pEnd, collision_endposnudge.value, end, end);
}
else
VectorCopy(pEnd, end);
finished:
#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd);
#endif
return cliptrace;
vec3_t end;
vec_t len = 0;
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
{
// TRICK: make the trace 1 qu longer!
VectorSubtract(pEnd, start, end);
len = VectorNormalizeLength(end);
- VectorAdd(pEnd, end, end);
+ VectorMA(pEnd, collision_endposnudge.value, end, end);
}
else
VectorCopy(pEnd, end);
finished:
#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd);
#endif
return cliptrace;
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)"};
+#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+cvar_t collision_endposnudge = {0, "collision_endposnudge", "0", "workaround to fix trace_endpos sometimes being returned where it would be inside solid by making that collision hit (recommended: values like 1)"};
+#endif
void Collision_Init (void)
{
Cvar_RegisterVariable(&collision_enternudge);
Cvar_RegisterVariable(&collision_leavenudge);
Cvar_RegisterVariable(&collision_prefernudgedfraction);
+#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+ Cvar_RegisterVariable(&collision_endposnudge);
+#endif
}
// 3 = spew detailed trace flow (bsp tree recursion info)
#define COLLISIONPARANOID 0
-// make every trace 1qu longer, and shorten the result, to work around a stupid bug somewhere
-//#define COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+// make every trace <collision_endposnudge>qu longer, and shorten the result, to work around a stupid bug somewhere
+#define COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
+extern cvar_t collision_endposnudge;
+#endif
#endif
vec3_t end;
vec_t len = 0;
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
{
// TRICK: make the trace 1 qu longer!
VectorSubtract(pEnd, start, end);
len = VectorNormalizeLength(end);
- VectorAdd(pEnd, end, end);
+ VectorMA(pEnd, collision_endposnudge.value, end, end);
}
else
VectorCopy(pEnd, end);
finished:
#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd);
#endif
return cliptrace;
vec3_t end;
vec_t len = 0;
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
{
// TRICK: make the trace 1 qu longer!
VectorSubtract(pEnd, start, end);
len = VectorNormalizeLength(end);
- VectorAdd(pEnd, end, end);
+ VectorMA(pEnd, collision_endposnudge.value, end, end);
}
else
VectorCopy(pEnd, end);
finished:
#ifdef COLLISION_STUPID_TRACE_ENDPOS_IN_SOLID_WORKAROUND
- if(!VectorCompare(start, pEnd))
+ if(!VectorCompare(start, pEnd) && collision_endposnudge.value > 0)
Collision_ShortenTrace(&cliptrace, len / (len + 1), pEnd);
#endif
return cliptrace;