Torque3D Documentation / _generateds / afxZodiacDefs.h

afxZodiacDefs.h

Engine/source/afx/ce/afxZodiacDefs.h

More...

Classes:

Detailed Description

  1
  2
  3//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
  4// Arcane-FX for MIT Licensed Open Source version of Torque 3D from GarageGames
  5// Copyright (C) 2015 Faust Logic, Inc.
  6//
  7// Permission is hereby granted, free of charge, to any person obtaining a copy
  8// of this software and associated documentation files (the "Software"), to
  9// deal in the Software without restriction, including without limitation the
 10// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 11// sell copies of the Software, and to permit persons to whom the Software is
 12// furnished to do so, subject to the following conditions:
 13//
 14// The above copyright notice and this permission notice shall be included in
 15// all copies or substantial portions of the Software.
 16//
 17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 20// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 23// IN THE SOFTWARE.
 24//
 25//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 26
 27#ifndef _AFX_ZODIAC_DEFS_H_
 28#define _AFX_ZODIAC_DEFS_H_
 29
 30class afxZodiacDefs
 31{
 32public:
 33  enum 
 34  {
 35     MAX_ZODIACS = 256,
 36     N_ZODIAC_FIELD_INTS = (MAX_ZODIACS - 1) / 32 + 1,
 37  };
 38
 39  enum
 40  {
 41    BLEND_NORMAL      = 0x0,
 42    BLEND_ADDITIVE    = 0x1,
 43    BLEND_SUBTRACTIVE = 0x2,
 44    BLEND_RESERVED    = 0x3,
 45    BLEND_MASK        = 0x3
 46  };
 47
 48  enum 
 49  {
 50    SHOW_ON_TERRAIN       = BIT(2),
 51    SHOW_ON_INTERIORS     = BIT(3),
 52    SHOW_ON_WATER         = BIT(4),
 53    SHOW_ON_MODELS        = BIT(5),
 54    //
 55    SHOW_IN_NON_REFLECTIONS = BIT(6),
 56    SHOW_IN_REFLECTIONS     = BIT(7),
 57    //
 58    RESPECT_ORIENTATION   = BIT(8),
 59    SCALE_VERT_RANGE      = BIT(9),
 60    INVERT_GRADE_RANGE    = BIT(10),
 61    USE_GRADE_RANGE       = BIT(11),
 62    PREFER_DEST_GRADE     = BIT(12),
 63    //
 64    INTERIOR_VERT_IGNORE    = BIT(13),
 65    INTERIOR_HORIZ_ONLY     = BIT(14),
 66    INTERIOR_BACK_IGNORE    = BIT(15),
 67    INTERIOR_OPAQUE_IGNORE  = BIT(16),
 68    INTERIOR_TRANSP_IGNORE  = BIT(17),
 69    //
 70    INTERIOR_FILTERS = INTERIOR_VERT_IGNORE | INTERIOR_HORIZ_ONLY | INTERIOR_BACK_IGNORE
 71  };
 72};
 73
 74//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
 75
 76class afxZodiacBitmask : public afxZodiacDefs
 77{
 78  U32 mBits[N_ZODIAC_FIELD_INTS];
 79  
 80public:
 81  afxZodiacBitmask() { clear(); }
 82  afxZodiacBitmask(const afxZodiacBitmask& field) { *this = field; }
 83  
 84  bool test(U32 index)
 85  {
 86    U32 word = index / 32;
 87    U32 bit = index % 32;
 88    return mBits[word] & (1 << bit);
 89  }
 90  
 91  void set(U32 index)
 92  {
 93    U32 word = index / 32;
 94    U32 bit = index % 32;
 95    mBits[word] |= 1 << bit;
 96  }
 97  
 98  void unset(U32 index)
 99  {
100    U32 word = index / 32;
101    U32 bit = index % 32;
102    mBits[word] &= ~(1 << bit);
103  }
104  
105  S32 findLastSetBit(U32 startbit=(MAX_ZODIACS-1))
106  {
107    U32 word = startbit / 32;
108    U32 bit = startbit % 32;
109
110    if (mBits[word] != 0)
111    { 
112      U32 mask = mBits[word] << (31-bit);
113      for (U32 j = bit; j >= 0; j--)
114      {
115        if (mask & 0x80000000)
116          return word*32 + j;
117        mask <<= 1;
118      }
119    }
120    
121    for (U32 k = word-1; k >= 0; k--)
122    {
123      if (mBits[k] != 0)
124      { 
125        U32 mask = mBits[k];
126        for (U32 j = 31; j >= 0; j--)
127        {
128          if (mask & 0x80000000)
129            return k*32 + j;
130          mask <<= 1;
131        }
132      }
133    }
134
135    return -1;
136  }
137  
138  void clear()
139  {
140    for (U32 k = 0; k < N_ZODIAC_FIELD_INTS; k++)
141      mBits[k] = 0x00000000;
142  }
143  
144  bool isEmpty()
145  {
146    for (U32 k = 0; k < N_ZODIAC_FIELD_INTS; k++)
147      if (mBits[k] != 0)
148        return false;
149      return true;
150  }
151  
152  afxZodiacBitmask& operator=(const afxZodiacBitmask& field)
153  {
154    for (U32 k = 0; k < N_ZODIAC_FIELD_INTS; k++)
155      mBits[k] = field.mBits[k];
156    return *this;
157  }
158  
159  operator bool() { return !isEmpty(); }
160};
161
162//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~//~~~~~~~~~~~~~~~~~~~~~//
163
164#endif // _AFX_ZODIAC_DEFS_H_
165