Problem with CollisionPlane and CollisionHandlerPusher

Hi all,

I’m trying to use the CollisionHandlerPusher in conjunction with a CollisionSphere and a CollisionPlane. I modified one of the examples to show my problem:

import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *

#initialize traverser
base.cTrav = CollisionTraverser()

#initialize pusher
pusher = CollisionHandlerPusher()

#########

#load a model. reparent it to the camera so we can move it.
smiley = loader.loadModel('smiley')
#smiley.reparentTo(camera)
smiley.reparentTo(render)
smiley.setPos(0.5, 25.0, 0.5)

#create a collision solid for this model
cNode = CollisionNode('smiley')

# if 1: use collision sphere: frowney deflected
# if 0: use collision plane: frowney ignores plane
if 0:
   cNode.addSolid (CollisionSphere(0,0,0,1.1))
else:
   cNode.addSolid (CollisionPlane (Plane (Vec3 (0, 0, 1), Point3 (0, 0, 0))))

smileyC = smiley.attachNewNode(cNode)
smileyC.node ().setIntoCollideMask (BitMask32.bit (0))
smileyC.show()

#########

#load a model
frowney = loader.loadModel('frowney')
frowney.reparentTo(render)
frowney.setPos(5.0, 25.0, 0.0)

#create a collsion solid for this model
cNode = CollisionNode('frowney')
cNode.addSolid (CollisionSphere(0,0,0,1.1))
frowneyC = frowney.attachNewNode(cNode)
frowneyC.node ().setFromCollideMask (BitMask32.bit (0))
frowneyC.node ().setIntoCollideMask (BitMask32.allOff ())
frowneyC.show()

#########
#add collision node to the traverser and the pusher

base.cTrav.addCollider(frowneyC,pusher)
pusher.addCollider(frowneyC,frowney, base.drive.node())

#########

#have the one ball moving to help show what is happening
frowney.posInterval (5, Point3 (0.0, 25.0, -3.0), startPos = Point3 (0.0, 25.0, 3.0),                     fluid = 1).loop()
run()

When running the above code, the “frowney” passes right through the collision plane. Should it not stop or do something else?
If the line starting with “if 0:” is replaced with “if 1:” the CollisionPlane is replaced with a CollisionSphere, the move sphere “frowney” is deflected as I would expect it.

What am I doing wrong? Thanks for your help.

Cheerio
pit007

Same problem. Bump.

Hmm, something strange does appear to be going on here. Let me investigate.

David

Ah, I found it. I’m not sure how this happened, but it looks like the default behavior for CollisionHandlerPusher is now to be horizontal, which means it will only push in the XY plane, and never along the Z axis. Unfortunately, SourceForge CVS appears to be down at the moment, so I can’t consult the CVS logs to see when that happened or why, but for the meantime, the workaround is this:

#initialize pusher
pusher = CollisionHandlerPusher()
pusher.setHorizontal(False)

David