Author Topic: Collision Detection Rewrites  (Read 10671 times)

0 Members and 1 Guest are viewing this topic.

Offline Swifty

  • 210
  • I reject your fantasy & substitute my own
Collision Detection Rewrites
My collision detection optimizations are finally ready for testing. I've done a couple things to the collision detection system in the Freespace Open engine.

First has been rewriting the time caching system that keeps track of all potential collision pairs in the gameplay simulation. Freespace brute forces this and ends up going through all n^2 pairs each frame in order to find valid collisions to test. This ends up becoming costly, especially when an object is deleted which results going through all n^2 pairs to find which pairs to delete.

I end up fixing this by finding potential collision pairs through applying Quicksort on all three axes to find objects that have their bounding boxes overlapping. I then use a hash table to store and keep track of the next check time for each pair that I get a positive on. The pair itself is collision tested business as usual if the next check time has been elapsed.

Second has been rewriting the collision data format for models. The internal data structure I use to store POF collision data from is much more leaner while being well formed. This means the traversal algorithm doesn't have to play with headache inducing pointer math to go down the collision data tree to find a hit on a model. The traversal algorithm is much simpler and much more readable which in the end should make it faster.

I've been playing around with multithreading the collision code. Due to the collision code becoming more efficient from my rewrites of these key portions, it's not longer necessary to multithread that section of the code.

My build with these changes are here: http://www.hard-light.net/forums/index.php?topic=81087.0 . It includes a bunch of rendering optimizations including a soft particle rendering optimization and better OpenGL state change management.

 

Offline T-Man

  • 210
  • I came... I saw... I had a cuppa!
Re: Collision Detection Rewrites
 :shaking: [Whine] i no speak coder [/whine] *head implodes* :lol:

Nah i think i got the basic jist of this; the computer doesen't have to do so many checks for colissions each frame, so it'll free up a lot of memory?

Sounds impressive nevertheless; nice one. :yes:
Also goes by 'Murasaki-Tatsu' outside of Hard-Light

UEF fanboy. Rabid Imagination.

 

Offline Valathil

  • ...And I would have had a custom title if it wasn't for you meddling kids!
  • 29
  • Custom Title? Wizards need no Custom Title!
Re: Collision Detection Rewrites
First bug report. Game hangs on loading Tethis.pof in bp2-massivebattle with the released bp2 version. Spoon reports BP SVN seems to be working. I get one core 100% and then nothing no error etc.
┏┓╋┏┓╋╋╋╋╋╋╋╋╋┏┓
┃┃╋┃┃╋╋╋╋╋╋╋╋╋┃┃
┃┃┏┫┃┏┳━━┓┏━━┓┃┗━┳━━┳━━┳━━┓
┃┃┣┫┗┛┫┃━┫┃┏┓┃┃┏┓┃┏┓┃━━┫━━┫
┃┗┫┃┏┓┫┃━┫┃┏┓┃┃┗┛┃┗┛┣━━┣━━┃
┗━┻┻┛┗┻━━┛┗┛┗┛┗━━┻━━┻━━┻━━┛

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Re: Collision Detection Rewrites
First bug report. Game hangs on loading Tethis.pof in bp2-massivebattle with the released bp2 version. Spoon reports BP SVN seems to be working. I get one core 100% and then nothing no error etc.
its something related to pof loading iirc. i purged the data/cache and ran through rc4 build to get the caches rebuilt, worked afterwards.
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Collision Detection Rewrites
This has the potential to be awesome. :yes:

 

Offline MatthTheGeek

  • Captain Obvious
  • 212
  • Frenchie McFrenchface
Re: Collision Detection Rewrites
Yes it has. The fact it currently seems to have a few bugs doesn't take any of the awe I have for someone who managed not only to face the collision code, survive to tell the tale and keep his sanity, but actually rewrote the damn thing.
People are stupid, therefore anything popular is at best suspicious.

Mod management tools     -     Wiki stuff!     -     Help us help you

666maslo666: Releasing a finished product is not a good thing! It is a modern fad.

SpardaSon21: it seems like you exist in a permanent state of half-joking misanthropy

Axem: when you put it like that, i sound like an insane person

bigchunk1: it's not retarded it's american!
bigchunk1: ...

