• ### What is your GameDev Story?

#### Archived

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

# Collision System

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

## Recommended Posts

I dont 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;

float Dist=Vector3(Sphere2.Center-Sphere1.Center).length();

}

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... Im gonna do a test in the future.

##### 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 predefinableSphere2.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).

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 9
• ### Forum Statistics

• Total Topics
634085
• Total Posts
3015407
×