About the size of triangles and objects

Post Reply
Nkp
Posts: 7
Joined: Sun Jul 11, 2021 6:51 am

About the size of triangles and objects

Post by Nkp »

Hello

I'm trying to use Bullet for a game under development.
But there is a problem, in Bullet it is calculated as 1 unit = 1 meter, but in the game it is calculated as 1 unit = 0.01 meter.
Therefore, it sends a triangle 100 times larger than the one expected on the bullet side to the bullet.
The document stated that the size of the triangle should be 10 meters or less.
What kind of problems can occur if you continue to use Bullet in an environment where 1 unit = 0.01 meters?
I'm worried about the solution.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: About the size of triangles and objects

Post by drleviathan »

You definitely don't want to use shapes as small as 0.01 meters. Bullet is effectively hard-coded to work best for dynamic objects on the order of a few tenths of a meter to a few tens of meters. That is: assumptions are made in the default parameters and logic that make it problematic to wander outside that range. For example, the default "collision tolerance" of some shape types is 0.04m and for stability/correctness reasons you wouldn't want to make such shapes smaller than two or three collision tolerance units.

One way to do it: just define 1.0 Bullet distance unit = 0.01m and scale all of your object sizes up x100, such that a 0.01m shape is really 1.0 simulation units. The problem with this approach is that when you scale linear distances you mess with some of the other units of the simulation. For example: the default acceleration of gravity is no longer about 9.8 distance/time^2, it is 980 distance/time^2! To compensate you can do a similar scaling factor with time: define 1.0 unit of "Bullet time" to be 0.1 second, which will bring your default acceleration of gravity back to 9.8 units/time^2, however both distance and time are involved in units of force (1 Newton = 1 mass * distance / time^2) and mass and distance are involved in angular mass (inertia = mass * distance^2). Not only do the units start to get confusing but when you go this path it becomes difficult to run the simulation at real-time because you have to take so many steps. If you take long steps then object velocities will be too high and you'll get tunneling, and if you take many small steps the CPU can't keep up. Also, you're starting to wander outside some assumptions that Bullet makes: (a) rigid bodies really are rigid (not true at small timescales) (b) electrostatic forces are negligible (no true at small distances) (c) naive velocity damping is a good approximation for air frictions (not true...), etc.

Since you're making a game then "fun" is probably a higher priority than "physical accuracy". I recommend you just scale all of your objects up by x100 and tweak gravity, time, inertia, damping, friction, restitution etc until it is fun while still being physically interesting: and probably run the game in effective "slow motion": not slow to the player but slow compared to real-time at such small distances. Also, there are ways to write motion control algorithms that manipulate velocity and are mass agnostic such that you never really need to compute/manipulate units of force: If you start tweaking the mass/distance/time then I would expect you to go crazy trying to figure out units of force or torque: best to avoid them.
Nkp
Posts: 7
Joined: Sun Jul 11, 2021 6:51 am

Re: About the size of triangles and objects

Post by Nkp »

Thank you for your reply

In the game, 1 unit = 0.01 meters.
In other words, 100 units = 1 meter, so
If match it to the game side, it will be a big collision mesh x100 larger.
So it seems that it is actually necessary to size down it to 1/100.

Does sending Bullet a huge 100x collision mesh without scaling from the game also cause problems?

But anyway, as you say, somewhere it looks like need to scale the object.
Nkp
Posts: 7
Joined: Sun Jul 11, 2021 6:51 am

Re: About the size of triangles and objects

Post by Nkp »

Sorry I'm not good at English.
In my game, a triangle with a side of 10m is expressed as follows.

btVector3 tri_vertex[3] = {
btVector3(0,0,0),
btVector3(1000,0,1000),
btVector3(1000,0,0)
};

I think this is calculated as a triangle with a side of 1000m in Bullet.
I thought it would be a problem.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: About the size of triangles and objects

Post by drleviathan »

It is OK for Bullet bodies to larger than 100 units. In particular: it is OK for static or relatively slow kinematic objects to be very large (100s or 1000s of units) however be careful when making very large (>100 units) dynamic objects or fast moving kinematic.

Basically, if you have very large fast dynamic objects in your simulation then it becomes likely you will get penetrations instead of just collisions. When two objects penetrate then the "penetration resolution" logic will push them apart. It works well most of the time, but is non-physical and can introduce surprising results and sometimes can pump energy into the system... especially when there are very BIG and very tiny dynamic objects colliding with each other.
Nkp
Posts: 7
Joined: Sun Jul 11, 2021 6:51 am

Re: About the size of triangles and objects

Post by Nkp »

Thank you for your reply.

I was a little relieved to know that Bullet can be used even if it is larger than 100 units.
Huge dynamic objects will appear in the game, but it seems that it is okay to penetrate a little because the purpose is to directing .
The biggest concern is whether the contactTest and rayTest and contactPairTest functions will be less accurate.
Post Reply