Collision Detection 0.9 Release
Patrick Lam | 12 April, 2009 | 16:15
Hurray to the birth of Collision Detection~! Release 0.9~! The last plans for collision detection has finally been implemented. With sectioning and stepping coded in, the collision detection doesn’t take as long for large amounts of objects in the scene and the accuracy is increased.
The sectioning process didn’t take as long to implement. Originally, I have a list of objects from the scene and I test against that list. Now, I’ve replaced that list with a new list that is returned from a function that returns the list of objects depending on the section requested. I know I explained that a little to wordy, but the basic idea is as followed:
Also, to help speed up the process, I’ve implemented the getObjInSection() is such a way, that calls to lengthy functions such as getBoundingSphere() are made only when necessary.
The stepping process was a little tricky at first. I had some trouble trying to figure out, how I could change my existing code, so it’ll know to use the position of the object in a certain time step of the update. But after carefully reviewing my codes, I found that there was mainly 3 functions I needed to make changes to get the stepping working: objInSection(), boundingSphereTest(), and tri_tri_test(). For all the parts that are getting the object’s position or the bounding sphere’s position, I simply replaced them with the getNextPosition() which returns the position of the object at a certain time step in the update. So now, the code is in the following structure:
With the sectioning and stepping, the plans for collision detection 1.0 has been completed. To finish off, in the 1.0 release, a demo will be made using collision detection showing what it’s capable of doing.
The sectioning process didn’t take as long to implement. Originally, I have a list of objects from the scene and I test against that list. Now, I’ve replaced that list with a new list that is returned from a function that returns the list of objects depending on the section requested. I know I explained that a little to wordy, but the basic idea is as followed:
for each section {
list = getObjInSection();
for each obj in list {
test for collision;
}
}Also, to help speed up the process, I’ve implemented the getObjInSection() is such a way, that calls to lengthy functions such as getBoundingSphere() are made only when necessary.
The stepping process was a little tricky at first. I had some trouble trying to figure out, how I could change my existing code, so it’ll know to use the position of the object in a certain time step of the update. But after carefully reviewing my codes, I found that there was mainly 3 functions I needed to make changes to get the stepping working: objInSection(), boundingSphereTest(), and tri_tri_test(). For all the parts that are getting the object’s position or the bounding sphere’s position, I simply replaced them with the getNextPosition() which returns the position of the object at a certain time step in the update. So now, the code is in the following structure:
for each timestep {
for each section {
list = getObjInSection();
for each obj in list {
test for collision;
}
}
}With the sectioning and stepping, the plans for collision detection 1.0 has been completed. To finish off, in the 1.0 release, a demo will be made using collision detection showing what it’s capable of doing.
