def test_collision_handler_floor_pickle():
    from panda3d.core import CollisionHandlerFloor

    collider1 = NodePath(CollisionNode("collider1"))
    collider2 = NodePath(CollisionNode("collider2"))
    target1 = NodePath("target1")
    target2 = NodePath("target2")
    center = NodePath("center")

    handler = CollisionHandlerFloor()
    handler.add_out_pattern("out pattern")
    handler.add_collider(collider1, target1)
    handler.add_collider(collider2, target2)
    handler.center = center
    handler.offset = 1.0
    handler.reach = 2.0
    handler.max_velocity = 3.0

    handler = loads(dumps(handler, -1))

    assert tuple(handler.in_patterns) == ()
    assert tuple(handler.again_patterns) == ()
    assert tuple(handler.out_patterns) == ("out pattern", )
    assert handler.center.name == "center"
    assert handler.offset == 1.0
    assert handler.reach == 2.0
    assert handler.max_velocity == 3.0
Example #2
0
 def setup_shadow_ray(self, shadow_node, mat):
     ray = CollisionRay(0.0, 0.0, CollisionHandlerRayStart, 0.0, 0.0, -1.0)
     ray_node = CollisionNode('ray_node')
     ray_node.add_solid(ray)
     self.ray_np = shadow_node.attach_new_node(ray_node)
     self.ray_np.node().set_from_collide_mask(CIGlobals.FloorBitmask)
     self.ray_np.node().set_into_collide_mask(BitMask32.allOff())
     floor_offset = 0.025
     lifter = CollisionHandlerFloor()
     lifter.set_offset(floor_offset)
     lifter.set_reach(4.0)
     lifter.add_collider(self.ray_np, shadow_node)
     if not mat:
         base.cTrav.add_collider(self.ray_np, lifter)