   Collision detection in major games
  Hi guys I was wondering how the people who made GTA 4 did the collision for cars? Do they have like 40 collision boxes all over the car? For example when you hit a window it gets blown in or cracks(vinyls I think, btw do they do this by picking?) and if you hit your door or your hood it breaks or comes off. So do they have different collision boxes for each door. Just wondering as I have little clue as to how they do this.   
Quote:Original post by emforceDo they have like 40 collision boxes all over the car? For example when you hit a window it gets blown in or cracks(vinyls I think, btw do they do this by picking?) and if you hit your door or your hood it breaks or comes off. So do they have different collision boxes for each door.Don't you think you sort of answered your own question already? :)Note that even though a car contains multiple collision shapes, that doesn't mean you need to check all of them. It's often better to check against the cars bounding box or sphere first - if the bullets are so far off that they don't even hit that, then you don't need to check all the collision shapes of that car either.And yeah, I imagine that for direct-hit weapons, you'd trace a line, rather than having an actual bullet object flying around for collision detection.   ;  Or the entire collision boxes-scheme could be setup up hierarchically, using a "shallow" octree or something. So, at first shot, you'd check against the main bounding box. Then, once a collision has occurred, you'd traverse the hierarchy in order to check against the children of the parent boxes, each of these children could correspond to stuff on the model - say windows/ doors etc etc.That way, every frame, your high level collision detection scheme remains the same, just that upon detecting a collision, you'd need to further refine the positional data.   ;  Thanks guys :D really helpful :DI wanted to know this because I wanted to try and create a destructable car program which would just show off simple damage things.   ;  yeah you'd probably have a single sphere or something to check if there is a collision with the whole object, and then if there is, you'd localize that collision.   ;  I think that a collision box would be a bit more efficient for a car model because you could tighten it pretty close but yeh I see what you mean thanks :D   ;  collision box could be made tigher around the car, but the test for sphere intersection against a line is faster than line against box, and also a box takes more memory to represent.pros and cons to both, youd have to try each and see which worked better for you (probably doesnt even make a difference in your case since it's a sandbox car damage program!)(:   ;  Ahh I didn't know this thanks alot! :D is there any particular reason that the line to sphere is slower than line to box?   ;Quote:Original post by emforceAhh I didn't know this thanks alot! :D is there any particular reason that the line to sphere is slower than line to box?It's not, it's faster, because to test to see if a point is within a sphere, you only have to check to see if the distance of the colliding object from the center of the sphere is less than the sphere's radius, whereas for a box you'd have to check if the object is within all 6 of the box's planes.When you have 100's of objects, checking tight bounding volumes for each one takes a lot of time, many many calculations, which is why you'd use a rough sphere for each object, and then if there's a collision with hte sphere, you can check to see if it collides with the tighter bounding volume.EDIT: There are many other ways of cuttin down on time, such as organizing objects into sections and using trees   ;  Sorry I meant why is line to box slower, just as you said previously but yeh I understand :D. Thanks guys for the insightful answers you have given me :D   