| 1 | /* |
| 2 | * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property |
| 5 | * and proprietary rights in and to this software, related documentation |
| 6 | * and any modifications thereto. Any use, reproduction, disclosure or |
| 7 | * distribution of this software and related documentation without an express |
| 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. |
| 9 | */ |
| 10 | // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. |
| 11 | // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. |
| 12 | |
| 13 | |
| 14 | #ifndef PX_FOUNDATION_PX_BIT_AND_DATA_H |
| 15 | #define PX_FOUNDATION_PX_BIT_AND_DATA_H |
| 16 | |
| 17 | #include "foundation/Px.h" |
| 18 | |
| 19 | /** \addtogroup foundation |
| 20 | @{ |
| 21 | */ |
| 22 | #ifndef PX_DOXYGEN |
| 23 | namespace physx |
| 24 | { |
| 25 | #endif |
| 26 | |
| 27 | template <typename storageType, storageType bitMask> |
| 28 | class PxBitAndDataT |
| 29 | { |
| 30 | public: |
| 31 | |
| 32 | PX_FORCE_INLINE PxBitAndDataT(const PxEMPTY&) {} |
| 33 | PX_FORCE_INLINE PxBitAndDataT() : mData(0) {} |
| 34 | PX_FORCE_INLINE PxBitAndDataT(storageType data, bool bit=false) { mData = bit ? data | bitMask : data; } |
| 35 | |
| 36 | PX_CUDA_CALLABLE PX_FORCE_INLINE operator storageType() const { return storageType(mData & ~bitMask); } |
| 37 | PX_CUDA_CALLABLE PX_FORCE_INLINE void setBit() { mData |= bitMask; } |
| 38 | PX_CUDA_CALLABLE PX_FORCE_INLINE void clearBit() { mData &= ~bitMask; } |
| 39 | PX_CUDA_CALLABLE PX_FORCE_INLINE storageType isBitSet() const { return storageType(mData & bitMask); } |
| 40 | |
| 41 | protected: |
| 42 | storageType mData; |
| 43 | }; |
| 44 | typedef PxBitAndDataT<unsigned char, 0x80> PxBitAndByte; |
| 45 | typedef PxBitAndDataT<unsigned short, 0x8000> PxBitAndWord; |
| 46 | typedef PxBitAndDataT<unsigned int, 0x80000000> PxBitAndDword; |
| 47 | |
| 48 | #ifndef PX_DOXYGEN |
| 49 | } // namespace physx |
| 50 | #endif |
| 51 | |
| 52 | /** @} */ |
| 53 | #endif // PX_FOUNDATION_PX_BIT_AND_DATA_H |
| 54 | |