ODE P3D Error

This error is being thrown when running the p3d. It works fine when running directly however.

Yes I’m using -r ode with packp3d :slight_smile:

panda3d prototype.p3d
DirectStart: Starting the game.
:display: loading display module: libpandagl.so
:display: loading display module: libtinydisplay.so
Known pipe types:
glxGraphicsPipe
TinyXGraphicsPipe
TinyOffscreenGraphicsPipe
(all display modules loaded.)
:ShowBase: Default graphics pipe is glxGraphicsPipe (OpenGL).
:pnmtext: Loaded font Perspective Sans Regular
:display: Unable to set window properties: !undecorated
:ShowBase: Successfully opened window of type glxGraphicsWindow (OpenGL)
:audio: NullAudioManager
:audio: NullAudioManager
:ShowBase: dev == 0
Loading:mercury
:loader: Reading /mf/planet_sphere.bam
:gobj: Loading texture /mf/mercury_1k_tex.jpg
Loading:earth
:gobj: Loading texture /mf/earth_1k_tex.jpg
Loading:Moon
:gobj: Loading texture /mf/moon_1k_tex.jpg
Loading:star
:gobj: Loading texture /mf/sun_1k_tex.jpg
:loader: Reading /mf/sphere.bam
:ShowBase: Got window event: origin=(-1, -1) size=(640, 480) title=“Panda” !undecorated !fullscreen foreground !minimized open !cursor_hidden absolute

ODE INTERNAL ERROR 1: assertion “bNormalizationResult” failed in _dNormalize4() […/…/include/ode/odemath.h]

Here is my ode section of the code

world = OdeWorld()

# As explained in the manual, we need bodies to represent objects. Planets, ships, stations.
# Then we need to give them mass
for body in bodies:
    object = OdeBody(world)
    object.setPosition(body.position)
    # Currently our bodies are spheres, so rotation does not matter
    #myBody.setQuaternion(somePandaObject.getQuat(render))
    mass = OdeMass()
    # setSphere uses radius and density, however setSphereTotal uses radius and mass, values we do have
    # Radius multipled by a thousand to convert from km to meters
    mass.setSphereTotal(float(body.bodyDB['mass']), float(body.bodyDB['radius'])*1000)
    object.setMass(mass)
    body.object = object

# Now to create us
me = OdeBody(world)
me.setPosition(position)
# Currently our bodies are spheres, so rotation does not matter
#myBody.setQuaternion(somePandaObject.getQuat(render))
mass = OdeMass()
# setSphere uses radius and density, however setSphereTotal uses radius and mass, values we do have
# Radius multipled by a thousand to convert from km to meters
mass.setSphereTotal(80, 1)
me.setMass(mass)

# Create an accumulator to track the time since the sim
# has been running
deltaTimeAccumulator = 0.0
# This stepSize makes the simulation run at 90 frames per second
stepSize = 1.0 / 90.0
 
# The task for our simulation
def simulationTask(task):
    global deltaTimeAccumulator
    global position
    # Set the force on the body to push it off the ridge
    #body.setForce(0, min(task.time**4 * 500000 - 500000, 0), 0)
    # Add the deltaTime for the task to the accumulator
    deltaTimeAccumulator += globalClock.getDt()
    while deltaTimeAccumulator > stepSize:
        # Remove a stepSize from the accumulator until
        # the accumulated time is less than the stepsize
        deltaTimeAccumulator -= stepSize
        # Step the simulation
        world.quickStep(stepSize)
        #print "Step"
    # set the new positions
    #sphere.setPosQuat(render, body.getPosition(), Quat(body.getQuaternion()))
    #print Point3(me.getPosition())
    # First we will calculate the acceleration from each body.
    # This may take too long so it will need optimization later
    accelerations = {}
    for body in bodies:
        difference = body.position - position
        r = difference.length()
        acceleration = body.getAcceleration(r)
        accelerations[acceleration] = body
    # Sort the keys from our temporary list and nab the two largest
    aKeys = accelerations.keys()
    aKeys.sort()
    aKey = aKeys[-2:]
    # body1 is the strongest
    # body2 is the second strongest
    body1 = accelerations[aKey[1]]
    body2 = accelerations[aKey[0]]
    body1Force = me.getMass().getMagnitude() * aKey[1]
    body2Force = me.getMass().getMagnitude() * aKey[0]
    # Break force into xyz coordinates
    body1Difference = body1.position - position
    body2Difference = body2.position - position
    #print body1Force, body1Difference, body1Difference.length()
    #print "Body1:", body1.name, aKey[1]
    #print "Body2:", body2.name, aKey[0]
    body1forces = (body1Difference/body1Difference.length())*body1Force
    body2forces = (body2Difference/body2Difference.length())*body2Force
    totalForce =  body1forces+body2forces
    me.setForce(totalForce)
    position = Point3(me.getPosition())
    #print position, totalForce
    return task.cont
 
taskMgr.doMethodLater(0.0, simulationTask, "Physics Simulation")

Update, it is the line:

world.quickStep(stepSize)

which is throwing the error

Edit:

I lied. The step is not the issue (directly). The error is being thrown when setting the mass of the object, specifically my planets.

for body in bodies:
   object = OdeBody(world)
   object.setPosition(body.position)
   mass = OdeMass()
   # setSphere uses radius and density, however setSphereTotal uses radius and mass, values we do have
   # Radius multipled by a thousand to convert from km to meters
   mass.setSphereTotal(float(body.bodyDB['mass']), float(body.bodyDB['radius'])*1000)
   object.setMass(mass) # Right here

This seems to set correctly, however when running the simulation step in a p3d the error is thrown.

Edit2: I lied yet again. mass.setSphereTotal() is NOT setting the mass properly when in a p3d file. When running directly “print mass” will print out the details. In p3d it does not. However calling “print mass.getMagnitude()” will return the mass in both environments.

I’m getting close I can feel it. Something about the p3d environment does not like very large values. When the mass and radius in mass.setSphereTotal() reach about 1e+25 and 1e+6, respectively, the ODE simulation throws its error when it takes it step. Seeing as it runs fine in my normal python environment tells me that the panda3d.ode ppackage has something going on.

Or we can order a smaller, lighter sun :smiley: