RigsofRods
Soft-body Physics Simulation
BitFlags.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 
7 typedef uint32_t BitMask_t;
8 typedef uint64_t BitMask64_t;
9 
10 #define BITMASK( OFFSET ) ( 1 << ((OFFSET) - 1) )
11 #define BITMASK64( OFFSET ) ( BitMask64_t(1) << BitMask64_t((OFFSET) - 1) )
12 
13 #define BITMASK_IS_0( VAR, FLAGS ) ( ((VAR) & (FLAGS)) == 0 )
14 #define BITMASK_IS_1( VAR, FLAGS ) ( ((VAR) & (FLAGS)) == (FLAGS) )
15 
16 #define BITMASK_SET_0( VAR, FLAGS ) ( (VAR) &= ~ (FLAGS) )
17 #define BITMASK_SET_1( VAR, FLAGS ) ( (VAR) |= (FLAGS) )
18 
19 inline void BITMASK_SET(BitMask_t& mask, BitMask_t flag, bool val)
20 {
21  if (val) { BITMASK_SET_1(mask, flag); }
22  else { BITMASK_SET_0(mask, flag); }
23 }
24 
25 // --------------- TO BE REMOVED --------------- //
26 
28 #define BITMASK_PROPERTY_GET(VAR, BIT_INDEX, FLAG_NAME, GETTER_NAME) \
29  static const BitMask_t FLAG_NAME = BITMASK((BIT_INDEX)); \
30  inline bool GETTER_NAME() const { return BITMASK_IS_1((VAR), FLAG_NAME); }
31 
BITMASK_SET
void BITMASK_SET(BitMask_t &mask, BitMask_t flag, bool val)
Definition: BitFlags.h:19
BITMASK_SET_0
#define BITMASK_SET_0(VAR, FLAGS)
Definition: BitFlags.h:16
BITMASK_SET_1
#define BITMASK_SET_1(VAR, FLAGS)
Definition: BitFlags.h:17
BitMask_t
uint32_t BitMask_t
Definition: BitFlags.h:7
BitMask64_t
uint64_t BitMask64_t
Definition: BitFlags.h:8