kookaburragamer

Just a gaming and programming enthusiast.

GTGameEngine – In-Editor Physics Simulation and Previewing

I find that one of the more frustrating things in game development is getting physics working properly. It’s especially annoying when you don’t have the tools easily available for proper previewing. Thus, what I’ve done is added support for previewing the physics of a scene through the editor. This is best demonstrated with a video:

Here’s how I do it:

  1. Serialize the scene to a memory buffer (needs to be restored afterwards)
  2. Enable physics simulation
  3. … observe physics …
  4. Disable physics simulation
  5. Deserialize the scene to restore everything back to normal

And that is it. It’s so damn simple, it’s a bit of a wonder why other engines don’t do this. But maybe they do and I’ve just not noticed. Let me know! (No, Unity’s “Play” button doesn’t count because I’m talking about ONLY physics simulations with nothing else.)

I serialize into a memory buffer instead of a file because 1) it makes things a lot simpler and 2) it should be a bit quicker.

The physics simulation is enabled and disabled through a single boolean. That boolean is just flipped when the simulation state changes. When physics is disabled, the editor simply neglects to call the physics manager’s Step() function. When it’s enabled, it calls it like normal.

My plan for much later on is to allow the user to leave an object where it was at the end of the physics simulation so that the physics engine can be used to position objects realistically rather than having them positioned by hand. I’ve go no idea how useful it’d be, but might come in handy for things like clutter or something…

And now for good measure, here’s another video of me playing around with the physics. Here I’m just testing the difference between different masses by watch how forcefully a ball pushes itself through a wall.

I can imagine this feature being especially useful later on when working with constraints. They’re always a pain…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: