Model Scaling

Post Reply
shravan tata
Posts: 2
Joined: Tue Apr 09, 2019 8:11 am

Model Scaling

Post by shravan tata » Tue Apr 09, 2019 8:15 am

Hi All,

I recently read a post about model scaling in bullet on the forum.
But the link they refer to as wiki, here (http://www.bulletphysics.org/mediawiki- ... _The_World) no longer exists.
Could any one point me to the right page about Scaling the World wiki for Bullet. Thank you

S1L3nCe
Posts: 42
Joined: Thu Mar 24, 2016 10:22 am
Location: France

Re: Model Scaling

Post by S1L3nCe » Tue Apr 09, 2019 9:06 am

Hi,

I don't know when the wiki will be back but you could still access some tutorials with this:
https://web.archive.org/web/20170706235 ... /Main_Page

Yours is in Various Tutorial Articles>Scaling The World :)

shravan tata
Posts: 2
Joined: Tue Apr 09, 2019 8:11 am

Re: Model Scaling

Post by shravan tata » Tue Apr 09, 2019 12:30 pm

Hi,

Thank you very much for pointing to the right reference. After reading through the wiki it seems like this was almost 10 years ago and a lot has changed over this time. I am not sure anymore if model scaling is still relevant/necessary in bullet or it is handled much better now?

Thank you

S1L3nCe
Posts: 42
Joined: Thu Mar 24, 2016 10:22 am
Location: France

Re: Model Scaling

Post by S1L3nCe » Tue Apr 09, 2019 12:47 pm

I'm not very aware on this subject anymore but I think this tutorial is still relevant.

PcChip
Posts: 31
Joined: Sun May 20, 2018 3:09 pm

Re: Model Scaling

Post by PcChip » Fri Apr 12, 2019 2:47 am

thanks for the updated links, I was just looking for that thing as well

question - will I also have to update my debug drawer to scale all points/lines down by a factor of 10 (or whatever I scale everything by) ?

also how will this work with OpenGL picking by using raycasting from the screen/camera position?

S1L3nCe
Posts: 42
Joined: Thu Mar 24, 2016 10:22 am
Location: France

Re: Model Scaling

Post by S1L3nCe » Fri Apr 12, 2019 4:10 pm

You will scale values gived to Bullet so you will need to unscale values coming from Bullet to use them.

The fastest way is to use methods like xxx_to_bullet and bulet_to_xxx
With vector3, the first one will take a vector3 used in your project and will generate a btVector3 where the scale factor has been applied.
The second one will do the opposite and generate a vector3 used in your project from a btVector3 by removing the scale factor from it.

RayTest won't change that much, you still need to compute start and end points as before. (take a look at Bullet ExampleBrowser if you don't know how)
But then use xxx_to_bullet to scale those vector3 before using them.

PcChip
Posts: 31
Joined: Sun May 20, 2018 3:09 pm

Re: Model Scaling

Post by PcChip » Fri Apr 12, 2019 8:57 pm

Thanks for the advice

for the longest time I've been having problems with small items falling through the ground. When dumping lots of small boxes on the ground, about 50% fall through. If I crank the step up from 1/60 to 1/120, about half as many fall through, so it's better, but this really isn't acceptable

So I tried scaling the entire world up by 10x, however still half the boxes fall through :(

I've tried with terrain made from a heightfield, and a btBvhTriangleMeshShape made from btTriangleMesh, and both have this issue

User avatar
drleviathan
Posts: 528
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Model Scaling

Post by drleviathan » Mon Apr 15, 2019 5:26 pm

Have you enabled continuous collision detection (CCD) on the small moving objects? It definitely helps solve the tunnelling problem but my experience has been: it doesn't fix it completely. To enable CCD you set the radius of the proxy sphere and a minimum motion delta at which to use CCD. For decent results set them to both the same value:

Code: Select all

object->setCcdSweptSphereRadius(boundingRadius);
object->setCcdMotionThreshold(boundingRadius);
To disable CCD for the object set the motion threshold to zero:

Code: Select all

object->setCcdMotionThreshold(0.0);

PcChip
Posts: 31
Joined: Sun May 20, 2018 3:09 pm

Re: Model Scaling

Post by PcChip » Tue Apr 16, 2019 1:23 am

Thanks for the tip DrLeviathan,

I just tried that, unfortunately it made no difference

Image

I also tried one of Lunkhound's fixes to flip the normals when an object starts falling through the ground:

Image

The problem that I see is that a simple scene with objects dropping onto terrain is one of the first tests a developer that is looking for a physics engine for their game is going to try, and if their first interaction with Bullet is "half the things just fall through the ground", then they're going to pick a different physics engine. I hate saying that because I love Bullet, but...

User avatar
drleviathan
Posts: 528
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Model Scaling

Post by drleviathan » Tue Apr 16, 2019 8:45 pm

I dunno. The tunnelling problem is a fundamental issue for physics simulations. You need to understand it and tweak your simulation or your content to solve it. I'm sure it is solvable. Answer these questions and maybe someone here will have an idea:

What are the dimensions of your objects? How big are the mesh's triangles and how small are the dynamic objects?
What shape types are you using? What collision margin are you using on your shapes?
What is your substep duration? Are you using fixed substeps or variable?
What are you using for your CCD radius and motionThreshold?

steven
Posts: 54
Joined: Mon Nov 05, 2018 8:16 am
Location: China

Re: Model Scaling

Post by steven » Thu Apr 18, 2019 6:49 am

hi PcChip,
PcChip wrote:
Fri Apr 12, 2019 8:57 pm

So I tried scaling the entire world up by 10x, however still half the boxes fall through :(
this is strange, could you share with me your scene or some code of how do you create your world? thanks.
i want to figure out what happened.

thanks.

steven
Posts: 54
Joined: Mon Nov 05, 2018 8:16 am
Location: China

Re: Model Scaling

Post by steven » Fri Apr 19, 2019 8:37 am

hi PcChip,

please add this interface below which should can fix your issue.

Code: Select all

m_dynamicsWorld->getDispatchInfo().m_allowedCcdPenetration = boundingRadius

Post Reply