Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Advice on speeding up collision

Author
Message
Erick G
Retired Moderator
20
Years of Service
User Offline
Joined: 2nd Oct 2004
Location: Texas, USA
Posted: 18th Jul 2005 17:53
Hi all, any advice on this would be awsome.

I have written a little shoot em up demo for the community, but I dont want to release it yet, as the app is dog slow when activating collision.

Below is pseudo code of what I am sure the problem is, i dont know of any other way to do this.

for all active bullets
for all active enemies
check collision (dbHitObject(bullet,enemy))
next
next

I call this every frame so it is understandable why it is so slow.
Can anyone of you guru's point me out to a better solution ?
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 18th Jul 2005 21:24
One thing I often do is something like that but before hand I check if objects are within a certain distance of anything they would collide against and if not I disable their collision completly to get alot of fps back.

However it is important to do the distance check using a fsqrt (fast square root) function and not the normal sqrt or dbsqrt - both are far too slow.

Theres a fsqrt in my "The DarkSDK Collection" in code snippets - I think.

Also obviously have the fastest collision type set to objects that you can get away with. I would make a big point out of making sure all bullets were set to box collision as they really dont need anymore - the enemies would be spheres generally or in rare cases polygon I guess.

Erick G
Retired Moderator
20
Years of Service
User Offline
Joined: 2nd Oct 2004
Location: Texas, USA
Posted: 18th Jul 2005 22:02
Thanks mate, I am gonna try that tonight and report back
Erick G
Retired Moderator
20
Years of Service
User Offline
Joined: 2nd Oct 2004
Location: Texas, USA
Posted: 19th Jul 2005 05:59
excellant, works 100%, steady framerate with quite a lot of objects on screen !! w00t !
Erick G
Retired Moderator
20
Years of Service
User Offline
Joined: 2nd Oct 2004
Location: Texas, USA
Posted: 19th Jul 2005 07:11 Edited at: 19th Jul 2005 07:12
Here are some very early screenshots.





Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 19th Jul 2005 08:11
glad it was usful Screenies look nice!

Login to post a reply

Server time is: 2024-11-19 00:22:18
Your offset time is: 2024-11-19 00:22:18