Fixed bug with SimpleVolume and negative positions.
This commit is contained in:
parent
4ed8d4303b
commit
3f87fc780f
@ -174,17 +174,19 @@ namespace PolyVox
|
|||||||
throw std::invalid_argument("Block side length must be a power of two.");
|
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;
|
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
|
//Compute the block side length
|
||||||
m_uBlockSideLength = uBlockSideLength;
|
m_uBlockSideLength = uBlockSideLength;
|
||||||
m_uBlockSideLengthPower = logBase2(m_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)
|
//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;
|
m_uWidthInBlocks = m_regValidRegionInBlocks.getUpperCorner().getX() - m_regValidRegionInBlocks.getLowerCorner().getX() + 1;
|
||||||
|
@ -34,8 +34,7 @@ using namespace PolyVox;
|
|||||||
template <typename VolumeType>
|
template <typename VolumeType>
|
||||||
int32_t complexVolumeTest(void)
|
int32_t complexVolumeTest(void)
|
||||||
{
|
{
|
||||||
//VolumeType testVolume(Region(-57, -31, 12, 64, 96, 131)); // Deliberatly awkward size
|
VolumeType testVolume(Region(-57, -31, 12, 64, 96, 131)); // Deliberatly awkward size
|
||||||
VolumeType testVolume(Region(0, 0, 0, 63, 63, 63));
|
|
||||||
for(int z = testVolume.getEnclosingRegion().getLowerZ(); z <= testVolume.getEnclosingRegion().getUpperZ(); z++)
|
for(int z = testVolume.getEnclosingRegion().getLowerZ(); z <= testVolume.getEnclosingRegion().getUpperZ(); z++)
|
||||||
{
|
{
|
||||||
for(int y = testVolume.getEnclosingRegion().getLowerY(); y <= testVolume.getEnclosingRegion().getUpperY(); y++)
|
for(int y = testVolume.getEnclosingRegion().getLowerY(); y <= testVolume.getEnclosingRegion().getUpperY(); y++)
|
||||||
@ -66,19 +65,19 @@ int32_t complexVolumeTest(void)
|
|||||||
void TestVolume::testLargeVolume()
|
void TestVolume::testLargeVolume()
|
||||||
{
|
{
|
||||||
int32_t result = complexVolumeTest< LargeVolume<int32_t> >();
|
int32_t result = complexVolumeTest< LargeVolume<int32_t> >();
|
||||||
QCOMPARE(result, static_cast<int32_t>(24772608));
|
QCOMPARE(result, static_cast<int32_t>(201446400));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestVolume::testRawVolume()
|
void TestVolume::testRawVolume()
|
||||||
{
|
{
|
||||||
int32_t result = complexVolumeTest< RawVolume<int32_t> >();
|
int32_t result = complexVolumeTest< RawVolume<int32_t> >();
|
||||||
QCOMPARE(result, static_cast<int32_t>(24772608));
|
QCOMPARE(result, static_cast<int32_t>(201446400));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestVolume::testSimpleVolume()
|
void TestVolume::testSimpleVolume()
|
||||||
{
|
{
|
||||||
int32_t result = complexVolumeTest< SimpleVolume<int32_t> >();
|
int32_t result = complexVolumeTest< SimpleVolume<int32_t> >();
|
||||||
QCOMPARE(result, static_cast<int32_t>(24772608));
|
QCOMPARE(result, static_cast<int32_t>(201446400));
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(TestVolume)
|
QTEST_MAIN(TestVolume)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user