Fixed bug with SimpleVolume and negative positions.

This commit is contained in:
David Williams 2012-12-05 23:49:39 +01:00
parent 4ed8d4303b
commit 3f87fc780f
2 changed files with 12 additions and 11 deletions

View File

@ -174,17 +174,19 @@ namespace PolyVox
throw std::invalid_argument("Block side length must be a power of two.");
}
m_uBlockSideLength = uBlockSideLength;
m_uNoOfVoxelsPerBlock = m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength;
this->m_regValidRegion = regValidRegion;
m_regValidRegionInBlocks.setLowerCorner(this->m_regValidRegion.getLowerCorner() / static_cast<int32_t>(uBlockSideLength));
m_regValidRegionInBlocks.setUpperCorner(this->m_regValidRegion.getUpperCorner() / static_cast<int32_t>(uBlockSideLength));
//Compute the block side length
m_uBlockSideLength = uBlockSideLength;
m_uBlockSideLengthPower = logBase2(m_uBlockSideLength);
m_uNoOfVoxelsPerBlock = m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength;
m_regValidRegionInBlocks.setLowerX(this->m_regValidRegion.getLowerX() >> m_uBlockSideLengthPower);
m_regValidRegionInBlocks.setLowerY(this->m_regValidRegion.getLowerY() >> m_uBlockSideLengthPower);
m_regValidRegionInBlocks.setLowerZ(this->m_regValidRegion.getLowerZ() >> m_uBlockSideLengthPower);
m_regValidRegionInBlocks.setUpperX(this->m_regValidRegion.getUpperX() >> m_uBlockSideLengthPower);
m_regValidRegionInBlocks.setUpperY(this->m_regValidRegion.getUpperY() >> m_uBlockSideLengthPower);
m_regValidRegionInBlocks.setUpperZ(this->m_regValidRegion.getUpperZ() >> m_uBlockSideLengthPower);
//Compute the size of the volume in blocks (and note +1 at the end)
m_uWidthInBlocks = m_regValidRegionInBlocks.getUpperCorner().getX() - m_regValidRegionInBlocks.getLowerCorner().getX() + 1;

View File

@ -34,8 +34,7 @@ using namespace PolyVox;
template <typename VolumeType>
int32_t complexVolumeTest(void)
{
//VolumeType testVolume(Region(-57, -31, 12, 64, 96, 131)); // Deliberatly awkward size
VolumeType testVolume(Region(0, 0, 0, 63, 63, 63));
VolumeType testVolume(Region(-57, -31, 12, 64, 96, 131)); // Deliberatly awkward size
for(int z = testVolume.getEnclosingRegion().getLowerZ(); z <= testVolume.getEnclosingRegion().getUpperZ(); z++)
{
for(int y = testVolume.getEnclosingRegion().getLowerY(); y <= testVolume.getEnclosingRegion().getUpperY(); y++)
@ -66,19 +65,19 @@ int32_t complexVolumeTest(void)
void TestVolume::testLargeVolume()
{
int32_t result = complexVolumeTest< LargeVolume<int32_t> >();
QCOMPARE(result, static_cast<int32_t>(24772608));
QCOMPARE(result, static_cast<int32_t>(201446400));
}
void TestVolume::testRawVolume()
{
int32_t result = complexVolumeTest< RawVolume<int32_t> >();
QCOMPARE(result, static_cast<int32_t>(24772608));
QCOMPARE(result, static_cast<int32_t>(201446400));
}
void TestVolume::testSimpleVolume()
{
int32_t result = complexVolumeTest< SimpleVolume<int32_t> >();
QCOMPARE(result, static_cast<int32_t>(24772608));
QCOMPARE(result, static_cast<int32_t>(201446400));
}
QTEST_MAIN(TestVolume)