mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-10 04:27:10 +03:00
Terrain trace freeze fix
This commit is contained in:
parent
a71c6db442
commit
65475f6bcc
1 changed files with 54 additions and 44 deletions
|
@ -1005,12 +1005,15 @@ void CM_TracePointThroughTerrainCollide( void )
|
|||
|
||||
fx = (g_trace.vStart[0] - g_trace.tc->vBounds[0][0]) * (SURFACE_CLIP_EPSILON / 8);
|
||||
fy = (g_trace.vStart[1] - g_trace.tc->vBounds[0][1]) * (SURFACE_CLIP_EPSILON / 8);
|
||||
i0 = ( int )floor( fx );
|
||||
j0 = ( int )floor( fy );
|
||||
i1 = ( int )floor( ( g_trace.vEnd[ 0 ] - g_trace.tc->vBounds[ 0 ][ 0 ] ) * ( SURFACE_CLIP_EPSILON / 8 ) );
|
||||
j1 = ( int )floor( ( g_trace.vEnd[ 1 ] - g_trace.tc->vBounds[ 0 ][ 1 ] ) * ( SURFACE_CLIP_EPSILON / 8 ) );
|
||||
i0 = (int64_t)floor(fx);
|
||||
j0 = (int64_t)floor(fy);
|
||||
i1 = (int64_t)floor((g_trace.vEnd[0] - g_trace.tc->vBounds[0][0]) * (SURFACE_CLIP_EPSILON / 8));
|
||||
j1 = (int64_t)floor((g_trace.vEnd[1] - g_trace.tc->vBounds[0][1]) * (SURFACE_CLIP_EPSILON / 8));
|
||||
|
||||
if( CM_CheckStartInsideTerrain( i0, j0, fx - i0, fy - j0 ) )
|
||||
const float dfx = fx - i0;
|
||||
const float dfy = fy - j0;
|
||||
|
||||
if (CM_CheckStartInsideTerrain(i0, j0, dfx, dfy))
|
||||
{
|
||||
g_trace.tw->trace.startsolid = qtrue;
|
||||
g_trace.tw->trace.allsolid = qtrue;
|
||||
|
@ -1103,8 +1106,14 @@ void CM_TracePointThroughTerrainCollide( void )
|
|||
dx = g_trace.vEnd[0] - g_trace.vStart[0];
|
||||
dy = g_trace.vEnd[1] - g_trace.vStart[1];
|
||||
|
||||
if( dx > 0 )
|
||||
// Fix
|
||||
//==
|
||||
// The original compares if delta float is zero
|
||||
// not only it's slower, but it can be problematic if those floats are NaN
|
||||
//==
|
||||
if (i1 > i0)
|
||||
{
|
||||
// dx positive
|
||||
d1 = 1;
|
||||
di = i1 - i0;
|
||||
dx2 = (i0 + 1 - fx) * dy;
|
||||
|
@ -1114,11 +1123,12 @@ void CM_TracePointThroughTerrainCollide( void )
|
|||
d1 = -1;
|
||||
di = i0 - i1;
|
||||
dx = -dx;
|
||||
dx2 = ( fx - i0 ) * dy;
|
||||
dx2 = dfx * dy;
|
||||
}
|
||||
|
||||
if( dy > 0 )
|
||||
if (j1 > j0)
|
||||
{
|
||||
// dy positive
|
||||
d2 = 1;
|
||||
dj = di + j1 - j0 + 1;
|
||||
dy2 = (j0 + 1 - fy) * dx;
|
||||
|
@ -1128,7 +1138,7 @@ void CM_TracePointThroughTerrainCollide( void )
|
|||
d2 = -1;
|
||||
dy = -dy;
|
||||
dj = di + j0 - j1 + 1;
|
||||
dy2 = ( fy - j0 ) * dx;
|
||||
dy2 = dfy * dx;
|
||||
dx2 = -dx2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue