Sorry if this is not the place for this.
I am making a game for one of my University subjects and I am having problems with the collision detection. Right now I use a simple but fast sphere-based collision detection system. The problem of it is that it detects collisions a lot of time before "the real collision" happens. I am actually looking for a box-based system.
That's the one I am currently using. I found it on gamedev. Very simple to understand and implement. The problem is that is too unefficient.
bool bSphereTest(Object3D* obj1, Object3D* obj2 )
{
point relPos = obj1->GetPos() - obj2->GetPos(); //Calculem el vector entre els 2
float dist = relPos.x * relPos.x + relPos.y * relPos.y + relPos.z * relPos.z; //Distà ncia que els separa
float minDist = obj1->GetRadi() + obj2->GetRadi(); //La suma de les 2 distà ncies
return dist <= minDist * minDist; //Si això es compleix vol dir que s'estan tocant ! retornem 1
}
Can you give me the scopes of a better algorythm ???
I am making a game for one of my University subjects and I am having problems with the collision detection. Right now I use a simple but fast sphere-based collision detection system. The problem of it is that it detects collisions a lot of time before "the real collision" happens. I am actually looking for a box-based system.
That's the one I am currently using. I found it on gamedev. Very simple to understand and implement. The problem is that is too unefficient.
bool bSphereTest(Object3D* obj1, Object3D* obj2 )
{
point relPos = obj1->GetPos() - obj2->GetPos(); //Calculem el vector entre els 2
float dist = relPos.x * relPos.x + relPos.y * relPos.y + relPos.z * relPos.z; //Distà ncia que els separa
float minDist = obj1->GetRadi() + obj2->GetRadi(); //La suma de les 2 distà ncies
return dist <= minDist * minDist; //Si això es compleix vol dir que s'estan tocant ! retornem 1
}
Can you give me the scopes of a better algorythm ???