mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
add BitMask::range()
This commit is contained in:
parent
bcc386430d
commit
7d3fa1b266
@ -123,6 +123,27 @@ bit(int index) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: BitMask::Named range constructor
|
||||||
|
// Access: Published, Static
|
||||||
|
// Description: Returns a BitMask whose size bits, beginning at
|
||||||
|
// low_bit, are on.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
template<class WordType, int num_bits>
|
||||||
|
INLINE BitMask<WordType, num_bits> BitMask<WordType, num_bits>::
|
||||||
|
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
|
// Function: BitMask::Destructor
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -46,6 +46,7 @@ PUBLISHED:
|
|||||||
INLINE static BitMask<WordType, num_bits> all_off();
|
INLINE static BitMask<WordType, num_bits> all_off();
|
||||||
INLINE static BitMask<WordType, num_bits> lower_on(int on_bits);
|
INLINE static BitMask<WordType, num_bits> lower_on(int on_bits);
|
||||||
INLINE static BitMask<WordType, num_bits> bit(int index);
|
INLINE static BitMask<WordType, num_bits> bit(int index);
|
||||||
|
INLINE static BitMask<WordType, num_bits> range(int low_bit, int size);
|
||||||
|
|
||||||
INLINE ~BitMask();
|
INLINE ~BitMask();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user