From 5cab70b24cc6f7deedfc582fe02d83ea1f127134 Mon Sep 17 00:00:00 2001 From: David Williams Date: Mon, 4 Mar 2013 22:01:43 +0100 Subject: [PATCH] Fixed code to use proper zero initialisation. --- library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h | 6 +++--- library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl | 2 +- .../PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl | 4 ++-- .../PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h | 4 ++-- .../include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h | 4 ++-- library/PolyVoxCore/include/PolyVoxCore/Density.h | 3 --- library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h | 4 ++-- library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl | 2 +- .../include/PolyVoxCore/MarchingCubesSurfaceExtractor.h | 4 ++-- library/PolyVoxCore/include/PolyVoxCore/Material.h | 3 --- .../PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h | 4 ---- library/PolyVoxCore/include/PolyVoxCore/RawVolume.h | 4 ++-- library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl | 2 +- library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h | 4 ++-- library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl | 2 +- tests/TestSurfaceExtractor.cpp | 2 +- 16 files changed, 22 insertions(+), 32 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h index a7013746..f0e3f4ad 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.h @@ -69,7 +69,7 @@ namespace PolyVox void setPosition(const Vector3DInt32& v3dNewPos); void setPosition(int32_t xPos, int32_t yPos, int32_t zPos); inline bool setVoxel(VoxelType tValue); - void setWrapMode(WrapMode eWrapMode, VoxelType tBorder = VoxelType(0)); + void setWrapMode(WrapMode eWrapMode, VoxelType tBorder = VoxelType()); void movePositiveX(void); void movePositiveY(void); @@ -156,9 +156,9 @@ namespace PolyVox /// Gets a voxel at the position given by a 3D vector VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; /// Gets a voxel at the position given by x,y,z coordinates - VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const; + VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType()) const; /// Gets a voxel at the position given by a 3D vector - VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const; + VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType()) const; /// Sets the value used for voxels which are outside the volume void setBorderValue(const VoxelType& tBorder); diff --git a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl index 96c5ddf0..4a525440 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolume.inl @@ -31,7 +31,7 @@ namespace PolyVox template BaseVolume::BaseVolume(const Region& regValid) :m_regValidRegion(regValid) - ,m_tBorderValue(0) + ,m_tBorderValue() { } diff --git a/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl b/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl index ef136db8..a941dd8b 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/BaseVolumeSampler.inl @@ -33,7 +33,7 @@ namespace PolyVox ,mYPosInVolume(0) ,mZPosInVolume(0) ,m_eWrapMode(WrapModes::Border) - ,m_tBorder(0) + ,m_tBorder() ,m_bIsCurrentPositionValidInX(false) ,m_bIsCurrentPositionValidInY(false) ,m_bIsCurrentPositionValidInZ(false) @@ -376,7 +376,7 @@ namespace PolyVox { //Should never happen POLYVOX_ASSERT(false, "Invalid case."); - return VoxelType(0); + return VoxelType(); } } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h index b77c83c2..a225a3b5 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractor.h @@ -113,9 +113,9 @@ namespace PolyVox // This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template // Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC? #if defined(_MSC_VER) - CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(0), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); + CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); #else - CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(0), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); + CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), bool bMergeQuads = true, IsQuadNeeded isQuadNeeded = IsQuadNeeded()); #endif diff --git a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h index 138887cb..211734f0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h +++ b/library/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h @@ -39,9 +39,9 @@ namespace PolyVox // This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template // Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC? #if defined(_MSC_VER) - CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(0), IsQuadNeeded isQuadNeeded = IsQuadNeeded()); + CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), IsQuadNeeded isQuadNeeded = IsQuadNeeded()); #else - CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(0), IsQuadNeeded isQuadNeeded = IsQuadNeeded()); + CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), IsQuadNeeded isQuadNeeded = IsQuadNeeded()); #endif void execute(); diff --git a/library/PolyVoxCore/include/PolyVoxCore/Density.h b/library/PolyVoxCore/include/PolyVoxCore/Density.h index f44d8875..8869b094 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Density.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Density.h @@ -39,9 +39,6 @@ namespace PolyVox //////////////////////////////////////////////////////////////////////////////// /// Detailed description... //////////////////////////////////////////////////////////////////////////////// - - // int32_t template parameter is a dummy, required as the compiler expects to be able to declare an - // instance of VoxelType::MaterialType without knowing that VoxelType doesn't actually have a material. template class Density { diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h index 7b8316b2..adbe3d58 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.h @@ -275,9 +275,9 @@ namespace PolyVox /// Gets a voxel at the position given by a 3D vector VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; /// Gets a voxel at the position given by x,y,z coordinates - VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const; + VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType()) const; /// Gets a voxel at the position given by a 3D vector - VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const; + VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType()) const; /// Sets the number of blocks for which uncompressed data is stored void setMaxNumberOfUncompressedBlocks(uint32_t uMaxNumberOfUncompressedBlocks); diff --git a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl index e92bda05..d6f112d6 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/LargeVolume.inl @@ -229,7 +229,7 @@ namespace PolyVox { //Should never happen POLYVOX_ASSERT(false, "Invlaid case."); - return VoxelType(0); + return VoxelType(); } } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h index 094ed4c5..31803437 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h @@ -41,9 +41,9 @@ namespace PolyVox // This is a bit ugly - it seems that the C++03 syntax is different from the C++11 syntax? See this thread: http://stackoverflow.com/questions/6076015/typename-outside-of-template // Long term we should probably come back to this and if the #ifdef is still needed then maybe it should check for C++11 mode instead of MSVC? #if defined(_MSC_VER) - MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(0), Controller controller = Controller()); + MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = VolumeType::VoxelType(), Controller controller = Controller()); #else - MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(0), Controller controller = Controller()); + MarchingCubesSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh* result, WrapMode eWrapMode = WrapModes::Border, typename VolumeType::VoxelType tBorderValue = typename VolumeType::VoxelType(), Controller controller = Controller()); #endif void execute(); diff --git a/library/PolyVoxCore/include/PolyVoxCore/Material.h b/library/PolyVoxCore/include/PolyVoxCore/Material.h index b8b80b2e..86bfbc9a 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Material.h +++ b/library/PolyVoxCore/include/PolyVoxCore/Material.h @@ -36,9 +36,6 @@ namespace PolyVox /// /// \sa Density, MaterialDensityPair //////////////////////////////////////////////////////////////////////////////// - - // int32_t template parameter is a dummy, required as the compiler expects to be able to declare an - // instance of VoxelType::DensityType without knowing that VoxelType doesn't actually have a density. template class Material { diff --git a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h index 9ae3bca0..cdde07f7 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MaterialDensityPair.h @@ -42,10 +42,6 @@ namespace PolyVox { public: MaterialDensityPair() : m_uMaterial(0), m_uDensity(0) {} - - // FIXME - This is a bit odd... we need to allow the MaterialDensityPair to be initialised with a single integer - // because PolyVox often initialises voxels by calling VoxelType(0). Is there a better way we should handle this? - MaterialDensityPair(Type tValue) : m_uMaterial(tValue), m_uDensity(tValue) {} MaterialDensityPair(Type uMaterial, Type uDensity) : m_uMaterial(uMaterial), m_uDensity(uDensity) {} bool operator==(const MaterialDensityPair& rhs) const diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h index 07ae1b37..ed213fe2 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.h @@ -125,9 +125,9 @@ namespace PolyVox /// Gets a voxel at the position given by a 3D vector VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; /// Gets a voxel at the position given by x,y,z coordinates - VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const; + VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType()) const; /// Gets a voxel at the position given by a 3D vector - VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const; + VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType()) const; /// Sets the voxel at the position given by x,y,z coordinates bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue); diff --git a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl index 17e300e6..36023c5b 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl @@ -187,7 +187,7 @@ namespace PolyVox { //Should never happen POLYVOX_ASSERT(false, "Invalid case."); - return VoxelType(0); + return VoxelType(); } } } diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h index 896d5480..66f24cc3 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.h @@ -164,9 +164,9 @@ namespace PolyVox /// Gets a voxel at the position given by a 3D vector VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const; /// Gets a voxel at the position given by x,y,z coordinates - VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const; + VoxelType getVoxelWithWrapping(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType()) const; /// Gets a voxel at the position given by a 3D vector - VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType(0)) const; + VoxelType getVoxelWithWrapping(const Vector3DInt32& v3dPos, WrapMode eWrapMode = WrapModes::Border, VoxelType tBorder = VoxelType()) const; /// Sets the voxel at the position given by x,y,z coordinates bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue); diff --git a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl index 738ce7aa..b4750ca0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/SimpleVolume.inl @@ -187,7 +187,7 @@ namespace PolyVox { //Should never happen POLYVOX_ASSERT(false, "Invalid case."); - return VoxelType(0); + return VoxelType(); } } } diff --git a/tests/TestSurfaceExtractor.cpp b/tests/TestSurfaceExtractor.cpp index 80416eb4..45c0958a 100644 --- a/tests/TestSurfaceExtractor.cpp +++ b/tests/TestSurfaceExtractor.cpp @@ -122,7 +122,7 @@ void testForType(SurfaceMesh& result) DefaultMarchingCubesController controller; controller.setThreshold(50); - MarchingCubesSurfaceExtractor< SimpleVolume > extractor(&volData, volData.getEnclosingRegion(), &result, WrapModes::Border, 0, controller); + MarchingCubesSurfaceExtractor< SimpleVolume > extractor(&volData, volData.getEnclosingRegion(), &result, WrapModes::Border, VoxelType(), controller); extractor.execute(); }