Saturday, September 18, 2010

Bullet SoC - Still researching the "brick wall" scenario + Potential Solutions

It's been a while since I've made an update on this project, so it's probably time that I did so. Last time I did, I was still investigating the making sure that "brick walls" could be simulated easily using the Rigid Body tools I'd put in place (including changes/improvements to the brick wall template).

Perhaps seeing so many crumbling chimneys, and fallen-away walls around the place in recent weeks has further highlighted the importance of being able to simulate this. And perhaps, indirectly, suggests a solution :)



The Problem
So, as a refresher to where we left off, the current situation is that once you've got the brick wall set up, it will very easily (or quickly) start wobbling and then collapse, and all before whatever you were planning to have collide into it gets there.

Potential Solutions
Over the past few days, as time has allowed, I've started researching these issues again. One particularly informative thread discussing these matters that I've found is: http://forums.cgsociety.org/archive/index.php/t-396405.html

Solution 1 - Start the simulation when the collision should take place
"rsquires" (on 08-23-2006, 06:28 AM) suggests in the thread this technique.
There are currently 84 "bricks" in my wall.. this number isn't set in stone though. Can anyone w/ dynamics experience help me out? I'm trying to make the bricks settle happily with each other without toppling over before the object gets to them.

I think a way of doing it is to have a key frame that turns on the sim just as the object hits the wall. This way they don't settle but just react to the impact. However doing it for 84 blocks seems tedious

Inspired by this thought, I quickly tested this out in one of the test scenes I had. Indeed it works as expected, as the blocks simply haven't fully settled and applied forces on each other, forcing the wall to topple.

What I did was quite simple:
1) Scrub through the animation to see when the ball would roughly be standing right in front of the wall, ready to knock it over.
2) Note the frame (add a marker if it helps to remember this)
3) Set the start frame for the simulation world (that the wall and the ball belonged to) to this frame.

Playing back the sim, the result was that the wall stayed still until the ball hit it, which is when the sim started kicking in, thus achieving our goal.

For simple situations, this should be enough. Hopefully this is enough to get your problem out of the way, if this is what is causing you problems.

Solution 2 - Find the friction value that approximates the strength of the mortar holding the wall together
The previous solution fails in more complicated cases, where we may have two towers, one of which bowls over the other. Or what if the ball was not hand animated, but rather, an active RigidBody? Basically, the problem is: what happens if we cannot isolated the simulation so that we can delay its start time until we know a collision may occur.

Hence, enter solution 2, as suggested by another poster in the thread:
"bcbarnes" (on 08-23-2006, 06:39 PM)
In general, I have found that the rigid body dynamics works pretty well [...snip...] The only thing that might be difficult is coming up with a friction value between the bricks that simulates the way the mortar (sp?) would hold together and then break apart

Indeed, this is quite a sensible suggestion, especially in light of seeing the collapsed chimneys, and some of the older brick homesteads. Apparently the mortar becomes weaker as it gets older, as it dries up and turns into mere sand/dust. Hence, we can say that friction is what can be used to hold the bricks together a bit better.

I haven't yet tried this suggestion, as I'm sure it does involve a bit of trial and error to get right. However, I will update this if and when I do find some suitable settings. Certainly, if we can get this set up right by default, things will work better "out of the box" than otherwise.

Solution 3 - Check on the space between bricks
The previous solution also raises in interesting point: the mortar between bricks kindof acts to give a bit of separation between them. This raises the issue that perhaps the collision margins could be tweaked, and/or the original spacing of the bricks could also be looked into.

I think I read somewhere in the thread a suggestion that Maxon used to pre-roll their brick-wall sims, with the walls created with spaces between the bricks, which are then flattened by having gravity pull them together before freezing the result. Perhaps some tweaks are needed in this respect?



I'd be interested in hearing if anybody finds any of these methods particularly valuable in getting this working well.

Laters!

3 comments:

  1. looking forward to what you find out

    ReplyDelete
  2. I have a solution to your problem!

    Check out my YouTube video here (badly lit, I know):

    http://www.youtube.com/watch?v=A2KwOPtnF

    And here is how I fixed it:

    I assume you already put the blocks together properly (Not that hard).

    There is a python script that I used to fix this.

    import GameLogic
    import PhysicsConstraints
    PhysicsConstraints.setNumTimeSubSteps(10)
    controller = GameLogic.getCurrentController()
    owner = controller.getOwner()
    owner.setCollisionMargin(0.00)
    PhysicsConstraints.setNumIterations(99999999)

    Link that script with logic bricks to all of your objects. Here is how:

    1. Go to the bottom left of the 3D view, and change the Window Type to Text Editor.

    2. Copy and paste that script.

    3. At the bottom of the text editor, it will say something like "Text.001", "Text.002", or simply "Text".

    4. In the logic bricks, connect an always sensor to a python controller.

    5. Type in the name of the text (eg. Text.001)

    6. Select all the physics object except for the one you did that on.

    7. Select the object that you just did that on

    8. Press Ctrl-C, and in the drop down choose logic bricks.

    9. Done.

    ReplyDelete
  3. Sorry, I screwed up the URL :D.

    Here is the good one:

    http://www.youtube.com/watch?v=A2KwOPtnF-0

    ReplyDelete