too much collision check

Started by
7 comments, last by TheUnbeliever 12 years, 5 months ago
Hi. I'm working on a 3D space shooter game with opengl. I've working collision checks but problem is there are too much of them so game slows down. Currently there are asteroids in the space and they have bounding spheres. Also spaceship has a bounding sphere so i check collision with all of asteroids. Also spaceship can shoot bullets and i check every bullet with every asteroid. I use point-sphere collision check for bullets. I remove bullets if they traveled some distance so it is not that bullet count it increasing always. So how can i decrease collision checks to get better fps? Thanks.
Advertisement
You could divide the space into a grid and put each object to a grid cell and only check objects in nearby cells.

Or you can use some more complex space partitioning thingie but i dont think you need one.

o3o

Thanks for fast reply. I'll try dividing space and tell you about results.
This is an absolutely fantastic tutorial on collision:
http://www.metanetsoftware.com/technique/tutorialB.html
I am currently looking for an internship in the games industry in Japan. Please visit my my portfolio.
????????????????????????????????????????????????????????
I've other things to do so I just finished coding and it works fine. So thanks Waterlimon.
And thanks Adam Yaxley i'll check that tutorial.
Or look into bounding volume hiearcies.. Theres a good chapter on them in the Real Time Collision book by Christer Ericsson..
Or look into bounding volume hiearcies[/quote] How does that help, he already is only using spheres as his primitive.

One thing you might be doing wrong is that if you have say the asteroids:
A,B,C
so i check collision with all of asteroids[/quote]
Then make sure you only test:
A vs B
A vs C
B vs C

and not:
A vs B
A vs C
B vs A
B vs C etc

NBA2K, Madden, Maneater, Killing Floor, Sims http://www.pawlowskipinball.com/pinballeternal

Hold on, here. How many asteroids and bullets are we talking about? Let's make sure we have a good idea what the real problem is before we try to solve it :)

Or look into bounding volume hiearcies
How does that help, he already is only using spheres as his primitive.[/quote]
He says he's using bounding spheres, not that he's using a BVH. It sounds like he's doing sphere-sphere collision tests for everything, rather than a hierarchy that allows him to cull some of those tests.
[TheUnbeliever]

This topic is closed to new replies.

Advertisement