mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #1947
1947: Optimize CCollision::MoveBox to stop looping once velocity is 0 r=heinrich5991 a=def- Co-authored-by: def <dennis@felsin9.de>
This commit is contained in:
commit
3b5a085de7
|
@ -491,13 +491,16 @@ void CCollision::MoveBox(vec2 *pInoutPos, vec2 *pInoutVel, vec2 Size, float Elas
|
|||
|
||||
if(Distance > 0.00001f)
|
||||
{
|
||||
//vec2 old_pos = pos;
|
||||
float Fraction = 1.0f/(float)(Max+1);
|
||||
for(int i = 0; i <= Max; i++)
|
||||
{
|
||||
//float amount = i/(float)max;
|
||||
//if(max == 0)
|
||||
//amount = 0;
|
||||
// Early break as optimization to stop checking for collisions for
|
||||
// large distances after the obstacles we have already hit reduced
|
||||
// our speed to exactly 0.
|
||||
if(Vel == vec2(0, 0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
vec2 NewPos = Pos + Vel*Fraction; // TODO: this row is not nice
|
||||
|
||||
|
|
Loading…
Reference in a new issue