Skip to content

Instantly share code, notes, and snippets.

@seanh
Created November 12, 2009 11:07
Show Gist options
  • Select an option

  • Save seanh/232817 to your computer and use it in GitHub Desktop.

Select an option

Save seanh/232817 to your computer and use it in GitHub Desktop.
Adding and removing collide masks (Python, Panda3D)
def addCollideMask(np,mask):
"""Add mask to the NodePath's existing collide mask (do a binary OR of
the two bitmasks)."""
np.setCollideMask(np.getCollideMask() | mask)
def removeCollideMask(np,mask):
"""Remove mask from the NodePath's existing collide mask (all bits set
to 1 in mask will be set to 0 in the NodePath's mask)."""
# Need to copy mask first to avoid modifying it in place.
copy = mask & BitMask32.allOn()
copy.invertInPlace()
np.setCollideMask(np.getCollideMask() & copy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment