From 5acbd012cf3c8b7e3ed99685b9ab649367e362fc Mon Sep 17 00:00:00 2001 From: David Williams Date: Mon, 30 Mar 2009 21:44:23 +0000 Subject: [PATCH] Switched to integer naming conventions from C++0x (e.g. uint16_t) --- .../OpenGL/OpenGLImmediateModeSupport.cpp | 6 +- examples/OpenGL/OpenGLSupport.cpp | 2 +- examples/OpenGL/OpenGLSupport.h | 2 +- .../OpenGLVertexBufferObjectSupport.cpp | 6 +- examples/OpenGL/OpenGLWidget.cpp | 26 +- examples/OpenGL/OpenGLWidget.h | 10 +- examples/OpenGL/Shapes.cpp | 4 +- examples/OpenGL/Shapes.h | 4 +- examples/OpenGL/main.cpp | 46 +-- library/include/PolyVoxCore/BlockData.h | 12 +- library/include/PolyVoxCore/BlockData.inl | 12 +- .../include/PolyVoxCore/GradientEstimators.h | 4 +- .../PolyVoxCore/GradientEstimators.inl | 18 +- .../include/PolyVoxCore/IndexedSurfacePatch.h | 18 +- .../PolyVoxCore/PolyVoxForwardDeclarations.h | 18 +- .../PolyVoxImpl/CPlusPlusZeroXSupport.h | 12 +- .../PolyVoxImpl/DecimatedSurfaceExtractor.h | 12 +- .../PolyVoxImpl/FastSurfaceExtractor.h | 12 +- .../PolyVoxImpl/ReferenceSurfaceExtractor.h | 6 +- library/include/PolyVoxCore/Region.h | 8 +- .../include/PolyVoxCore/SurfaceAdjusters.h | 4 +- .../include/PolyVoxCore/SurfaceExtractors.h | 4 +- library/include/PolyVoxCore/Utility.h | 4 +- library/include/PolyVoxCore/Vector.h | 28 +- library/include/PolyVoxCore/Vector.inl | 102 +++---- library/include/PolyVoxCore/Volume.h | 26 +- library/include/PolyVoxCore/Volume.inl | 44 +-- library/include/PolyVoxCore/VolumeIterator.h | 58 ++-- .../include/PolyVoxCore/VolumeIterator.inl | 30 +- library/include/PolyVoxCore/VoxelFilters.h | 2 +- library/include/PolyVoxUtil/Serialization.h | 8 +- .../include/PolyVoxUtil/VolumeChangeTracker.h | 32 +-- .../source/PolyVoxCore/GradientEstimators.cpp | 16 +- .../PolyVoxCore/IndexedSurfacePatch.cpp | 22 +- .../PolyVoxImpl/DecimatedSurfaceExtractor.cpp | 262 +++++++++--------- .../PolyVoxImpl/FastSurfaceExtractor.cpp | 252 ++++++++--------- .../PolyVoxImpl/ReferenceSurfaceExtractor.cpp | 70 ++--- library/source/PolyVoxCore/Region.cpp | 8 +- .../source/PolyVoxCore/SurfaceAdjusters.cpp | 20 +- .../source/PolyVoxCore/SurfaceExtractors.cpp | 4 +- library/source/PolyVoxCore/Utility.cpp | 8 +- library/source/PolyVoxCore/VoxelFilters.cpp | 2 +- library/source/PolyVoxUtil/Serialization.cpp | 102 +++---- .../PolyVoxUtil/VolumeChangeTracker.cpp | 76 ++--- 44 files changed, 711 insertions(+), 711 deletions(-) diff --git a/examples/OpenGL/OpenGLImmediateModeSupport.cpp b/examples/OpenGL/OpenGLImmediateModeSupport.cpp index d3a06d3c..4b1edde7 100644 --- a/examples/OpenGL/OpenGLImmediateModeSupport.cpp +++ b/examples/OpenGL/OpenGLImmediateModeSupport.cpp @@ -9,10 +9,10 @@ using namespace std; void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp) { const vector& vecVertices = isp.getVertices(); - const vector& vecIndices = isp.getIndices(); + const vector& vecIndices = isp.getIndices(); glBegin(GL_TRIANGLES); - for(vector::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex) + for(vector::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex) { const SurfaceVertex& vertex = vecVertices[*iterIndex]; const Vector3DFloat& v3dVertexPos = vertex.getPosition(); @@ -22,7 +22,7 @@ void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp) - uint8 material = vertex.getMaterial() + 0.5; + uint8_t material = vertex.getMaterial() + 0.5; OpenGLColour colour = convertMaterialIDToColour(material); diff --git a/examples/OpenGL/OpenGLSupport.cpp b/examples/OpenGL/OpenGLSupport.cpp index 2c3595dd..4d7b642c 100644 --- a/examples/OpenGL/OpenGLSupport.cpp +++ b/examples/OpenGL/OpenGLSupport.cpp @@ -2,7 +2,7 @@ using namespace PolyVox; -OpenGLColour convertMaterialIDToColour(PolyVox::uint8 materialID) +OpenGLColour convertMaterialIDToColour(PolyVox::uint8_t materialID) { OpenGLColour colour; diff --git a/examples/OpenGL/OpenGLSupport.h b/examples/OpenGL/OpenGLSupport.h index 5ecad4e1..d259b6dc 100644 --- a/examples/OpenGL/OpenGLSupport.h +++ b/examples/OpenGL/OpenGLSupport.h @@ -12,6 +12,6 @@ struct OpenGLColour GLfloat blue; }; -OpenGLColour convertMaterialIDToColour(PolyVox::uint8 materialID); +OpenGLColour convertMaterialIDToColour(PolyVox::uint8_t materialID); #endif //__OpenGLExample_OpenGLSupport_H__ \ No newline at end of file diff --git a/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp b/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp index 62695430..f5f16df3 100644 --- a/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp +++ b/examples/OpenGL/OpenGLVertexBufferObjectSupport.cpp @@ -13,7 +13,7 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp) //Convienient access to the vertices and indices const vector& vecVertices = isp.getVertices(); - const vector& vecIndices = isp.getIndices(); + const vector& vecIndices = isp.getIndices(); //If we have any indices... if(!vecIndices.empty()) @@ -26,7 +26,7 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp) GLvoid* pIndices = (GLvoid*)(&(vecIndices[0])); //Fill the OpenGL index buffer with our data. - glBufferData(GL_ELEMENT_ARRAY_BUFFER, vecIndices.size() * sizeof(uint32), pIndices, GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, vecIndices.size() * sizeof(uint32_t), pIndices, GL_STATIC_DRAW); } result.noOfIndices = vecIndices.size(); @@ -57,7 +57,7 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp) *ptr = vertex.getNormal().getZ(); ptr++; - uint8 material = vertex.getMaterial() + 0.5; + uint8_t material = vertex.getMaterial() + 0.5; OpenGLColour colour = convertMaterialIDToColour(material); diff --git a/examples/OpenGL/OpenGLWidget.cpp b/examples/OpenGL/OpenGLWidget.cpp index c7007b45..de923970 100644 --- a/examples/OpenGL/OpenGLWidget.cpp +++ b/examples/OpenGL/OpenGLWidget.cpp @@ -14,7 +14,7 @@ OpenGLWidget::OpenGLWidget(QWidget *parent) } -void OpenGLWidget::setVolume(PolyVox::Volume* volData) +void OpenGLWidget::setVolume(PolyVox::Volume* volData) { //First we free anything from the previous volume (if there was one). m_mapOpenGLSurfacePatches.clear(); @@ -26,11 +26,11 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) { //Our volume is broken down into cuboid regions, and we create one mesh for each region. //This three-level for loop iterates over each region. - for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) + for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) { - for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) + for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) { - for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) + for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) { //Create a new surface patch (which is basiaclly the PolyVox term for a mesh). IndexedSurfacePatch* ispCurrent = new IndexedSurfacePatch(); @@ -38,13 +38,13 @@ void OpenGLWidget::setVolume(PolyVox::Volume* volData) //Compute the extents of the current region //FIXME - This is a little complex? PolyVox could //provide more functions for dealing with regions? - uint16 regionStartX = uRegionX * g_uRegionSideLength; - uint16 regionStartY = uRegionY * g_uRegionSideLength; - uint16 regionStartZ = uRegionZ * g_uRegionSideLength; + uint16_t regionStartX = uRegionX * g_uRegionSideLength; + uint16_t regionStartY = uRegionY * g_uRegionSideLength; + uint16_t regionStartZ = uRegionZ * g_uRegionSideLength; - uint16 regionEndX = regionStartX + g_uRegionSideLength + 1; //Why do we need the '+1' here? - uint16 regionEndY = regionStartY + g_uRegionSideLength + 1; //Why do we need the '+1' here? - uint16 regionEndZ = regionStartZ + g_uRegionSideLength + 1; //Why do we need the '+1' here? + uint16_t regionEndX = regionStartX + g_uRegionSideLength + 1; //Why do we need the '+1' here? + uint16_t regionEndY = regionStartY + g_uRegionSideLength + 1; //Why do we need the '+1' here? + uint16_t regionEndZ = regionStartZ + g_uRegionSideLength + 1; //Why do we need the '+1' here? Vector3DInt32 regLowerCorner(regionStartX, regionStartY, regionStartZ); Vector3DInt32 regUpperCorner(regionEndX, regionEndY, regionEndZ); @@ -131,11 +131,11 @@ void OpenGLWidget::paintGL() //Centre the volume on the origin glTranslatef(-g_uVolumeSideLength/2,-g_uVolumeSideLength/2,-g_uVolumeSideLength/2); - for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) + for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) { - for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) + for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) { - for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) + for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) { Vector3DUint8 v3dRegPos(uRegionX,uRegionY,uRegionZ); if(m_bUseOpenGLVertexBufferObjects) diff --git a/examples/OpenGL/OpenGLWidget.h b/examples/OpenGL/OpenGLWidget.h index 0d6dddd6..8ebc525c 100644 --- a/examples/OpenGL/OpenGLWidget.h +++ b/examples/OpenGL/OpenGLWidget.h @@ -14,9 +14,9 @@ #include "OpenGLVertexBufferObjectSupport.h" #include "Shapes.h" -const PolyVox::uint16 g_uVolumeSideLength = 128; -const PolyVox::uint16 g_uRegionSideLength = 16; -const PolyVox::uint16 g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength; +const PolyVox::uint16_t g_uVolumeSideLength = 128; +const PolyVox::uint16_t g_uRegionSideLength = 16; +const PolyVox::uint16_t g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength; class OpenGLWidget : public QGLWidget { @@ -24,7 +24,7 @@ class OpenGLWidget : public QGLWidget public: OpenGLWidget(QWidget *parent); - void setVolume(PolyVox::Volume* volData); + void setVolume(PolyVox::Volume* volData); protected: void initializeGL(); @@ -36,7 +36,7 @@ class OpenGLWidget : public QGLWidget bool m_bUseOpenGLVertexBufferObjects; //Creates a volume 128x128x128 - PolyVox::Volume* m_volData; + PolyVox::Volume* m_volData; //Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region std::map m_mapOpenGLSurfacePatches; diff --git a/examples/OpenGL/Shapes.cpp b/examples/OpenGL/Shapes.cpp index 86ffb5a4..b898b19c 100644 --- a/examples/OpenGL/Shapes.cpp +++ b/examples/OpenGL/Shapes.cpp @@ -2,7 +2,7 @@ using namespace PolyVox; -void createSphereInVolume(Volume& volData, float fRadius, uint8 uValue) +void createSphereInVolume(Volume& volData, float fRadius, uint8_t uValue) { //This vector hold the position of the center of the volume Vector3DFloat v3dVolCenter(volData.getSideLength() / 2, volData.getSideLength() / 2, volData.getSideLength() / 2); @@ -30,7 +30,7 @@ void createSphereInVolume(Volume& volData, float fRadius, uint8 uValue) } } -void createCubeInVolume(Volume& volData, Vector3DUint16 lowerCorner, Vector3DUint16 upperCorner, uint8 uValue) +void createCubeInVolume(Volume& volData, Vector3DUint16 lowerCorner, Vector3DUint16 upperCorner, uint8_t uValue) { //This three-level for loop iterates over every voxel between the specified corners for (int z = lowerCorner.getZ(); z <= upperCorner.getZ(); z++) diff --git a/examples/OpenGL/Shapes.h b/examples/OpenGL/Shapes.h index 0e2a46eb..43df1fcf 100644 --- a/examples/OpenGL/Shapes.h +++ b/examples/OpenGL/Shapes.h @@ -3,7 +3,7 @@ #include "PolyVoxCore/Volume.h" -void createSphereInVolume(PolyVox::Volume& volData, float fRadius, PolyVox::uint8 uValue); -void createCubeInVolume(PolyVox::Volume& volData, PolyVox::Vector3DUint16 lowerCorner, PolyVox::Vector3DUint16 upperCorner, PolyVox::uint8 uValue); +void createSphereInVolume(PolyVox::Volume& volData, float fRadius, PolyVox::uint8_t uValue); +void createCubeInVolume(PolyVox::Volume& volData, PolyVox::Vector3DUint16 lowerCorner, PolyVox::Vector3DUint16 upperCorner, PolyVox::uint8_t uValue); #endif //__OpenGLExample_Shapes_H__ \ No newline at end of file diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index fa51a573..e824ade8 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -22,12 +22,12 @@ using namespace std; int main(int argc, char *argv[]) { - Volume volData(g_uVolumeSideLength); + Volume volData(g_uVolumeSideLength); //Make our volume contain a sphere in the center. - uint16 minPos = 0; - uint16 midPos = volData.getSideLength() / 2; - uint16 maxPos = volData.getSideLength() - 1; + uint16_t minPos = 0; + uint16_t midPos = volData.getSideLength() / 2; + uint16_t maxPos = volData.getSideLength() - 1; createCubeInVolume(volData, Vector3DUint16(minPos, minPos, minPos), Vector3DUint16(maxPos, maxPos, maxPos), 0); createSphereInVolume(volData, 50.0f, 5); @@ -72,9 +72,9 @@ using namespace std; //Global variables are easier for demonstration purposes, especially //as I'm not sure how/if I can pass variables to the GLUT functions. //Global variables are denoted by the 'g_' prefix -const uint16 g_uVolumeSideLength = 256; -const uint16 g_uRegionSideLength = 16; -const uint16 g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength; +const uint16_t g_uVolumeSideLength = 256; +const uint16_t g_uRegionSideLength = 16; +const uint16_t g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength; int g_xRotation = 0.0f; int g_yRotation = 0.0f; @@ -86,7 +86,7 @@ int g_frameCounter = 0; bool g_bUseOpenGLVertexBufferObjects; //Creates a volume 128x128x128 -Volume g_volData(g_uVolumeSideLength); +Volume g_volData(g_uVolumeSideLength); //Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region OpenGLSurfacePatch g_openGLSurfacePatches[g_uVolumeSideLengthInRegions][g_uVolumeSideLengthInRegions][g_uVolumeSideLengthInRegions]; @@ -133,11 +133,11 @@ void display ( void ) // Create The Display Function //Centre the volume on the origin glTranslatef(-g_uVolumeSideLength/2,-g_uVolumeSideLength/2,-g_uVolumeSideLength/2); - for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) + for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) { - for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) + for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) { - for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) + for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) { if(g_bUseOpenGLVertexBufferObjects) { @@ -254,9 +254,9 @@ void main ( int argc, char** argv ) // Create Main Function For Bringing It Al } //Make our volume contain a sphere in the center. - uint16 minPos = 0; - uint16 midPos = g_volData.getSideLength() / 2; - uint16 maxPos = g_volData.getSideLength() - 1; + uint16_t minPos = 0; + uint16_t midPos = g_volData.getSideLength() / 2; + uint16_t maxPos = g_volData.getSideLength() - 1; createCubeInVolume(g_volData, Vector3DUint16(minPos, minPos, minPos), Vector3DUint16(maxPos, maxPos, maxPos), 0); createSphereInVolume(g_volData, 50.0f, 5); @@ -272,11 +272,11 @@ void main ( int argc, char** argv ) // Create Main Function For Bringing It Al //Our volume is broken down into cuboid regions, and we create one mesh for each region. //This three-level for loop iterates over each region. - for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) + for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) { - for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) + for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) { - for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) + for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) { //Create a new surface patch (which is basiaclly the PolyVox term for a mesh). IndexedSurfacePatch* ispCurrent = new IndexedSurfacePatch(); @@ -284,13 +284,13 @@ void main ( int argc, char** argv ) // Create Main Function For Bringing It Al //Compute the extents of the current region //FIXME - This is a little complex? PolyVox could //provide more functions for dealing with regions? - uint16 regionStartX = uRegionX * g_uRegionSideLength; - uint16 regionStartY = uRegionY * g_uRegionSideLength; - uint16 regionStartZ = uRegionZ * g_uRegionSideLength; + uint16_t regionStartX = uRegionX * g_uRegionSideLength; + uint16_t regionStartY = uRegionY * g_uRegionSideLength; + uint16_t regionStartZ = uRegionZ * g_uRegionSideLength; - uint16 regionEndX = regionStartX + g_uRegionSideLength + 1; //Why do we need the '+1' here? - uint16 regionEndY = regionStartY + g_uRegionSideLength + 1; //Why do we need the '+1' here? - uint16 regionEndZ = regionStartZ + g_uRegionSideLength + 1; //Why do we need the '+1' here? + uint16_t regionEndX = regionStartX + g_uRegionSideLength + 1; //Why do we need the '+1' here? + uint16_t regionEndY = regionStartY + g_uRegionSideLength + 1; //Why do we need the '+1' here? + uint16_t regionEndZ = regionStartZ + g_uRegionSideLength + 1; //Why do we need the '+1' here? Vector3DInt32 regLowerCorner(regionStartX, regionStartY, regionStartZ); Vector3DInt32 regUpperCorner(regionEndX, regionEndY, regionEndZ); diff --git a/library/include/PolyVoxCore/BlockData.h b/library/include/PolyVoxCore/BlockData.h index 8eaf9abc..8ae30d47 100644 --- a/library/include/PolyVoxCore/BlockData.h +++ b/library/include/PolyVoxCore/BlockData.h @@ -36,25 +36,25 @@ namespace PolyVox //Make VolumeIterator a friend friend class VolumeIterator; public: - BlockData(uint8 uSideLength); + BlockData(uint8_t uSideLength); BlockData(const BlockData& rhs); ~BlockData(); BlockData& operator=(const BlockData& rhs); - uint16 getSideLength(void) const; - VoxelType getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const; + uint16_t getSideLength(void) const; + VoxelType getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const; VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const; - void setVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos, VoxelType tValue); + void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue); void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue); void fill(VoxelType tValue); bool isHomogeneous(void); private: - uint16 m_uSideLength; - uint8 m_uSideLengthPower; + uint16_t m_uSideLength; + uint8_t m_uSideLengthPower; VoxelType* m_tData; }; } diff --git a/library/include/PolyVoxCore/BlockData.inl b/library/include/PolyVoxCore/BlockData.inl index 7ca65bad..b65190a3 100644 --- a/library/include/PolyVoxCore/BlockData.inl +++ b/library/include/PolyVoxCore/BlockData.inl @@ -33,7 +33,7 @@ namespace PolyVox { #pragma region Constructors/Destructors template - BlockData::BlockData(uint8 uSideLength) + BlockData::BlockData(uint8_t uSideLength) :m_tData(0) { //Debug mode validation @@ -87,13 +87,13 @@ namespace PolyVox #pragma region Getters template - uint16 BlockData::getSideLength(void) const + uint16_t BlockData::getSideLength(void) const { return m_uSideLength; } template - VoxelType BlockData::getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const + VoxelType BlockData::getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const { assert(uXPos < m_uSideLength); assert(uYPos < m_uSideLength); @@ -116,7 +116,7 @@ namespace PolyVox #pragma region Setters template - void BlockData::setVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos, VoxelType tValue) + void BlockData::setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue) { assert(uXPos < m_uSideLength); assert(uYPos < m_uSideLength); @@ -150,8 +150,8 @@ namespace PolyVox VoxelType currentVoxel = m_tData; VoxelType firstVal = *currentVoxel; - uint32 uNoOfVoxels = m_uSideLength * m_uSideLength * m_uSideLength; - for(uint32 ct = 1; ct < uNoOfVoxels; ++ct) + uint32_t uNoOfVoxels = m_uSideLength * m_uSideLength * m_uSideLength; + for(uint32_t ct = 1; ct < uNoOfVoxels; ++ct) { ++currentVoxel; if(*currentVoxel != firstVal) diff --git a/library/include/PolyVoxCore/GradientEstimators.h b/library/include/PolyVoxCore/GradientEstimators.h index 3b9bb5d9..a7e05e88 100644 --- a/library/include/PolyVoxCore/GradientEstimators.h +++ b/library/include/PolyVoxCore/GradientEstimators.h @@ -42,8 +42,8 @@ namespace PolyVox template Vector3DFloat computeSmoothSobelGradient(VolumeIterator& volIter); - POLYVOX_API void computeNormalsForVertices(Volume* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod); - POLYVOX_API Vector3DFloat computeNormal(Volume* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod); + POLYVOX_API void computeNormalsForVertices(Volume* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod); + POLYVOX_API Vector3DFloat computeNormal(Volume* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod); } #include "GradientEstimators.inl" diff --git a/library/include/PolyVoxCore/GradientEstimators.inl b/library/include/PolyVoxCore/GradientEstimators.inl index d5680c15..d4770988 100644 --- a/library/include/PolyVoxCore/GradientEstimators.inl +++ b/library/include/PolyVoxCore/GradientEstimators.inl @@ -47,9 +47,9 @@ namespace PolyVox template Vector3DFloat computeDecimatedCentralDifferenceGradient(const VolumeIterator& volIter) { - const uint16 x = volIter.getPosX(); - const uint16 y = volIter.getPosY(); - const uint16 z = volIter.getPosZ(); + const uint16_t x = volIter.getPosX(); + const uint16_t y = volIter.getPosY(); + const uint16_t z = volIter.getPosZ(); //FIXME - bitwise way of doing this? VoxelType voxel1nx = volIter.getVoxelAt(x-2, y ,z ) > 0 ? 1: 0; @@ -72,9 +72,9 @@ namespace PolyVox template Vector3DFloat computeSmoothCentralDifferenceGradient(VolumeIterator& volIter) { - uint16 initialX = volIter.getPosX(); - uint16 initialY = volIter.getPosY(); - uint16 initialZ = volIter.getPosZ(); + uint16_t initialX = volIter.getPosX(); + uint16_t initialY = volIter.getPosY(); + uint16_t initialZ = volIter.getPosZ(); //FIXME - bitwise way of doing this? volIter.setPosition(initialX-1, initialY, initialZ); @@ -189,9 +189,9 @@ namespace PolyVox static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, { {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } }; - uint16 initialX = volIter.getPosX(); - uint16 initialY = volIter.getPosY(); - uint16 initialZ = volIter.getPosZ(); + uint16_t initialX = volIter.getPosX(); + uint16_t initialY = volIter.getPosY(); + uint16_t initialZ = volIter.getPosZ(); volIter.setPosition(initialX-1, initialY-1, initialZ-1); const float pVoxel1nx1ny1nz = computeSmoothedVoxel(volIter); volIter.setPosition(initialX-1, initialY-1, initialZ ); const float pVoxel1nx1ny0pz = computeSmoothedVoxel(volIter); diff --git a/library/include/PolyVoxCore/IndexedSurfacePatch.h b/library/include/PolyVoxCore/IndexedSurfacePatch.h index 3d45c83a..39556bb7 100644 --- a/library/include/PolyVoxCore/IndexedSurfacePatch.h +++ b/library/include/PolyVoxCore/IndexedSurfacePatch.h @@ -39,25 +39,25 @@ namespace PolyVox IndexedSurfacePatch(); ~IndexedSurfacePatch(); - const std::vector& getIndices(void) const; - uint32 getNoOfIndices(void) const; - uint32 getNoOfNonUniformTrianges(void) const; - uint32 getNoOfUniformTrianges(void) const; - uint32 getNoOfVertices(void) const; + const std::vector& getIndices(void) const; + uint32_t getNoOfIndices(void) const; + uint32_t getNoOfNonUniformTrianges(void) const; + uint32_t getNoOfUniformTrianges(void) const; + uint32_t getNoOfVertices(void) const; std::vector& getRawVertexData(void); //FIXME - this shoudl be removed const std::vector& getVertices(void) const; - void addTriangle(uint32 index0, uint32 index1, uint32 index2); - uint32 addVertex(const SurfaceVertex& vertex); + void addTriangle(uint32_t index0, uint32_t index1, uint32_t index2); + uint32_t addVertex(const SurfaceVertex& vertex); void clear(void); const bool isEmpty(void) const; Vector3DInt32 m_v3dRegionPosition; //FIXME - remove this? - int32 m_iTimeStamp; + int32_t m_iTimeStamp; private: - std::vector m_vecTriangleIndices; + std::vector m_vecTriangleIndices; std::vector m_vecVertices; }; diff --git a/library/include/PolyVoxCore/PolyVoxForwardDeclarations.h b/library/include/PolyVoxCore/PolyVoxForwardDeclarations.h index 3f8ff913..0face6b4 100644 --- a/library/include/PolyVoxCore/PolyVoxForwardDeclarations.h +++ b/library/include/PolyVoxCore/PolyVoxForwardDeclarations.h @@ -32,8 +32,8 @@ namespace PolyVox //---------- Volume ---------- template class Volume; typedef Volume FloatVolume; - typedef Volume UInt8Volume; - typedef Volume UInt16Volume; + typedef Volume UInt8Volume; + typedef Volume UInt16Volume; //--------------------------------- class IndexedSurfacePatch; @@ -42,15 +42,15 @@ namespace PolyVox class SurfaceVertex; //---------- Vector ---------- - template class Vector; + template class Vector; typedef Vector<3,float> Vector3DFloat; typedef Vector<3,double> Vector3DDouble; - typedef Vector<3,int8> Vector3DInt8; - typedef Vector<3,uint8> Vector3DUint8; - typedef Vector<3,int16> Vector3DInt16; - typedef Vector<3,uint16> Vector3DUint16; - typedef Vector<3,int32> Vector3DInt32; - typedef Vector<3,uint32> Vector3DUint32; + typedef Vector<3,int8_t> Vector3DInt8; + typedef Vector<3,uint8_t> Vector3DUint8; + typedef Vector<3,int16_t> Vector3DInt16; + typedef Vector<3,uint16_t> Vector3DUint16; + typedef Vector<3,int32_t> Vector3DInt32; + typedef Vector<3,uint32_t> Vector3DUint32; //---------------------------- template class VolumeIterator; diff --git a/library/include/PolyVoxCore/PolyVoxImpl/CPlusPlusZeroXSupport.h b/library/include/PolyVoxCore/PolyVoxImpl/CPlusPlusZeroXSupport.h index cdbded9a..476b9c34 100644 --- a/library/include/PolyVoxCore/PolyVoxImpl/CPlusPlusZeroXSupport.h +++ b/library/include/PolyVoxCore/PolyVoxImpl/CPlusPlusZeroXSupport.h @@ -28,12 +28,12 @@ //temporary work around until it's properly supported by C++ anyway... namespace PolyVox { - typedef POLYVOX_STD_NAMESPACE::int8_t int8; - typedef POLYVOX_STD_NAMESPACE::int16_t int16; - typedef POLYVOX_STD_NAMESPACE::int32_t int32; - typedef POLYVOX_STD_NAMESPACE::uint8_t uint8; - typedef POLYVOX_STD_NAMESPACE::uint16_t uint16; - typedef POLYVOX_STD_NAMESPACE::uint32_t uint32; + typedef POLYVOX_STD_NAMESPACE::int8_t int8_t; + typedef POLYVOX_STD_NAMESPACE::int16_t int16_t; + typedef POLYVOX_STD_NAMESPACE::int32_t int32_t; + typedef POLYVOX_STD_NAMESPACE::uint8_t uint8_t; + typedef POLYVOX_STD_NAMESPACE::uint16_t uint16_t; + typedef POLYVOX_STD_NAMESPACE::uint32_t uint32_t; } #endif \ No newline at end of file diff --git a/library/include/PolyVoxCore/PolyVoxImpl/DecimatedSurfaceExtractor.h b/library/include/PolyVoxCore/PolyVoxImpl/DecimatedSurfaceExtractor.h index 5fe9fc64..b0d8d4f0 100644 --- a/library/include/PolyVoxCore/PolyVoxImpl/DecimatedSurfaceExtractor.h +++ b/library/include/PolyVoxCore/PolyVoxImpl/DecimatedSurfaceExtractor.h @@ -32,13 +32,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - uint32 getDecimatedIndex(uint32 x, uint32 y, uint32 regionWidth); + uint32_t getDecimatedIndex(uint32_t x, uint32_t y, uint32_t regionWidth); - void extractDecimatedSurfaceImpl(Volume* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch); - uint32 computeInitialDecimatedBitmaskForSlice(VolumeIterator& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask); - uint32 computeDecimatedBitmaskForSliceFromPrevious(VolumeIterator& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask, uint8 *previousBitmask); - void generateDecimatedIndicesForSlice(VolumeIterator& volIter, uint8 uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]); - void generateDecimatedVerticesForSlice(VolumeIterator& volIter, uint8 uLevel, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]); + void extractDecimatedSurfaceImpl(Volume* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch); + uint32_t computeInitialDecimatedBitmaskForSlice(VolumeIterator& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t *bitmask); + uint32_t computeDecimatedBitmaskForSliceFromPrevious(VolumeIterator& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t *bitmask, uint8_t *previousBitmask); + void generateDecimatedIndicesForSlice(VolumeIterator& volIter, uint8_t uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8_t* bitmask0, uint8_t* bitmask1, int32_t vertexIndicesX0[],int32_t vertexIndicesY0[],int32_t vertexIndicesZ0[], int32_t vertexIndicesX1[],int32_t vertexIndicesY1[],int32_t vertexIndicesZ1[]); + void generateDecimatedVerticesForSlice(VolumeIterator& volIter, uint8_t uLevel, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32_t vertexIndicesX[],int32_t vertexIndicesY[],int32_t vertexIndicesZ[]); } #endif diff --git a/library/include/PolyVoxCore/PolyVoxImpl/FastSurfaceExtractor.h b/library/include/PolyVoxCore/PolyVoxImpl/FastSurfaceExtractor.h index e4c76b51..be09ac11 100644 --- a/library/include/PolyVoxCore/PolyVoxImpl/FastSurfaceExtractor.h +++ b/library/include/PolyVoxCore/PolyVoxImpl/FastSurfaceExtractor.h @@ -32,12 +32,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - void extractFastSurfaceImpl(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); - uint32 getIndex(uint32 x, uint32 y, uint32 regionWidth); - uint32 computeInitialRoughBitmaskForSlice(VolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask); - uint32 computeRoughBitmaskForSliceFromPrevious(VolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask, uint8 *previousBitmask); - void generateRoughIndicesForSlice(VolumeIterator& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]); - void generateRoughVerticesForSlice(VolumeIterator& volIter, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]); + void extractFastSurfaceImpl(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); + uint32_t getIndex(uint32_t x, uint32_t y, uint32_t regionWidth); + uint32_t computeInitialRoughBitmaskForSlice(VolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t *bitmask); + uint32_t computeRoughBitmaskForSliceFromPrevious(VolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t *bitmask, uint8_t *previousBitmask); + void generateRoughIndicesForSlice(VolumeIterator& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8_t* bitmask0, uint8_t* bitmask1, int32_t vertexIndicesX0[],int32_t vertexIndicesY0[],int32_t vertexIndicesZ0[], int32_t vertexIndicesX1[],int32_t vertexIndicesY1[],int32_t vertexIndicesZ1[]); + void generateRoughVerticesForSlice(VolumeIterator& volIter, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32_t vertexIndicesX[],int32_t vertexIndicesY[],int32_t vertexIndicesZ[]); } #endif diff --git a/library/include/PolyVoxCore/PolyVoxImpl/ReferenceSurfaceExtractor.h b/library/include/PolyVoxCore/PolyVoxImpl/ReferenceSurfaceExtractor.h index b8fa7ed9..75beb2b9 100644 --- a/library/include/PolyVoxCore/PolyVoxImpl/ReferenceSurfaceExtractor.h +++ b/library/include/PolyVoxCore/PolyVoxImpl/ReferenceSurfaceExtractor.h @@ -35,11 +35,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { ///A simple version of the surface extractor optimised for readability rather than speed. - void extractReferenceSurfaceImpl(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); //FIXME - should pass variables by reference? + void extractReferenceSurfaceImpl(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); //FIXME - should pass variables by reference? ///Determines whether a vertex already exists for a given edge, and if so returns it's index. - int32 getIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, const std::vector& vertexIndicesX, const std::vector& vertexIndicesY, const std::vector& vertexIndicesZ); + int32_t getIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, const std::vector& vertexIndicesX, const std::vector& vertexIndicesY, const std::vector& vertexIndicesZ); ///Sets the index of an existing vertex for a given edge. - void setIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, int32 newIndex, std::vector& vertexIndicesX, std::vector& vertexIndicesY, std::vector& vertexIndicesZ); + void setIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, int32_t newIndex, std::vector& vertexIndicesX, std::vector& vertexIndicesY, std::vector& vertexIndicesZ); } #endif \ No newline at end of file diff --git a/library/include/PolyVoxCore/Region.h b/library/include/PolyVoxCore/Region.h index 249e702c..7762402f 100644 --- a/library/include/PolyVoxCore/Region.h +++ b/library/include/PolyVoxCore/Region.h @@ -42,15 +42,15 @@ namespace PolyVox void setUpperCorner(const Vector3DInt32& v3dUpperCorner); bool containsPoint(const Vector3DFloat& pos, float boundary) const; - bool containsPoint(const Vector3DInt32& pos, uint8 boundary) const; + bool containsPoint(const Vector3DInt32& pos, uint8_t boundary) const; void cropTo(const Region& other); - int32 depth(void) const; - int32 height(void) const; + int32_t depth(void) const; + int32_t height(void) const; void shift(const Vector3DInt32& amount); void shiftLowerCorner(const Vector3DInt32& amount); void shiftUpperCorner(const Vector3DInt32& amount); Vector3DInt32 dimensions(void); - int32 width(void) const; + int32_t width(void) const; private: Vector3DInt32 m_v3dLowerCorner; diff --git a/library/include/PolyVoxCore/SurfaceAdjusters.h b/library/include/PolyVoxCore/SurfaceAdjusters.h index 86a752f1..6b88f31c 100644 --- a/library/include/PolyVoxCore/SurfaceAdjusters.h +++ b/library/include/PolyVoxCore/SurfaceAdjusters.h @@ -32,8 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - POLYVOX_API void smoothRegionGeometry(Volume* volumeData, IndexedSurfacePatch& isp); - POLYVOX_API void adjustDecimatedGeometry(Volume* volumeData, IndexedSurfacePatch& isp, uint8 val); + POLYVOX_API void smoothRegionGeometry(Volume* volumeData, IndexedSurfacePatch& isp); + POLYVOX_API void adjustDecimatedGeometry(Volume* volumeData, IndexedSurfacePatch& isp, uint8_t val); } #endif \ No newline at end of file diff --git a/library/include/PolyVoxCore/SurfaceExtractors.h b/library/include/PolyVoxCore/SurfaceExtractors.h index d1f8cf64..fe04b8f0 100644 --- a/library/include/PolyVoxCore/SurfaceExtractors.h +++ b/library/include/PolyVoxCore/SurfaceExtractors.h @@ -34,8 +34,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - POLYVOX_API void extractSurface(Volume* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch); - POLYVOX_API void extractReferenceSurface(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); + POLYVOX_API void extractSurface(Volume* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch); + POLYVOX_API void extractReferenceSurface(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); } #endif diff --git a/library/include/PolyVoxCore/Utility.h b/library/include/PolyVoxCore/Utility.h index 49996368..0cd81706 100644 --- a/library/include/PolyVoxCore/Utility.h +++ b/library/include/PolyVoxCore/Utility.h @@ -30,8 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - POLYVOX_API uint8 logBase2(uint32 uInput); - POLYVOX_API bool isPowerOf2(uint32 uInput); + POLYVOX_API uint8_t logBase2(uint32_t uInput); + POLYVOX_API bool isPowerOf2(uint32_t uInput); template Type trilinearlyInterpolate( diff --git a/library/include/PolyVoxCore/Vector.h b/library/include/PolyVoxCore/Vector.h index b9b358b0..5f750b79 100644 --- a/library/include/PolyVoxCore/Vector.h +++ b/library/include/PolyVoxCore/Vector.h @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { ///Represents a vector in space. - template + template class Vector { public: @@ -66,7 +66,7 @@ namespace PolyVox Vector& operator/=(const Type& rhs) throw(); ///Element Access. - Type getElement(uint32 index) const throw(); + Type getElement(uint32_t index) const throw(); ///Get the x component of the vector. Type getX(void) const throw(); ///Get the y component of the vector. @@ -77,7 +77,7 @@ namespace PolyVox Type getW(void) const throw(); ///Element Access. - void setElement(uint32 index, Type tValue) throw(); + void setElement(uint32_t index, Type tValue) throw(); ///Element Access. void setElements(Type x, Type y) throw(); ///Element Access. @@ -113,19 +113,19 @@ namespace PolyVox //Non-member overloaded operators. ///Addition operator. - template + template Vector operator+(const Vector& lhs, const Vector& rhs) throw(); ///Subtraction operator. - template + template Vector operator-(const Vector& lhs, const Vector& rhs) throw(); ///Multiplication operator. - template + template Vector operator*(const Vector& lhs, const Type& rhs) throw(); ///Division operator. - template + template Vector operator/(const Vector& lhs, const Type& rhs) throw(); ///Stream insertion operator. - template + template std::ostream& operator<<(std::ostream& os, const Vector& vector) throw(); //Some handy typedefs @@ -134,17 +134,17 @@ namespace PolyVox ///A 3D Vector of doubles. typedef Vector<3,double> Vector3DDouble; ///A 3D Vector of signed 8-bit values. - typedef Vector<3,int8> Vector3DInt8; + typedef Vector<3,int8_t> Vector3DInt8; ///A 3D Vector of unsigned 8-bit values. - typedef Vector<3,uint8> Vector3DUint8; + typedef Vector<3,uint8_t> Vector3DUint8; ///A 3D Vector of signed 16-bit values. - typedef Vector<3,int16> Vector3DInt16; + typedef Vector<3,int16_t> Vector3DInt16; ///A 3D Vector of unsigned 16-bit values. - typedef Vector<3,uint16> Vector3DUint16; + typedef Vector<3,uint16_t> Vector3DUint16; ///A 3D Vector of signed 32-bit values. - typedef Vector<3,int32> Vector3DInt32; + typedef Vector<3,int32_t> Vector3DInt32; ///A 3D Vector of unsigned 32-bit values. - typedef Vector<3,uint32> Vector3DUint32; + typedef Vector<3,uint32_t> Vector3DUint32; diff --git a/library/include/PolyVoxCore/Vector.inl b/library/include/PolyVoxCore/Vector.inl index 8d64ea5d..52657b9d 100644 --- a/library/include/PolyVoxCore/Vector.inl +++ b/library/include/PolyVoxCore/Vector.inl @@ -43,7 +43,7 @@ namespace PolyVox documented below - however often binary versions are also generated by std::operators. Lastly, note that for convienience a set of typedefs are included for 2 and 3 dimentionsal - vectors with type float, double, int32, and uint32. They are used as follows: + vectors with type float, double, int32_t, and uint32_t. They are used as follows: Vector2DInt4 test(1,2); //Declares a 2 dimensional Vector of type int4. */ @@ -55,7 +55,7 @@ namespace PolyVox \param x x component to set. \param y y component to set. */ - template + template Vector::Vector(Type x, Type y) throw() { m_tElements[0] = x; @@ -69,7 +69,7 @@ namespace PolyVox \param y y component to set. \param z z component to set. */ - template + template Vector::Vector(Type x, Type y, Type z) throw() { m_tElements[0] = x; @@ -85,7 +85,7 @@ namespace PolyVox \param z z component to set. \param w w component to set. */ - template + template Vector::Vector(Type x, Type y, Type z, Type w) throw() { m_tElements[0] = x; @@ -97,7 +97,7 @@ namespace PolyVox /** Creates a Vector object but does not initialise it. */ - template + template Vector::Vector(void) throw() { } @@ -106,7 +106,7 @@ namespace PolyVox Copy constructor builds object based on object passed as parameter. \param vector A reference to the Vector to be copied. */ - template + template Vector::Vector(const Vector& vector) throw() { std::memcpy(m_tElements, vector.m_tElements, sizeof(Type) * Size); @@ -121,11 +121,11 @@ namespace PolyVox \param vector A reference to the Vector to be copied. */ - template + template template Vector::Vector(const Vector& vector) throw() { - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { m_tElements[ct] = static_cast(vector.getElement(ct)); } @@ -134,7 +134,7 @@ namespace PolyVox /** Destroys the Vector. */ - template + template Vector::~Vector(void) throw() { } @@ -146,7 +146,7 @@ namespace PolyVox \param rhs Vector to assign to. \return A reference to the result to allow chaining. */ - template + template Vector& Vector::operator=(const Vector& rhs) throw() { if(this == &rhs) @@ -163,11 +163,11 @@ namespace PolyVox \return true if the Vectors match. \see operator!= */ - template + template inline bool Vector::operator==(const Vector &rhs) const throw() { bool equal = true; - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { if(m_tElements[ct] != rhs.m_tElements[ct]) { @@ -185,7 +185,7 @@ namespace PolyVox \return true if this is less than the parameter \see operator!= */ - template + template inline bool Vector::operator<(const Vector &rhs) const throw() { for(int ct = 0; ct < Size; ++ct) @@ -203,10 +203,10 @@ namespace PolyVox \param rhs Vector to add \return The resulting Vector. */ - template + template inline Vector& Vector::operator+=(const Vector& rhs) throw() { - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { m_tElements[ct] += rhs.m_tElements[ct]; } @@ -219,7 +219,7 @@ namespace PolyVox \param rhs Vector to add. \return The resulting Vector. */ - template + template Vector operator+(const Vector& lhs, const Vector& rhs) throw() { Vector result = lhs; @@ -232,10 +232,10 @@ namespace PolyVox \param rhs Vector to subtract \return The resulting Vector. */ - template + template inline Vector& Vector::operator-=(const Vector& rhs) throw() { - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { m_tElements[ct] -= rhs.m_tElements[ct]; } @@ -248,7 +248,7 @@ namespace PolyVox \param rhs Vector to subtract. \return The resulting Vector. */ - template + template Vector operator-(const Vector& lhs, const Vector& rhs) throw() { Vector result = lhs; @@ -261,10 +261,10 @@ namespace PolyVox \param rhs the number the Vector is multiplied by. \return The resulting Vector. */ - template + template inline Vector& Vector::operator*=(const Type& rhs) throw() { - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { m_tElements[ct] *= rhs; } @@ -277,7 +277,7 @@ namespace PolyVox \param rhs the number the Vector is multiplied by. \return The resulting Vector. */ - template + template Vector operator*(const Vector& lhs, const Type& rhs) throw() { Vector result = lhs; @@ -290,10 +290,10 @@ namespace PolyVox \param rhs the number the Vector is divided by. \return The resulting Vector. */ - template + template inline Vector& Vector::operator/=(const Type& rhs) throw() { - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { m_tElements[ct] /= rhs; } @@ -306,7 +306,7 @@ namespace PolyVox \param rhs the number the Vector is divided by. \return The resulting Vector. */ - template + template Vector operator/(const Vector& lhs, const Type& rhs) throw() { Vector result = lhs; @@ -320,11 +320,11 @@ namespace PolyVox \param vector The Vector to write to the stream. \return A reference to the output stream to allow chaining. */ - template + template std::ostream& operator<<(std::ostream& os, const Vector& vector) throw() { os << "("; - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { os << vector.getElement(ct); if(ct < (Size-1)) @@ -343,8 +343,8 @@ namespace PolyVox \param index The index of the element to return. \return The element. */ - template - inline Type Vector::getElement(uint32 index) const throw() + template + inline Type Vector::getElement(uint32_t index) const throw() { return m_tElements[index]; } @@ -352,7 +352,7 @@ namespace PolyVox /** \return A const reference to the X component of a 1, 2, 3, or 4 dimensional Vector. */ - template + template inline Type Vector::getX(void) const throw() { return m_tElements[0]; @@ -361,7 +361,7 @@ namespace PolyVox /** \return A const reference to the Y component of a 2, 3, or 4 dimensional Vector. */ - template + template inline Type Vector::getY(void) const throw() { return m_tElements[1]; @@ -370,7 +370,7 @@ namespace PolyVox /** \return A const reference to the Z component of a 3 or 4 dimensional Vector. */ - template + template inline Type Vector::getZ(void) const throw() { return m_tElements[2]; @@ -379,7 +379,7 @@ namespace PolyVox /** \return A const reference to the W component of a 4 dimensional Vector. */ - template + template inline Type Vector::getW(void) const throw() { return m_tElements[3]; @@ -391,8 +391,8 @@ namespace PolyVox \param index The index of the element to set. \param tValue The new value for the element. */ - template - inline void Vector::setElement(uint32 index, Type tValue) throw() + template + inline void Vector::setElement(uint32_t index, Type tValue) throw() { m_tElements[index] = tValue; } @@ -402,7 +402,7 @@ namespace PolyVox \param x x component to set. \param y y component to set. */ - template + template inline void Vector::setElements(Type x, Type y) throw() { m_tElements[0] = x; @@ -416,7 +416,7 @@ namespace PolyVox \param y y component to set. \param z z component to set. */ - template + template inline void Vector::setElements(Type x, Type y, Type z) throw() { m_tElements[0] = x; @@ -432,7 +432,7 @@ namespace PolyVox \param z z component to set. \param w w component to set. */ - template + template inline void Vector::setElements(Type x, Type y, Type z, Type w) throw() { m_tElements[0] = x; @@ -444,7 +444,7 @@ namespace PolyVox /** \param tX The new value for the X component of a 1, 2, 3, or 4 dimensional Vector. */ - template + template inline void Vector::setX(Type tX) throw() { m_tElements[0] = tX; @@ -453,7 +453,7 @@ namespace PolyVox /** \param tX The new value for the Y component of a 2, 3, or 4 dimensional Vector. */ - template + template inline void Vector::setY(Type tY) throw() { m_tElements[1] = tY; @@ -462,7 +462,7 @@ namespace PolyVox /** \param tX The new value for the Z component of a 3 or 4 dimensional Vector. */ - template + template inline void Vector::setZ(Type tZ) throw() { m_tElements[2] = tZ; @@ -471,7 +471,7 @@ namespace PolyVox /** \param tX The new value for the W component of a 4 dimensional Vector. */ - template + template inline void Vector::setW(Type tW) throw() { m_tElements[3] = tW; @@ -483,7 +483,7 @@ namespace PolyVox NOTE: This function does not make much sense on integer Vectors. \return Length of the Vector. */ - template + template inline double Vector::length(void) const throw() { return sqrt(lengthSquared()); @@ -492,11 +492,11 @@ namespace PolyVox /** \return Squared length of the Vector. */ - template + template inline double Vector::lengthSquared(void) const throw() { double result = 0.0f; - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { result += m_tElements[ct] * m_tElements[ct]; } @@ -512,7 +512,7 @@ namespace PolyVox \param Vector3D The Vector to find the angle to. \return The angle between them in radians. */ - template + template inline double Vector::angleTo(const Vector& vector) const throw() { return acos(dot(vector) / (vector.length() * this->length())); @@ -531,7 +531,7 @@ namespace PolyVox \return The value of the cross product. \see dot() */ - template + template inline Vector Vector::cross(const Vector& vector) const throw() { Type i = vector.getZ() * this->getY() - vector.getY() * this->getZ(); @@ -547,11 +547,11 @@ namespace PolyVox \return The value of the dot product. \see cross() */ - template + template inline Type Vector::dot(const Vector& rhs) const throw() { Type dotProduct = static_cast(0); - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { dotProduct += m_tElements[ct] * rhs.m_tElements[ct]; } @@ -563,7 +563,7 @@ namespace PolyVox NOTE: This function does not make much sense on integer Vectors. */ - template + template inline void Vector::normalise(void) throw() { double length = this->length(); @@ -572,7 +572,7 @@ namespace PolyVox { return; } - for(uint32 ct = 0; ct < Size; ++ct) + for(uint32_t ct = 0; ct < Size; ++ct) { m_tElements[ct] /= static_cast(length); } diff --git a/library/include/PolyVoxCore/Volume.h b/library/include/PolyVoxCore/Volume.h index 5bbd81a0..84880f64 100644 --- a/library/include/PolyVoxCore/Volume.h +++ b/library/include/PolyVoxCore/Volume.h @@ -49,22 +49,22 @@ namespace PolyVox friend class VolumeIterator; public: - Volume(uint16 uSideLength, uint16 uBlockSideLength = 64); + Volume(uint16_t uSideLength, uint16_t uBlockSideLength = 64); Volume(const Volume& rhs); ~Volume(); Volume& operator=(const Volume& rhs); Region getEnclosingRegion(void) const; - uint16 getSideLength(void) const; - VoxelType getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const; + uint16_t getSideLength(void) const; + VoxelType getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const; VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const; - void setVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos, VoxelType tValue); + void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue); void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue); VolumeIterator firstVoxel(void); - void idle(uint32 uAmount); + void idle(uint32_t uAmount); bool isRegionHomogenous(const Region& region); VolumeIterator lastVoxel(void); @@ -74,20 +74,20 @@ namespace PolyVox Block* m_pBlocks; mutable std::map > > m_pHomogenousBlockData; - uint32 m_uNoOfBlocksInVolume; - uint16 m_uSideLengthInBlocks; + uint32_t m_uNoOfBlocksInVolume; + uint16_t m_uSideLengthInBlocks; - uint8 m_uSideLengthPower; - uint16 m_uSideLength; + uint8_t m_uSideLengthPower; + uint16_t m_uSideLength; - uint8 m_uBlockSideLengthPower; - uint16 m_uBlockSideLength; + uint8_t m_uBlockSideLengthPower; + uint16_t m_uBlockSideLength; }; //Some handy typedefs typedef Volume FloatVolume; - typedef Volume UInt8Volume; - typedef Volume UInt16Volume; + typedef Volume UInt8Volume; + typedef Volume UInt16Volume; } #include "Volume.inl" diff --git a/library/include/PolyVoxCore/Volume.inl b/library/include/PolyVoxCore/Volume.inl index 05698bb6..3482767a 100644 --- a/library/include/PolyVoxCore/Volume.inl +++ b/library/include/PolyVoxCore/Volume.inl @@ -34,7 +34,7 @@ namespace PolyVox { #pragma region Constructors/Destructors template - Volume::Volume(uint16 uSideLength, uint16 uBlockSideLength) + Volume::Volume(uint16_t uSideLength, uint16_t uBlockSideLength) :m_pBlocks(0) { //Debug mode validation @@ -75,7 +75,7 @@ namespace PolyVox m_bIsShared = new bool[m_uNoOfBlocksInVolume]; m_bIsPotentiallySharable = new bool[m_uNoOfBlocksInVolume]; m_pHomogenousValue = new VoxelType[m_uNoOfBlocksInVolume]; - for(uint32 i = 0; i < m_uNoOfBlocksInVolume; ++i) + for(uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i) { m_pBlocks[i] = getHomogenousBlock(0); m_bIsShared[i] = true; @@ -84,7 +84,7 @@ namespace PolyVox }*/ m_pBlocks = new Block[m_uNoOfBlocksInVolume]; - for(uint32 i = 0; i < m_uNoOfBlocksInVolume; ++i) + for(uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i) { m_pBlocks[i].m_pBlockData = getHomogenousBlockData(0); m_pBlocks[i].m_bIsShared = true; @@ -102,7 +102,7 @@ namespace PolyVox template Volume::~Volume() { - /*for(uint32 i = 0; i < m_uNoOfBlocksInVolume; ++i) + /*for(uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i) { if(m_pBlocks[i].m_bIsShared == false) { @@ -133,25 +133,25 @@ namespace PolyVox } template - uint16 Volume::getSideLength(void) const + uint16_t Volume::getSideLength(void) const { return m_uSideLength; } template - VoxelType Volume::getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const + VoxelType Volume::getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const { assert(uXPos < getSideLength()); assert(uYPos < getSideLength()); assert(uZPos < getSideLength()); - const uint16 blockX = uXPos >> m_uBlockSideLengthPower; - const uint16 blockY = uYPos >> m_uBlockSideLengthPower; - const uint16 blockZ = uZPos >> m_uBlockSideLengthPower; + const uint16_t blockX = uXPos >> m_uBlockSideLengthPower; + const uint16_t blockY = uYPos >> m_uBlockSideLengthPower; + const uint16_t blockZ = uZPos >> m_uBlockSideLengthPower; - const uint16 xOffset = uXPos - (blockX << m_uBlockSideLengthPower); - const uint16 yOffset = uYPos - (blockY << m_uBlockSideLengthPower); - const uint16 zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); + const uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower); + const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower); + const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); const POLYVOX_SHARED_PTR< BlockData > block = m_pBlocks [ @@ -176,17 +176,17 @@ namespace PolyVox #pragma region Setters template - void Volume::setVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos, VoxelType tValue) + void Volume::setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue) { - const uint16 blockX = uXPos >> m_uBlockSideLengthPower; - const uint16 blockY = uYPos >> m_uBlockSideLengthPower; - const uint16 blockZ = uZPos >> m_uBlockSideLengthPower; + const uint16_t blockX = uXPos >> m_uBlockSideLengthPower; + const uint16_t blockY = uYPos >> m_uBlockSideLengthPower; + const uint16_t blockZ = uZPos >> m_uBlockSideLengthPower; - const uint16 xOffset = uXPos - (blockX << m_uBlockSideLengthPower); - const uint16 yOffset = uYPos - (blockY << m_uBlockSideLengthPower); - const uint16 zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); + const uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower); + const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower); + const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); - const uint32 uBlockIndex = + const uint32_t uBlockIndex = blockX + blockY * m_uSideLengthInBlocks + blockZ * m_uSideLengthInBlocks * m_uSideLengthInBlocks; @@ -230,14 +230,14 @@ namespace PolyVox } template - void Volume::idle(uint32 uAmount) + void Volume::idle(uint32_t uAmount) { //This function performs two roles. Firstly, it examines all of the blocks which are marked as //'potentially sharable' to determine whether they really are sharable or not. For those which //are sharable, it adjusts the pointer and deletes tho old data. Secondly, it determines which //homogeneous regions are not actually being used (by thier reference count) and frees them. - for(uint32 i = 0; i < m_uNoOfBlocksInVolume; ++i) + for(uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i) { Block block = m_pBlocks[i]; if(block.m_bIsPotentiallySharable) diff --git a/library/include/PolyVoxCore/VolumeIterator.h b/library/include/PolyVoxCore/VolumeIterator.h index 5685fd40..6e7cf9cd 100644 --- a/library/include/PolyVoxCore/VolumeIterator.h +++ b/library/include/PolyVoxCore/VolumeIterator.h @@ -43,17 +43,17 @@ namespace PolyVox bool operator<=(const VolumeIterator& rhs); bool operator>=(const VolumeIterator& rhs); - uint16 getPosX(void) const; - uint16 getPosY(void) const; - uint16 getPosZ(void) const; - VoxelType getSubSampledVoxel(uint8 uLevel) const; + uint16_t getPosX(void) const; + uint16_t getPosY(void) const; + uint16_t getPosZ(void) const; + VoxelType getSubSampledVoxel(uint8_t uLevel) const; const Volume& getVolume(void) const; VoxelType getVoxel(void) const; void setPosition(const Vector3DInt16& v3dNewPos); - void setPosition(uint16 xPos, uint16 yPos, uint16 zPos); + void setPosition(uint16_t xPos, uint16_t yPos, uint16_t zPos); void setValidRegion(const Region& region); - void setValidRegion(uint16 xFirst, uint16 yFirst, uint16 zFirst, uint16 xLast, uint16 yLast, uint16 zLast); + void setValidRegion(uint16_t xFirst, uint16_t yFirst, uint16_t zFirst, uint16_t xLast, uint16_t yLast, uint16_t zLast); bool isValidForRegion(void) const; void moveForwardInRegionFast(void); @@ -95,38 +95,38 @@ namespace PolyVox Volume& mVolume; //The current position in the volume - uint16 mXPosInVolume; - uint16 mYPosInVolume; - uint16 mZPosInVolume; + uint16_t mXPosInVolume; + uint16_t mYPosInVolume; + uint16_t mZPosInVolume; //The position of the current block - uint16 mXBlock; - uint16 mYBlock; - uint16 mZBlock; + uint16_t mXBlock; + uint16_t mYBlock; + uint16_t mZBlock; //The offset into the current block - uint16 mXPosInBlock; - uint16 mYPosInBlock; - uint16 mZPosInBlock; + uint16_t mXPosInBlock; + uint16_t mYPosInBlock; + uint16_t mZPosInBlock; //Other current position information VoxelType* mCurrentVoxel; - uint32 mBlockIndexInVolume; - uint32 mVoxelIndexInBlock; + uint32_t mBlockIndexInVolume; + uint32_t mVoxelIndexInBlock; - uint16 mXRegionFirst; - uint16 mYRegionFirst; - uint16 mZRegionFirst; - uint16 mXRegionLast; - uint16 mYRegionLast; - uint16 mZRegionLast; + uint16_t mXRegionFirst; + uint16_t mYRegionFirst; + uint16_t mZRegionFirst; + uint16_t mXRegionLast; + uint16_t mYRegionLast; + uint16_t mZRegionLast; - uint16 mXRegionFirstBlock; - uint16 mYRegionFirstBlock; - uint16 mZRegionFirstBlock; - uint16 mXRegionLastBlock; - uint16 mYRegionLastBlock; - uint16 mZRegionLastBlock; + uint16_t mXRegionFirstBlock; + uint16_t mYRegionFirstBlock; + uint16_t mZRegionFirstBlock; + uint16_t mXRegionLastBlock; + uint16_t mYRegionLastBlock; + uint16_t mZRegionLastBlock; bool mIsValidForRegion; }; diff --git a/library/include/PolyVoxCore/VolumeIterator.inl b/library/include/PolyVoxCore/VolumeIterator.inl index 39ec8496..9dc3ac4c 100644 --- a/library/include/PolyVoxCore/VolumeIterator.inl +++ b/library/include/PolyVoxCore/VolumeIterator.inl @@ -108,25 +108,25 @@ namespace PolyVox #pragma region Getters template - uint16 VolumeIterator::getPosX(void) const + uint16_t VolumeIterator::getPosX(void) const { return mXPosInVolume; } template - uint16 VolumeIterator::getPosY(void) const + uint16_t VolumeIterator::getPosY(void) const { return mYPosInVolume; } template - uint16 VolumeIterator::getPosZ(void) const + uint16_t VolumeIterator::getPosZ(void) const { return mZPosInVolume; } template - VoxelType VolumeIterator::getSubSampledVoxel(uint8 uLevel) const + VoxelType VolumeIterator::getSubSampledVoxel(uint8_t uLevel) const { if(uLevel == 0) { @@ -146,14 +146,14 @@ namespace PolyVox } else { - const uint8 uSize = 1 << uLevel; + const uint8_t uSize = 1 << uLevel; VoxelType tValue = std::numeric_limits::max(); - for(uint8 z = 0; z < uSize; ++z) + for(uint8_t z = 0; z < uSize; ++z) { - for(uint8 y = 0; y < uSize; ++y) + for(uint8_t y = 0; y < uSize; ++y) { - for(uint8 x = 0; x < uSize; ++x) + for(uint8_t x = 0; x < uSize; ++x) { tValue = (std::min)(tValue, mVolume.getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z)); } @@ -184,7 +184,7 @@ namespace PolyVox } template - void VolumeIterator::setPosition(uint16 xPos, uint16 yPos, uint16 zPos) + void VolumeIterator::setPosition(uint16_t xPos, uint16_t yPos, uint16_t zPos) { mXPosInVolume = xPos; mYPosInVolume = yPos; @@ -217,7 +217,7 @@ namespace PolyVox } template - void VolumeIterator::setValidRegion(uint16 xFirst, uint16 yFirst, uint16 zFirst, uint16 xLast, uint16 yLast, uint16 zLast) + void VolumeIterator::setValidRegion(uint16_t xFirst, uint16_t yFirst, uint16_t zFirst, uint16_t xLast, uint16_t yLast, uint16_t zLast) { mXRegionFirst = xFirst; mYRegionFirst = yFirst; @@ -252,7 +252,7 @@ namespace PolyVox mXPosInVolume++; if((mXPosInBlock == mVolume.m_uBlockSideLength) || (mXPosInVolume > mXRegionLast)) { - mXPosInVolume = (std::max)(mXRegionFirst,uint16(mXBlock * mVolume.m_uBlockSideLength)); + mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * mVolume.m_uBlockSideLength)); mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.m_uBlockSideLengthPower); mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * mVolume.m_uBlockSideLength + @@ -265,7 +265,7 @@ namespace PolyVox mCurrentVoxel += mVolume.m_uBlockSideLength; if((mYPosInBlock == mVolume.m_uBlockSideLength) || (mYPosInVolume > mYRegionLast)) { - mYPosInVolume = (std::max)(mYRegionFirst,uint16(mYBlock * mVolume.m_uBlockSideLength)); + mYPosInVolume = (std::max)(mYRegionFirst,uint16_t(mYBlock * mVolume.m_uBlockSideLength)); mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.m_uBlockSideLengthPower); mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * mVolume.m_uBlockSideLength + @@ -312,9 +312,9 @@ namespace PolyVox BlockData* currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; //mCurrentBlock = mVolume->m_pBlocks[mBlockIndexInVolume]; - mXPosInVolume = (std::max)(mXRegionFirst,uint16(mXBlock * mVolume.m_uBlockSideLength)); - mYPosInVolume = (std::max)(mYRegionFirst,uint16(mYBlock * mVolume.m_uBlockSideLength)); - mZPosInVolume = (std::max)(mZRegionFirst,uint16(mZBlock * mVolume.m_uBlockSideLength)); + mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * mVolume.m_uBlockSideLength)); + mYPosInVolume = (std::max)(mYRegionFirst,uint16_t(mYBlock * mVolume.m_uBlockSideLength)); + mZPosInVolume = (std::max)(mZRegionFirst,uint16_t(mZBlock * mVolume.m_uBlockSideLength)); mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.m_uBlockSideLengthPower); mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.m_uBlockSideLengthPower); diff --git a/library/include/PolyVoxCore/VoxelFilters.h b/library/include/PolyVoxCore/VoxelFilters.h index 79f1721c..ddfcd8b6 100644 --- a/library/include/PolyVoxCore/VoxelFilters.h +++ b/library/include/PolyVoxCore/VoxelFilters.h @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - float computeSmoothedVoxel(VolumeIterator& volIter); + float computeSmoothedVoxel(VolumeIterator& volIter); } #endif \ No newline at end of file diff --git a/library/include/PolyVoxUtil/Serialization.h b/library/include/PolyVoxUtil/Serialization.h index 60e85874..54f45eed 100644 --- a/library/include/PolyVoxUtil/Serialization.h +++ b/library/include/PolyVoxUtil/Serialization.h @@ -31,11 +31,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - POLYVOX_API Volume* loadVolumeRaw(std::istream& stream); - POLYVOX_API void saveVolumeRaw(std::ostream& stream, Volume& volume); + POLYVOX_API Volume* loadVolumeRaw(std::istream& stream); + POLYVOX_API void saveVolumeRaw(std::ostream& stream, Volume& volume); - POLYVOX_API Volume* loadVolumeRle(std::istream& stream); - POLYVOX_API void saveVolumeRle(std::ostream& stream, Volume& volume); + POLYVOX_API Volume* loadVolumeRle(std::istream& stream); + POLYVOX_API void saveVolumeRle(std::ostream& stream, Volume& volume); } #endif diff --git a/library/include/PolyVoxUtil/VolumeChangeTracker.h b/library/include/PolyVoxUtil/VolumeChangeTracker.h index bc1330b4..771bd9b6 100644 --- a/library/include/PolyVoxUtil/VolumeChangeTracker.h +++ b/library/include/PolyVoxUtil/VolumeChangeTracker.h @@ -36,43 +36,43 @@ namespace PolyVox { public: //Constructors, etc - VolumeChangeTracker(Volume* volumeDataToSet, uint16 regionSideLength); + VolumeChangeTracker(Volume* volumeDataToSet, uint16_t regionSideLength); ~VolumeChangeTracker(); //Getters - int32 getCurrentTime(void) const; + int32_t getCurrentTime(void) const; Region getEnclosingRegion(void) const; - int32 getLastModifiedTimeForRegion(uint16 uX, uint16 uY, uint16 uZ); - uint16 getSideLength(void); - Volume* getVolumeData(void) const; - uint8 getVoxelAt(const Vector3DUint16& pos); - uint8 getVoxelAt(uint16 uX, uint16 uY, uint16 uZ); + int32_t getLastModifiedTimeForRegion(uint16_t uX, uint16_t uY, uint16_t uZ); + uint16_t getSideLength(void); + Volume* getVolumeData(void) const; + uint8_t getVoxelAt(const Vector3DUint16& pos); + uint8_t getVoxelAt(uint16_t uX, uint16_t uY, uint16_t uZ); //Setters void setAllRegionsModified(void); - void setLockedVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value); - void setVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value); + void setLockedVoxelAt(uint16_t x, uint16_t y, uint16_t z, uint8_t value); + void setVoxelAt(uint16_t x, uint16_t y, uint16_t z, uint8_t value); //Others void lockRegion(const Region& regToLock); void unlockRegion(void); - //void markRegionChanged(uint16 firstX, uint16 firstY, uint16 firstZ, uint16 lastX, uint16 lastY, uint16 lastZ); + //void markRegionChanged(uint16_t firstX, uint16_t firstY, uint16_t firstZ, uint16_t lastX, uint16_t lastY, uint16_t lastZ); private: bool m_bIsLocked; Region m_regLastLocked; - Volume* volumeData; + Volume* volumeData; - uint16 m_uRegionSideLength; - uint8 m_uRegionSideLengthPower; - uint16 m_uVolumeSideLengthInRegions; + uint16_t m_uRegionSideLength; + uint8_t m_uRegionSideLengthPower; + uint16_t m_uVolumeSideLengthInRegions; //It's not what the block class was designed for, but it //provides a handy way of storing a 3D grid of values. - BlockData* volRegionLastModified; + BlockData* volRegionLastModified; - static int32 m_iCurrentTime; + static int32_t m_iCurrentTime; }; } diff --git a/library/source/PolyVoxCore/GradientEstimators.cpp b/library/source/PolyVoxCore/GradientEstimators.cpp index 8e927317..4b8c393f 100644 --- a/library/source/PolyVoxCore/GradientEstimators.cpp +++ b/library/source/PolyVoxCore/GradientEstimators.cpp @@ -6,7 +6,7 @@ using namespace std; namespace PolyVox { - POLYVOX_API void computeNormalsForVertices(Volume* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod) + POLYVOX_API void computeNormalsForVertices(Volume* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod) { std::vector& vecVertices = isp.getRawVertexData(); std::vector::iterator iterSurfaceVertex = vecVertices.begin(); @@ -15,7 +15,7 @@ namespace PolyVox const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast(isp.m_v3dRegionPosition); const Vector3DInt32 v3dFloor = static_cast(v3dPos); - VolumeIterator volIter(*volumeData); + VolumeIterator volIter(*volumeData); //Check all corners are within the volume, allowing a boundary for gradient estimation bool lowerCornerInside = volumeData->getEnclosingRegion().containsPoint(v3dFloor,2); @@ -37,11 +37,11 @@ namespace PolyVox } } - Vector3DFloat computeNormal(Volume* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod) + Vector3DFloat computeNormal(Volume* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod) { Vector3DFloat v3dGradient; //To store the result - VolumeIterator volIter(*volumeData); + VolumeIterator volIter(*volumeData); const Vector3DInt32 v3dFloor = static_cast(v3dPos); @@ -103,20 +103,20 @@ namespace PolyVox if(normalGenerationMethod == SIMPLE) { volIter.setPosition(static_cast(v3dFloor)); - const uint8 uFloor = volIter.getVoxel() > 0 ? 1 : 0; + const uint8_t uFloor = volIter.getVoxel() > 0 ? 1 : 0; if((v3dPos.getX() - v3dFloor.getX()) > 0.25) //The result should be 0.0 or 0.5 { - uint8 uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; + uint8_t uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; v3dGradient = Vector3DFloat(static_cast(uFloor - uCeil),0.0,0.0); } else if((v3dPos.getY() - v3dFloor.getY()) > 0.25) //The result should be 0.0 or 0.5 { - uint8 uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; + uint8_t uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; v3dGradient = Vector3DFloat(0.0,static_cast(uFloor - uCeil),0.0); } else if((v3dPos.getZ() - v3dFloor.getZ()) > 0.25) //The result should be 0.0 or 0.5 { - uint8 uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; + uint8_t uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; v3dGradient = Vector3DFloat(0.0, 0.0,static_cast(uFloor - uCeil)); } } diff --git a/library/source/PolyVoxCore/IndexedSurfacePatch.cpp b/library/source/PolyVoxCore/IndexedSurfacePatch.cpp index b6fba1f3..78f58dd9 100644 --- a/library/source/PolyVoxCore/IndexedSurfacePatch.cpp +++ b/library/source/PolyVoxCore/IndexedSurfacePatch.cpp @@ -34,20 +34,20 @@ namespace PolyVox { } - const std::vector& IndexedSurfacePatch::getIndices(void) const + const std::vector& IndexedSurfacePatch::getIndices(void) const { return m_vecTriangleIndices; } - uint32 IndexedSurfacePatch::getNoOfIndices(void) const + uint32_t IndexedSurfacePatch::getNoOfIndices(void) const { return m_vecTriangleIndices.size(); } - uint32 IndexedSurfacePatch::getNoOfNonUniformTrianges(void) const + uint32_t IndexedSurfacePatch::getNoOfNonUniformTrianges(void) const { - uint32 result = 0; - for(uint32 i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) + uint32_t result = 0; + for(uint32_t i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) { if((m_vecVertices[m_vecTriangleIndices[i]].getMaterial() == m_vecVertices[m_vecTriangleIndices[i+1]].getMaterial()) && (m_vecVertices[m_vecTriangleIndices[i]].getMaterial() == m_vecVertices[m_vecTriangleIndices[i+2]].getMaterial())) @@ -61,10 +61,10 @@ namespace PolyVox return result; } - uint32 IndexedSurfacePatch::getNoOfUniformTrianges(void) const + uint32_t IndexedSurfacePatch::getNoOfUniformTrianges(void) const { - uint32 result = 0; - for(uint32 i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) + uint32_t result = 0; + for(uint32_t i = 0; i < m_vecTriangleIndices.size() - 2; i += 3) { if((m_vecVertices[m_vecTriangleIndices[i]].getMaterial() == m_vecVertices[m_vecTriangleIndices[i+1]].getMaterial()) && (m_vecVertices[m_vecTriangleIndices[i]].getMaterial() == m_vecVertices[m_vecTriangleIndices[i+2]].getMaterial())) @@ -75,7 +75,7 @@ namespace PolyVox return result; } - uint32 IndexedSurfacePatch::getNoOfVertices(void) const + uint32_t IndexedSurfacePatch::getNoOfVertices(void) const { return m_vecVertices.size(); } @@ -90,14 +90,14 @@ namespace PolyVox return m_vecVertices; } - void IndexedSurfacePatch::addTriangle(uint32 index0, uint32 index1, uint32 index2) + void IndexedSurfacePatch::addTriangle(uint32_t index0, uint32_t index1, uint32_t index2) { m_vecTriangleIndices.push_back(index0); m_vecTriangleIndices.push_back(index1); m_vecTriangleIndices.push_back(index2); } - uint32 IndexedSurfacePatch::addVertex(const SurfaceVertex& vertex) + uint32_t IndexedSurfacePatch::addVertex(const SurfaceVertex& vertex) { m_vecVertices.push_back(vertex); return m_vecVertices.size() - 1; diff --git a/library/source/PolyVoxCore/PolyVoxImpl/DecimatedSurfaceExtractor.cpp b/library/source/PolyVoxCore/PolyVoxImpl/DecimatedSurfaceExtractor.cpp index 6db1c47e..c3749ce5 100644 --- a/library/source/PolyVoxCore/PolyVoxImpl/DecimatedSurfaceExtractor.cpp +++ b/library/source/PolyVoxCore/PolyVoxImpl/DecimatedSurfaceExtractor.cpp @@ -34,12 +34,12 @@ using namespace std; namespace PolyVox { - uint32 getDecimatedIndex(uint32 x, uint32 y , uint32 regionWidth) + uint32_t getDecimatedIndex(uint32_t x, uint32_t y , uint32_t regionWidth) { return x + (y * (regionWidth+1)); } - void extractDecimatedSurfaceImpl(Volume* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch) + void extractDecimatedSurfaceImpl(Volume* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch) { singleMaterialPatch->clear(); @@ -48,18 +48,18 @@ namespace PolyVox //FIXME - Instead of region.width()+2 we used to use POLYVOX_REGION_SIDE_LENGTH+1 //Normally POLYVOX_REGION_SIDE_LENGTH is the same as region.width() (often 32) but at the //edges of the volume it is 1 smaller. Need to think what values really belong here. - int32* vertexIndicesX0 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesY0 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesZ0 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesX1 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesY1 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesZ1 = new int32[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesX0 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesY0 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesZ0 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesX1 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesY1 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesZ1 = new int32_t[(region.width()+2) * (region.height()+2)]; //Cell bitmasks - uint8* bitmask0 = new uint8[(region.width()+2) * (region.height()+2)]; - uint8* bitmask1 = new uint8[(region.width()+2) * (region.height()+2)]; + uint8_t* bitmask0 = new uint8_t[(region.width()+2) * (region.height()+2)]; + uint8_t* bitmask1 = new uint8_t[(region.width()+2) * (region.height()+2)]; - const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; //When generating the mesh for a region we actually look outside it in the // back, bottom, right direction. Protect against access violations by cropping region here @@ -77,22 +77,22 @@ namespace PolyVox regSlice0.setUpperCorner(v3dUpperCorner); //Iterator to access the volume data - VolumeIterator volIter(*volumeData); + VolumeIterator volIter(*volumeData); //Compute bitmask for initial slice - uint32 uNoOfNonEmptyCellsForSlice0 = computeInitialDecimatedBitmaskForSlice(volIter, uLevel, regSlice0, offset, bitmask0); + uint32_t uNoOfNonEmptyCellsForSlice0 = computeInitialDecimatedBitmaskForSlice(volIter, uLevel, regSlice0, offset, bitmask0); if(uNoOfNonEmptyCellsForSlice0 != 0) { //If there were some non-empty cells then generate initial slice vertices for them generateDecimatedVerticesForSlice(volIter, uLevel, regSlice0, offset, bitmask0, singleMaterialPatch, vertexIndicesX0, vertexIndicesY0, vertexIndicesZ0); } - for(uint32 uSlice = 1; ((uSlice <= region.depth()) && (uSlice + offset.getZ() <= regVolume.getUpperCorner().getZ())); uSlice += uStepSize) + for(uint32_t uSlice = 1; ((uSlice <= region.depth()) && (uSlice + offset.getZ() <= regVolume.getUpperCorner().getZ())); uSlice += uStepSize) { Region regSlice1(regSlice0); regSlice1.shift(Vector3DInt32(0,0,uStepSize)); - uint32 uNoOfNonEmptyCellsForSlice1 = computeDecimatedBitmaskForSliceFromPrevious(volIter, uLevel, regSlice1, offset, bitmask1, bitmask0); + uint32_t uNoOfNonEmptyCellsForSlice1 = computeDecimatedBitmaskForSliceFromPrevious(volIter, uLevel, regSlice1, offset, bitmask1, bitmask0); if(uNoOfNonEmptyCellsForSlice1 != 0) { @@ -132,41 +132,41 @@ namespace PolyVox }*/ } - uint32 computeInitialDecimatedBitmaskForSlice(VolumeIterator& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask) + uint32_t computeInitialDecimatedBitmaskForSlice(VolumeIterator& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask) { - const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; - uint32 uNoOfNonEmptyCells = 0; + const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + uint32_t uNoOfNonEmptyCells = 0; //Iterate over each cell in the region - for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) + for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) { - for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) + for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) { //Current position volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8 iCubeIndex = 0; + uint8_t iCubeIndex = 0; if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY())) { volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()); - const uint8 v000 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v000 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()); - const uint8 v100 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v100 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8 v010 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v010 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8 v110 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v001 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v001 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v101 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v011 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v111 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); if (v000 == 0) iCubeIndex |= 1; if (v100 == 0) iCubeIndex |= 2; @@ -180,28 +180,28 @@ namespace PolyVox else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY()) { volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()); - const uint8 v100 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v100 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8 v110 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v101 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v111 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); //x - uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)]; - uint8 srcBit6 = iPreviousCubeIndexX & 64; - uint8 destBit7 = srcBit6 << 1; + uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)]; + uint8_t srcBit6 = iPreviousCubeIndexX & 64; + uint8_t destBit7 = srcBit6 << 1; - uint8 srcBit5 = iPreviousCubeIndexX & 32; - uint8 destBit4 = srcBit5 >> 1; + uint8_t srcBit5 = iPreviousCubeIndexX & 32; + uint8_t destBit4 = srcBit5 >> 1; - uint8 srcBit2 = iPreviousCubeIndexX & 4; - uint8 destBit3 = srcBit2 << 1; + uint8_t srcBit2 = iPreviousCubeIndexX & 4; + uint8_t destBit3 = srcBit2 << 1; - uint8 srcBit1 = iPreviousCubeIndexX & 2; - uint8 destBit0 = srcBit1 >> 1; + uint8_t srcBit1 = iPreviousCubeIndexX & 2; + uint8_t destBit0 = srcBit1 >> 1; iCubeIndex |= destBit0; if (v100 == 0) iCubeIndex |= 2; @@ -215,28 +215,28 @@ namespace PolyVox else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY())) { volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8 v010 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v010 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8 v110 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v011 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v111 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); //y - uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)]; - uint8 srcBit7 = iPreviousCubeIndexY & 128; - uint8 destBit4 = srcBit7 >> 3; + uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)]; + uint8_t srcBit7 = iPreviousCubeIndexY & 128; + uint8_t destBit4 = srcBit7 >> 3; - uint8 srcBit6 = iPreviousCubeIndexY & 64; - uint8 destBit5 = srcBit6 >> 1; + uint8_t srcBit6 = iPreviousCubeIndexY & 64; + uint8_t destBit5 = srcBit6 >> 1; - uint8 srcBit3 = iPreviousCubeIndexY & 8; - uint8 destBit0 = srcBit3 >> 3; + uint8_t srcBit3 = iPreviousCubeIndexY & 8; + uint8_t destBit0 = srcBit3 >> 3; - uint8 srcBit2 = iPreviousCubeIndexY & 4; - uint8 destBit1 = srcBit2 >> 1; + uint8_t srcBit2 = iPreviousCubeIndexY & 4; + uint8_t destBit1 = srcBit2 >> 1; iCubeIndex |= destBit0; iCubeIndex |= destBit1; @@ -250,32 +250,32 @@ namespace PolyVox else { volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8 v110 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v111 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); //y - uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)]; - uint8 srcBit7 = iPreviousCubeIndexY & 128; - uint8 destBit4 = srcBit7 >> 3; + uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)]; + uint8_t srcBit7 = iPreviousCubeIndexY & 128; + uint8_t destBit4 = srcBit7 >> 3; - uint8 srcBit6 = iPreviousCubeIndexY & 64; - uint8 destBit5 = srcBit6 >> 1; + uint8_t srcBit6 = iPreviousCubeIndexY & 64; + uint8_t destBit5 = srcBit6 >> 1; - uint8 srcBit3 = iPreviousCubeIndexY & 8; - uint8 destBit0 = srcBit3 >> 3; + uint8_t srcBit3 = iPreviousCubeIndexY & 8; + uint8_t destBit0 = srcBit3 >> 3; - uint8 srcBit2 = iPreviousCubeIndexY & 4; - uint8 destBit1 = srcBit2 >> 1; + uint8_t srcBit2 = iPreviousCubeIndexY & 4; + uint8_t destBit1 = srcBit2 >> 1; //x - uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)]; + uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)]; srcBit6 = iPreviousCubeIndexX & 64; - uint8 destBit7 = srcBit6 << 1; + uint8_t destBit7 = srcBit6 << 1; srcBit2 = iPreviousCubeIndexX & 4; - uint8 destBit3 = srcBit2 << 1; + uint8_t destBit3 = srcBit2 << 1; iCubeIndex |= destBit0; iCubeIndex |= destBit1; @@ -301,35 +301,35 @@ namespace PolyVox return uNoOfNonEmptyCells; } - uint32 computeDecimatedBitmaskForSliceFromPrevious(VolumeIterator& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, uint8* previousBitmask) + uint32_t computeDecimatedBitmaskForSliceFromPrevious(VolumeIterator& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, uint8_t* previousBitmask) { - const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; - uint32 uNoOfNonEmptyCells = 0; + const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + uint32_t uNoOfNonEmptyCells = 0; //Iterate over each cell in the region - for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) + for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) { - for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) + for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) { //Current position volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8 iCubeIndex = 0; + uint8_t iCubeIndex = 0; if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY())) { volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v001 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v001 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v101 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v011 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v111 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); //z - uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)]; + uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)]; iCubeIndex = iPreviousCubeIndexZ >> 4; if (v001 == 0) iCubeIndex |= 16; @@ -340,21 +340,21 @@ namespace PolyVox else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY()) { volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v101 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v111 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); //z - uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)]; + uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)]; iCubeIndex = iPreviousCubeIndexZ >> 4; //x - uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)]; - uint8 srcBit6 = iPreviousCubeIndexX & 64; - uint8 destBit7 = srcBit6 << 1; + uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)]; + uint8_t srcBit6 = iPreviousCubeIndexX & 64; + uint8_t destBit7 = srcBit6 << 1; - uint8 srcBit5 = iPreviousCubeIndexX & 32; - uint8 destBit4 = srcBit5 >> 1; + uint8_t srcBit5 = iPreviousCubeIndexX & 32; + uint8_t destBit4 = srcBit5 >> 1; iCubeIndex |= destBit4; if (v101 == 0) iCubeIndex |= 32; @@ -364,21 +364,21 @@ namespace PolyVox else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY())) { volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v011 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v111 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); //z - uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)]; + uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)]; iCubeIndex = iPreviousCubeIndexZ >> 4; //y - uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)]; - uint8 srcBit7 = iPreviousCubeIndexY & 128; - uint8 destBit4 = srcBit7 >> 3; + uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)]; + uint8_t srcBit7 = iPreviousCubeIndexY & 128; + uint8_t destBit4 = srcBit7 >> 3; - uint8 srcBit6 = iPreviousCubeIndexY & 64; - uint8 destBit5 = srcBit6 >> 1; + uint8_t srcBit6 = iPreviousCubeIndexY & 64; + uint8_t destBit5 = srcBit6 >> 1; iCubeIndex |= destBit4; iCubeIndex |= destBit5; @@ -388,24 +388,24 @@ namespace PolyVox else { volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8 v111 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); //z - uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)]; + uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)]; iCubeIndex = iPreviousCubeIndexZ >> 4; //y - uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)]; - uint8 srcBit7 = iPreviousCubeIndexY & 128; - uint8 destBit4 = srcBit7 >> 3; + uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)]; + uint8_t srcBit7 = iPreviousCubeIndexY & 128; + uint8_t destBit4 = srcBit7 >> 3; - uint8 srcBit6 = iPreviousCubeIndexY & 64; - uint8 destBit5 = srcBit6 >> 1; + uint8_t srcBit6 = iPreviousCubeIndexY & 64; + uint8_t destBit5 = srcBit6 >> 1; //x - uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)]; + uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)]; srcBit6 = iPreviousCubeIndexX & 64; - uint8 destBit7 = srcBit6 << 1; + uint8_t destBit7 = srcBit6 << 1; iCubeIndex |= destBit4; iCubeIndex |= destBit5; @@ -427,23 +427,23 @@ namespace PolyVox return uNoOfNonEmptyCells; } - void generateDecimatedVerticesForSlice(VolumeIterator& volIter, uint8 uLevel, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]) + void generateDecimatedVerticesForSlice(VolumeIterator& volIter, uint8_t uLevel, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32_t vertexIndicesX[],int32_t vertexIndicesY[],int32_t vertexIndicesZ[]) { - const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; //Iterate over each cell in the region - for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) + for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) { - for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) + for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) { //Current position - const uint16 z = regSlice.getLowerCorner().getZ(); + const uint16_t z = regSlice.getLowerCorner().getZ(); volIter.setPosition(x,y,z); - const uint8 v000 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v000 = volIter.getSubSampledVoxel(uLevel); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8 iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)]; + uint8_t iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)]; /* Cube is entirely in/out of the surface */ if (edgeTable[iCubeIndex] == 0) @@ -457,12 +457,12 @@ namespace PolyVox if(x != regSlice.getUpperCorner().getX()) { volIter.setPosition(x + uStepSize,y,z); - const uint8 v100 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v100 = volIter.getSubSampledVoxel(uLevel); const Vector3DFloat v3dPosition(x - offset.getX() + 0.5f * uStepSize, y - offset.getY(), z - offset.getZ()); const Vector3DFloat v3dNormal(v000 > v100 ? 1.0f : -1.0f,0.0,0.0); - const uint8 uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. + const uint8_t uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); - uint32 uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); + uint32_t uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); vertexIndicesX[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)] = uLastVertexIndex; } } @@ -471,12 +471,12 @@ namespace PolyVox if(y != regSlice.getUpperCorner().getY()) { volIter.setPosition(x,y + uStepSize,z); - const uint8 v010 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v010 = volIter.getSubSampledVoxel(uLevel); const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY() + 0.5f * uStepSize, z - offset.getZ()); const Vector3DFloat v3dNormal(0.0,v000 > v010 ? 1.0f : -1.0f,0.0); - const uint8 uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max. + const uint8_t uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max. SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); - uint32 uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); + uint32_t uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); vertexIndicesY[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)] = uLastVertexIndex; } } @@ -485,12 +485,12 @@ namespace PolyVox //if(z != regSlice.getUpperCorner.getZ()) { volIter.setPosition(x,y,z + uStepSize); - const uint8 v001 = volIter.getSubSampledVoxel(uLevel); + const uint8_t v001 = volIter.getSubSampledVoxel(uLevel); const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY(), z - offset.getZ() + 0.5f * uStepSize); const Vector3DFloat v3dNormal(0.0,0.0,v000 > v001 ? 1.0f : -1.0f); - const uint8 uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max. + const uint8_t uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max. const SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); - uint32 uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); + uint32_t uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); vertexIndicesZ[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)] = uLastVertexIndex; } } @@ -498,20 +498,20 @@ namespace PolyVox } } - void generateDecimatedIndicesForSlice(VolumeIterator& volIter, uint8 uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]) + void generateDecimatedIndicesForSlice(VolumeIterator& volIter, uint8_t uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8_t* bitmask0, uint8_t* bitmask1, int32_t vertexIndicesX0[],int32_t vertexIndicesY0[],int32_t vertexIndicesZ0[], int32_t vertexIndicesX1[],int32_t vertexIndicesY1[],int32_t vertexIndicesZ1[]) { - const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; - uint32 indlist[12]; + const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + uint32_t indlist[12]; - for(uint16 y = regSlice.getLowerCorner().getY() - offset.getY(); y < regSlice.getUpperCorner().getY() - offset.getY(); y += uStepSize) + for(uint16_t y = regSlice.getLowerCorner().getY() - offset.getY(); y < regSlice.getUpperCorner().getY() - offset.getY(); y += uStepSize) { - for(uint16 x = regSlice.getLowerCorner().getX() - offset.getX(); x < regSlice.getUpperCorner().getX() - offset.getX(); x += uStepSize) + for(uint16_t x = regSlice.getLowerCorner().getX() - offset.getX(); x < regSlice.getUpperCorner().getX() - offset.getX(); x += uStepSize) { //Current position - const uint16 z = regSlice.getLowerCorner().getZ() - offset.getZ(); + const uint16_t z = regSlice.getLowerCorner().getZ() - offset.getZ(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8 iCubeIndex = bitmask0[getDecimatedIndex(x,y, regSlice.width()+1)]; + uint8_t iCubeIndex = bitmask0[getDecimatedIndex(x,y, regSlice.width()+1)]; /* Cube is entirely in/out of the surface */ if (edgeTable[iCubeIndex] == 0) @@ -583,9 +583,9 @@ namespace PolyVox for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3) { - uint32 ind0 = indlist[triTable[iCubeIndex][i ]]; - uint32 ind1 = indlist[triTable[iCubeIndex][i+1]]; - uint32 ind2 = indlist[triTable[iCubeIndex][i+2]]; + uint32_t ind0 = indlist[triTable[iCubeIndex][i ]]; + uint32_t ind1 = indlist[triTable[iCubeIndex][i+1]]; + uint32_t ind2 = indlist[triTable[iCubeIndex][i+2]]; singleMaterialPatch->addTriangle(ind0, ind1, ind2); }//For each triangle diff --git a/library/source/PolyVoxCore/PolyVoxImpl/FastSurfaceExtractor.cpp b/library/source/PolyVoxCore/PolyVoxImpl/FastSurfaceExtractor.cpp index 4152dbc7..acd16ac2 100644 --- a/library/source/PolyVoxCore/PolyVoxImpl/FastSurfaceExtractor.cpp +++ b/library/source/PolyVoxCore/PolyVoxImpl/FastSurfaceExtractor.cpp @@ -29,21 +29,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - void extractFastSurfaceImpl(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) + void extractFastSurfaceImpl(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) { singleMaterialPatch->clear(); //For edge indices - int32* vertexIndicesX0 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesY0 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesZ0 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesX1 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesY1 = new int32[(region.width()+2) * (region.height()+2)]; - int32* vertexIndicesZ1 = new int32[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesX0 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesY0 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesZ0 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesX1 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesY1 = new int32_t[(region.width()+2) * (region.height()+2)]; + int32_t* vertexIndicesZ1 = new int32_t[(region.width()+2) * (region.height()+2)]; //Cell bitmasks - uint8* bitmask0 = new uint8[(region.width()+2) * (region.height()+2)]; - uint8* bitmask1 = new uint8[(region.width()+2) * (region.height()+2)]; + uint8_t* bitmask0 = new uint8_t[(region.width()+2) * (region.height()+2)]; + uint8_t* bitmask1 = new uint8_t[(region.width()+2) * (region.height()+2)]; //When generating the mesh for a region we actually look one voxel outside it in the // back, bottom, right direction. Protect against access violations by cropping region here @@ -59,22 +59,22 @@ namespace PolyVox regSlice0.setUpperCorner(Vector3DInt32(regSlice0.getUpperCorner().getX(),regSlice0.getUpperCorner().getY(),regSlice0.getLowerCorner().getZ())); //Iterator to access the volume data - VolumeIterator volIter(*volumeData); + VolumeIterator volIter(*volumeData); //Compute bitmask for initial slice - uint32 uNoOfNonEmptyCellsForSlice0 = computeInitialRoughBitmaskForSlice(volIter, regSlice0, offset, bitmask0); + uint32_t uNoOfNonEmptyCellsForSlice0 = computeInitialRoughBitmaskForSlice(volIter, regSlice0, offset, bitmask0); if(uNoOfNonEmptyCellsForSlice0 != 0) { //If there were some non-empty cells then generate initial slice vertices for them generateRoughVerticesForSlice(volIter,regSlice0, offset, bitmask0, singleMaterialPatch, vertexIndicesX0, vertexIndicesY0, vertexIndicesZ0); } - for(uint32 uSlice = 0; ((uSlice <= region.depth()-1) && (uSlice + offset.getZ() < region.getUpperCorner().getZ())); ++uSlice) + for(uint32_t uSlice = 0; ((uSlice <= region.depth()-1) && (uSlice + offset.getZ() < region.getUpperCorner().getZ())); ++uSlice) { Region regSlice1(regSlice0); regSlice1.shift(Vector3DInt32(0,0,1)); - uint32 uNoOfNonEmptyCellsForSlice1 = computeRoughBitmaskForSliceFromPrevious(volIter, regSlice1, offset, bitmask1, bitmask0); + uint32_t uNoOfNonEmptyCellsForSlice1 = computeRoughBitmaskForSliceFromPrevious(volIter, regSlice1, offset, bitmask1, bitmask0); if(uNoOfNonEmptyCellsForSlice1 != 0) { @@ -105,14 +105,14 @@ namespace PolyVox delete[] vertexIndicesZ1; } - uint32 getIndex(uint32 x, uint32 y, uint32 regionWidth) + uint32_t getIndex(uint32_t x, uint32_t y, uint32_t regionWidth) { return x + (y * (regionWidth+1)); } - uint32 computeInitialRoughBitmaskForSlice(VolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask) + uint32_t computeInitialRoughBitmaskForSlice(VolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask) { - uint32 uNoOfNonEmptyCells = 0; + uint32_t uNoOfNonEmptyCells = 0; //Iterate over each cell in the region volIter.setPosition(regSlice.getLowerCorner().getX(),regSlice.getLowerCorner().getY(), regSlice.getLowerCorner().getZ()); @@ -120,23 +120,23 @@ namespace PolyVox do { //Current position - const uint16 x = volIter.getPosX() - offset.getX(); - const uint16 y = volIter.getPosY() - offset.getY(); + const uint16_t x = volIter.getPosX() - offset.getX(); + const uint16_t y = volIter.getPosY() - offset.getY(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8 iCubeIndex = 0; + uint8_t iCubeIndex = 0; if((x==0) && (y==0)) { - const uint8 v000 = volIter.getVoxel(); - const uint8 v100 = volIter.peekVoxel1px0py0pz(); - const uint8 v010 = volIter.peekVoxel0px1py0pz(); - const uint8 v110 = volIter.peekVoxel1px1py0pz(); + const uint8_t v000 = volIter.getVoxel(); + const uint8_t v100 = volIter.peekVoxel1px0py0pz(); + const uint8_t v010 = volIter.peekVoxel0px1py0pz(); + const uint8_t v110 = volIter.peekVoxel1px1py0pz(); - const uint8 v001 = volIter.peekVoxel0px0py1pz(); - const uint8 v101 = volIter.peekVoxel1px0py1pz(); - const uint8 v011 = volIter.peekVoxel0px1py1pz(); - const uint8 v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v001 = volIter.peekVoxel0px0py1pz(); + const uint8_t v101 = volIter.peekVoxel1px0py1pz(); + const uint8_t v011 = volIter.peekVoxel0px1py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); if (v000 == 0) iCubeIndex |= 1; if (v100 == 0) iCubeIndex |= 2; @@ -149,25 +149,25 @@ namespace PolyVox } else if((x>0) && y==0) { - const uint8 v100 = volIter.peekVoxel1px0py0pz(); - const uint8 v110 = volIter.peekVoxel1px1py0pz(); + const uint8_t v100 = volIter.peekVoxel1px0py0pz(); + const uint8_t v110 = volIter.peekVoxel1px1py0pz(); - const uint8 v101 = volIter.peekVoxel1px0py1pz(); - const uint8 v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v101 = volIter.peekVoxel1px0py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); //x - uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y, regSlice.width()+1)]; - uint8 srcBit6 = iPreviousCubeIndexX & 64; - uint8 destBit7 = srcBit6 << 1; + uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y, regSlice.width()+1)]; + uint8_t srcBit6 = iPreviousCubeIndexX & 64; + uint8_t destBit7 = srcBit6 << 1; - uint8 srcBit5 = iPreviousCubeIndexX & 32; - uint8 destBit4 = srcBit5 >> 1; + uint8_t srcBit5 = iPreviousCubeIndexX & 32; + uint8_t destBit4 = srcBit5 >> 1; - uint8 srcBit2 = iPreviousCubeIndexX & 4; - uint8 destBit3 = srcBit2 << 1; + uint8_t srcBit2 = iPreviousCubeIndexX & 4; + uint8_t destBit3 = srcBit2 << 1; - uint8 srcBit1 = iPreviousCubeIndexX & 2; - uint8 destBit0 = srcBit1 >> 1; + uint8_t srcBit1 = iPreviousCubeIndexX & 2; + uint8_t destBit0 = srcBit1 >> 1; iCubeIndex |= destBit0; if (v100 == 0) iCubeIndex |= 2; @@ -180,25 +180,25 @@ namespace PolyVox } else if((x==0) && (y>0)) { - const uint8 v010 = volIter.peekVoxel0px1py0pz(); - const uint8 v110 = volIter.peekVoxel1px1py0pz(); + const uint8_t v010 = volIter.peekVoxel0px1py0pz(); + const uint8_t v110 = volIter.peekVoxel1px1py0pz(); - const uint8 v011 = volIter.peekVoxel0px1py1pz(); - const uint8 v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v011 = volIter.peekVoxel0px1py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); //y - uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1, regSlice.width()+1)]; - uint8 srcBit7 = iPreviousCubeIndexY & 128; - uint8 destBit4 = srcBit7 >> 3; + uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1, regSlice.width()+1)]; + uint8_t srcBit7 = iPreviousCubeIndexY & 128; + uint8_t destBit4 = srcBit7 >> 3; - uint8 srcBit6 = iPreviousCubeIndexY & 64; - uint8 destBit5 = srcBit6 >> 1; + uint8_t srcBit6 = iPreviousCubeIndexY & 64; + uint8_t destBit5 = srcBit6 >> 1; - uint8 srcBit3 = iPreviousCubeIndexY & 8; - uint8 destBit0 = srcBit3 >> 3; + uint8_t srcBit3 = iPreviousCubeIndexY & 8; + uint8_t destBit0 = srcBit3 >> 3; - uint8 srcBit2 = iPreviousCubeIndexY & 4; - uint8 destBit1 = srcBit2 >> 1; + uint8_t srcBit2 = iPreviousCubeIndexY & 4; + uint8_t destBit1 = srcBit2 >> 1; iCubeIndex |= destBit0; iCubeIndex |= destBit1; @@ -211,31 +211,31 @@ namespace PolyVox } else { - const uint8 v110 = volIter.peekVoxel1px1py0pz(); + const uint8_t v110 = volIter.peekVoxel1px1py0pz(); - const uint8 v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); //y - uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1, regSlice.width()+1)]; - uint8 srcBit7 = iPreviousCubeIndexY & 128; - uint8 destBit4 = srcBit7 >> 3; + uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1, regSlice.width()+1)]; + uint8_t srcBit7 = iPreviousCubeIndexY & 128; + uint8_t destBit4 = srcBit7 >> 3; - uint8 srcBit6 = iPreviousCubeIndexY & 64; - uint8 destBit5 = srcBit6 >> 1; + uint8_t srcBit6 = iPreviousCubeIndexY & 64; + uint8_t destBit5 = srcBit6 >> 1; - uint8 srcBit3 = iPreviousCubeIndexY & 8; - uint8 destBit0 = srcBit3 >> 3; + uint8_t srcBit3 = iPreviousCubeIndexY & 8; + uint8_t destBit0 = srcBit3 >> 3; - uint8 srcBit2 = iPreviousCubeIndexY & 4; - uint8 destBit1 = srcBit2 >> 1; + uint8_t srcBit2 = iPreviousCubeIndexY & 4; + uint8_t destBit1 = srcBit2 >> 1; //x - uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y, regSlice.width()+1)]; + uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y, regSlice.width()+1)]; srcBit6 = iPreviousCubeIndexX & 64; - uint8 destBit7 = srcBit6 << 1; + uint8_t destBit7 = srcBit6 << 1; srcBit2 = iPreviousCubeIndexX & 4; - uint8 destBit3 = srcBit2 << 1; + uint8_t destBit3 = srcBit2 << 1; iCubeIndex |= destBit0; iCubeIndex |= destBit1; @@ -260,9 +260,9 @@ namespace PolyVox return uNoOfNonEmptyCells; } - uint32 computeRoughBitmaskForSliceFromPrevious(VolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, uint8* previousBitmask) + uint32_t computeRoughBitmaskForSliceFromPrevious(VolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, uint8_t* previousBitmask) { - uint32 uNoOfNonEmptyCells = 0; + uint32_t uNoOfNonEmptyCells = 0; //Iterate over each cell in the region volIter.setPosition(regSlice.getLowerCorner().getX(),regSlice.getLowerCorner().getY(), regSlice.getLowerCorner().getZ()); @@ -270,21 +270,21 @@ namespace PolyVox do { //Current position - const uint16 x = volIter.getPosX() - offset.getX(); - const uint16 y = volIter.getPosY() - offset.getY(); + const uint16_t x = volIter.getPosX() - offset.getX(); + const uint16_t y = volIter.getPosY() - offset.getY(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8 iCubeIndex = 0; + uint8_t iCubeIndex = 0; if((x==0) && (y==0)) { - const uint8 v001 = volIter.peekVoxel0px0py1pz(); - const uint8 v101 = volIter.peekVoxel1px0py1pz(); - const uint8 v011 = volIter.peekVoxel0px1py1pz(); - const uint8 v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v001 = volIter.peekVoxel0px0py1pz(); + const uint8_t v101 = volIter.peekVoxel1px0py1pz(); + const uint8_t v011 = volIter.peekVoxel0px1py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); //z - uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y, regSlice.width()+1)]; + uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y, regSlice.width()+1)]; iCubeIndex = iPreviousCubeIndexZ >> 4; if (v001 == 0) iCubeIndex |= 16; @@ -294,20 +294,20 @@ namespace PolyVox } else if((x>0) && y==0) { - const uint8 v101 = volIter.peekVoxel1px0py1pz(); - const uint8 v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v101 = volIter.peekVoxel1px0py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); //z - uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y, regSlice.width()+1)]; + uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y, regSlice.width()+1)]; iCubeIndex = iPreviousCubeIndexZ >> 4; //x - uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y, regSlice.width()+1)]; - uint8 srcBit6 = iPreviousCubeIndexX & 64; - uint8 destBit7 = srcBit6 << 1; + uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y, regSlice.width()+1)]; + uint8_t srcBit6 = iPreviousCubeIndexX & 64; + uint8_t destBit7 = srcBit6 << 1; - uint8 srcBit5 = iPreviousCubeIndexX & 32; - uint8 destBit4 = srcBit5 >> 1; + uint8_t srcBit5 = iPreviousCubeIndexX & 32; + uint8_t destBit4 = srcBit5 >> 1; iCubeIndex |= destBit4; if (v101 == 0) iCubeIndex |= 32; @@ -316,20 +316,20 @@ namespace PolyVox } else if((x==0) && (y>0)) { - const uint8 v011 = volIter.peekVoxel0px1py1pz(); - const uint8 v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v011 = volIter.peekVoxel0px1py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); //z - uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y, regSlice.width()+1)]; + uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y, regSlice.width()+1)]; iCubeIndex = iPreviousCubeIndexZ >> 4; //y - uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1, regSlice.width()+1)]; - uint8 srcBit7 = iPreviousCubeIndexY & 128; - uint8 destBit4 = srcBit7 >> 3; + uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1, regSlice.width()+1)]; + uint8_t srcBit7 = iPreviousCubeIndexY & 128; + uint8_t destBit4 = srcBit7 >> 3; - uint8 srcBit6 = iPreviousCubeIndexY & 64; - uint8 destBit5 = srcBit6 >> 1; + uint8_t srcBit6 = iPreviousCubeIndexY & 64; + uint8_t destBit5 = srcBit6 >> 1; iCubeIndex |= destBit4; iCubeIndex |= destBit5; @@ -338,24 +338,24 @@ namespace PolyVox } else { - const uint8 v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); //z - uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y, regSlice.width()+1)]; + uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y, regSlice.width()+1)]; iCubeIndex = iPreviousCubeIndexZ >> 4; //y - uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1, regSlice.width()+1)]; - uint8 srcBit7 = iPreviousCubeIndexY & 128; - uint8 destBit4 = srcBit7 >> 3; + uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1, regSlice.width()+1)]; + uint8_t srcBit7 = iPreviousCubeIndexY & 128; + uint8_t destBit4 = srcBit7 >> 3; - uint8 srcBit6 = iPreviousCubeIndexY & 64; - uint8 destBit5 = srcBit6 >> 1; + uint8_t srcBit6 = iPreviousCubeIndexY & 64; + uint8_t destBit5 = srcBit6 >> 1; //x - uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y, regSlice.width()+1)]; + uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y, regSlice.width()+1)]; srcBit6 = iPreviousCubeIndexX & 64; - uint8 destBit7 = srcBit6 << 1; + uint8_t destBit7 = srcBit6 << 1; iCubeIndex |= destBit4; iCubeIndex |= destBit5; @@ -376,7 +376,7 @@ namespace PolyVox return uNoOfNonEmptyCells; } - void generateRoughVerticesForSlice(VolumeIterator& volIter, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]) + void generateRoughVerticesForSlice(VolumeIterator& volIter, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32_t vertexIndicesX[],int32_t vertexIndicesY[],int32_t vertexIndicesZ[]) { //Iterate over each cell in the region volIter.setPosition(regSlice.getLowerCorner().getX(),regSlice.getLowerCorner().getY(), regSlice.getLowerCorner().getZ()); @@ -385,14 +385,14 @@ namespace PolyVox do { //Current position - const uint16 x = volIter.getPosX() - offset.getX(); - const uint16 y = volIter.getPosY() - offset.getY(); - const uint16 z = volIter.getPosZ() - offset.getZ(); + const uint16_t x = volIter.getPosX() - offset.getX(); + const uint16_t y = volIter.getPosY() - offset.getY(); + const uint16_t z = volIter.getPosZ() - offset.getZ(); - const uint8 v000 = volIter.getVoxel(); + const uint8_t v000 = volIter.getVoxel(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8 iCubeIndex = bitmask[getIndex(x,y, regSlice.width()+1)]; + uint8_t iCubeIndex = bitmask[getIndex(x,y, regSlice.width()+1)]; /* Cube is entirely in/out of the surface */ if (edgeTable[iCubeIndex] == 0) @@ -405,12 +405,12 @@ namespace PolyVox { if((x + offset.getX()) != regSlice.getUpperCorner().getX()) { - const uint8 v100 = volIter.peekVoxel1px0py0pz(); + const uint8_t v100 = volIter.peekVoxel1px0py0pz(); const Vector3DFloat v3dPosition(x + 0.5f, y, z); const Vector3DFloat v3dNormal(v000 > v100 ? 1.0f : -1.0f, 0.0f, 0.0f); - const uint8 uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. + const uint8_t uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. const SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); - uint32 uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); + uint32_t uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); vertexIndicesX[getIndex(x,y, regSlice.width()+1)] = uLastVertexIndex; } } @@ -418,12 +418,12 @@ namespace PolyVox { if((y + offset.getY()) != regSlice.getUpperCorner().getY()) { - const uint8 v010 = volIter.peekVoxel0px1py0pz(); + const uint8_t v010 = volIter.peekVoxel0px1py0pz(); const Vector3DFloat v3dPosition(x, y + 0.5f, z); const Vector3DFloat v3dNormal(0.0f, v000 > v010 ? 1.0f : -1.0f, 0.0f); - const uint8 uMaterial = v000 | v010; + const uint8_t uMaterial = v000 | v010; SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); - uint32 uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); + uint32_t uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); vertexIndicesY[getIndex(x,y, regSlice.width()+1)] = uLastVertexIndex; } } @@ -431,21 +431,21 @@ namespace PolyVox { //if((z + offset.getZ()) != upperCorner.getZ()) { - const uint8 v001 = volIter.peekVoxel0px0py1pz(); + const uint8_t v001 = volIter.peekVoxel0px0py1pz(); const Vector3DFloat v3dPosition(x, y, z + 0.5f); const Vector3DFloat v3dNormal(0.0f, 0.0f, v000 > v001 ? 1.0f : -1.0f); - const uint8 uMaterial = v000 | v001; + const uint8_t uMaterial = v000 | v001; SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); - uint32 uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); + uint32_t uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex); vertexIndicesZ[getIndex(x,y, regSlice.width()+1)] = uLastVertexIndex; } } }while(volIter.moveForwardInRegionXYZ());//For each cell } - void generateRoughIndicesForSlice(VolumeIterator& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]) + void generateRoughIndicesForSlice(VolumeIterator& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8_t* bitmask0, uint8_t* bitmask1, int32_t vertexIndicesX0[],int32_t vertexIndicesY0[],int32_t vertexIndicesZ0[], int32_t vertexIndicesX1[],int32_t vertexIndicesY1[],int32_t vertexIndicesZ1[]) { - uint32 indlist[12]; + uint32_t indlist[12]; Region regCroppedSlice(regSlice); regCroppedSlice.setUpperCorner(regCroppedSlice.getUpperCorner() - Vector3DInt32(1,1,0)); @@ -455,12 +455,12 @@ namespace PolyVox do { //Current position - const uint16 x = volIter.getPosX() - offset.getX(); - const uint16 y = volIter.getPosY() - offset.getY(); - const uint16 z = volIter.getPosZ() - offset.getZ(); + const uint16_t x = volIter.getPosX() - offset.getX(); + const uint16_t y = volIter.getPosY() - offset.getY(); + const uint16_t z = volIter.getPosZ() - offset.getZ(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8 iCubeIndex = bitmask0[getIndex(x,y, regSlice.width()+1)]; + uint8_t iCubeIndex = bitmask0[getIndex(x,y, regSlice.width()+1)]; /* Cube is entirely in/out of the surface */ if (edgeTable[iCubeIndex] == 0) @@ -532,9 +532,9 @@ namespace PolyVox for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3) { - uint32 ind0 = indlist[triTable[iCubeIndex][i ]]; - uint32 ind1 = indlist[triTable[iCubeIndex][i+1]]; - uint32 ind2 = indlist[triTable[iCubeIndex][i+2]]; + uint32_t ind0 = indlist[triTable[iCubeIndex][i ]]; + uint32_t ind1 = indlist[triTable[iCubeIndex][i+1]]; + uint32_t ind2 = indlist[triTable[iCubeIndex][i+2]]; singleMaterialPatch->addTriangle(ind0, ind1, ind2); }//For each triangle diff --git a/library/source/PolyVoxCore/PolyVoxImpl/ReferenceSurfaceExtractor.cpp b/library/source/PolyVoxCore/PolyVoxImpl/ReferenceSurfaceExtractor.cpp index c8ccb7f5..567784b6 100644 --- a/library/source/PolyVoxCore/PolyVoxImpl/ReferenceSurfaceExtractor.cpp +++ b/library/source/PolyVoxCore/PolyVoxImpl/ReferenceSurfaceExtractor.cpp @@ -31,16 +31,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - void extractReferenceSurfaceImpl(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) + void extractReferenceSurfaceImpl(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) { - /*static int32 vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; - static int32 vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; - static int32 vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1];*/ + /*static int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; + static int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; + static int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1];*/ Vector3DInt32 regionDimensions = region.dimensions() + Vector3DInt32(1,1,1); - std::vector vertexIndicesX(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ()); - std::vector vertexIndicesY(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ()); - std::vector vertexIndicesZ(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ()); + std::vector vertexIndicesX(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ()); + std::vector vertexIndicesY(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ()); + std::vector vertexIndicesZ(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ()); memset(&vertexIndicesX[0],0xFF,sizeof(vertexIndicesX[0]) * vertexIndicesX.size()); //0xFF is -1 as two's complement - this may not be portable... memset(&vertexIndicesY[0],0xFF,sizeof(vertexIndicesY[0]) * vertexIndicesY.size()); //FIXME - can we just use sizeof(vertexIndicesY)? @@ -58,8 +58,8 @@ namespace PolyVox Vector3DFloat vertlist[12]; Vector3DFloat normlist[12]; - uint8 vertMaterials[12]; - VolumeIterator volIter(*volumeData); + uint8_t vertMaterials[12]; + VolumeIterator volIter(*volumeData); volIter.setValidRegion(region); ////////////////////////////////////////////////////////////////////////// @@ -71,22 +71,22 @@ namespace PolyVox while(volIter.moveForwardInRegionXYZ()) { //Current position - const uint16 x = volIter.getPosX(); - const uint16 y = volIter.getPosY(); - const uint16 z = volIter.getPosZ(); + const uint16_t x = volIter.getPosX(); + const uint16_t y = volIter.getPosY(); + const uint16_t z = volIter.getPosZ(); //Voxels values - const uint8 v000 = volIter.getVoxel(); - const uint8 v100 = volIter.peekVoxel1px0py0pz(); - const uint8 v010 = volIter.peekVoxel0px1py0pz(); - const uint8 v110 = volIter.peekVoxel1px1py0pz(); - const uint8 v001 = volIter.peekVoxel0px0py1pz(); - const uint8 v101 = volIter.peekVoxel1px0py1pz(); - const uint8 v011 = volIter.peekVoxel0px1py1pz(); - const uint8 v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v000 = volIter.getVoxel(); + const uint8_t v100 = volIter.peekVoxel1px0py0pz(); + const uint8_t v010 = volIter.peekVoxel0px1py0pz(); + const uint8_t v110 = volIter.peekVoxel1px1py0pz(); + const uint8_t v001 = volIter.peekVoxel0px0py1pz(); + const uint8_t v101 = volIter.peekVoxel1px0py1pz(); + const uint8_t v011 = volIter.peekVoxel0px1py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8 iCubeIndex = 0; + uint8_t iCubeIndex = 0; if (v000 == 0) iCubeIndex |= 1; if (v100 == 0) iCubeIndex |= 2; @@ -241,30 +241,30 @@ namespace PolyVox //const Vector3DFloat vertex1AsFloat = (static_cast(vertex1) / 2.0f) - offset; //const Vector3DFloat vertex2AsFloat = (static_cast(vertex2) / 2.0f) - offset; - const uint8 material0 = vertMaterials[triTable[iCubeIndex][i ]]; - const uint8 material1 = vertMaterials[triTable[iCubeIndex][i+1]]; - const uint8 material2 = vertMaterials[triTable[iCubeIndex][i+2]]; + const uint8_t material0 = vertMaterials[triTable[iCubeIndex][i ]]; + const uint8_t material1 = vertMaterials[triTable[iCubeIndex][i+1]]; + const uint8_t material2 = vertMaterials[triTable[iCubeIndex][i+2]]; //If all the materials are the same, we just need one triangle for that material with all the alphas set high. SurfaceVertex v0(vertex0, normal0, material0 + 0.1f); SurfaceVertex v1(vertex1, normal1, material1 + 0.1f); SurfaceVertex v2(vertex2, normal2, material2 + 0.1f); - int32 index0 = getIndexFor(v0.getPosition(), regionDimensions, vertexIndicesX, vertexIndicesY, vertexIndicesZ); + int32_t index0 = getIndexFor(v0.getPosition(), regionDimensions, vertexIndicesX, vertexIndicesY, vertexIndicesZ); if(index0 == -1) { index0 = singleMaterialPatch->addVertex(v0); setIndexFor(v0.getPosition(), regionDimensions, index0, vertexIndicesX, vertexIndicesY, vertexIndicesZ); } - int32 index1 = getIndexFor(v1.getPosition(), regionDimensions, vertexIndicesX, vertexIndicesY, vertexIndicesZ); + int32_t index1 = getIndexFor(v1.getPosition(), regionDimensions, vertexIndicesX, vertexIndicesY, vertexIndicesZ); if(index1 == -1) { index1 = singleMaterialPatch->addVertex(v1); setIndexFor(v1.getPosition(), regionDimensions, index1, vertexIndicesX, vertexIndicesY, vertexIndicesZ); } - int32 index2 = getIndexFor(v2.getPosition(), regionDimensions, vertexIndicesX, vertexIndicesY, vertexIndicesZ); + int32_t index2 = getIndexFor(v2.getPosition(), regionDimensions, vertexIndicesX, vertexIndicesY, vertexIndicesZ); if(index2 == -1) { index2 = singleMaterialPatch->addVertex(v2); @@ -276,7 +276,7 @@ namespace PolyVox }//For each cell } - int32 getIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, const std::vector& vertexIndicesX, const std::vector& vertexIndicesY, const std::vector& vertexIndicesZ) + int32_t getIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, const std::vector& vertexIndicesX, const std::vector& vertexIndicesY, const std::vector& vertexIndicesZ) { float xIntPartAsFloat; float xFracPart = std::modf(pos.getX(), &xIntPartAsFloat); @@ -285,9 +285,9 @@ namespace PolyVox float zIntPartAsFloat; float zFracPart = std::modf(pos.getZ(), &zIntPartAsFloat); - uint16 xIntPart = static_cast(xIntPartAsFloat); - uint16 yIntPart = static_cast(yIntPartAsFloat); - uint16 zIntPart = static_cast(zIntPartAsFloat); + uint16_t xIntPart = static_cast(xIntPartAsFloat); + uint16_t yIntPart = static_cast(yIntPartAsFloat); + uint16_t zIntPart = static_cast(zIntPartAsFloat); //Of all the fractional parts, two should be zero and one should be 0.5. if(xFracPart > 0.25f) @@ -304,7 +304,7 @@ namespace PolyVox } } - void setIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, int32 newIndex, std::vector& vertexIndicesX, std::vector& vertexIndicesY, std::vector& vertexIndicesZ) + void setIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, int32_t newIndex, std::vector& vertexIndicesX, std::vector& vertexIndicesY, std::vector& vertexIndicesZ) { float xIntPartAsFloat; float xFracPart = std::modf(pos.getX(), &xIntPartAsFloat); @@ -313,9 +313,9 @@ namespace PolyVox float zIntPartAsFloat; float zFracPart = std::modf(pos.getZ(), &zIntPartAsFloat); - uint16 xIntPart = static_cast(xIntPartAsFloat); - uint16 yIntPart = static_cast(yIntPartAsFloat); - uint16 zIntPart = static_cast(zIntPartAsFloat); + uint16_t xIntPart = static_cast(xIntPartAsFloat); + uint16_t yIntPart = static_cast(yIntPartAsFloat); + uint16_t zIntPart = static_cast(zIntPartAsFloat); //Of all the fractional parts, two should be zero and one should be 0.5. if(xFracPart > 0.25f) diff --git a/library/source/PolyVoxCore/Region.cpp b/library/source/PolyVoxCore/Region.cpp index 247b2cdb..011f63c5 100644 --- a/library/source/PolyVoxCore/Region.cpp +++ b/library/source/PolyVoxCore/Region.cpp @@ -44,7 +44,7 @@ namespace PolyVox && (pos.getZ() >= m_v3dLowerCorner.getZ() + boundary); } - bool Region::containsPoint(const Vector3DInt32& pos, uint8 boundary) const + bool Region::containsPoint(const Vector3DInt32& pos, uint8_t boundary) const { return (pos.getX() <= m_v3dUpperCorner.getX() - boundary) && (pos.getY() <= m_v3dUpperCorner.getY() - boundary) @@ -64,12 +64,12 @@ namespace PolyVox m_v3dUpperCorner.setZ((std::min)(m_v3dUpperCorner.getZ(), other.m_v3dUpperCorner.getZ())); } - int32 Region::depth(void) const + int32_t Region::depth(void) const { return m_v3dUpperCorner.getZ() - m_v3dLowerCorner.getZ(); } - int32 Region::height(void) const + int32_t Region::height(void) const { return m_v3dUpperCorner.getY() - m_v3dLowerCorner.getY(); } @@ -95,7 +95,7 @@ namespace PolyVox return m_v3dUpperCorner - m_v3dLowerCorner; } - int32 Region::width(void) const + int32_t Region::width(void) const { return m_v3dUpperCorner.getX() - m_v3dLowerCorner.getX(); } diff --git a/library/source/PolyVoxCore/SurfaceAdjusters.cpp b/library/source/PolyVoxCore/SurfaceAdjusters.cpp index 14ab00d8..bae605ad 100644 --- a/library/source/PolyVoxCore/SurfaceAdjusters.cpp +++ b/library/source/PolyVoxCore/SurfaceAdjusters.cpp @@ -12,12 +12,12 @@ using namespace std; namespace PolyVox { - void smoothRegionGeometry(Volume* volumeData, IndexedSurfacePatch& isp) + void smoothRegionGeometry(Volume* volumeData, IndexedSurfacePatch& isp) { - const uint8 uSmoothingFactor = 2; + const uint8_t uSmoothingFactor = 2; const float fThreshold = 0.5f; - VolumeIterator volIter(*volumeData); + VolumeIterator volIter(*volumeData); std::vector& vecVertices = isp.getRawVertexData(); std::vector::iterator iterSurfaceVertex = vecVertices.begin(); @@ -76,9 +76,9 @@ namespace PolyVox } //while(iterSurfaceVertex != vecVertices.end()) } - void adjustDecimatedGeometry(Volume* volumeData, IndexedSurfacePatch& isp, uint8 val) + void adjustDecimatedGeometry(Volume* volumeData, IndexedSurfacePatch& isp, uint8_t val) { - VolumeIterator volIter(*volumeData); + VolumeIterator volIter(*volumeData); std::vector& vecVertices = isp.getRawVertexData(); std::vector::iterator iterSurfaceVertex = vecVertices.begin(); @@ -87,7 +87,7 @@ namespace PolyVox Vector3DFloat v3dPos = iterSurfaceVertex->getPosition() + static_cast(isp.m_v3dRegionPosition); Vector3DInt32 v3dFloor = static_cast(v3dPos); - VolumeIterator volIter(*volumeData); + VolumeIterator volIter(*volumeData); //Check all corners are within the volume, allowing a boundary for gradient estimation bool lowerCornerInside = volumeData->getEnclosingRegion().containsPoint(v3dFloor,1); @@ -96,7 +96,7 @@ namespace PolyVox if(lowerCornerInside && upperCornerInside) //If this test fails the vertex will be left as it was { //volIter.setPosition(static_cast(v3dFloor)); - //const uint8 uFloor = volIter.getVoxel(); + //const uint8_t uFloor = volIter.getVoxel(); if(((v3dPos.getX() - v3dFloor.getX()) < 0.001) && ((v3dPos.getY() - v3dFloor.getY()) < 0.001) && ((v3dPos.getZ() - v3dFloor.getZ()) < 0.001)) //int x = v3dPos.getX(); //if(x % 2 != 0) @@ -104,7 +104,7 @@ namespace PolyVox { //exit(0); //volIter.setPosition(static_cast(v3dFloor+Vector3DInt32(1,0,0))); - //const uint8 uCeil = volIter.getVoxel(); + //const uint8_t uCeil = volIter.getVoxel(); //if(uFloor == uCeil) //In this case they must both be zero { //if(iterSurfaceVertex->getNormal().getX() > 0) @@ -114,9 +114,9 @@ namespace PolyVox v3dFloor = static_cast(v3dPos); volIter.setPosition(static_cast(v3dFloor)); - const uint8 uFloor = volIter.getVoxel(); + const uint8_t uFloor = volIter.getVoxel(); - uint8 uCeil; + uint8_t uCeil; if((iterSurfaceVertex->getNormal().getX() > 0.5f) || (iterSurfaceVertex->getNormal().getX() < -0.5f)) { volIter.setPosition(static_cast(v3dFloor+Vector3DInt32(1,0,0))); diff --git a/library/source/PolyVoxCore/SurfaceExtractors.cpp b/library/source/PolyVoxCore/SurfaceExtractors.cpp index 1aa01058..01b94e2a 100644 --- a/library/source/PolyVoxCore/SurfaceExtractors.cpp +++ b/library/source/PolyVoxCore/SurfaceExtractors.cpp @@ -18,7 +18,7 @@ using namespace std; namespace PolyVox { - void extractSurface(Volume* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch) + void extractSurface(Volume* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch) { if(uLevel == 0) { @@ -32,7 +32,7 @@ namespace PolyVox singleMaterialPatch->m_v3dRegionPosition = region.getLowerCorner(); } - void extractReferenceSurface(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) + void extractReferenceSurface(Volume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) { extractReferenceSurfaceImpl(volumeData, region, singleMaterialPatch); diff --git a/library/source/PolyVoxCore/Utility.cpp b/library/source/PolyVoxCore/Utility.cpp index 3e158dda..cb6059ac 100644 --- a/library/source/PolyVoxCore/Utility.cpp +++ b/library/source/PolyVoxCore/Utility.cpp @@ -28,7 +28,7 @@ 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 logBase2(uint32 uInput) + uint8_t logBase2(uint32_t uInput) { //Debug mode validation assert(uInput != 0); @@ -44,16 +44,16 @@ namespace PolyVox throw std::invalid_argument("Input must be a power of two in order to compute the log."); } - uint32 uResult = 0; + uint32_t uResult = 0; while( (uInput >> uResult) != 0) { ++uResult; } - return static_cast(uResult-1); + return static_cast(uResult-1); } - bool isPowerOf2(uint32 uInput) + bool isPowerOf2(uint32_t uInput) { if(uInput == 0) return false; diff --git a/library/source/PolyVoxCore/VoxelFilters.cpp b/library/source/PolyVoxCore/VoxelFilters.cpp index 3c54c29c..7746ec41 100644 --- a/library/source/PolyVoxCore/VoxelFilters.cpp +++ b/library/source/PolyVoxCore/VoxelFilters.cpp @@ -4,7 +4,7 @@ namespace PolyVox { - float computeSmoothedVoxel(VolumeIterator& volIter) + float computeSmoothedVoxel(VolumeIterator& volIter) { assert(volIter.getPosX() >= 1); assert(volIter.getPosY() >= 1); diff --git a/library/source/PolyVoxUtil/Serialization.cpp b/library/source/PolyVoxUtil/Serialization.cpp index 28f7c74e..b874e6b8 100644 --- a/library/source/PolyVoxUtil/Serialization.cpp +++ b/library/source/PolyVoxUtil/Serialization.cpp @@ -10,31 +10,31 @@ namespace PolyVox { //Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller. //FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow - Volume* loadVolumeRaw(istream& stream) + Volume* loadVolumeRaw(istream& stream) { //Read volume dimensions - uint8 volumeWidthPower = 0; - uint8 volumeHeightPower = 0; - uint8 volumeDepthPower = 0; + uint8_t volumeWidthPower = 0; + uint8_t volumeHeightPower = 0; + uint8_t volumeDepthPower = 0; stream.read(reinterpret_cast(&volumeWidthPower), sizeof(volumeWidthPower)); stream.read(reinterpret_cast(&volumeHeightPower), sizeof(volumeHeightPower)); stream.read(reinterpret_cast(&volumeDepthPower), sizeof(volumeDepthPower)); - uint16 volumeWidth = 0x0001 << volumeWidthPower; - uint16 volumeHeight = 0x0001 << volumeHeightPower; - uint16 volumeDepth = 0x0001 << volumeDepthPower; + uint16_t volumeWidth = 0x0001 << volumeWidthPower; + uint16_t volumeHeight = 0x0001 << volumeHeightPower; + uint16_t volumeDepth = 0x0001 << volumeDepthPower; //FIXME - need to support non cubic volumes - Volume* volume = new Volume(volumeWidth); + Volume* volume = new Volume(volumeWidth); //Read data - for(uint16 z = 0; z < volumeDepth; ++z) + for(uint16_t z = 0; z < volumeDepth; ++z) { - for(uint16 y = 0; y < volumeHeight; ++y) + for(uint16_t y = 0; y < volumeHeight; ++y) { - for(uint16 x = 0; x < volumeWidth; ++x) + for(uint16_t x = 0; x < volumeWidth; ++x) { - uint8 value = 0; + uint8_t value = 0; stream.read(reinterpret_cast(&value), sizeof(value)); volume->setVoxelAt(x,y,z,value); @@ -45,31 +45,31 @@ namespace PolyVox return volume; } - void saveVolumeRaw(std::ostream& stream, Volume& volume) + void saveVolumeRaw(std::ostream& stream, Volume& volume) { //Write volume dimensions - uint16 volumeWidth = volume.getSideLength(); - uint16 volumeHeight = volume.getSideLength(); - uint16 volumeDepth = volume.getSideLength(); + uint16_t volumeWidth = volume.getSideLength(); + uint16_t volumeHeight = volume.getSideLength(); + uint16_t volumeDepth = volume.getSideLength(); - uint8 volumeWidthPower = logBase2(volumeWidth); - uint8 volumeHeightPower = logBase2(volumeHeight); - uint8 volumeDepthPower = logBase2(volumeDepth); + uint8_t volumeWidthPower = logBase2(volumeWidth); + uint8_t volumeHeightPower = logBase2(volumeHeight); + uint8_t volumeDepthPower = logBase2(volumeDepth); stream.write(reinterpret_cast(&volumeWidthPower), sizeof(volumeWidthPower)); stream.write(reinterpret_cast(&volumeHeightPower), sizeof(volumeHeightPower)); stream.write(reinterpret_cast(&volumeDepthPower), sizeof(volumeDepthPower)); //Write data - VolumeIterator volIter(volume); - for(uint16 z = 0; z < volumeDepth; ++z) + VolumeIterator volIter(volume); + for(uint16_t z = 0; z < volumeDepth; ++z) { - for(uint16 y = 0; y < volumeHeight; ++y) + for(uint16_t y = 0; y < volumeHeight; ++y) { - for(uint16 x = 0; x < volumeWidth; ++x) + for(uint16_t x = 0; x < volumeWidth; ++x) { volIter.setPosition(x,y,z); - uint8 value = volIter.getVoxel(); + uint8_t value = volIter.getVoxel(); stream.write(reinterpret_cast(&value), sizeof(value)); } } @@ -78,34 +78,34 @@ namespace PolyVox //Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller. //FIXME - think about pointer ownership issues. Or could return volume by value if the copy constructor is shallow - Volume* loadVolumeRle(istream& stream) + Volume* loadVolumeRle(istream& stream) { //Read volume dimensions - uint8 volumeWidthPower = 0; - uint8 volumeHeightPower = 0; - uint8 volumeDepthPower = 0; + uint8_t volumeWidthPower = 0; + uint8_t volumeHeightPower = 0; + uint8_t volumeDepthPower = 0; stream.read(reinterpret_cast(&volumeWidthPower), sizeof(volumeWidthPower)); stream.read(reinterpret_cast(&volumeHeightPower), sizeof(volumeHeightPower)); stream.read(reinterpret_cast(&volumeDepthPower), sizeof(volumeDepthPower)); - uint16 volumeWidth = 0x0001 << volumeWidthPower; - uint16 volumeHeight = 0x0001 << volumeHeightPower; - uint16 volumeDepth = 0x0001 << volumeDepthPower; + uint16_t volumeWidth = 0x0001 << volumeWidthPower; + uint16_t volumeHeight = 0x0001 << volumeHeightPower; + uint16_t volumeDepth = 0x0001 << volumeDepthPower; //FIXME - need to support non cubic volumes - Volume* volume = new Volume(volumeWidth); + Volume* volume = new Volume(volumeWidth); //Read data bool firstTime = true; - uint32 runLength = 0; - uint8 value = 0; + uint32_t runLength = 0; + uint8_t value = 0; stream.read(reinterpret_cast(&value), sizeof(value)); stream.read(reinterpret_cast(&runLength), sizeof(runLength)); - for(uint16 z = 0; z < volumeDepth; ++z) + for(uint16_t z = 0; z < volumeDepth; ++z) { - for(uint16 y = 0; y < volumeHeight; ++y) + for(uint16_t y = 0; y < volumeHeight; ++y) { - for(uint16 x = 0; x < volumeWidth; ++x) + for(uint16_t x = 0; x < volumeWidth; ++x) { if(runLength != 0) { @@ -127,34 +127,34 @@ namespace PolyVox return volume; } - void saveVolumeRle(std::ostream& stream, Volume& volume) + void saveVolumeRle(std::ostream& stream, Volume& volume) { //Write volume dimensions - uint16 volumeWidth = volume.getSideLength(); - uint16 volumeHeight = volume.getSideLength(); - uint16 volumeDepth = volume.getSideLength(); + uint16_t volumeWidth = volume.getSideLength(); + uint16_t volumeHeight = volume.getSideLength(); + uint16_t volumeDepth = volume.getSideLength(); - uint8 volumeWidthPower = logBase2(volumeWidth); - uint8 volumeHeightPower = logBase2(volumeHeight); - uint8 volumeDepthPower = logBase2(volumeDepth); + uint8_t volumeWidthPower = logBase2(volumeWidth); + uint8_t volumeHeightPower = logBase2(volumeHeight); + uint8_t volumeDepthPower = logBase2(volumeDepth); stream.write(reinterpret_cast(&volumeWidthPower), sizeof(volumeWidthPower)); stream.write(reinterpret_cast(&volumeHeightPower), sizeof(volumeHeightPower)); stream.write(reinterpret_cast(&volumeDepthPower), sizeof(volumeDepthPower)); //Write data - VolumeIterator volIter(volume); - uint8 current = 0; - uint32 runLength = 0; + VolumeIterator volIter(volume); + uint8_t current = 0; + uint32_t runLength = 0; bool firstTime = true; - for(uint16 z = 0; z < volumeDepth; ++z) + for(uint16_t z = 0; z < volumeDepth; ++z) { - for(uint16 y = 0; y < volumeHeight; ++y) + for(uint16_t y = 0; y < volumeHeight; ++y) { - for(uint16 x = 0; x < volumeWidth; ++x) + for(uint16_t x = 0; x < volumeWidth; ++x) { volIter.setPosition(x,y,z); - uint8 value = volIter.getVoxel(); + uint8_t value = volIter.getVoxel(); if(firstTime) { current = value; diff --git a/library/source/PolyVoxUtil/VolumeChangeTracker.cpp b/library/source/PolyVoxUtil/VolumeChangeTracker.cpp index efa80870..22c2b137 100644 --- a/library/source/PolyVoxUtil/VolumeChangeTracker.cpp +++ b/library/source/PolyVoxUtil/VolumeChangeTracker.cpp @@ -35,12 +35,12 @@ using namespace std; namespace PolyVox { - int32 VolumeChangeTracker::m_iCurrentTime = 0; + int32_t VolumeChangeTracker::m_iCurrentTime = 0; ////////////////////////////////////////////////////////////////////////// // VolumeChangeTracker ////////////////////////////////////////////////////////////////////////// - VolumeChangeTracker::VolumeChangeTracker(Volume* volumeDataToSet, uint16 regionSideLength) + VolumeChangeTracker::VolumeChangeTracker(Volume* volumeDataToSet, uint16_t regionSideLength) :m_bIsLocked(false) ,volumeData(0) ,m_uRegionSideLength(regionSideLength) @@ -49,7 +49,7 @@ namespace PolyVox m_uVolumeSideLengthInRegions = volumeData->getSideLength() / m_uRegionSideLength; m_uRegionSideLengthPower = PolyVox::logBase2(m_uRegionSideLength); - volRegionLastModified = new BlockData(m_uRegionSideLength); + volRegionLastModified = new BlockData(m_uRegionSideLength); } VolumeChangeTracker::~VolumeChangeTracker() @@ -58,11 +58,11 @@ namespace PolyVox void VolumeChangeTracker::setAllRegionsModified(void) { - for(uint16 blockZ = 0; blockZ < m_uVolumeSideLengthInRegions; ++blockZ) + for(uint16_t blockZ = 0; blockZ < m_uVolumeSideLengthInRegions; ++blockZ) { - for(uint16 blockY = 0; blockY < m_uVolumeSideLengthInRegions; ++blockY) + for(uint16_t blockY = 0; blockY < m_uVolumeSideLengthInRegions; ++blockY) { - for(uint16 blockX = 0; blockX < m_uVolumeSideLengthInRegions; ++blockX) + for(uint16_t blockX = 0; blockX < m_uVolumeSideLengthInRegions; ++blockX) { volRegionLastModified->setVoxelAt(blockX, blockY, blockZ, m_iCurrentTime); ++m_iCurrentTime; @@ -71,12 +71,12 @@ namespace PolyVox } } - int32 VolumeChangeTracker::getCurrentTime(void) const + int32_t VolumeChangeTracker::getCurrentTime(void) const { return m_iCurrentTime; } - uint16 VolumeChangeTracker::getSideLength(void) + uint16_t VolumeChangeTracker::getSideLength(void) { return volumeData->getSideLength(); } @@ -86,38 +86,38 @@ namespace PolyVox return volumeData->getEnclosingRegion(); } - int32 VolumeChangeTracker::getLastModifiedTimeForRegion(uint16 uX, uint16 uY, uint16 uZ) + int32_t VolumeChangeTracker::getLastModifiedTimeForRegion(uint16_t uX, uint16_t uY, uint16_t uZ) { return volRegionLastModified->getVoxelAt(uX, uY, uZ); } - uint8 VolumeChangeTracker::getVoxelAt(const Vector3DUint16& pos) + uint8_t VolumeChangeTracker::getVoxelAt(const Vector3DUint16& pos) { return getVoxelAt(pos.getX(), pos.getY(), pos.getZ()); } - uint8 VolumeChangeTracker::getVoxelAt(uint16 uX, uint16 uY, uint16 uZ) + uint8_t VolumeChangeTracker::getVoxelAt(uint16_t uX, uint16_t uY, uint16_t uZ) { assert(uX < volumeData->getSideLength()); assert(uY < volumeData->getSideLength()); assert(uZ < volumeData->getSideLength()); - VolumeIterator volIter(*volumeData); + VolumeIterator volIter(*volumeData); volIter.setPosition(uX,uY,uZ); return volIter.getVoxel(); } - Volume* VolumeChangeTracker::getVolumeData(void) const + Volume* VolumeChangeTracker::getVolumeData(void) const { return volumeData; } //NOTE - Document the fact that the time stamp is incremented at the start, not the end. - void VolumeChangeTracker::setVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value) + void VolumeChangeTracker::setVoxelAt(uint16_t x, uint16_t y, uint16_t z, uint8_t value) { ++m_iCurrentTime; //FIXME - rather than creating a iterator each time we should have one stored - //VolumeIterator iterVol(*volumeData); + //VolumeIterator iterVol(*volumeData); /*iterVol.setPosition(x,y,z); iterVol.setVoxel(value);*/ @@ -135,23 +135,23 @@ namespace PolyVox } else //Mark surrounding regions as well { - const uint16 regionX = x >> m_uRegionSideLengthPower; - const uint16 regionY = y >> m_uRegionSideLengthPower; - const uint16 regionZ = z >> m_uRegionSideLengthPower; + const uint16_t regionX = x >> m_uRegionSideLengthPower; + const uint16_t regionY = y >> m_uRegionSideLengthPower; + const uint16_t regionZ = z >> m_uRegionSideLengthPower; - const uint16 minRegionX = (std::max)(uint16(0),uint16(regionX-1)); - const uint16 minRegionY = (std::max)(uint16(0),uint16(regionY-1)); - const uint16 minRegionZ = (std::max)(uint16(0),uint16(regionZ-1)); + const uint16_t minRegionX = (std::max)(uint16_t(0),uint16_t(regionX-1)); + const uint16_t minRegionY = (std::max)(uint16_t(0),uint16_t(regionY-1)); + const uint16_t minRegionZ = (std::max)(uint16_t(0),uint16_t(regionZ-1)); - const uint16 maxRegionX = (std::min)(uint16(m_uVolumeSideLengthInRegions-1),uint16(regionX+1)); - const uint16 maxRegionY = (std::min)(uint16(m_uVolumeSideLengthInRegions-1),uint16(regionY+1)); - const uint16 maxRegionZ = (std::min)(uint16(m_uVolumeSideLengthInRegions-1),uint16(regionZ+1)); + const uint16_t maxRegionX = (std::min)(uint16_t(m_uVolumeSideLengthInRegions-1),uint16_t(regionX+1)); + const uint16_t maxRegionY = (std::min)(uint16_t(m_uVolumeSideLengthInRegions-1),uint16_t(regionY+1)); + const uint16_t maxRegionZ = (std::min)(uint16_t(m_uVolumeSideLengthInRegions-1),uint16_t(regionZ+1)); - for(uint16 zCt = minRegionZ; zCt <= maxRegionZ; zCt++) + for(uint16_t zCt = minRegionZ; zCt <= maxRegionZ; zCt++) { - for(uint16 yCt = minRegionY; yCt <= maxRegionY; yCt++) + for(uint16_t yCt = minRegionY; yCt <= maxRegionY; yCt++) { - for(uint16 xCt = minRegionX; xCt <= maxRegionX; xCt++) + for(uint16_t xCt = minRegionX; xCt <= maxRegionX; xCt++) { volRegionLastModified->setVoxelAt(xCt,yCt,zCt,m_iCurrentTime); } @@ -161,12 +161,12 @@ namespace PolyVox //++m_iCurrentTime; } - void VolumeChangeTracker::setLockedVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value) + void VolumeChangeTracker::setLockedVoxelAt(uint16_t x, uint16_t y, uint16_t z, uint8_t value) { assert(m_bIsLocked); //FIXME - rather than creating a iterator each time we should have one stored - /*VolumeIterator iterVol(*volumeData); + /*VolumeIterator iterVol(*volumeData); iterVol.setPosition(x,y,z); iterVol.setVoxel(value);*/ volumeData->setVoxelAt(x,y,z,value); @@ -191,19 +191,19 @@ namespace PolyVox throw std::logic_error("No region is locked. You must lock a region before you can unlock it."); } - const uint16 firstRegionX = m_regLastLocked.getLowerCorner().getX() >> m_uRegionSideLengthPower; - const uint16 firstRegionY = m_regLastLocked.getLowerCorner().getY() >> m_uRegionSideLengthPower; - const uint16 firstRegionZ = m_regLastLocked.getLowerCorner().getZ() >> m_uRegionSideLengthPower; + const uint16_t firstRegionX = m_regLastLocked.getLowerCorner().getX() >> m_uRegionSideLengthPower; + const uint16_t firstRegionY = m_regLastLocked.getLowerCorner().getY() >> m_uRegionSideLengthPower; + const uint16_t firstRegionZ = m_regLastLocked.getLowerCorner().getZ() >> m_uRegionSideLengthPower; - const uint16 lastRegionX = m_regLastLocked.getUpperCorner().getX() >> m_uRegionSideLengthPower; - const uint16 lastRegionY = m_regLastLocked.getUpperCorner().getY() >> m_uRegionSideLengthPower; - const uint16 lastRegionZ = m_regLastLocked.getUpperCorner().getZ() >> m_uRegionSideLengthPower; + const uint16_t lastRegionX = m_regLastLocked.getUpperCorner().getX() >> m_uRegionSideLengthPower; + const uint16_t lastRegionY = m_regLastLocked.getUpperCorner().getY() >> m_uRegionSideLengthPower; + const uint16_t lastRegionZ = m_regLastLocked.getUpperCorner().getZ() >> m_uRegionSideLengthPower; - for(uint16 zCt = firstRegionZ; zCt <= lastRegionZ; zCt++) + for(uint16_t zCt = firstRegionZ; zCt <= lastRegionZ; zCt++) { - for(uint16 yCt = firstRegionY; yCt <= lastRegionY; yCt++) + for(uint16_t yCt = firstRegionY; yCt <= lastRegionY; yCt++) { - for(uint16 xCt = firstRegionX; xCt <= lastRegionX; xCt++) + for(uint16_t xCt = firstRegionX; xCt <= lastRegionX; xCt++) { volRegionLastModified->setVoxelAt(xCt,yCt,zCt,m_iCurrentTime); }