diff --git a/library/PolyVoxCore/include/PolyVoxCore/Array.h b/library/PolyVoxCore/include/PolyVoxCore/Array.h index e8a51b05..ae59524a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Array.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Array.h @@ -171,7 +171,7 @@ namespace PolyVox typedef Array<1,uint32_t> Array1DUint32; ///A 2D Array of floats. - typedef Array<2,float> Array2DFloat; + /*typedef Array<2,float> Array2DFloat; ///A 2D Array of doubles. typedef Array<2,double> Array2DDouble; ///A 2D Array of signed 8-bit values. @@ -185,7 +185,7 @@ namespace PolyVox ///A 2D Array of signed 32-bit values. typedef Array<2,int32_t> Array2DInt32; ///A 2D Array of unsigned 32-bit values. - typedef Array<2,uint32_t> Array2DUint32; + typedef Array<2,uint32_t> Array2DUint32;*/ ///A 3D Array of floats. typedef Array<3,float> Array3DFloat; diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Array2D.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/Array2D.h index 635a6328..b6713ae9 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Impl/Array2D.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Array2D.h @@ -44,17 +44,56 @@ namespace PolyVox delete[] m_pData; } + ElementType operator()(uint32_t x, uint32_t y) const + { + return m_pData[y * m_uWidth + x]; + } + ElementType& operator()(uint32_t x, uint32_t y) { return m_pData[y * m_uWidth + x]; } + ElementType* getRawData() + { + return m_pData; + } + + size_t getNoOfElements() + { + return m_uWidth * m_uHeight; + } + + void swap(Array2D& other) + { + ElementType* temp = other.m_pData; + other.m_pData = m_pData; + m_pData = temp; + } + private: uint32_t m_uWidth; uint32_t m_uHeight; ElementType* m_pData; }; + + ///A 2D Array of floats. + typedef Array2D Array2DFloat; + ///A 2D Array of doubles. + typedef Array2D Array2DDouble; + ///A 2D Array of signed 8-bit values. + typedef Array2D Array2DInt8; + ///A 2D Array of unsigned 8-bit values. + typedef Array2D Array2DUint8; + ///A 2D Array of signed 16-bit values. + typedef Array2D Array2DInt16; + ///A 2D Array of unsigned 16-bit values. + typedef Array2D Array2DUint16; + ///A 2D Array of signed 32-bit values. + typedef Array2D Array2DInt32; + ///A 2D Array of unsigned 32-bit values. + typedef Array2D Array2DUint32; } #endif //__PolyVox_Array2D_H__ \ No newline at end of file diff --git a/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h b/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h index 0b401a98..75ddf905 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h +++ b/library/PolyVoxCore/include/PolyVoxCore/PolyVoxForwardDeclarations.h @@ -44,14 +44,14 @@ namespace PolyVox typedef Array<1,int32_t> Array1DInt32; typedef Array<1,uint32_t> Array1DUint32; - typedef Array<2,float> Array2DFloat; + /*typedef Array<2,float> Array2DFloat; typedef Array<2,double> Array2DDouble; typedef Array<2,int8_t> Array2DInt8; typedef Array<2,uint8_t> Array2DUint8; typedef Array<2,int16_t> Array2DInt16; typedef Array<2,uint16_t> Array2DUint16; typedef Array<2,int32_t> Array2DInt32; - typedef Array<2,uint32_t> Array2DUint32; + typedef Array<2,uint32_t> Array2DUint32;*/ typedef Array<3,float> Array3DFloat; typedef Array<3,double> Array3DDouble;