🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Retention In Physics Simulations

Started by
3 comments, last by SillyCow 5 years, 2 months ago

Hi everyone, I wanna know the thoughts of people who have implemented or have experience with physics sims and/or collision detection routines, on the retention and data representation part of the equation.

I've recently poked PhysX to see how it can be integrated to my 3D game, but immediately realized that i absolutely hate the way it wants me to keep all state in sync, and it gets ugly very quickly, not to mention all the copying and conversions that should happen every frame. All because it keeps an internal representation called "Actors" to make everything magically work after simulate(); . I know this gives the API more control over its internal simulation and optimization, but it becomes trouble for the app that's using it. As if the API was made with the expectation that the user only loads a scene once and never wants to inject changes into it...

 

 Now I've decided to make my own collision detection/physics without use of any retention, and just use the entity state as the input to test functions.

But Considering that i haven't implemented any physics sim yet, i can't foresee the requirements and challenges, so i don't know.. even retention might become necessary. and my game doesn't depend much on physics nor does it use any substantial number of rigid bodies. for now i'm just thinking about simple collision detection. 

Any thoughts?

Advertisement

Physics sims retain data because some relationships and interactions between objects can span frames. You can of course add objects to an existing scene, but that would require you to renegotiate what is happening.

I have programmed a simple physics engine before, and I can say that it was very fun! I definitely recommend it as a learning experience. It will really improve your knowledge in applied math, and performance optimisation.

However: Writing a good physics engine is much harder than just doing collision detection. Simulating basic physics, such as a pool table. Is pretty straight forward. However, when processing interactions of more than 2 bodies (like a Jenga tower, or a solid ragdoll with hinges) : You should expect to run into alot of complex algebrical integration problems. One might say that this is what the likes of "PhysX" was designed to do. Using "physX" or "Havok" for a pool game would be overkill. 

So I would wholeheartedly recommend that you embark on writing your own Physics engine as a learning excersize:

0. Start by implementing some collision detection algorithms

1. Then make a 2D pool game.

2. Then make an angry birds clone. (If you've made it this far, you're a champ!)

3. Then try something simple in 3D (Maybe a racing game?)

 

 

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

2 hours ago, SillyCow said:

 

Sorry i wasn't clear with what i meant by challenges. I meant structural not maths. ie: Will i run into problems if i don't retain and just loop over the main entities? what would be the tradeoffs? Some i can think of are probably the data locality when dealing with spatial partitioning. But then even O(n^2) might not be a big problem with my game.

Quote

Physics sims retain data because some relationships and interactions between objects can span frames..

Can you give an example?

1 hour ago, Amir_r_KB said:

O(n^2) might not be a big problem with my game

This really depends on the type of game you are making. If you use an spatial partioner (like an octree) , your interaction rate should be much lower. However, if O(n^2) is acceptable, then I think that you have no reason at all to optimise your calls to PhysX. Just use an existing engine, you probably don't have alot of physics to deal with...

1 hour ago, Amir_r_KB said:

Can you give an example?

Stacked objects which are considered "stable" will cease physics calculations, even though they are touching other (static) objects. Adding a new "dynamic" block on top of that can casue the entire stack to spontaneously "explode".

My Oculus Rift Game: RaiderV

My Android VR games: Time-Rider& Dozer Driver

My browser game: Vitrage - A game of stained glass

My android games : Enemies of the Crown & Killer Bees

This topic is closed to new replies.

Advertisement