Moved Array2D to it's own file.
This commit is contained in:
parent
46358adfbc
commit
20815b6083
@ -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
|
||||
|
60
library/PolyVoxCore/include/PolyVoxCore/Impl/Array2D.h
Normal file
60
library/PolyVoxCore/include/PolyVoxCore/Impl/Array2D.h
Normal file
@ -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 <typename ElementType>
|
||||
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__
|
@ -25,40 +25,12 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
|
||||
#include "PolyVoxCore/Impl/Array2D.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
using namespace PolyVox;
|
||||
|
||||
template <typename ElementType>
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user