Post by tld2 on Jan 24, 2014 2:14:21 GMT -8
Hello dum dums,
Posting today about how collision detection works in Second Life, I'll try to explain the best that I can. I've been hearing some advice floating around the community about maximizing faces on projectiles to increase the chances of hit reg. I thought this practice was dispelled as myth a long time ago but it seems in these dark ages of military technology we've taken to revering sooth sayers as scripters. This is bad and you should feel bad.
The Basics: A bullet and an avatar both have a bounding box which occupy a 3D space in a sim. When both of these boxes occupy the same space at the same time collision is detected. This is how the Havok engine and indeed most physic engines work.
Physics in Second Life: The second life engine uses what's called "discrete collision detection" which is unique in that it uses frame rate to calculate it's physics. You may have heard something about "frames" mentioned by cool scripter kids in the past. In each frame the sim will calculate it's physics and generate a list of objects which are currently intersecting using GJK. The collision event will usually be generated on the next frame after the collision has actually taken place. This is why your bullets don't register kills when the sim is lagging to death, these collisions are occurring as the object moves at high speed between frames. Linden Labs attempts to overcome this flaw by representing "projectiles as arrows with invisible trailing tails longer than the gap in frames to collide with any object that might fit between the calculated frames." [1]
So why not faces?: Linden Labs chose DCD for SL because it's the simplest method collision detection. To check every face of every object would have a huge impact on performance especially with geometrically complex objects. This is why mesh is uploaded with a separate compound hitbox and does not use the actual object for physical interactions. [2]
Almighty Cube: So what shape should you use? I endorse the cube bullet for two reasons: it's easy for the viewer to render and it's a simpler physics shape for the engine to calculate.
Why not Spheres?: The second part of this equation is collision response. Although the sphere has the lowest performance cost of any of the shape types, Second Life's engine has a bit of a problem when it comes to dealing complicated shapes as this video demonstrates. [3] Spherical bullets will still register collisions, however they may respond with bouncing more often than a cube bullet, especially when the sim is under heavy load. Prim material settings also factor into collision response, but I won't get into that here.
Source: Artist Best Practices Havok Source
I hope this helps clear things up. Please spread the information around. Special thanks to Zantrua for helping me gather materials. If you disagree with me I encourage you to register and join in the discussion.
Posting today about how collision detection works in Second Life, I'll try to explain the best that I can. I've been hearing some advice floating around the community about maximizing faces on projectiles to increase the chances of hit reg. I thought this practice was dispelled as myth a long time ago but it seems in these dark ages of military technology we've taken to revering sooth sayers as scripters. This is bad and you should feel bad.
The Basics: A bullet and an avatar both have a bounding box which occupy a 3D space in a sim. When both of these boxes occupy the same space at the same time collision is detected. This is how the Havok engine and indeed most physic engines work.
Physics in Second Life: The second life engine uses what's called "discrete collision detection" which is unique in that it uses frame rate to calculate it's physics. You may have heard something about "frames" mentioned by cool scripter kids in the past. In each frame the sim will calculate it's physics and generate a list of objects which are currently intersecting using GJK. The collision event will usually be generated on the next frame after the collision has actually taken place. This is why your bullets don't register kills when the sim is lagging to death, these collisions are occurring as the object moves at high speed between frames. Linden Labs attempts to overcome this flaw by representing "projectiles as arrows with invisible trailing tails longer than the gap in frames to collide with any object that might fit between the calculated frames." [1]
So why not faces?: Linden Labs chose DCD for SL because it's the simplest method collision detection. To check every face of every object would have a huge impact on performance especially with geometrically complex objects. This is why mesh is uploaded with a separate compound hitbox and does not use the actual object for physical interactions. [2]
Almighty Cube: So what shape should you use? I endorse the cube bullet for two reasons: it's easy for the viewer to render and it's a simpler physics shape for the engine to calculate.
Why not Spheres?: The second part of this equation is collision response. Although the sphere has the lowest performance cost of any of the shape types, Second Life's engine has a bit of a problem when it comes to dealing complicated shapes as this video demonstrates. [3] Spherical bullets will still register collisions, however they may respond with bouncing more often than a cube bullet, especially when the sim is under heavy load. Prim material settings also factor into collision response, but I won't get into that here.
Source: Artist Best Practices Havok Source
I hope this helps clear things up. Please spread the information around. Special thanks to Zantrua for helping me gather materials. If you disagree with me I encourage you to register and join in the discussion.