batwota: steele's maneuvering for the coup de gras
MatthTheGeek: you mispelled grâce
Awaesaar: grace
batwota: oh right :P
Darius: ah!
Darius: yes, i like that
MatthTheGeek: the way you just spelled it it means fat
Awaesaar: +accent I forgot how to keyboard
MatthTheGeek: or grease
Darius: the killing fat!
Axem: jabba does the coup de gras
MatthTheGeek: XD
Axem: bring me solo and a cookie

 

Offline Valathil

  • ...And I would have had a custom title if it wasn't for you meddling kids!
  • 29
  • Custom Title? Wizards need no Custom Title!
Re: Collision Detection Rewrites
i still cant get the caches to rebuild for whatever reason but just running the new build gives me about 3 fold increase in bp2 massive battle. if thats not awesome i dont know what is.

But dont do == with floats if(blown_off == 1.0) should be if(blown_off > 0.9) or you get wierd results from the vertex interpolation.

EDIT: Get some extracted shaders here for MOD's that have shaders in their VP's ( WAR IN HEAVEN IM LOOKING AT YOU!!!!)



[attachment deleted by a ninja]
« Last Edit: June 12, 2012, 08:47:53 am by Valathil »
┏┓╋┏┓╋╋╋╋╋╋╋╋╋┏┓
┃┃╋┃┃╋╋╋╋╋╋╋╋╋┃┃
┃┃┏┫┃┏┳━━┓┏━━┓┃┗━┳━━┳━━┳━━┓
┃┃┣┫┗┛┫┃━┫┃┏┓┃┃┏┓┃┏┓┃━━┫━━┫
┃┗┫┃┏┓┫┃━┫┃┏┓┃┃┗┛┃┗┛┣━━┣━━┃
┗━┻┻┛┗┻━━┛┗┛┗┛┗━━┻━━┻━━┻━━┛

 

Offline Kobrar44

  • On Suspended Sentence
  • 29
  • Let me tilerape it for you!
    • Steam
Re: Collision Detection Rewrites
I've been awaiting this since April 30  :yes:
Sadly multithreading didn't make it into the build  :( Feature is feature. I hope I made it clear enough that I am not serious about this one.
Oh guys, use that [ url ][ img ][ /img ][ /url ] :/

 
Re: Collision Detection Rewrites
I agree this is awesome, a shame multithreading didnt made it yet, but nonetheless awesome stuff will help a lot with BOE scenenarios and on my case with Dominion Battles for my ST mod.

tho i still hope you wont drop multithreading support please *-* i want moar perfomance.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Collision Detection Rewrites
What makes you think multi-threading will speed things up so much? Especially when a coder has told you it's not worth doing because it's not getting enough of a speed gain? :p
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline MatthTheGeek

  • Captain Obvious
  • 212
  • Frenchie McFrenchface
Re: Collision Detection Rewrites
I wish people would stop thinking multithreading is some sort of magic solution to all performance problems. That's not how it works !
People are stupid, therefore anything popular is at best suspicious.

Mod management tools     -     Wiki stuff!     -     Help us help you

666maslo666: Releasing a finished product is not a good thing! It is a modern fad.

SpardaSon21: it seems like you exist in a permanent state of half-joking misanthropy

Axem: when you put it like that, i sound like an insane person

bigchunk1: it's not retarded it's american!
bigchunk1: ...

batwota: steele's maneuvering for the coup de gras
MatthTheGeek: you mispelled grâce
Awaesaar: grace
batwota: oh right :P
Darius: ah!
Darius: yes, i like that
MatthTheGeek: the way you just spelled it it means fat
Awaesaar: +accent I forgot how to keyboard
MatthTheGeek: or grease
Darius: the killing fat!
Axem: jabba does the coup de gras
MatthTheGeek: XD
Axem: bring me solo and a cookie

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: Collision Detection Rewrites
I wish people would stop thinking multithreading is some sort of magic solution to all performance problems. That's not how it works !
lalalalala I can't hear you! You sir are a liar and a ruffian.
Multi threading banzai! Huzzah, huzzah, huzzah!
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 

Offline JGZinv

  • 211
  • The Last Dual! Guardian
    • The FringeSpace Conversion Mod
Re: Collision Detection Rewrites
Been looking forward to this for 6 years...  yay.

Due to the new calculation method, are very thin geometry structures more apt to be hit / recognized / registered or is that a separate issue?
Got some wing tips / surfaces that are very thin on a few models, don't always register hits in those areas, and was curious....
True power comes not from strength, but from the soul and imagination.
Max to PCS2 to FS2 SCP Guide
The FringeSpace Conversion Mod

 

