Collision tests on demand?

In what I’m currently working on, I need to check if a box centered around a point doesn’t intersect with anything, but only during a keyboard event. Currently my code is:

testCollisionHandler=CollisionHandlerQueue()
testCollisionNode=render.attachNewNode(CollisionNode("TestCollisionNode"))
testCollisionSolid=CollisionBox(Point3(d['X']/2,d['Y']/2,d['Z']/2),
                                Point3(-d['X']/2,-d['Y']/2,-d['Z']/2))
testCollisionNode.node().addSolid(testCollisionSolid)
testCollisionNode.node().setFromCollideMask(BitMask32.allOn())
estCollisionNode.node().setIntoCollideMask(BitMask32.allOff())
testCollisionNode.setPos(testPoint)
testCollisionNode.show()
cTrav.addCollider(testCollisionNode, testCollisionHandler)
cTrav.traverse(render)
t=(testCollisionHandler.getNumEntries()!=0)
testCollisionNode.remove()
return t

Basically, I just create a collision node, attach a solid of the size I need, run a traverse of the CollisionTraverser and see if the queue that is made has any entries in. However, it doesn’t seem to pick up any collisions at all and I can’t tell how it doesn’t work…

Does anyone have any way of making this code do what I want?

I don’t see anything obviously wrong with that code, although you are aware that a CollisionBox does not detect intersections within it, right? It only detects intersections with its sides.

You might want to use a CollisionSphere instead, which is actually solid. Or use six CollisionPlanes, and consider an intersection detected if it detects all six planes.

David