Classes | Public Member Functions | Static Public Member Functions | Protected Attributes

OrbazTrueBlock Class Reference

Search for all occurrences

#include <IParticleChannelTrueFalseIterator.h>

Inheritance diagram for OrbazTrueBlock:
Inheritance graph
[legend]

List of all members.

Classes

class   NumberBitsSetInUChar

Public Member Functions

  OrbazTrueBlock ()
  OrbazTrueBlock (const OrbazTrueBlock &block)
  OrbazTrueBlock (int majorIndex, DWORD32 blockIndices)
int  GetMajorIndex (void) const
void  SetMajorIndex (int index)
void  AddBlockIndex (int index)
int  NumberSet (void) const

Static Public Member Functions

static int  SetAllTrueBlocks (int particleCount, OrbazTrueBlock *&trueBlocks)
static int  GetMaxNumTrueBlocks (int particleCount)
static int  OptimizeMemoryUsage (int numBlocksSet, int numBlocksAllocated, OrbazTrueBlock *&trueBlocks)

Protected Attributes

int  m_majorIndex
DWORD32  m_blockIndices

Constructor & Destructor Documentation

OrbazTrueBlock ( ) [inline]
OrbazTrueBlock ( const OrbazTrueBlock block ) [inline]
OrbazTrueBlock ( int  majorIndex,
DWORD32  blockIndices 
) [inline]
        :   m_majorIndex(majorIndex)
        ,   m_blockIndices(blockIndices)
    {
    }

Member Function Documentation

int GetMajorIndex ( void  ) const [inline]
void SetMajorIndex ( int  index ) [inline]
void AddBlockIndex ( int  index ) [inline]
{ m_blockIndices |= (1<<(index&kBitsPerDWORDMask)); }
int NumberSet ( void  ) const [inline]
    {
        static NumberBitsSetInUChar nbc;
        int numSet = 0;
        uchar*  miniBlocks = (uchar*)(&m_blockIndices);
        for(int i=0; i<4; ++i)
            numSet += nbc.getNumBitsSet(miniBlocks[i]);
        return numSet;
    }
static int SetAllTrueBlocks ( int  particleCount,
OrbazTrueBlock *&  trueBlocks 
) [inline, static]
    {
        if (trueBlocks != NULL)
        {
            delete [] trueBlocks;
            trueBlocks = NULL;
        }

        int numTrueBlocks = particleCount>>5;
        bool incompleteEndBlock = (particleCount%kBitsPerDWORD != 0);
        int numCompleteBlocks = numTrueBlocks;
        if (incompleteEndBlock)
            ++numTrueBlocks;
        trueBlocks = new OrbazTrueBlock[numTrueBlocks];
        int i=0;
        for(; i<numCompleteBlocks; ++i)
            trueBlocks[i] = OrbazTrueBlock(i<<5, 0xFFFFFFFF);
        if (incompleteEndBlock)
            for(int j=i<<5; j<particleCount; ++j)
                trueBlocks[i].AddBlockIndex(j);
        return numTrueBlocks;
    }
static int GetMaxNumTrueBlocks ( int  particleCount ) [inline, static]
    {
        int numTrueBlocks = particleCount >> 5;
        if (particleCount % kBitsPerDWORD != 0)
            ++numTrueBlocks;
        return numTrueBlocks;
    }
static int OptimizeMemoryUsage ( int  numBlocksSet,
int  numBlocksAllocated,
OrbazTrueBlock *&  trueBlocks 
) [inline, static]
    {
        if (numBlocksSet != numBlocksAllocated)
        {
            OrbazTrueBlock* temp = new OrbazTrueBlock[numBlocksSet];
            memcpy(temp, trueBlocks, sizeof(OrbazTrueBlock)*numBlocksSet);
            delete [] trueBlocks;
            trueBlocks = temp;
        }
        return numBlocksSet;
    }

Member Data Documentation

int m_majorIndex [protected]
DWORD32 m_blockIndices [protected]

OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock
OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock OrbazTrueBlock