I'm having problems with rotating rigid bodies because my method of finding contact points is flawed.
Sometimes the rotational velocity spikes on some rigid bodies because of incorrect contact points.
What I do currently, is find the point on the polygon the lowest along its contact normal.
The problem is that i will find two contact points and i have no idea on how to determine which contact point is the real contact point.
Here is what my code looks like for finding contacts for each polygon:
template<class Shape>
static void Find_POI(Shape * A,Vector2D MTD,Vector2D & CPmin){ //MTD is contact normal, CPmin is returning a contact point byref
float Dot[10];
Dot[0] = MTD^(*A->PointList[0]);
float Min= Dot[0];
int MinIndex = 0 ;
for(unsigned int K = 1; K < A->PointList.size(); K++){
Dot[K] = (*A->PointList[K])^MTD;
if(Dot[K] < Min){
Min = Dot[K];
MinIndex = K;
}
}
CPmin = *(A->PointList[MinIndex]);
}
My Question is:
How do you guys find your contact points(Edge vs Point)?
Am i going in the right direction with my method or am i completely wrong?
Can't understand - how did you get 2 contact points? In case of edge-point the projection on normal (assuming that you separate bodies from penetration) should return total 3 points - vertex of the object that penetrates and two vertices of an other object edge. In that case you should take only the first point - i.e. vertex of object that penetrates.
My Question is:
How do you guys find your contact points(Edge vs Point)?
Am i going in the right direction with my method or am i completely wrong?
Take a look at my article on the physics and collision detection of an angry birds style game - scroll down a bit, I discuss generating the contact set which sounds like what you are after:
Take a look at my article on the physics and collision detection of an angry birds style game - scroll down a bit, I discuss generating the contact set which sounds like what you are after: http://www.wildbunny...y-birds-part-2/
Cheers, Paul.
Thanks for the article.This method makes a lot more sense than what i was doing.
*EDIT*
It worked.
Rigid bodies no longer Spin-out thanks to a proper contact finder.