diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index 36f794d42c..c01581ac6b 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -123,6 +123,27 @@ bit(int index) { return result; } +//////////////////////////////////////////////////////////////////// +// Function: BitMask::Named range constructor +// Access: Published, Static +// Description: Returns a BitMask whose size bits, beginning at +// low_bit, are on. +//////////////////////////////////////////////////////////////////// +template +INLINE BitMask BitMask:: +range(int low_bit, int size) { + BitMask result; + if (size <= 0) { + result._word = 0; + } else if (size >= num_bits) { + result._word = ~0; + } else { + result._word = ((WordType)1 << size) - 1; + } + result._word <<= low_bit; + return result; +} + //////////////////////////////////////////////////////////////////// // Function: BitMask::Destructor // Access: Published diff --git a/panda/src/putil/bitMask.h b/panda/src/putil/bitMask.h index 6187a0a5c9..bc341e60de 100644 --- a/panda/src/putil/bitMask.h +++ b/panda/src/putil/bitMask.h @@ -46,6 +46,7 @@ PUBLISHED: INLINE static BitMask all_off(); INLINE static BitMask lower_on(int on_bits); INLINE static BitMask bit(int index); + INLINE static BitMask range(int low_bit, int size); INLINE ~BitMask();