Archived

This topic is now archived and is closed to further replies.

Need collision optimzation advice

This topic is 5114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey all. okay, so i''ve got my game (RC car racing, top down view) i''ve got my scene (track is 20,000 poly including all objects) i''ve got my car, which collides with track. without collision, i get 170fps. with collision (against EVERY poly in track i get like 20fps) this clearly is no good. so then i''ve got a low poly track (2,000) which i check for collision. with the low poly track i get 150fps, great! heres my question, it takes me all of 20min to create the lowpoly track after the original, however, this is not very modular. I would like to use just one track (only because this is a school project and i''m being marked on code and design). Is it possible using trees, BSP, high-level/lowlevel collision to increase that 20-30fps up to my current 150fps?? Even though this would be a great exercise, i need this game to run smooth on my schools slow computers. thanks.

Share this post


Link to post
Share on other sites
if you use a hierarchical datastructure for your terrain, a quadtree for example, 20000 polys should be no problem. besides quadtrees arnt that hard.

Share this post


Link to post
Share on other sites

Well i''m not too worried about difficulty (i''ve coded trees before, along with various other data structures) but i''m worried about time.

Even though that stuff could also help my rendering, I really dont need it for my engine.

If I waste 2 weeks coding a hierarchical collision model, I dont want to end up with 100fps, whereas in 20 min of fiddling in 3ds max with my model I can get 150fps.

Ah well, thanks for ther reply anyways.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
try and do collisions on primitives vs per poly. for a driving game many polys will be on the same plane. that with a nice culling routine may help.

Share this post


Link to post
Share on other sites
That can work, but if you are doing decals and other stuff, using the polygon version of the track will result in errors, and the cars might look like not sticking to the road exactly.


For collision detection, a culling algorithm is necessary. It''s not very hard to implemement. Try a loose AABox tree, or if you can use the RAPID or OPCODE collision detection library to get the polygons. They both use some kind of subdivision.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I agree with Oliii - you *have* to code up some sort of culling mechanism (f.ex. a quadtree would probably do nicely).

Think about it - don''t you think it''s extremely wasteful to check for collision against *every* triangle in the mesh? Actually, even with a 2000 polygon version of the track it is extremely wasteful to check them all, since obviously only those triangles *near* the car can be potential colliders. I''ll bet you can, with a quadtree or something else, cull away so many triangles that you''ll only have to check a few handfulls of triangles... even when using the original mesh.

So here''s what I would do. Given the cars position, size and its velocity vector I would calculate a sphere that surrounds the car and as far as it can possibly go (length of velocity) in any direction. This would be a sphere with center at the car position and with a radius equal to the velocity length - plus something more to make sure not just the car center, but actually the entire car is within the sphere. Add for example the radius of the cars bounding sphere or add the maximum side length in its bounding box if that''s what you got.

It''s then pretty easy to "send" this sphere down through a quadtree (or even a BSP tree if you got that already) and gather all those polygons that intersect the sphere. Those are the only ones you have to check for collision..


- Kasper Fauerby

Share this post


Link to post
Share on other sites
yes, quadtree is a good solution. Its so simple to implement (if your track is like a terrain heightmap (with other objects) it would help with culling and collision.

Simply get the leaf node of quadtree in which your collider lies on. Then you will have a list of objects (or polygons) to test collision, less than 2k tris.

Share this post


Link to post
Share on other sites