Page 1 of 1

Mass not effecting dynamic rigid bodies?

Posted: Sun Mar 19, 2017 10:53 pm
by jimjamjack
It appears that whatever I set my object's mass to be, it has no effect on how it behaves in the scene. When changing the gravity, my object falls faster or slower, but not when changing the mass (even from 1 to 10000, no change).

Am I doing something wrong here?

Re: Mass not effecting dynamic rigid bodies?

Posted: Sun Mar 19, 2017 11:03 pm
by ktfh
gravity accelerates all objects equally https://www.youtube.com/watch?v=5C5_dOEyAfk

Re: Mass not effecting dynamic rigid bodies?

Posted: Mon Mar 20, 2017 8:57 pm
by jimjamjack
Well how can I have objects that fall differently then, without changing the gravity?

Re: Mass not effecting dynamic rigid bodies?

Posted: Mon Mar 20, 2017 10:45 pm
by Typhontaur
I use setLinearFactor()...

http://www.bulletphysics.org/mediawiki- ... e_Snippets

may be is wrong but for my engine is good... try.

Re: Mass not effecting dynamic rigid bodies?

Posted: Mon Mar 20, 2017 11:50 pm
by jimjamjack
Hmm, I tried setLinearFactor() but after entering the weight of my bullet (0.00745KG) for the y-axis value, it just stops mid-air after falling slightly.

Re: Mass not effecting dynamic rigid bodies?

Posted: Tue Mar 21, 2017 12:08 am
by jimjamjack
Is this to do with my stepSimulation()? I'm currently doing dynamicsWorld->stepSimulation(1 / 60.f, 10) but I've tried using deltaTime and my object just instantly appears on the ground then, it's so fast.

When I draw the scene with a debug drawer, the object seems to be falling as expected (with different gravities at least, mass still has no effect), which is even weirder because I don't see how that would affect things.

Re: Mass not effecting dynamic rigid bodies?

Posted: Thu Mar 23, 2017 11:33 am
by Ziket
jimjamjack wrote:Is this to do with my stepSimulation()? I'm currently doing dynamicsWorld->stepSimulation(1 / 60.f, 10) but I've tried using deltaTime and my object just instantly appears on the ground then, it's so fast.

When I draw the scene with a debug drawer, the object seems to be falling as expected (with different gravities at least, mass still has no effect), which is even weirder because I don't see how that would affect things.
There is a diference between delta time and time step. Delta time is using to calculate the last time passed since the frame start, time step is how many steps do you want to use in this process. For example, only call this function if the delta_time is greater than 16.6 (in miliseconds), you need this if in your engine there is a frame that consumes a lot of time to process a task and your delta_time increases

Re: Mass not effecting dynamic rigid bodies?

Posted: Thu Mar 23, 2017 11:50 am
by DannyChapman
If you want heavy objects to fall (accelerate) faster than light ones, you have to ask yourself why. The most likely answer is that the objects are affected by drag (air resistance) too - in which case rather than hacking gravity, it's probably better to add a drag force. This will give more realistic motion in all directions, not just vertically.

Drag affects lighter objects more because the drag force is calculated as:

dragForce = CL * dynamicPressure * area

where

* CL is the coefficient of drag (look it up - for a sphere it's around 0.5)
* dynamicPressure = 0.5 * airDensity * speed^2 where speed is the speed of the object relative to the air.
* area is the cross-sectional area of the object (pi r^2 for a sphere).
* the force acts in the direciton opposite to the motion of the object relative to the air.

This force only depends on the properties and motion of the object - not on its mass. The acceleration it produces is therefore greater on objects with low mass, since acceleration = force / mass (Newton's second law). That's why a feather falls slower than a stone on earth, where there's an atmosphere, and on the moon where there's not. It's also why you can throw a stone further than a feather (on Earth).

Re: Mass not effecting dynamic rigid bodies?

Posted: Fri Mar 24, 2017 1:10 am
by jimjamjack
Thanks DannyChapman, I'm assuming this is what I'm looking for. Does Bullet have built-in functions for altering a specific rigidBody's drag?

The reason I posted the thread was because I found it strange that my bullet object was falling extremely quickly under the default "earth" gravity, and when trying to change this by altering the rigidBody's mass, obviously had no success. So although I could probably just alter the gravity, it seems like a bit of a hack, so drag seems like the way to go.

But yeah, finding the right values for 'dragForce = CL * dynamicPressure * area' for my own model would be a bit of a pain so hopefully Bullet has something to help with it.