Bullet in TP tips and tricks

In TP we have three main solvers, SC, physics and Bullet.  Physics looks like is not anymore upgraded and we dont have right now autojoints on it.

So mainly you have two choices, the slow but very accurate SC or the really fast but not so accurate Bullet. There is always moments where is better to use one or another. Lately I worked a lot with Bullet in production. It is true that some times is really frustrating because explosions, or inacuracy on collisions, but here I will try to give you some tricks to understand it better and take proffit of all the potential that offers:


For bullet in TP you have a number of diferent settings that define how accurate/stable/fast your simulation will be, and both influence on it in a different way, the key with bullet is to understand well them. This parameters are tp subsamples, shape used for simulation, margin, scene scale, ERP and bullet iterations. Lets see how they affect your sim:


-Tp subsamples: more subsamples more accuracy and more time needed for sim. You need more subsamples specially when you have objects going thought another. This happens when you have high velocity objects, when you use mesh as shapes or bulletsoftbodies. In bulletnormally I use half iteration per frame for rbd slow collisions or up to 300 iterations per second if you have cloth or high viscosity fluids.  Always use multiples of your fps. So if you are in 24fps use 48, 72, 96… Samples per second.


-Shape: Bullet use an aproximation of your geo to calculate collisions, the most used are:


Convex hull


You have now cylinder and cone that I will not coment since I never used.
The order writed is the level of complexity for the sim calculations in bullet.  The most simple is a sphere, even you can think a sphere is more complex than a box because you need more polys to create one than a box, mathematically is not. To define over a pivot the collision level of a sphere you only need a radius, while for a box you need three distances.  However siming times using sphere or box are really small and not so much diferent. I use sphere when I want that the object rolls when is in contact with the floor, and I use a box if I want that after a number of collisions the particle stays static.
Convex hull is a little more complex, is creating a geometry hull that will be convex always (event the original object is concave) using few polys and will calculate collisions based on this geo. If we want concave object we need to go to mesh, where all faces from the original object are used for collision and is the most time consuming system.

But there is some exceptions, when we use convex hull, tp calculates and assign a new geometry to every particle based on the original frame, while using mesh tp dont recreate a new mesh. So in scenes with a lot of objects you can experience that tp needs a lot of time for the first frame, while using mesh this time is no needed.

Also using mesh you will have much more objects passing through, you will need to increase subsamples or avoid using mesh


Tricks: If you need to have a concave deflector and using mesh is slow or inacurate for you, try creating diferent concave lowpoly objects linked to your deflector, and use this multiple objects as convex hull instead of one single object as mesh.
If the object is complex, you can send it to a fragmenter, fragment the object by angle, give some thickness, pattach or follow the original animation and use this as your convex hull collider.  You will have more accuracy and faster sim times.


As I mention before box shape should be more accurate or easy to calculate han convexhull shape, but in some test I found using box mode behave worst than using convex (even using a box as a geo!).


Bugs: if you add a deforming mesh using an o2p and using bullet rbd, bullet is siming this wrong. On first frame will be fine but when mesh starts to deform you will see is creating a kind of convexhull for calculations. This doesnt happen if you use this mesh directly as a “floor” inbullet node.


-Margin: this define a space that bullet will have in mind for collisions. Is adding a gap bettwen objects but if you have problems of pieces going throught this will help a lot. I dont see this affecting sim times.  On the first beta margin was only working for mesh and convex hull, on the latest beta was also working for box, and I guess than soon will be available for sphere, but check it because depending on the beta you are will have no effect.


-Scene scale: In some scenes I was working in small scale stuff, and since the units setup we have at work 1 unit=10 cm I think tp is having some internal accuracy problems. Increasing everything by 10 from origin and increasing gravity acordingly helped me on sim accuracy. I sim everything and once simed I bring back to original scale. If you scale down inside tp the cache yoy will have some jittering(should be fixed on latest beta) instead scale down tpmesher.


-ERP: when one object is inside another bullet understands there is a collision and needs to repulse it, think about this ERP as the force of this repulsion, also is a kind of elasticity. High ERP you will have more bouncines, lower ERP you will loose a lot of energy from the two bodies interacting. If you have objects interpenetrated on first frame a high ERP will cause explosion, but in another hand a low ERP will cause your object going throught another.  I like to keep erp between 0.1 and 0.2 and if there is explosions I try to separate the elements so there is no interpenetration.


-Bullet iterations: Affects accuracy of bullet, however I dont see so much change n rbd or cloth, biggest difference I see with this iterations is on joints accuracy. For problems of objects passing thought I prefer to increase subsamples or marging than bullet iterations.


I hope this helps you understand more Bullet, controlling this parameters will help you having more accurate simulations. If you have any question drop it below:

One Comment

  1. Really great tips Eloi but never the less it’s very hard to keep attached frags with joints without and obvious seem when they are hit by sth, even if the joint is not broken but still the frags are separated a bit unlike SC. I tried increasing Friction and reducing Margin but with no hope.
    Thanx again

Leave a Comment

Awesome! You've decided to leave a comment. Please keep in mind that comments are moderated.