Offline jg18

  • A very happy zod
  • 210
  • can do more than spellcheck
Re: Collision Detection Rewrites
I've been awaiting this since April 30  :yes:
Sadly multithreading didn't make it into the build  :( Feature is feature. I hope I made it clear enough that I am not serious about this one.
I agree this is awesome, a shame multithreading didnt made it yet, but nonetheless awesome stuff will help a lot with BOE scenenarios and on my case with Dominion Battles for my ST mod.

tho i still hope you wont drop multithreading support please *-* i want moar perfomance.
Yeah let's multithread away even though it's notoriously hard to get right and it doesn't even guarantee an automatic performance improvement (also see: false sharing). (No offense to any SCP member's coding skills intended.)

Back on topic, though, very cool stuff, Swifty. My impression from E9's post in the release thread was that more work was needed for OS X compatibility (although I'm using Snow Leopard and my Lion box is 3,000 miles away), so I might need to wait before trying this out. :)

Oh, and also (recolored for readability):
I hope I made it clear enough that I am not serious about this one.
Not quite clearly enough. :p

 

Offline Sushi

  • Art Critic
  • 211
Re: Collision Detection Rewrites
Is the stuff in the test build the same as the stuff in the test build you made for Diaspora? (I want to know if my feedback on the Diaspora variant is relevant in this thread).

 
Re: Collision Detection Rewrites
Out of curiosity (I know **** about coding): On which machine will he performance gain be most recognizable? Low-End or on all machines? Will be there an overall performance gain or mostly in large battles?

 

Offline MatthTheGeek

  • Captain Obvious
  • 212
  • Frenchie McFrenchface
Re: Collision Detection Rewrites
Well, obviously, if you have a high-end machine that run 99% of the game at solid 60fps, you'll have a significant trouble noticing any performance gain...

But to be more precise, the whole thing is supposed to reduce the CPU bottleneck of collision detection, so the difference will mainly be seen on computers which have a decent graphic card compared to their CPU. For people with intelgrated, the major bottleneck isn't exactly the CPU.
People are stupid, therefore anything popular is at best suspicious.

Mod management tools     -     Wiki stuff!     -     Help us help you

666maslo666: Releasing a finished product is not a good thing! It is a modern fad.

SpardaSon21: it seems like you exist in a permanent state of half-joking misanthropy

Axem: when you put it like that, i sound like an insane person

bigchunk1: it's not retarded it's american!
bigchunk1: ...

batwota: steele's maneuvering for the coup de gras
MatthTheGeek: you mispelled grâce
Awaesaar: grace
batwota: oh right :P
Darius: ah!
Darius: yes, i like that
MatthTheGeek: the way you just spelled it it means fat
Awaesaar: +accent I forgot how to keyboard
MatthTheGeek: or grease
Darius: the killing fat!
Axem: jabba does the coup de gras
MatthTheGeek: XD
Axem: bring me solo and a cookie

 

Offline pecenipicek

  • Roast Chicken
  • 211
  • Powered by copious amounts of coffee and nicotine
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • PeceniPicek's own deviantart page
Re: Collision Detection Rewrites
Out of curiosity (I know **** about coding): On which machine will he performance gain be most recognizable? Low-End or on all machines? Will be there an overall performance gain or mostly in large battles?
doesnt matter. i have a i7 860 which is no slouch. bp2-massivebattle still brings the fps down to a piddly 4(or rather, seconds per frame).

the performance gain will be everywhere.
Skype: vrganjko
Ho, ho, ho, to the bottle I go
to heal my heart and drown my woe!
Rain may fall and wind may blow,
and many miles be still to go,
but under a tall tree I will lie!

The Apocalypse Project needs YOU! - recruiting info thread.

 

Offline SypheDMar

  • 210
  • Student, Volunteer, Savior
    • Minecraft
Re: Collision Detection Rewrites
I hope I made it clear enough that I am not serious about this one.
Oh my gosh. I should do this from now on. Also not serious.
Collision rewrite sounds amazing! I wonder how it'll affect multiplayer.

 

Offline Al-Rik

  • 27
Re: Collision Detection Rewrites
:shaking: [Whine] i no speak coder [/whine] *head implodes* :lol:

Nah i think i got the basic jist of this; the computer doesen't have to do so many checks for colissions each frame, so it'll free up a lot of memory?

Sounds impressive nevertheless; nice one. :yes:
So moar dakka on the screen is possible ? :D