This is odd. I’ve written some code to test a CollisionSphere colliding with a CollisionPlane (below). The code as shown works fine. But if you increase the “scale” variable, the ball sinks further into the plane before the collision is noticed. It seems to max at out the radius of the ball.
import direct.directbase.DirectStart
from pandac.PandaModules import *
from direct.gui.DirectGui import *
class World(DirectObject):
def __init__(self):
scale = 1.0;
# make a plane and a ball
collisionMask = BitMask32.bit(0);
self.bottom = render.attachNewNode("bottom");
self.bottom.setPos(0, 0.0, -10);
self.bottom.setScale(scale, 1.0, 1.0)
plane = CollisionPlane(Plane(Vec3(0, 0, 1), Point3(0, 0, 0)))
self.cBottom = self.bottom.attachNewNode(CollisionNode('cBottom'))
self.cBottom.node().addSolid(plane)
self.cBottom.node().setIntoCollideMask(collisionMask)
self.cBottom.show()
self.ball = render.attachNewNode("bottom");
self.ball.reparentTo(render);
sphere = CollisionSphere(0, 0, 0, 1.0);
self.cBall = self.ball.attachNewNode(CollisionNode('cBall'))
self.cBall.node().addSolid(sphere);
self.cBall.node().setFromCollideMask(collisionMask)
self.cBall.node().setIntoCollideMask(BitMask32.allOff())
self.cBall.show();
self.cTrav = CollisionTraverser()
self.cHandler = CollisionHandlerQueue()
self.cTrav.addCollider(self.cBall, self.cHandler)
base.cTrav = self.cTrav;
taskMgr.remove("moveBall")
self.mainLoop = taskMgr.add(self.moveBall, "moveBall")
self.mainLoop.last = 0
def moveBall(self, task):
print "ball: ", self.ball.getPos()
for i in range(self.cHandler.getNumEntries()):
entry = self.cHandler.getEntry(i)
name = entry.getIntoNode().getName()
print "Collision: ", name
return Task.done;
pos = self.ball.getPos();
pos += Vec3(0,0,-0.1)
self.ball.setPos(pos)
return Task.cont;
w = World()
run()