Simulating dominoes

peltonen
Posts: 18
Joined: Thu Jan 17, 2008 8:16 pm

Simulating dominoes

Post by peltonen »

Hi everyone,
I have a question about simulating dominoes. When I set up a very long line of dominoes, once everything falls, I'm afraid I end up with a massive island where every domino is connected to every other one. Is there any standard methodology to break these into smaller islands, especially when most dominoes are sleeping?
The only way I can think of to prevent this from being an n^2 problem is by doing really kludgy hacks (e.g. removing the physical bodies of sleeping dominoes at every Xth position, then re-adding them if my own collision routine shows that something else is coming into contact where the physical object should be, etc.).
Thanks!
User avatar
ejtttje
Posts: 96
Joined: Mon Nov 03, 2008 9:57 pm

Re: Simulating dominoes

Post by ejtttje »

I wonder if you look at contiguous chunks of N dominoes, and they're all deactivated, then replace them with a compound shape and a single body. Then if something wakes up the body, replace it with the original individual dominoes. This could even be done recursively, so it will scale well.

I'm a newb though, so no idea if this would actually be feasible to implement, but it seems intuitive. One complication would be branch points where one domino knocks down two others... doesn't fundamentally break anything, just means 'N' might refer to child depth instead of an explicit number of dominoes in the chunk.