mirror of
https://github.com/GTAmodding/re3.git
synced 2024-11-29 11:13:44 +00:00
Fix CCollision::DistToLine
This commit is contained in:
parent
8cdc6b5d7c
commit
d68ec362dd
1 changed files with 6 additions and 6 deletions
|
@ -2099,12 +2099,12 @@ CCollision::DistToLine(const CVector *l0, const CVector *l1, const CVector *poin
|
||||||
float dot = DotProduct(*point - *l0, *l1 - *l0);
|
float dot = DotProduct(*point - *l0, *l1 - *l0);
|
||||||
// Between 0 and len we're above the line.
|
// Between 0 and len we're above the line.
|
||||||
// if not, calculate distance to endpoint
|
// if not, calculate distance to endpoint
|
||||||
if(dot <= 0.0f)
|
if(dot <= 0.0f) return (*point - *l0).Magnitude();
|
||||||
return (*point - *l0).Magnitude();
|
if(dot >= lensq) return (*point - *l1).Magnitude();
|
||||||
if(dot >= lensq)
|
|
||||||
return (*point - *l1).Magnitude();
|
|
||||||
// distance to line
|
// distance to line
|
||||||
return Sqrt((*point - *l0).MagnitudeSqr() - dot*dot/lensq);
|
float distSqr = (*point - *l0).MagnitudeSqr() - dot * dot / lensq;
|
||||||
|
if(distSqr <= 0.f) return 0.f;
|
||||||
|
return Sqrt(distSqr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// same as above but also return the point on the line
|
// same as above but also return the point on the line
|
||||||
|
@ -2571,4 +2571,4 @@ CCollision::DrawColModel_Coloured(const CMatrix &mat, const CColModel &colModel,
|
||||||
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
|
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)FALSE);
|
||||||
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
|
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)TRUE);
|
||||||
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
|
RwRenderStateSet(rwRENDERSTATEZTESTENABLE, (void*)TRUE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue