[Week 7] Ray-Triangle intersection, friction and I’m starting to get done.

This seems to be it. Even if most of the mechanics are currently locked down in a conveiently named test kernel, they are there and they seem to work. Now I can start working with making the code more readable, isolate parts into their own kernels, and of course optimize the code after doing this. Then I can set up example scenes for the upcoming milestone. For demonstrating them at the gradshow, I may or may not add functionality to alter the system on the fly, adding several force fields and several particle systems at a time; all with activated and/or deactivated kernels.

So, today  I wish to go through the particle-triangle collisions. For the collision detection, I’m using Möller & Trumbore’s fast triangle intersection test, modified as to return ray values of (float)INFINITY if there are no intersecting rays. (or if the ray is behind a triangle). For detecting the actual collision, I make a ray with an origin on the particle, with it’s velocity as its reach, and if I get a proper collision, the distance to the collision point is returned. When a collision happens, I split the current velocity vector in two components; one component that is aligned with the surface normal, and another that is aligned with the surface tangent. This is so that I can apply particle restitution and plane friction using:

V=(1-F )*vT – R*vN.
Where V = velocity,
F = friction,
vT = Tangent Force,
R = restitution,
vN = Normal Force

Be Sociable, Share!