Collision Detection – Recap of Release 0.8
Patrick Lam | 1 April, 2009 | 13:10
So, the 0.8′s goal was the same as 0.7′s, improving efficiency. That, I would say have been achieved as discussed in my previous posts Collision Detection and here. In terms of implementations, I think I have cut out as much unnecessary processing/calculations as I could with the code. And with the results in time showing a significant improvement from my previous result time, I’d say this release was a big jump from 0.7.
From looking at the demo of two colliding spheres (here), the collision test is considerably usable compared to how it was before where the browser gives a warning asking if I wanted to stop the script (hinting that the code is taking to long to run). You’ll notice that in this demo, you can actually see the movements speed up as the distance between the two sphere gets smaller and smaller. This is happening because as the two sphere gets closer, the first pair of vertices that collides are founding faster and faster. Depending on the model, the order the vertices are defined may vary. In the case of the sphere, I believe the vertices start from the very top of the sphere, and spiral down to the bottom of the sphere. That’s why in this demo, it takes a bit of time to get to the vertices on the side, about 300 ms, and when the two spheres have vertices colliding near the top, it takes about 100ms or even less.
In case some users don’t want to use the triangle test, and think the bounding sphere is enough for their usage, they can turn that off. Of course, the bounding sphere will take a lot less time than the triangle test, since it doesn’t need to go through the vertices in one object against the vertices of the other object to find a collision. Right now, the triangle test is turn off by default, so if the user ever needs the triangle test, they’d need to turn it on. And turning it on doesn’t take much work, after they’ve created their collision detection, they just need to set the triangle test property on and it’d use the triangle test.
This sums up the work done in 0.8. And now, plans for 0.9 and 1.0.
0.9 – Implement Sectioning and Stepping
1.0 – Create demo using collision detection.
From looking at the demo of two colliding spheres (here), the collision test is considerably usable compared to how it was before where the browser gives a warning asking if I wanted to stop the script (hinting that the code is taking to long to run). You’ll notice that in this demo, you can actually see the movements speed up as the distance between the two sphere gets smaller and smaller. This is happening because as the two sphere gets closer, the first pair of vertices that collides are founding faster and faster. Depending on the model, the order the vertices are defined may vary. In the case of the sphere, I believe the vertices start from the very top of the sphere, and spiral down to the bottom of the sphere. That’s why in this demo, it takes a bit of time to get to the vertices on the side, about 300 ms, and when the two spheres have vertices colliding near the top, it takes about 100ms or even less.
In case some users don’t want to use the triangle test, and think the bounding sphere is enough for their usage, they can turn that off. Of course, the bounding sphere will take a lot less time than the triangle test, since it doesn’t need to go through the vertices in one object against the vertices of the other object to find a collision. Right now, the triangle test is turn off by default, so if the user ever needs the triangle test, they’d need to turn it on. And turning it on doesn’t take much work, after they’ve created their collision detection, they just need to set the triangle test property on and it’d use the triangle test.
cd = new CollisionDetection(scn);
cd.setTriangleTest(true);This sums up the work done in 0.8. And now, plans for 0.9 and 1.0.
0.9 – Implement Sectioning and Stepping
1.0 – Create demo using collision detection.
