diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractor.h b/library/PolyVoxCore/include/CubicSurfaceExtractor.h index 3e681cca..3178c4a0 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractor.h +++ b/library/PolyVoxCore/include/CubicSurfaceExtractor.h @@ -55,7 +55,6 @@ namespace PolyVox //Information about the region we are currently processing Region m_regSizeInVoxels; - Region m_regSizeInCells; //The surface patch we are currently filling. SurfaceMesh* m_meshCurrent; diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractor.inl b/library/PolyVoxCore/include/CubicSurfaceExtractor.inl index c0502af2..e2bac8ec 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/CubicSurfaceExtractor.inl @@ -39,16 +39,15 @@ namespace PolyVox ,m_regSizeInVoxels(region) ,m_meshCurrent(result) { - m_regSizeInCells = m_regSizeInVoxels; - m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt32(1,1,1)); - m_meshCurrent->clear(); } template void CubicSurfaceExtractor::execute() { - uint32_t arraySize[3]= {m_regSizeInVoxels.getWidth()+2, m_regSizeInVoxels.getHeight()+2, MaxQuadsSharingVertex}; + uint32_t uArrayWidth = m_regSizeInVoxels.getUpperCorner().getX() - m_regSizeInVoxels.getLowerCorner().getX() + 2; + uint32_t uArrayHeight = m_regSizeInVoxels.getUpperCorner().getY() - m_regSizeInVoxels.getLowerCorner().getY() + 2; + uint32_t arraySize[3]= {uArrayWidth, uArrayHeight, MaxQuadsSharingVertex}; m_previousSliceVertices.resize(arraySize); m_currentSliceVertices.resize(arraySize); memset(m_previousSliceVertices.getRawData(), 0xff, m_previousSliceVertices.getNoOfElements() * sizeof(IndexAndMaterial)); diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h index ecee9f3c..dfb5ae2b 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h +++ b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.h @@ -49,7 +49,6 @@ namespace PolyVox //Information about the region we are currently processing Region m_regSizeInVoxels; - Region m_regSizeInCells; }; } diff --git a/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.inl b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.inl index eb690673..c1c74867 100644 --- a/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.inl +++ b/library/PolyVoxCore/include/CubicSurfaceExtractorWithNormals.inl @@ -36,9 +36,6 @@ namespace PolyVox ,m_regSizeInVoxels(region) ,m_meshCurrent(result) { - m_regSizeInCells = m_regSizeInVoxels; - m_regSizeInCells.setUpperCorner(m_regSizeInCells.getUpperCorner() - Vector3DInt32(1,1,1)); - m_meshCurrent->clear(); } diff --git a/library/PolyVoxCore/include/Filters.inl b/library/PolyVoxCore/include/Filters.inl index c0c34994..4ec87956 100644 --- a/library/PolyVoxCore/include/Filters.inl +++ b/library/PolyVoxCore/include/Filters.inl @@ -7,13 +7,16 @@ namespace PolyVox { Region croppedRegion = regionToSmooth; - Array<3, uint16_t> temp(ArraySizes(croppedRegion.getWidth())(croppedRegion.getHeight())(croppedRegion.getDepth())); + uint32_t uArrayWidth = croppedRegion.getUpperCorner().getX() - croppedRegion.getLowerCorner().getX() + 1; + uint32_t uArrayHeight = croppedRegion.getUpperCorner().getY() - croppedRegion.getLowerCorner().getY() + 1; + uint32_t uArrayDepth = croppedRegion.getUpperCorner().getZ() - croppedRegion.getLowerCorner().getZ() + 1; + Array<3, uint16_t> temp(ArraySizes(uArrayWidth)(uArrayHeight)(uArrayDepth)); - for (int z = croppedRegion.getLowerCorner().getZ(); z < croppedRegion.getUpperCorner().getZ(); z++) + for (int32_t z = croppedRegion.getLowerCorner().getZ(); z <= croppedRegion.getUpperCorner().getZ(); z++) { - for (int y = croppedRegion.getLowerCorner().getY(); y < croppedRegion.getUpperCorner().getY(); y++) + for (int32_t y = croppedRegion.getLowerCorner().getY(); y <= croppedRegion.getUpperCorner().getY(); y++) { - for (int x = croppedRegion.getLowerCorner().getX(); x < croppedRegion.getUpperCorner().getX(); x++) + for (int32_t x = croppedRegion.getLowerCorner().getX(); x <= croppedRegion.getUpperCorner().getX(); x++) { uint16_t& uDensity = temp[x-croppedRegion.getLowerCorner().getX()][y-croppedRegion.getLowerCorner().getY()][z-croppedRegion.getLowerCorner().getZ()]; @@ -52,11 +55,11 @@ namespace PolyVox } } - for (int z = croppedRegion.getLowerCorner().getZ(); z < croppedRegion.getUpperCorner().getZ(); z++) + for (int32_t z = croppedRegion.getLowerCorner().getZ(); z < croppedRegion.getUpperCorner().getZ(); z++) { - for (int y = croppedRegion.getLowerCorner().getY(); y < croppedRegion.getUpperCorner().getY(); y++) + for (int32_t y = croppedRegion.getLowerCorner().getY(); y < croppedRegion.getUpperCorner().getY(); y++) { - for (int x = croppedRegion.getLowerCorner().getX(); x < croppedRegion.getUpperCorner().getX(); x++) + for (int32_t x = croppedRegion.getLowerCorner().getX(); x < croppedRegion.getUpperCorner().getX(); x++) { uint16_t& uDensity = temp[x-croppedRegion.getLowerCorner().getX()][y-croppedRegion.getLowerCorner().getY()][z-croppedRegion.getLowerCorner().getZ()]; diff --git a/library/PolyVoxCore/include/Region.h b/library/PolyVoxCore/include/Region.h index d8177a35..fa0a7b8e 100644 --- a/library/PolyVoxCore/include/Region.h +++ b/library/PolyVoxCore/include/Region.h @@ -42,12 +42,9 @@ namespace PolyVox Region(); Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner); - uint32_t getDepth(void) const; Vector3DUint32 getDimensions(void); - uint32_t getHeight(void) const; const Vector3DInt32& getLowerCorner(void) const; const Vector3DInt32& getUpperCorner(void) const; - uint32_t getWidth(void) const; void setLowerCorner(const Vector3DInt32& v3dLowerCorner); void setUpperCorner(const Vector3DInt32& v3dUpperCorner); @@ -55,16 +52,16 @@ namespace PolyVox bool containsPoint(const Vector3DFloat& pos, float boundary = 0.0f) const; bool containsPoint(const Vector3DInt32& pos, uint8_t boundary = 0) const; void cropTo(const Region& other); - /// Deprecated and wrong by 1 - use getDepth() instead. + /// Deprecated and misleading int32_t depth(void) const; - /// Deprecated and wrong by 1 - use getHeight() instead. + /// Deprecated and misleading int32_t height(void) const; void shift(const Vector3DInt32& amount); void shiftLowerCorner(const Vector3DInt32& amount); void shiftUpperCorner(const Vector3DInt32& amount); - /// Deprecated and wrong by 1 - use getDimensions() instead. + /// Deprecated and misleading Vector3DInt32 dimensions(void); - /// Deprecated and wrong by 1 - use getWidth() instead. + /// Deprecated and misleading int32_t width(void) const; private: diff --git a/library/PolyVoxCore/include/SurfaceExtractor.inl b/library/PolyVoxCore/include/SurfaceExtractor.inl index 2f8ab91e..208a2e50 100644 --- a/library/PolyVoxCore/include/SurfaceExtractor.inl +++ b/library/PolyVoxCore/include/SurfaceExtractor.inl @@ -46,7 +46,9 @@ namespace PolyVox template void SurfaceExtractor::execute() { - uint32_t arraySizes[2]= {m_regSizeInVoxels.getWidth(), m_regSizeInVoxels.getHeight()}; // Array dimensions + uint32_t uArrayWidth = m_regSizeInVoxels.getUpperCorner().getX() - m_regSizeInVoxels.getLowerCorner().getX() + 1; + uint32_t uArrayHeight = m_regSizeInVoxels.getUpperCorner().getY() - m_regSizeInVoxels.getLowerCorner().getY() + 1; + uint32_t arraySizes[2]= {uArrayWidth, uArrayHeight}; // Array dimensions //For edge indices Array2DInt32 m_pPreviousVertexIndicesX(arraySizes); @@ -91,7 +93,7 @@ namespace PolyVox m_regSliceCurrent.shift(Vector3DInt32(0,0,1)); //Process the other slices (previous slice is available) - for(int32_t uSlice = 1; uSlice <= m_regSizeInVoxels.getDepth()-1; uSlice++) + for(int32_t uSlice = 1; uSlice <= m_regSizeInVoxels.getUpperCorner().getZ() - m_regSizeInVoxels.getLowerCorner().getZ(); uSlice++) { computeBitmaskForSlice(pPreviousBitmask, pCurrentBitmask); uNoOfNonEmptyCellsForSlice1 = m_uNoOfOccupiedCells; diff --git a/library/PolyVoxCore/include/Volume.inl b/library/PolyVoxCore/include/Volume.inl index e274ad3a..0754f4c1 100644 --- a/library/PolyVoxCore/include/Volume.inl +++ b/library/PolyVoxCore/include/Volume.inl @@ -135,7 +135,7 @@ namespace PolyVox template int32_t Volume::getWidth(void) const { - return m_regValidRegion.getWidth(); + return m_regValidRegion.getUpperCorner().getX() - m_regValidRegion.getLowerCorner().getX() + 1; } //////////////////////////////////////////////////////////////////////////////// @@ -145,7 +145,7 @@ namespace PolyVox template int32_t Volume::getHeight(void) const { - return m_regValidRegion.getHeight(); + return m_regValidRegion.getUpperCorner().getY() - m_regValidRegion.getLowerCorner().getY() + 1; } //////////////////////////////////////////////////////////////////////////////// @@ -155,7 +155,7 @@ namespace PolyVox template int32_t Volume::getDepth(void) const { - return m_regValidRegion.getDepth(); + return m_regValidRegion.getUpperCorner().getZ() - m_regValidRegion.getLowerCorner().getZ() + 1; } //////////////////////////////////////////////////////////////////////////////// diff --git a/library/PolyVoxCore/source/Region.cpp b/library/PolyVoxCore/source/Region.cpp index d1155957..78a55a9d 100644 --- a/library/PolyVoxCore/source/Region.cpp +++ b/library/PolyVoxCore/source/Region.cpp @@ -50,14 +50,6 @@ namespace PolyVox assert(m_v3dUpperCorner.getZ() >= m_v3dLowerCorner.getZ()); } - uint32_t Region::getDepth(void) const - { - //We're returning the result as unsigned, so ensure that - //the upper value is at least as big as the lower value. - assert(m_v3dUpperCorner.getZ() >= m_v3dLowerCorner.getZ()); - return m_v3dUpperCorner.getZ() - m_v3dLowerCorner.getZ() + 1; - } - Vector3DUint32 Region::getDimensions(void) { //We're returning the result as unsigned, so ensure that @@ -68,14 +60,6 @@ namespace PolyVox return static_cast(m_v3dUpperCorner - m_v3dLowerCorner) + Vector3DUint32(1,1,1); } - uint32_t Region::getHeight(void) const - { - //We're returning the result as unsigned, so ensure that - //the upper value is at least as big as the lower value. - assert(m_v3dUpperCorner.getY() >= m_v3dLowerCorner.getY()); - return m_v3dUpperCorner.getY() - m_v3dLowerCorner.getY() + 1; - } - const Vector3DInt32& Region::getLowerCorner(void) const { return m_v3dLowerCorner; @@ -86,14 +70,6 @@ namespace PolyVox return m_v3dUpperCorner; } - uint32_t Region::getWidth(void) const - { - //We're returning the result as unsigned, so ensure that - //the upper value is at least as big as the lower value. - assert(m_v3dUpperCorner.getX() >= m_v3dLowerCorner.getX()); - return m_v3dUpperCorner.getX() - m_v3dLowerCorner.getX() + 1; - } - void Region::setLowerCorner(const Vector3DInt32& v3dLowerCorner) { m_v3dLowerCorner = v3dLowerCorner; diff --git a/tests/TestArray.cpp b/tests/TestArray.cpp index 1518ea39..fae1bea6 100644 --- a/tests/TestArray.cpp +++ b/tests/TestArray.cpp @@ -35,8 +35,7 @@ void TestArray::testReadWrite() int height = 10; int depth = 20; - uint32_t dimensions[3] = {width, height, depth}; // Array dimensions - Array<3, int> myArray(dimensions); + Array<3, int> myArray(ArraySizes(width)(height)(depth)); int ct = 1; int expectedTotal = 0;