Mass not effecting dynamic rigid bodies?

Post Reply
jimjamjack
Posts: 39
Joined: Tue Jan 31, 2017 8:07 pm

Mass not effecting dynamic rigid bodies?

Post 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?
Last edited by jimjamjack on Mon May 01, 2017 9:52 pm, edited 1 time in total.
ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: Mass not effecting dynamic rigid bodies?

Post by ktfh »

gravity accelerates all objects equally https://www.youtube.com/watch?v=5C5_dOEyAfk
jimjamjack
Posts: 39
Joined: Tue Jan 31, 2017 8:07 pm

Re: Mass not effecting dynamic rigid bodies?

Post by jimjamjack »

Well how can I have objects that fall differently then, without changing the gravity?
User avatar
Typhontaur
Posts: 135
Joined: Fri Nov 04, 2005 2:22 pm

Re: Mass not effecting dynamic rigid bodies?

Post by Typhontaur »

I use setLinearFactor()...

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

may be is wrong but for my engine is good... try.
jimjamjack
Posts: 39
Joined: Tue Jan 31, 2017 8:07 pm

Re: Mass not effecting dynamic rigid bodies?

Post 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.
jimjamjack
Posts: 39
Joined: Tue Jan 31, 2017 8:07 pm

Re: Mass not effecting dynamic rigid bodies?

Post 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.
Ziket
Posts: 3
Joined: Thu Mar 23, 2017 11:17 am

Re: Mass not effecting dynamic rigid bodies?

Post 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
DannyChapman
Posts: 84
Joined: Sun Jan 07, 2007 4:29 pm
Location: Oxford, England
Contact:

Re: Mass not effecting dynamic rigid bodies?

Post 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).
jimjamjack
Posts: 39
Joined: Tue Jan 31, 2017 8:07 pm

Re: Mass not effecting dynamic rigid bodies?

Post 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.
Post Reply