00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "physxGroupsMask.h"
00016
00017
00018
00019
00020
00021
00022 PhysxGroupsMask PhysxGroupsMask::
00023 all_on() {
00024
00025 PhysxGroupsMask mask;
00026 mask._mask.bits0 = 0xffffffff;
00027 mask._mask.bits1 = 0xffffffff;
00028 mask._mask.bits2 = 0xffffffff;
00029 mask._mask.bits3 = 0xffffffff;
00030 return mask;
00031 }
00032
00033
00034
00035
00036
00037
00038 PhysxGroupsMask PhysxGroupsMask::
00039 all_off() {
00040
00041 PhysxGroupsMask mask;
00042
00043 mask._mask.bits0 = 0x0000000;
00044 mask._mask.bits1 = 0x0000000;
00045 mask._mask.bits2 = 0x0000000;
00046 mask._mask.bits3 = 0x0000000;
00047
00048 return mask;
00049 }
00050
00051
00052
00053
00054
00055
00056
00057 void PhysxGroupsMask::
00058 set_bit(unsigned int idx) {
00059
00060 nassertv_always(idx >= 0 && idx <= 127);
00061
00062 NxU32 bits = 1 << (idx % 32);
00063
00064 if (idx < 32) {
00065 _mask.bits0 |= bits;
00066 }
00067 else if (idx < 64) {
00068 _mask.bits1 |= bits;
00069 }
00070 else if (idx < 96) {
00071 _mask.bits2 |= bits;
00072 }
00073 else {
00074 _mask.bits3 |= bits;
00075 }
00076 }
00077
00078
00079
00080
00081
00082
00083
00084 void PhysxGroupsMask::
00085 clear_bit(unsigned int idx) {
00086
00087 nassertv_always(idx >= 0 && idx <= 127);
00088
00089 NxU32 bits = 1 << (idx % 32);
00090
00091 if (idx < 32) {
00092 _mask.bits0 = _mask.bits0 & ~bits;
00093 }
00094 else if (idx < 64) {
00095 _mask.bits1 = _mask.bits1 & ~bits;
00096 }
00097 else if (idx < 96) {
00098 _mask.bits2 = _mask.bits2 & ~bits;
00099 }
00100 else {
00101 _mask.bits3 = _mask.bits3 & ~bits;
00102 }
00103 }
00104
00105
00106
00107
00108
00109
00110
00111
00112 bool PhysxGroupsMask::
00113 get_bit(unsigned int idx) const {
00114
00115 nassertr_always(idx >= 0 && idx <= 127, false);
00116
00117 NxU32 bits = 1 << (idx % 32);
00118
00119 if (idx < 32) {
00120 return (_mask.bits0 & bits) ? true : false;
00121 }
00122 else if (idx < 64) {
00123 return (_mask.bits1 & bits) ? true : false;
00124 }
00125 else if (idx < 96) {
00126 return (_mask.bits2 & bits) ? true : false;
00127 }
00128 else {
00129 return (_mask.bits3 & bits) ? true : false;
00130 }
00131 }
00132
00133
00134
00135
00136
00137
00138
00139 void PhysxGroupsMask::
00140 output(ostream &out) const {
00141
00142 string name0;
00143 string name1;
00144 string name2;
00145 string name3;
00146
00147 for (int i=0; i<32; i++) {
00148 name0 += (_mask.bits0 & (1 << i)) ? '1' : '0';
00149 name1 += (_mask.bits1 & (1 << i)) ? '1' : '0';
00150 name2 += (_mask.bits2 & (1 << i)) ? '1' : '0';
00151 name3 += (_mask.bits3 & (1 << i)) ? '1' : '0';
00152 }
00153
00154 out << "/" << name0 << "-" << name1 << "-" << name2 << "-" << name3 << "/";
00155 }
00156