Overlap bug fix for wall line collisions?

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2, Sig, Sigo 2 years ago
parent 94d0746ed5
commit 7b337b9c7c
  1. BIN
      C++ProjectTemplate.wasm
  2. 11
      main.cpp

Binary file not shown.

@ -66,6 +66,7 @@ public:
AddLine({76,68},{132,68},5);
AddLine({4,12},{4,60},5);
AddLine({140,12},{140,60},5);
ConsoleCaptureStdOut(true);
return true;
}
@ -127,9 +128,13 @@ public:
}
}
if(GetKey(F1).bPressed){
ConsoleShow(F1);
}
Clear(BLACK);
float stable=0.01f;
float stable=0.05f;
int simulationUpdates=4;
int maxSimulationSteps=15;
float simElapsedTime=fElapsedTime/(float)simulationUpdates;
@ -183,11 +188,11 @@ public:
Ball*fakeBall=new Ball();
fakeBall->radius=l.radius;
fakeBall->mass=b.mass*0.8f;
fakeBall->pos=closestPoint;
fakeBall->pos={closestPoint.x,closestPoint.y};
fakeBall->vel={-b.vel.x,-b.vel.y};
fakeBalls.push_back(fakeBall);
collidingPairs.push_back({&b,fakeBall});
float overlap=1.f*(dist-b.radius-fakeBall->radius);
float overlap=1.1f*(dist-b.radius-fakeBall->radius);
b.pos.x-=overlap*(b.pos.x-fakeBall->pos.x)/dist;
b.pos.y-=overlap*(b.pos.y-fakeBall->pos.y)/dist;
}

Loading…
Cancel
Save