Merge branch 'develop' into feature/cubiquity-version
Conflicts: library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl library/PolyVoxCore/source/Region.cpp
This commit is contained in:
@ -30,7 +30,7 @@ freely, subject to the following restrictions:
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
const int edgeTable[256]=
|
||||
const uint16_t edgeTable[256]=
|
||||
{
|
||||
0x000, 0x109, 0x203, 0x30a, 0x80c, 0x905, 0xa0f, 0xb06,
|
||||
0x406, 0x50f, 0x605, 0x70c, 0xc0a, 0xd03, 0xe09, 0xf00,
|
||||
@ -66,7 +66,7 @@ namespace PolyVox
|
||||
0xb06, 0xa0f, 0x905, 0x80c, 0x30a, 0x203, 0x109, 0x000
|
||||
};
|
||||
|
||||
const int triTable[256][16] =
|
||||
const int8_t triTable[256][16] =
|
||||
{
|
||||
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, },
|
||||
{ 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, },
|
||||
|
93
library/PolyVoxCore/source/Impl/Timer.cpp
Normal file
93
library/PolyVoxCore/source/Impl/Timer.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2005-20013 David Williams and Matthew 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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Impl/Timer.h"
|
||||
|
||||
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
Timer::Timer(bool bAutoStart)
|
||||
:m_fPCFreq(0.0)
|
||||
,m_iStartTime(0)
|
||||
{
|
||||
if(bAutoStart)
|
||||
{
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::start(void)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
if(!QueryPerformanceFrequency(&li))
|
||||
{
|
||||
logWarning() << "QueryPerformanceFrequency failed!";
|
||||
m_fPCFreq = 1.0f;
|
||||
}
|
||||
|
||||
m_fPCFreq = double(li.QuadPart);
|
||||
|
||||
QueryPerformanceCounter(&li);
|
||||
m_iStartTime = li.QuadPart;
|
||||
}
|
||||
|
||||
float Timer::elapsedTimeInSeconds(void)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
QueryPerformanceCounter(&li);
|
||||
double fDifference = static_cast<double>(li.QuadPart-m_iStartTime);
|
||||
return static_cast<float>(fDifference / m_fPCFreq);
|
||||
}
|
||||
|
||||
uint32_t Timer::elapsedTimeInMilliSeconds(void)
|
||||
{
|
||||
return static_cast<uint32_t>(elapsedTimeInSeconds() * 1000.0f);
|
||||
}
|
||||
#else //_MSC_VER
|
||||
Timer::Timer(bool bAutoStart)
|
||||
{
|
||||
if(bAutoStart)
|
||||
{
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
void Timer::start(void)
|
||||
{
|
||||
}
|
||||
|
||||
float Timer::elapsedTimeInSeconds(void)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
uint32_t Timer::elapsedTimeInMilliSeconds(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif //_MSC_VER
|
||||
}
|
@ -1,62 +1,62 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2005-2009 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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||
#include "PolyVoxCore/Impl/Utility.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
//Note: this function only works for inputs which are a power of two and not zero
|
||||
//If this is not the case then the output is undefined.
|
||||
uint8_t logBase2(uint32_t uInput)
|
||||
{
|
||||
//Release mode validation
|
||||
if(uInput == 0)
|
||||
{
|
||||
POLYVOX_THROW(std::invalid_argument, "Cannot compute the log of zero.");
|
||||
}
|
||||
if(!isPowerOf2(uInput))
|
||||
{
|
||||
POLYVOX_THROW(std::invalid_argument, "Input must be a power of two in order to compute the log.");
|
||||
}
|
||||
|
||||
uint32_t uResult = 0;
|
||||
while( (uInput >> uResult) != 0)
|
||||
{
|
||||
++uResult;
|
||||
}
|
||||
return static_cast<uint8_t>(uResult-1);
|
||||
}
|
||||
|
||||
|
||||
bool isPowerOf2(uint32_t uInput)
|
||||
{
|
||||
if(uInput == 0)
|
||||
return false;
|
||||
else
|
||||
return ((uInput & (uInput-1)) == 0);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2005-2009 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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Impl/ErrorHandling.h"
|
||||
#include "PolyVoxCore/Impl/Utility.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
//Note: this function only works for inputs which are a power of two and not zero
|
||||
//If this is not the case then the output is undefined.
|
||||
uint8_t logBase2(uint32_t uInput)
|
||||
{
|
||||
//Release mode validation
|
||||
if(uInput == 0)
|
||||
{
|
||||
POLYVOX_THROW(std::invalid_argument, "Cannot compute the log of zero.");
|
||||
}
|
||||
if(!isPowerOf2(uInput))
|
||||
{
|
||||
POLYVOX_THROW(std::invalid_argument, "Input must be a power of two in order to compute the log.");
|
||||
}
|
||||
|
||||
uint32_t uResult = 0;
|
||||
while( (uInput >> uResult) != 0)
|
||||
{
|
||||
++uResult;
|
||||
}
|
||||
return static_cast<uint8_t>(uResult-1);
|
||||
}
|
||||
|
||||
|
||||
bool isPowerOf2(uint32_t uInput)
|
||||
{
|
||||
if(uInput == 0)
|
||||
return false;
|
||||
else
|
||||
return ((uInput & (uInput-1)) == 0);
|
||||
}
|
||||
|
||||
// http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2
|
||||
uint32_t upperPowerOfTwo(uint32_t v)
|
||||
{
|
||||
@ -68,10 +68,10 @@ namespace PolyVox
|
||||
v |= v >> 16;
|
||||
v++;
|
||||
return v;
|
||||
}
|
||||
|
||||
float triangleFilter(float fInput)
|
||||
{
|
||||
return (std::max)(1.0f - (std::abs)(fInput), 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float triangleFilter(float fInput)
|
||||
{
|
||||
return (std::max)(1.0f - (std::abs)(fInput), 0.0f);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace PolyVox
|
||||
return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5);
|
||||
}
|
||||
|
||||
uint32_t MinizCompressor::compress(void* pSrcData, uint32_t uSrcLength, void* pDstData, uint32_t uDstLength)
|
||||
uint32_t MinizCompressor::compress(const void* pSrcData, uint32_t uSrcLength, void* pDstData, uint32_t uDstLength)
|
||||
{
|
||||
//Get the deflator
|
||||
tdefl_compressor* pDeflator = reinterpret_cast<tdefl_compressor*>(m_pDeflator);
|
||||
@ -103,7 +103,7 @@ namespace PolyVox
|
||||
return ulDstLength;
|
||||
}
|
||||
|
||||
uint32_t MinizCompressor::decompress(void* pSrcData, uint32_t uSrcLength, void* pDstData, uint32_t uDstLength)
|
||||
uint32_t MinizCompressor::decompress(const void* pSrcData, uint32_t uSrcLength, void* pDstData, uint32_t uDstLength)
|
||||
{
|
||||
// I don't know exactly why this limitation exists but it's an implementation detail of miniz. It shouldn't matter for our purposes
|
||||
// as our detination is a Block and those are always a power of two. If you need to use this class for other purposes then you'll
|
||||
|
@ -514,5 +514,5 @@ namespace PolyVox
|
||||
os << "(" << region.getLowerX() << "," << region.getLowerY() << "," << region.getLowerZ() <<
|
||||
") to (" << region.getUpperX() << "," << region.getUpperY() << "," << region.getUpperZ() << ")";
|
||||
return os;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user