a physics engine in a city

Started by
3 comments, last by oliii 17 years, 2 months ago
Over the last few months i've put together a 3D physics engine that can simulate stacks of blocks, balls, springs... the block collisions are checks with the SAT. and a deactivation algorithm is implemented. spatial partitioning is done by a sort and sweep method. So far i can simulate 10X10 "brick walls" with a good (80fps) framerate but when i start making bigger (20X20) walls then it runs very slowly (10fps) untill the blocks are deactivated. Now one of the things that i want to do with the engine is to make a city out of bricks where the player can walk around and knock down walls. the problem is that if i put in realistic size walls then it goes fast only after the blocks deactivate but if the player hits a wall (or multiple ones) everything suddenly becomes active and the FR plunges down. How is it possible to make something like a city all out of bricks (as i've seen done in other games)? is it only a matter of a more efficiant collision detection algorithm? the SAT test that i'm using is pretty optimized for blocks and i don't see how it could get significantly faster. Also the SP doesn't seem to be the problem because the program runs fast when non of the blocks are actually colliding even though it has to check for all the collisions. Any advice? Thanks.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
Advertisement
What other games? I've never heard of a game doing physics on that scale.

Still, your best bet at the moment would be to not construct things out of bricks. When something gets significantly damaged, spawn bricks around the damaged area rather than having them there the whole time.
It depends how the destruction happens - possibly you could record certain things (position/orientation for each object at least - also maybe a summary of the contacts) in non-real-time (using your own physics engine) and then when they are destroyed, play back this animation, checking it's plausable. Any animated object that touches something it shouldn't, or is at rest when there's nothing for it to rest on, would then get taken over by the physics engine. Of course - there's always the danger that a small change at the start of such a sequence would propogate through the system and everything would need to be physically simulated. Thus I have no idea if this idea would really work, and exactly what problems you'd have to solve.

The problem is - even with the best CPU implementation, what you want to do isn't really possible yet!

But... have a look here!

Btw - sorry I've not replied to your emails - got a bit swamped by things!

Not sure if this is any help but I'm pretty sure most games that feature destructable scenery (a great example being Black on XBox and PS2) use a simple proxy/lod system.

e.g Under normal circumstances a wall is repesented by a single, static piece of geometry. Upon contact the wall is destroyed and replaced by a collection of physically modelled bricks which then fade away over time (so as to avoid having too many separate objects in the world at any one time).

I guess how well this works for you will depend on how long you want the bricks to remain in the world (in the case of Black, debris fades away within a matter of seconds), and also on whether you have the time/inclination to rig up all the different objects for each situation. I honestly don't think it would be possible to simulate an entire city of bricks though, no matter how optimised you collision routines are.
There are lots of other optimisations, like debris not colliding against each other, not responding to player collisions, ect...

Your best bet is to profile your code and see what's the bottleneck. It could be anything. Vector maths? Physics update? SAT test? proximity test? Response code?

But in general, it's just a matter of reducing the interactions.

Everything is better with Metal.

This topic is closed to new replies.

Advertisement