Switched to integer naming conventions from C++0x (e.g. uint16_t)
This commit is contained in:
parent
47e0e66228
commit
5acbd012cf
@ -9,10 +9,10 @@ using namespace std;
|
||||
void renderRegionImmediateMode(PolyVox::IndexedSurfacePatch& isp)
|
||||
{
|
||||
const vector<SurfaceVertex>& vecVertices = isp.getVertices();
|
||||
const vector<uint32>& vecIndices = isp.getIndices();
|
||||
const vector<uint32_t>& vecIndices = isp.getIndices();
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
for(vector<uint32>::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex)
|
||||
for(vector<uint32_t>::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);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using namespace PolyVox;
|
||||
|
||||
OpenGLColour convertMaterialIDToColour(PolyVox::uint8 materialID)
|
||||
OpenGLColour convertMaterialIDToColour(PolyVox::uint8_t materialID)
|
||||
{
|
||||
OpenGLColour colour;
|
||||
|
||||
|
@ -12,6 +12,6 @@ struct OpenGLColour
|
||||
GLfloat blue;
|
||||
};
|
||||
|
||||
OpenGLColour convertMaterialIDToColour(PolyVox::uint8 materialID);
|
||||
OpenGLColour convertMaterialIDToColour(PolyVox::uint8_t materialID);
|
||||
|
||||
#endif //__OpenGLExample_OpenGLSupport_H__
|
@ -13,7 +13,7 @@ OpenGLSurfacePatch BuildOpenGLSurfacePatch(const IndexedSurfacePatch& isp)
|
||||
|
||||
//Convienient access to the vertices and indices
|
||||
const vector<SurfaceVertex>& vecVertices = isp.getVertices();
|
||||
const vector<uint32>& vecIndices = isp.getIndices();
|
||||
const vector<uint32_t>& 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);
|
||||
|
||||
|
@ -14,7 +14,7 @@ OpenGLWidget::OpenGLWidget(QWidget *parent)
|
||||
|
||||
}
|
||||
|
||||
void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8>* volData)
|
||||
void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8_t>* 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<PolyVox::uint8>* 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<PolyVox::uint8>* 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)
|
||||
|
@ -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<PolyVox::uint8>* volData);
|
||||
void setVolume(PolyVox::Volume<PolyVox::uint8_t>* volData);
|
||||
|
||||
protected:
|
||||
void initializeGL();
|
||||
@ -36,7 +36,7 @@ class OpenGLWidget : public QGLWidget
|
||||
bool m_bUseOpenGLVertexBufferObjects;
|
||||
|
||||
//Creates a volume 128x128x128
|
||||
PolyVox::Volume<PolyVox::uint8>* m_volData;
|
||||
PolyVox::Volume<PolyVox::uint8_t>* m_volData;
|
||||
|
||||
//Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region
|
||||
std::map<PolyVox::Vector3DUint8, OpenGLSurfacePatch> m_mapOpenGLSurfacePatches;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
using namespace PolyVox;
|
||||
|
||||
void createSphereInVolume(Volume<uint8>& volData, float fRadius, uint8 uValue)
|
||||
void createSphereInVolume(Volume<uint8_t>& 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<uint8>& volData, float fRadius, uint8 uValue)
|
||||
}
|
||||
}
|
||||
|
||||
void createCubeInVolume(Volume<uint8>& volData, Vector3DUint16 lowerCorner, Vector3DUint16 upperCorner, uint8 uValue)
|
||||
void createCubeInVolume(Volume<uint8_t>& 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++)
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "PolyVoxCore/Volume.h"
|
||||
|
||||
void createSphereInVolume(PolyVox::Volume<PolyVox::uint8>& volData, float fRadius, PolyVox::uint8 uValue);
|
||||
void createCubeInVolume(PolyVox::Volume<PolyVox::uint8>& volData, PolyVox::Vector3DUint16 lowerCorner, PolyVox::Vector3DUint16 upperCorner, PolyVox::uint8 uValue);
|
||||
void createSphereInVolume(PolyVox::Volume<PolyVox::uint8_t>& volData, float fRadius, PolyVox::uint8_t uValue);
|
||||
void createCubeInVolume(PolyVox::Volume<PolyVox::uint8_t>& volData, PolyVox::Vector3DUint16 lowerCorner, PolyVox::Vector3DUint16 upperCorner, PolyVox::uint8_t uValue);
|
||||
|
||||
#endif //__OpenGLExample_Shapes_H__
|
@ -22,12 +22,12 @@ using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Volume<uint8> volData(g_uVolumeSideLength);
|
||||
Volume<uint8_t> 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<uint8> g_volData(g_uVolumeSideLength);
|
||||
Volume<uint8_t> 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);
|
||||
|
@ -36,25 +36,25 @@ namespace PolyVox
|
||||
//Make VolumeIterator a friend
|
||||
friend class VolumeIterator<VoxelType>;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace PolyVox
|
||||
{
|
||||
#pragma region Constructors/Destructors
|
||||
template <typename VoxelType>
|
||||
BlockData<VoxelType>::BlockData(uint8 uSideLength)
|
||||
BlockData<VoxelType>::BlockData(uint8_t uSideLength)
|
||||
:m_tData(0)
|
||||
{
|
||||
//Debug mode validation
|
||||
@ -87,13 +87,13 @@ namespace PolyVox
|
||||
|
||||
#pragma region Getters
|
||||
template <typename VoxelType>
|
||||
uint16 BlockData<VoxelType>::getSideLength(void) const
|
||||
uint16_t BlockData<VoxelType>::getSideLength(void) const
|
||||
{
|
||||
return m_uSideLength;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType BlockData<VoxelType>::getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const
|
||||
VoxelType BlockData<VoxelType>::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 <typename VoxelType>
|
||||
void BlockData<VoxelType>::setVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos, VoxelType tValue)
|
||||
void BlockData<VoxelType>::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)
|
||||
|
@ -42,8 +42,8 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSmoothSobelGradient(VolumeIterator<VoxelType>& volIter);
|
||||
|
||||
POLYVOX_API void computeNormalsForVertices(Volume<uint8>* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod);
|
||||
POLYVOX_API Vector3DFloat computeNormal(Volume<uint8>* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod);
|
||||
POLYVOX_API void computeNormalsForVertices(Volume<uint8_t>* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod);
|
||||
POLYVOX_API Vector3DFloat computeNormal(Volume<uint8_t>* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod);
|
||||
}
|
||||
|
||||
#include "GradientEstimators.inl"
|
||||
|
@ -47,9 +47,9 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeDecimatedCentralDifferenceGradient(const VolumeIterator<VoxelType>& 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 <typename VoxelType>
|
||||
Vector3DFloat computeSmoothCentralDifferenceGradient(VolumeIterator<VoxelType>& 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);
|
||||
|
@ -39,25 +39,25 @@ namespace PolyVox
|
||||
IndexedSurfacePatch();
|
||||
~IndexedSurfacePatch();
|
||||
|
||||
const std::vector<uint32>& getIndices(void) const;
|
||||
uint32 getNoOfIndices(void) const;
|
||||
uint32 getNoOfNonUniformTrianges(void) const;
|
||||
uint32 getNoOfUniformTrianges(void) const;
|
||||
uint32 getNoOfVertices(void) const;
|
||||
const std::vector<uint32_t>& 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<SurfaceVertex>& getRawVertexData(void); //FIXME - this shoudl be removed
|
||||
const std::vector<SurfaceVertex>& 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<uint32> m_vecTriangleIndices;
|
||||
std::vector<uint32_t> m_vecTriangleIndices;
|
||||
std::vector<SurfaceVertex> m_vecVertices;
|
||||
};
|
||||
|
||||
|
@ -32,8 +32,8 @@ namespace PolyVox
|
||||
//---------- Volume ----------
|
||||
template <typename VoxelType> class Volume;
|
||||
typedef Volume<float> FloatVolume;
|
||||
typedef Volume<uint8> UInt8Volume;
|
||||
typedef Volume<uint16> UInt16Volume;
|
||||
typedef Volume<uint8_t> UInt8Volume;
|
||||
typedef Volume<uint16_t> UInt16Volume;
|
||||
//---------------------------------
|
||||
|
||||
class IndexedSurfacePatch;
|
||||
@ -42,15 +42,15 @@ namespace PolyVox
|
||||
class SurfaceVertex;
|
||||
|
||||
//---------- Vector ----------
|
||||
template <uint32 Size, typename Type> class Vector;
|
||||
template <uint32_t Size, typename Type> 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 <typename VoxelType> class VolumeIterator;
|
||||
|
@ -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
|
@ -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<uint8>* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
uint32 computeInitialDecimatedBitmaskForSlice(VolumeIterator<uint8>& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask);
|
||||
uint32 computeDecimatedBitmaskForSliceFromPrevious(VolumeIterator<uint8>& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask, uint8 *previousBitmask);
|
||||
void generateDecimatedIndicesForSlice(VolumeIterator<uint8>& 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<uint8>& volIter, uint8 uLevel, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]);
|
||||
void extractDecimatedSurfaceImpl(Volume<uint8_t>* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
uint32_t computeInitialDecimatedBitmaskForSlice(VolumeIterator<uint8_t>& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t *bitmask);
|
||||
uint32_t computeDecimatedBitmaskForSliceFromPrevious(VolumeIterator<uint8_t>& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t *bitmask, uint8_t *previousBitmask);
|
||||
void generateDecimatedIndicesForSlice(VolumeIterator<uint8_t>& 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<uint8_t>& volIter, uint8_t uLevel, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32_t vertexIndicesX[],int32_t vertexIndicesY[],int32_t vertexIndicesZ[]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -32,12 +32,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
void extractFastSurfaceImpl(Volume<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
uint32 getIndex(uint32 x, uint32 y, uint32 regionWidth);
|
||||
uint32 computeInitialRoughBitmaskForSlice(VolumeIterator<uint8>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask);
|
||||
uint32 computeRoughBitmaskForSliceFromPrevious(VolumeIterator<uint8>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask, uint8 *previousBitmask);
|
||||
void generateRoughIndicesForSlice(VolumeIterator<uint8>& 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<uint8>& volIter, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]);
|
||||
void extractFastSurfaceImpl(Volume<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
uint32_t getIndex(uint32_t x, uint32_t y, uint32_t regionWidth);
|
||||
uint32_t computeInitialRoughBitmaskForSlice(VolumeIterator<uint8_t>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t *bitmask);
|
||||
uint32_t computeRoughBitmaskForSliceFromPrevious(VolumeIterator<uint8_t>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t *bitmask, uint8_t *previousBitmask);
|
||||
void generateRoughIndicesForSlice(VolumeIterator<uint8_t>& 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<uint8_t>& volIter, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32_t vertexIndicesX[],int32_t vertexIndicesY[],int32_t vertexIndicesZ[]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); //FIXME - should pass variables by reference?
|
||||
void extractReferenceSurfaceImpl(Volume<uint8_t>* 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<int32>& vertexIndicesX, const std::vector<int32>& vertexIndicesY, const std::vector<int32>& vertexIndicesZ);
|
||||
int32_t getIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, const std::vector<int32_t>& vertexIndicesX, const std::vector<int32_t>& vertexIndicesY, const std::vector<int32_t>& vertexIndicesZ);
|
||||
///Sets the index of an existing vertex for a given edge.
|
||||
void setIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, int32 newIndex, std::vector<int32>& vertexIndicesX, std::vector<int32>& vertexIndicesY, std::vector<int32>& vertexIndicesZ);
|
||||
void setIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, int32_t newIndex, std::vector<int32_t>& vertexIndicesX, std::vector<int32_t>& vertexIndicesY, std::vector<int32_t>& vertexIndicesZ);
|
||||
}
|
||||
|
||||
#endif
|
@ -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;
|
||||
|
@ -32,8 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
POLYVOX_API void smoothRegionGeometry(Volume<uint8>* volumeData, IndexedSurfacePatch& isp);
|
||||
POLYVOX_API void adjustDecimatedGeometry(Volume<uint8>* volumeData, IndexedSurfacePatch& isp, uint8 val);
|
||||
POLYVOX_API void smoothRegionGeometry(Volume<uint8_t>* volumeData, IndexedSurfacePatch& isp);
|
||||
POLYVOX_API void adjustDecimatedGeometry(Volume<uint8_t>* volumeData, IndexedSurfacePatch& isp, uint8_t val);
|
||||
}
|
||||
|
||||
#endif
|
@ -34,8 +34,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
POLYVOX_API void extractSurface(Volume<uint8>* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API void extractReferenceSurface(Volume<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API void extractSurface(Volume<uint8_t>* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API void extractReferenceSurface(Volume<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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 <typename Type>
|
||||
Type trilinearlyInterpolate(
|
||||
|
@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
namespace PolyVox
|
||||
{
|
||||
///Represents a vector in space.
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
class Vector
|
||||
{
|
||||
public:
|
||||
@ -66,7 +66,7 @@ namespace PolyVox
|
||||
Vector<Size,Type>& 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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator+(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||
///Subtraction operator.
|
||||
template <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||
///Multiplication operator.
|
||||
template <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw();
|
||||
///Division operator.
|
||||
template <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator/(const Vector<Size,Type>& lhs, const Type& rhs) throw();
|
||||
///Stream insertion operator.
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
std::ostream& operator<<(std::ostream& os, const Vector<Size,Type>& 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;
|
||||
|
||||
|
||||
|
||||
|
@ -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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type>::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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type>::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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
Vector<Size, Type>::Vector(const Vector<Size, Type>& 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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
template <typename CastType>
|
||||
Vector<Size, Type>::Vector(const Vector<Size, CastType>& vector) throw()
|
||||
{
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] = static_cast<CastType>(vector.getElement(ct));
|
||||
}
|
||||
@ -134,7 +134,7 @@ namespace PolyVox
|
||||
/**
|
||||
Destroys the Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
Vector<Size, Type>::~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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
Vector<Size, Type>& Vector<Size, Type>::operator=(const Vector<Size, Type>& rhs) throw()
|
||||
{
|
||||
if(this == &rhs)
|
||||
@ -163,11 +163,11 @@ namespace PolyVox
|
||||
\return true if the Vectors match.
|
||||
\see operator!=
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline bool Vector<Size, Type>::operator==(const Vector<Size, Type> &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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline bool Vector<Size, Type>::operator<(const Vector<Size, Type> &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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator+=(const Vector<Size, Type>& 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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator+(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
@ -232,10 +232,10 @@ namespace PolyVox
|
||||
\param rhs Vector to subtract
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator-=(const Vector<Size, Type>& 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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
@ -261,10 +261,10 @@ namespace PolyVox
|
||||
\param rhs the number the Vector is multiplied by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
@ -290,10 +290,10 @@ namespace PolyVox
|
||||
\param rhs the number the Vector is divided by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
Vector<Size,Type> operator/(const Vector<Size,Type>& lhs, const Type& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> 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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
std::ostream& operator<<(std::ostream& os, const Vector<Size, Type>& 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 <uint32 Size, typename Type>
|
||||
inline Type Vector<Size, Type>::getElement(uint32 index) const throw()
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
inline void Vector<Size, Type>::setElement(uint32 index, Type tValue) throw()
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
inline void Vector<Size,Type>::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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
inline void Vector<Size,Type>::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 <uint32 Size,typename Type>
|
||||
template <uint32_t Size,typename Type>
|
||||
inline void Vector<Size,Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline double Vector<Size, Type>::length(void) const throw()
|
||||
{
|
||||
return sqrt(lengthSquared());
|
||||
@ -492,11 +492,11 @@ namespace PolyVox
|
||||
/**
|
||||
\return Squared length of the Vector.
|
||||
*/
|
||||
template <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline double Vector<Size, Type>::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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline double Vector<Size, Type>::angleTo(const Vector<Size, Type>& 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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Vector<Size, Type> Vector<Size, Type>::cross(const Vector<Size, Type>& 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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::dot(const Vector<Size, Type>& rhs) const throw()
|
||||
{
|
||||
Type dotProduct = static_cast<Type>(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 <uint32 Size, typename Type>
|
||||
template <uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::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<Type>(length);
|
||||
}
|
||||
|
@ -49,22 +49,22 @@ namespace PolyVox
|
||||
friend class VolumeIterator<VoxelType>;
|
||||
|
||||
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<VoxelType> firstVoxel(void);
|
||||
void idle(uint32 uAmount);
|
||||
void idle(uint32_t uAmount);
|
||||
bool isRegionHomogenous(const Region& region);
|
||||
VolumeIterator<VoxelType> lastVoxel(void);
|
||||
|
||||
@ -74,20 +74,20 @@ namespace PolyVox
|
||||
Block<VoxelType>* m_pBlocks;
|
||||
mutable std::map<VoxelType, POLYVOX_WEAK_PTR< BlockData<VoxelType> > > 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<float> FloatVolume;
|
||||
typedef Volume<uint8> UInt8Volume;
|
||||
typedef Volume<uint16> UInt16Volume;
|
||||
typedef Volume<uint8_t> UInt8Volume;
|
||||
typedef Volume<uint16_t> UInt16Volume;
|
||||
}
|
||||
|
||||
#include "Volume.inl"
|
||||
|
@ -34,7 +34,7 @@ namespace PolyVox
|
||||
{
|
||||
#pragma region Constructors/Destructors
|
||||
template <typename VoxelType>
|
||||
Volume<VoxelType>::Volume(uint16 uSideLength, uint16 uBlockSideLength)
|
||||
Volume<VoxelType>::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<VoxelType>[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 <typename VoxelType>
|
||||
Volume<VoxelType>::~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 <typename VoxelType>
|
||||
uint16 Volume<VoxelType>::getSideLength(void) const
|
||||
uint16_t Volume<VoxelType>::getSideLength(void) const
|
||||
{
|
||||
return m_uSideLength;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType Volume<VoxelType>::getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const
|
||||
VoxelType Volume<VoxelType>::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<VoxelType> > block = m_pBlocks
|
||||
[
|
||||
@ -176,17 +176,17 @@ namespace PolyVox
|
||||
|
||||
#pragma region Setters
|
||||
template <typename VoxelType>
|
||||
void Volume<VoxelType>::setVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos, VoxelType tValue)
|
||||
void Volume<VoxelType>::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 <typename VoxelType>
|
||||
void Volume<VoxelType>::idle(uint32 uAmount)
|
||||
void Volume<VoxelType>::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<VoxelType> block = m_pBlocks[i];
|
||||
if(block.m_bIsPotentiallySharable)
|
||||
|
@ -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<VoxelType>& 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<VoxelType>& 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;
|
||||
};
|
||||
|
@ -108,25 +108,25 @@ namespace PolyVox
|
||||
|
||||
#pragma region Getters
|
||||
template <typename VoxelType>
|
||||
uint16 VolumeIterator<VoxelType>::getPosX(void) const
|
||||
uint16_t VolumeIterator<VoxelType>::getPosX(void) const
|
||||
{
|
||||
return mXPosInVolume;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
uint16 VolumeIterator<VoxelType>::getPosY(void) const
|
||||
uint16_t VolumeIterator<VoxelType>::getPosY(void) const
|
||||
{
|
||||
return mYPosInVolume;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
uint16 VolumeIterator<VoxelType>::getPosZ(void) const
|
||||
uint16_t VolumeIterator<VoxelType>::getPosZ(void) const
|
||||
{
|
||||
return mZPosInVolume;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::getSubSampledVoxel(uint8 uLevel) const
|
||||
VoxelType VolumeIterator<VoxelType>::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<VoxelType>::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 <typename VoxelType>
|
||||
void VolumeIterator<VoxelType>::setPosition(uint16 xPos, uint16 yPos, uint16 zPos)
|
||||
void VolumeIterator<VoxelType>::setPosition(uint16_t xPos, uint16_t yPos, uint16_t zPos)
|
||||
{
|
||||
mXPosInVolume = xPos;
|
||||
mYPosInVolume = yPos;
|
||||
@ -217,7 +217,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void VolumeIterator<VoxelType>::setValidRegion(uint16 xFirst, uint16 yFirst, uint16 zFirst, uint16 xLast, uint16 yLast, uint16 zLast)
|
||||
void VolumeIterator<VoxelType>::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<VoxelType>* 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);
|
||||
|
@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
float computeSmoothedVoxel(VolumeIterator<uint8>& volIter);
|
||||
float computeSmoothedVoxel(VolumeIterator<uint8_t>& volIter);
|
||||
}
|
||||
|
||||
#endif
|
@ -31,11 +31,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
POLYVOX_API Volume<uint8>* loadVolumeRaw(std::istream& stream);
|
||||
POLYVOX_API void saveVolumeRaw(std::ostream& stream, Volume<uint8>& volume);
|
||||
POLYVOX_API Volume<uint8_t>* loadVolumeRaw(std::istream& stream);
|
||||
POLYVOX_API void saveVolumeRaw(std::ostream& stream, Volume<uint8_t>& volume);
|
||||
|
||||
POLYVOX_API Volume<uint8>* loadVolumeRle(std::istream& stream);
|
||||
POLYVOX_API void saveVolumeRle(std::ostream& stream, Volume<uint8>& volume);
|
||||
POLYVOX_API Volume<uint8_t>* loadVolumeRle(std::istream& stream);
|
||||
POLYVOX_API void saveVolumeRle(std::ostream& stream, Volume<uint8_t>& volume);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -36,43 +36,43 @@ namespace PolyVox
|
||||
{
|
||||
public:
|
||||
//Constructors, etc
|
||||
VolumeChangeTracker(Volume<uint8>* volumeDataToSet, uint16 regionSideLength);
|
||||
VolumeChangeTracker(Volume<uint8_t>* 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<uint8>* 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<uint8_t>* 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<uint8>* volumeData;
|
||||
Volume<uint8_t>* 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<int32>* volRegionLastModified;
|
||||
BlockData<int32_t>* volRegionLastModified;
|
||||
|
||||
static int32 m_iCurrentTime;
|
||||
static int32_t m_iCurrentTime;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
POLYVOX_API void computeNormalsForVertices(Volume<uint8>* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod)
|
||||
POLYVOX_API void computeNormalsForVertices(Volume<uint8_t>* volumeData, IndexedSurfacePatch& isp, NormalGenerationMethod normalGenerationMethod)
|
||||
{
|
||||
std::vector<SurfaceVertex>& vecVertices = isp.getRawVertexData();
|
||||
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = vecVertices.begin();
|
||||
@ -15,7 +15,7 @@ namespace PolyVox
|
||||
const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast<Vector3DFloat>(isp.m_v3dRegionPosition);
|
||||
const Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos);
|
||||
|
||||
VolumeIterator<uint8> volIter(*volumeData);
|
||||
VolumeIterator<uint8_t> 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<uint8>* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod)
|
||||
Vector3DFloat computeNormal(Volume<uint8_t>* volumeData, const Vector3DFloat& v3dPos, NormalGenerationMethod normalGenerationMethod)
|
||||
{
|
||||
Vector3DFloat v3dGradient; //To store the result
|
||||
|
||||
VolumeIterator<uint8> volIter(*volumeData);
|
||||
VolumeIterator<uint8_t> volIter(*volumeData);
|
||||
|
||||
const Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos);
|
||||
|
||||
@ -103,20 +103,20 @@ namespace PolyVox
|
||||
if(normalGenerationMethod == SIMPLE)
|
||||
{
|
||||
volIter.setPosition(static_cast<Vector3DInt16>(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<float>(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<float>(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<float>(uFloor - uCeil));
|
||||
}
|
||||
}
|
||||
|
@ -34,20 +34,20 @@ namespace PolyVox
|
||||
{
|
||||
}
|
||||
|
||||
const std::vector<uint32>& IndexedSurfacePatch::getIndices(void) const
|
||||
const std::vector<uint32_t>& 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;
|
||||
|
@ -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<uint8>* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void extractDecimatedSurfaceImpl(Volume<uint8_t>* 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<uint8> volIter(*volumeData);
|
||||
VolumeIterator<uint8_t> 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<uint8>& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask)
|
||||
uint32_t computeInitialDecimatedBitmaskForSlice(VolumeIterator<uint8_t>& 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<uint8>& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, uint8* previousBitmask)
|
||||
uint32_t computeDecimatedBitmaskForSliceFromPrevious(VolumeIterator<uint8_t>& 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<uint8>& volIter, uint8 uLevel, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[])
|
||||
void generateDecimatedVerticesForSlice(VolumeIterator<uint8_t>& 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<uint8>& 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<uint8_t>& 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
|
||||
|
@ -29,21 +29,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
namespace PolyVox
|
||||
{
|
||||
|
||||
void extractFastSurfaceImpl(Volume<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void extractFastSurfaceImpl(Volume<uint8_t>* 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<uint8> volIter(*volumeData);
|
||||
VolumeIterator<uint8_t> 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<uint8>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask)
|
||||
uint32_t computeInitialRoughBitmaskForSlice(VolumeIterator<uint8_t>& 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<uint8>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, uint8* previousBitmask)
|
||||
uint32_t computeRoughBitmaskForSliceFromPrevious(VolumeIterator<uint8_t>& 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<uint8>& volIter, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[])
|
||||
void generateRoughVerticesForSlice(VolumeIterator<uint8_t>& 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<uint8>& 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<uint8_t>& 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
|
||||
|
@ -31,16 +31,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
void extractReferenceSurfaceImpl(Volume<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void extractReferenceSurfaceImpl(Volume<uint8_t>* 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<int32> vertexIndicesX(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ());
|
||||
std::vector<int32> vertexIndicesY(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ());
|
||||
std::vector<int32> vertexIndicesZ(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ());
|
||||
std::vector<int32_t> vertexIndicesX(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ());
|
||||
std::vector<int32_t> vertexIndicesY(regionDimensions.getX() * regionDimensions.getY() * regionDimensions.getZ());
|
||||
std::vector<int32_t> 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<uint8> volIter(*volumeData);
|
||||
uint8_t vertMaterials[12];
|
||||
VolumeIterator<uint8_t> 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<Vector3DFloat>(vertex1) / 2.0f) - offset;
|
||||
//const Vector3DFloat vertex2AsFloat = (static_cast<Vector3DFloat>(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<int32>& vertexIndicesX, const std::vector<int32>& vertexIndicesY, const std::vector<int32>& vertexIndicesZ)
|
||||
int32_t getIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, const std::vector<int32_t>& vertexIndicesX, const std::vector<int32_t>& vertexIndicesY, const std::vector<int32_t>& 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<uint16>(xIntPartAsFloat);
|
||||
uint16 yIntPart = static_cast<uint16>(yIntPartAsFloat);
|
||||
uint16 zIntPart = static_cast<uint16>(zIntPartAsFloat);
|
||||
uint16_t xIntPart = static_cast<uint16_t>(xIntPartAsFloat);
|
||||
uint16_t yIntPart = static_cast<uint16_t>(yIntPartAsFloat);
|
||||
uint16_t zIntPart = static_cast<uint16_t>(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<int32>& vertexIndicesX, std::vector<int32>& vertexIndicesY, std::vector<int32>& vertexIndicesZ)
|
||||
void setIndexFor(const Vector3DFloat& pos, const Vector3DInt32& regionDimensions, int32_t newIndex, std::vector<int32_t>& vertexIndicesX, std::vector<int32_t>& vertexIndicesY, std::vector<int32_t>& 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<uint16>(xIntPartAsFloat);
|
||||
uint16 yIntPart = static_cast<uint16>(yIntPartAsFloat);
|
||||
uint16 zIntPart = static_cast<uint16>(zIntPartAsFloat);
|
||||
uint16_t xIntPart = static_cast<uint16_t>(xIntPartAsFloat);
|
||||
uint16_t yIntPart = static_cast<uint16_t>(yIntPartAsFloat);
|
||||
uint16_t zIntPart = static_cast<uint16_t>(zIntPartAsFloat);
|
||||
|
||||
//Of all the fractional parts, two should be zero and one should be 0.5.
|
||||
if(xFracPart > 0.25f)
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
void smoothRegionGeometry(Volume<uint8>* volumeData, IndexedSurfacePatch& isp)
|
||||
void smoothRegionGeometry(Volume<uint8_t>* volumeData, IndexedSurfacePatch& isp)
|
||||
{
|
||||
const uint8 uSmoothingFactor = 2;
|
||||
const uint8_t uSmoothingFactor = 2;
|
||||
const float fThreshold = 0.5f;
|
||||
|
||||
VolumeIterator<uint8> volIter(*volumeData);
|
||||
VolumeIterator<uint8_t> volIter(*volumeData);
|
||||
|
||||
std::vector<SurfaceVertex>& vecVertices = isp.getRawVertexData();
|
||||
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = vecVertices.begin();
|
||||
@ -76,9 +76,9 @@ namespace PolyVox
|
||||
} //while(iterSurfaceVertex != vecVertices.end())
|
||||
}
|
||||
|
||||
void adjustDecimatedGeometry(Volume<uint8>* volumeData, IndexedSurfacePatch& isp, uint8 val)
|
||||
void adjustDecimatedGeometry(Volume<uint8_t>* volumeData, IndexedSurfacePatch& isp, uint8_t val)
|
||||
{
|
||||
VolumeIterator<uint8> volIter(*volumeData);
|
||||
VolumeIterator<uint8_t> volIter(*volumeData);
|
||||
|
||||
std::vector<SurfaceVertex>& vecVertices = isp.getRawVertexData();
|
||||
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = vecVertices.begin();
|
||||
@ -87,7 +87,7 @@ namespace PolyVox
|
||||
Vector3DFloat v3dPos = iterSurfaceVertex->getPosition() + static_cast<Vector3DFloat>(isp.m_v3dRegionPosition);
|
||||
Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos);
|
||||
|
||||
VolumeIterator<uint8> volIter(*volumeData);
|
||||
VolumeIterator<uint8_t> 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<Vector3DInt16>(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<Vector3DInt16>(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<Vector3DInt32>(v3dPos);
|
||||
|
||||
volIter.setPosition(static_cast<Vector3DInt16>(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<Vector3DInt16>(v3dFloor+Vector3DInt32(1,0,0)));
|
||||
|
@ -18,7 +18,7 @@ using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
void extractSurface(Volume<uint8>* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void extractSurface(Volume<uint8_t>* 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<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void extractReferenceSurface(Volume<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
{
|
||||
extractReferenceSurfaceImpl(volumeData, region, singleMaterialPatch);
|
||||
|
||||
|
@ -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<uint8>(uResult-1);
|
||||
return static_cast<uint8_t>(uResult-1);
|
||||
}
|
||||
|
||||
|
||||
bool isPowerOf2(uint32 uInput)
|
||||
bool isPowerOf2(uint32_t uInput)
|
||||
{
|
||||
if(uInput == 0)
|
||||
return false;
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
float computeSmoothedVoxel(VolumeIterator<uint8>& volIter)
|
||||
float computeSmoothedVoxel(VolumeIterator<uint8_t>& volIter)
|
||||
{
|
||||
assert(volIter.getPosX() >= 1);
|
||||
assert(volIter.getPosY() >= 1);
|
||||
|
@ -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<uint8>* loadVolumeRaw(istream& stream)
|
||||
Volume<uint8_t>* 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<char*>(&volumeWidthPower), sizeof(volumeWidthPower));
|
||||
stream.read(reinterpret_cast<char*>(&volumeHeightPower), sizeof(volumeHeightPower));
|
||||
stream.read(reinterpret_cast<char*>(&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<uint8>* volume = new Volume<uint8>(volumeWidth);
|
||||
Volume<uint8_t>* volume = new Volume<uint8_t>(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<char*>(&value), sizeof(value));
|
||||
|
||||
volume->setVoxelAt(x,y,z,value);
|
||||
@ -45,31 +45,31 @@ namespace PolyVox
|
||||
return volume;
|
||||
}
|
||||
|
||||
void saveVolumeRaw(std::ostream& stream, Volume<uint8>& volume)
|
||||
void saveVolumeRaw(std::ostream& stream, Volume<uint8_t>& 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<char*>(&volumeWidthPower), sizeof(volumeWidthPower));
|
||||
stream.write(reinterpret_cast<char*>(&volumeHeightPower), sizeof(volumeHeightPower));
|
||||
stream.write(reinterpret_cast<char*>(&volumeDepthPower), sizeof(volumeDepthPower));
|
||||
|
||||
//Write data
|
||||
VolumeIterator<uint8> volIter(volume);
|
||||
for(uint16 z = 0; z < volumeDepth; ++z)
|
||||
VolumeIterator<uint8_t> 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<char*>(&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<uint8>* loadVolumeRle(istream& stream)
|
||||
Volume<uint8_t>* 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<char*>(&volumeWidthPower), sizeof(volumeWidthPower));
|
||||
stream.read(reinterpret_cast<char*>(&volumeHeightPower), sizeof(volumeHeightPower));
|
||||
stream.read(reinterpret_cast<char*>(&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<uint8>* volume = new Volume<uint8>(volumeWidth);
|
||||
Volume<uint8_t>* volume = new Volume<uint8_t>(volumeWidth);
|
||||
|
||||
//Read data
|
||||
bool firstTime = true;
|
||||
uint32 runLength = 0;
|
||||
uint8 value = 0;
|
||||
uint32_t runLength = 0;
|
||||
uint8_t value = 0;
|
||||
stream.read(reinterpret_cast<char*>(&value), sizeof(value));
|
||||
stream.read(reinterpret_cast<char*>(&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<uint8>& volume)
|
||||
void saveVolumeRle(std::ostream& stream, Volume<uint8_t>& 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<char*>(&volumeWidthPower), sizeof(volumeWidthPower));
|
||||
stream.write(reinterpret_cast<char*>(&volumeHeightPower), sizeof(volumeHeightPower));
|
||||
stream.write(reinterpret_cast<char*>(&volumeDepthPower), sizeof(volumeDepthPower));
|
||||
|
||||
//Write data
|
||||
VolumeIterator<uint8> volIter(volume);
|
||||
uint8 current = 0;
|
||||
uint32 runLength = 0;
|
||||
VolumeIterator<uint8_t> 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;
|
||||
|
@ -35,12 +35,12 @@ using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
int32 VolumeChangeTracker::m_iCurrentTime = 0;
|
||||
int32_t VolumeChangeTracker::m_iCurrentTime = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// VolumeChangeTracker
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
VolumeChangeTracker::VolumeChangeTracker(Volume<uint8>* volumeDataToSet, uint16 regionSideLength)
|
||||
VolumeChangeTracker::VolumeChangeTracker(Volume<uint8_t>* 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<int32>(m_uRegionSideLength);
|
||||
volRegionLastModified = new BlockData<int32_t>(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<uint8> volIter(*volumeData);
|
||||
VolumeIterator<uint8_t> volIter(*volumeData);
|
||||
volIter.setPosition(uX,uY,uZ);
|
||||
return volIter.getVoxel();
|
||||
}
|
||||
|
||||
Volume<uint8>* VolumeChangeTracker::getVolumeData(void) const
|
||||
Volume<uint8_t>* 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<uint8> iterVol(*volumeData);
|
||||
//VolumeIterator<uint8_t> 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<uint8> iterVol(*volumeData);
|
||||
/*VolumeIterator<uint8_t> 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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user