Archived

This topic is now archived and is closed to further replies.

Collision System

This topic is 5109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I don`t know if this may be a new collision system but I would want to know if someone came up with this earlier and already has something huge build upon it. So the algorithm would sound like this->sphere to sphere collision(with the radius) based upon a contact object(sphere 1) and the triangle (sphere 2). Sphere 2 would be Computed out of the G of triangle as center and the distance to any vertex as the radius...
//Sphere1 is predefinable

Sphere2.Center=Triangle.Center;
Sphere2.Radius=Triangle.Vertex[0]-Triangle.Center;

float Dist=Vector3(Sphere2.Center-Sphere1.Center).length();
float rads=Sphere1.Radius+Sphere2.Radius;
if (Dist<rads) {//we collided->Test succesufull

}
I think it should mostly work on surfaces wich have polys with the same sizes, or be equally distant to each other anyway it might prove faster than sometinng else... I`m gonna do a test in the future.

Share this post


Link to post
Share on other sites
What code are you using that this is a usefull function. (just curious)

And: if Vector3(...).length() calculates the distance, you''d better just do this:

#define kwad(a) ((a)*(a))
//Sphere1 is predefinable

Sphere2.Center=Triangle.Center;
Sphere2.Radius=Triangle.Vertex[0]-Triangle.Center;
float Dist=Vector3(Sphere2.Center-Sphere1.Center).lengthNOSQRT();
float rads=kwad(Sphere1.Radius+Sphere2.Radius);
if (Dist<rads) {//we collided->Test succesufull}


lengthNOSQRT() would return the distance variable before running the square root operation on it.
This way you won''t need the square root which is very expensive.
As you won''t need the exact distance (only if it''s more/less then the total radius) the result should be the same (even more precise).

Share this post


Link to post
Share on other sites