gravity + mass issue

trying to understand how to implement simple p3D physics I come up with a piece of code supposed to have a gravity force applied and a body weighting a 100Kg mass that placing it in the air it gotta fall with a quite noticeable incremental speed, but this do not happen 'cos the heavy panda goes down like a plume. Apparently all works upside down, as is if I specify a lighter mass the body fall faster than if I use a heavier mass. Of course there is something I’m missing otherwise somebody must have noticed a failure like this.
Here the code, the relevant part is in the terra_physics class:

strike SPACE to put the panda in the air
# Panda imports
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import *
from import Actor
from direct.task import Task

from pandac.PandaModules import PhysicsCollisionHandler

class terra_physics(DirectObject):
  '''a simple physics environment with terrain and an avatar
  def __init__(self, theavatar, floor, walls=None):
    # Enables the built-in physics

    # This is needed so we don't calculate collisions on the actual model,
    # but on the collision node we will add later
    # Whenever we want to inter-act with anything to do with collisions/physics,
    # we want to use the actor node path
    # Sets up the mass. Note that in this scenario, mass is not taken into consideration.
    # Parent our avatar to the ready to go physics node

    # Set up the gravity force
    # Attach it to the global physics manager

    # Set the collision traverser
    base.cTrav = CollisionTraverser( )
    #define 2 masks, one for the floor contacts between the avatar model and the collision surfaces
    mask_floor = BitMask32.bit(1)
    mask_walls = BitMask32.bit(2)

    # Assign the floor collsion mask to the floor model and hide it
    self.floor = floor

    # the fromObject is our collision information. The documentation for Panda3d
    # recommends that we use a sphere to handle collisions.
    fromObject = self.avatarNP.attachNewNode(CollisionNode("agentCollisionNode"))
    fromObject.node().addSolid(CollisionSphere(0, 0, 2.5, 2.5))
    # We want to handle any sort of collision that happens to us, but not
    # vice-versa
    # show the collision shpere

    # Create a collision handler to handle all the physics
    pusher = PhysicsCollisionHandler()
    # attach it our collision node along with our actor node
    pusher.addCollider(fromObject, self.avatarNP)
    # Add the handler to the main collision traverser
    base.cTrav.addCollider(fromObject, pusher)

    # Tell the global physicsMgr about our actor node
class World(DirectObject):
  def __init__(self):
  def showtime(self):
    '''relevant code for the sample
    ''' = Actor("panda", {"walk":"panda-walk"}), .5, .5)

    terra=loader.loadModel( 'environment' )
    terra.reparentTo( base.render )
    floor = loader.loadModel( 'environment' )
    floor.reparentTo( base.render )
    #** here is where the physics happens
    self.phy=terra_physics(, floor, None)

    self.accept("space", lambda x=50: self.phy.avatarNP.setZ(x))

    base.mouseInterfaceNode.setPos(-150, 30, 5)
    base.taskMgr.add(self.localtask, 'localtask' )
  def localtask(self, task):
    return Task.cont
  def setup_scene(self):
    # *** Setup lighting
    dlight = DirectionalLight('dlight')
    dlight.setColor(VBase4(lightLevel, lightLevel, lightLevel, 1))
    dlnp = render.attachNewNode(dlight.upcastToPandaNode())

    alight = AmbientLight('alight')
    alight.setColor(VBase4(0.2, 0.2, 0.2, 1))

    # *** Setup scene
    base.mouseInterfaceNode.setPos(3.9, 37.26, 3.8)
    base.mouseInterfaceNode.setHpr(-4.5, 35.4, 0.97)

if __name__ == "__main__":

hit SPACEBAR to put the panda in the air

Do you remember this from high school physics? Galileo dropping two different-sized rocks from the Tower of Pisa, and all that? Excepting air resistance, all objects always fall at exactly the same speed, regardless of mass. This is because the gravitational attraction is stronger in proportion to mass, but the inertial resistance to motion is weaker in proportion to mass, so the two proportions exactly cancel each other out.

It turns out that our intuition that heavy things fall faster is exactly wrong. It’s only that heavy things are less affected by air resistance. In a vacuum, that plume would fall with the same klunk that the rock falls. Panda’s simple physics engine, of course (as do most physics engines) ignores air resistance, which is incredibly difficult to compute; so all objects should fall at the same speed.

When you set your gravitational force to be “mass dependent”, you change that. What you have done is enabled the inertial resistance to that force. However, Panda doesn’t automatically scale the gravitational attraction due to mass, so you end up with what appears to be inverse gravity.


doh I would never found out - so I got to switch mass dependence off, but then a question arise: what is good for, as is why you have implemented it?

You would enable mass dependence on other kinds of forces, like winds, or rocket engines. You would expect a rocket engine to push a small object much more quickly than a large object.


ok tanks David!