Jump to content
  • Advertisement
Amir_r_KB

Retention In Physics Simulations

Recommended Posts

Posted (edited)

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?

Edited by Amir_r_KB

Share this post


Link to post
Share on other sites
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?)

 

 

Share this post


Link to post
Share on other sites
Posted (edited)
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?

Edited by Amir_r_KB

Share this post


Link to post
Share on other sites
Posted (edited)
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".

Edited by SillyCow

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!