increasing steps for baking engine into ipo ???

I saw on thread how to improve the physics calculation for getting ipo curves by increasing the steps, but dont understand how to make this …

is there a tut on this ?

Thanks …

not sure what you meant, link to the original thread please?

I can only recall that somebody was working on a way to decrease the complexity of the baked ipo through decimation.

I meant get a better simulation than the realtime settings …

For baking a a more accurate sim into IPO !
I read about this somewhere but cant find the link anymore …

hmm, maybe you mean by enable the option ‘enable all frames’? this will make sure that the simulation always run 60 steps per second.

he means lowering the PHYSICS time step, trading speed for quality, the reason he said “IPO” was because it wasn’t going to be an ingame simulation.

I ask the same question.

I found this :

"
I want higher quality simulation to create IPO keyframes for animation

If you are just rendering / creating keyframes, and don’t worry about realtime you can increate the substeps to improve quality of simulation, using a python script
import PhysicsConstraints
PhysicsConstraints.setNumTimeSubSteps(2)
default is 1. 2 or more make simulation more accurate."

But where to add these lines ?

I tried linking the script to an always sensor on both meshes that run in my sim …

But cant really figure out if it works, it seems not …

it’s a global setting, no need to link it to multiple meshes.

create a text file called A
paste the following line into the text file A(Alt+V)

import PhysicsConstraints
PhysicsConstraints.setNumTimeSubSteps(2)

create an empty
setup an always sensor and link it to a ‘python’ controller and make sure it points to file A

You are done. (I think) Check the console for any error messages.

Of course this only works with the bullet physics engine, not sumo.

It doesn’t work

I’m also interested in this issue… How to increase bullet physics simulation accuracy so that it can be better used for animation / still rendering purposes? And how to decrease gap between simulated objects? See this thread to see what I mean: http://blenderartists.org/forum/showthread.php?t=91647 .

What I have gathered this far is that you need Blender 2.42a to be able to control the accuracy. See here: http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=978
http://www.continuousphysics.com/mediawiki-1.5.8/index.php?title=Physics_Tips#There_is_a_small_gap_between_the_ground_and_my_object

But I just can’t get those to work… I don’t know how to use these two python scripts correctly in the game engine

1- increases the accuracy:

import PhysicsConstraints 
PhysicsConstraints.setNumTimeSubSteps(2)

2- narrows the gaps between objects:

controller = GameLogic.getCurrentController()
owner = controller.getOwner()
owner.setCollisionMargin(0.01)

I tried that what mpan3 suggested (at least I think that I did it correctly) in blender 2.42a and there were no difference in the simulations.

Help would be greatly appreciated!

as far as I can tell from other physics engines… you should increase the number of steps not decrease them. Increasing them should make the physics engine calculate more substeps between frames for the simulation resulting in more accuracy and of course slower frame rate because more steps get calculated between between each frame.

So try setting to 10 , 20 ,30 … and 40 for really slow… and see what happens

oh and I thinks you have to write it like this…

import GameLogic
import PhysicsConstraints
controller = GameLogic.getCurrentController()
owner = controller.getOwner()
PhysicsConstraints.setNumTimeSubSteps(10)
PhysicsConstraints.setCollisionMargin(0.01)

the setNumTimeSubSteps(10) iether has GameLogic or PhysicsContraints infront of it same for the setCollisionMargin(0.01)… not sure which one but i think it’s PhysicsContraints

Ok, now it’s working. Advice from mpan3 was just right for the simulation accuracy. It was just the collision margin tweak that I didn’t get to work before…

Here is little step by step tutorial for increased accuracy:

Remember, this is working only in Blender 2.42a. It’s not going to work in Blender 2.43!

1. Create 2 python script files:

quality.py

import PhysicsConstraints
PhysicsConstraints.setNumTimeSubSteps(2)

You can increase the setNumTimeSubSteps(2) number for even better accuracy (for example to 3, 4, 5 etc), but it’s going to slow down quite a bit and keeping it at 2 is usually accurate enogh.

spacing.py

controller = GameLogic.getCurrentController()
owner = controller.getOwner()
owner.setCollisionMargin(0.01)

This script is going to narrow down the gap between simulated objects. You can alter the setCollisionMargin(0.01) number too (Blender default is 0.04) but keep it minimum at 0.01

  1. Load both of those python scripts into blenders text editor in the scene where you want to simulate physics.

3. Create an empty to the scene.

Select the empty and go to Logic panel (F4). Do the following logic block settings for the empty:


4. Select your object that is going to be simulated and do the following logic block settings to specify collision margin for that object (you have to do this for every object that needs better accuracy or just create one and duplicate it many times)

Of course you have to use your own settings for mass, damping, bounds etc, but this is showing the logic blocks settings:


5. Turn on “Enable All Frames” from the game menu (and of course “Record Game Physics to IPO” when you are ready to record all the action)

6. Start the simulation and enjoy increased accuracy (and a coffee break if your scene is complex)!

I realize this thread was for 2.42a, but I was hoping for something to help spacing in 2.46. I just tried these scripts in 2.46 without luck.

I started with 1BU=1 inch for my physics simulation. The spacing was not an issue, but the physics seemed to be in slow motion. An object falling 10BU looked like it was falling 10 meters, not 10 inches.

When I scaled my objects down to 1BU=1 meter. The physics looked better, but the spacing issue appeared. because my 12BU object (12 inch) is now 0.305BU (meters).

The collision margin (0.04) seems to be fixed, rather than a percentage of the object size. So my 12BU object has a small margin (0.04 / 12 = 0.3%), vs. my 0.305BU object having a large margin (0.04 / 0.305 = 13%).

Is my thinking correct?

Can I change my margins for small parts in 2.46?

Is 1BU = 1 Meter a “fixed” ratio for the game engine?

Or is 2.46 completely different (and unrelated to this thread)?

I’m a newbie, so any hints are appreciated.