diff --git a/library/PolyVoxCore/CMakeLists.txt b/library/PolyVoxCore/CMakeLists.txt index db5caaa8..ed06c3c6 100644 --- a/library/PolyVoxCore/CMakeLists.txt +++ b/library/PolyVoxCore/CMakeLists.txt @@ -108,6 +108,7 @@ SET(IMPL_SRC_FILES ) SET(IMPL_INC_FILES + include/PolyVoxCore/Impl/Array2D.h include/PolyVoxCore/Impl/ArraySizesImpl.h include/PolyVoxCore/Impl/ArraySizesImpl.inl include/PolyVoxCore/Impl/AStarPathfinderImpl.h diff --git a/library/PolyVoxCore/include/PolyVoxCore/Impl/Array2D.h b/library/PolyVoxCore/include/PolyVoxCore/Impl/Array2D.h new file mode 100644 index 00000000..635a6328 --- /dev/null +++ b/library/PolyVoxCore/include/PolyVoxCore/Impl/Array2D.h @@ -0,0 +1,60 @@ +/******************************************************************************* +Copyright (c) 2005-20014 David Williams + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software +in a product, an acknowledgment in the product documentation would be +appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*******************************************************************************/ + +#ifndef __PolyVox_Array2D_H__ +#define __PolyVox_Array2D_H__ + +namespace PolyVox +{ + template + class Array2D + { + public: + + Array2D(uint32_t width, uint32_t height) + :m_uWidth(width) + , m_uHeight(height) + , m_pData(0) + { + m_pData = new ElementType[m_uWidth * m_uHeight]; + } + + ~Array2D() + { + delete[] m_pData; + } + + ElementType& operator()(uint32_t x, uint32_t y) + { + return m_pData[y * m_uWidth + x]; + } + + private: + + uint32_t m_uWidth; + uint32_t m_uHeight; + ElementType* m_pData; + }; +} + +#endif //__PolyVox_Array2D_H__ \ No newline at end of file diff --git a/tests/TestArray.cpp b/tests/TestArray.cpp index bf024061..6d41aa6e 100644 --- a/tests/TestArray.cpp +++ b/tests/TestArray.cpp @@ -25,40 +25,12 @@ freely, subject to the following restrictions: #include "PolyVoxCore/Array.h" +#include "PolyVoxCore/Impl/Array2D.h" + #include using namespace PolyVox; -template -class Array2D -{ -public: - - Array2D(uint32_t width, uint32_t height) - :m_uWidth(width) - ,m_uHeight(height) - ,m_pData(0) - { - m_pData = new ElementType[m_uWidth * m_uHeight]; - } - - ~Array2D() - { - delete[] m_pData; - } - - ElementType& operator()(uint32_t x, uint32_t y) - { - return m_pData[y * m_uWidth + x]; - } - -private: - - uint32_t m_uWidth; - uint32_t m_uHeight; - ElementType* m_pData; -}; - void TestArray::testCArraySpeed() { const int width = 128;