Applied default Visual Studio formatting to most files. This is a quick fix for the tabs vs spaces issue that messes up the formatting in any editor (esp. Linux) which handles tabs/spaces differently to Visual Studio. Some parts of the formatting look a bit worse but overall it should be better (or at least more consistent).

I didn't apply the changes to a few macro-heavy files as Visual Studio removes all indentation from macros, whereas the indentation can be handy to see nesting.
This commit is contained in:
David Williams 2015-12-26 23:11:27 +00:00
parent b3ca051878
commit e89a55d154
58 changed files with 1117 additions and 1114 deletions

View File

@ -47,14 +47,14 @@ void createSphereInVolume(RawVolume<uint8_t>& volData, float fRadius)
for (int x = 0; x < volData.getWidth(); x++) for (int x = 0; x < volData.getWidth(); x++)
{ {
//Store our current position as a vector... //Store our current position as a vector...
Vector3DFloat v3dCurrentPos(x,y,z); Vector3DFloat v3dCurrentPos(x, y, z);
//And compute how far the current position is from the center of the volume //And compute how far the current position is from the center of the volume
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length(); float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
uint8_t uVoxelValue = 0; uint8_t uVoxelValue = 0;
//If the current voxel is less than 'radius' units from the center then we make it solid. //If the current voxel is less than 'radius' units from the center then we make it solid.
if(fDistToCenter <= fRadius) if (fDistToCenter <= fRadius)
{ {
//Our new voxel value //Our new voxel value
uVoxelValue = 255; uVoxelValue = 255;

View File

@ -47,14 +47,14 @@ void createSphereInVolume(RawVolume<uint8_t>& volData, float fRadius)
for (int x = 0; x < volData.getWidth(); x++) for (int x = 0; x < volData.getWidth(); x++)
{ {
//Store our current position as a vector... //Store our current position as a vector...
Vector3DFloat v3dCurrentPos(x,y,z); Vector3DFloat v3dCurrentPos(x, y, z);
//And compute how far the current position is from the center of the volume //And compute how far the current position is from the center of the volume
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length(); float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
uint8_t uVoxelValue = 0; uint8_t uVoxelValue = 0;
//If the current voxel is less than 'radius' units from the center then we make it solid. //If the current voxel is less than 'radius' units from the center then we make it solid.
if(fDistToCenter <= fRadius) if (fDistToCenter <= fRadius)
{ {
//Our new voxel value //Our new voxel value
uVoxelValue = 255; uVoxelValue = 255;

View File

@ -41,15 +41,15 @@ void createSphereInVolume(RawVolume<MaterialDensityPair88>& volData, float fRadi
for (int x = 0; x < volData.getWidth(); x++) for (int x = 0; x < volData.getWidth(); x++)
{ {
//Store our current position as a vector... //Store our current position as a vector...
Vector3DInt32 v3dCurrentPos(x,y,z); Vector3DInt32 v3dCurrentPos(x, y, z);
//And compute how far the current position is from the center of the volume //And compute how far the current position is from the center of the volume
double fDistToCenter = (v3dCurrentPos - v3dVolCenter).length(); double fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
//If the current voxel is less than 'radius' units from the center //If the current voxel is less than 'radius' units from the center
//then we make it solid, otherwise we make it empty space. //then we make it solid, otherwise we make it empty space.
if(fDistToCenter <= fRadius) if (fDistToCenter <= fRadius)
{ {
volData.setVoxel(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? MaterialDensityPair88::getMaxDensity() : MaterialDensityPair88::getMinDensity())); volData.setVoxel(x, y, z, MaterialDensityPair88(uValue, uValue > 0 ? MaterialDensityPair88::getMaxDensity() : MaterialDensityPair88::getMinDensity()));
} }
} }
} }
@ -65,9 +65,9 @@ void createCubeInVolume(RawVolume<MaterialDensityPair88>& volData, Vector3DInt32
{ {
for (int y = lowerCorner.getY(); y <= upperCorner.getY(); y++) for (int y = lowerCorner.getY(); y <= upperCorner.getY(); y++)
{ {
for (int x = lowerCorner.getX() ; x <= upperCorner.getX(); x++) for (int x = lowerCorner.getX(); x <= upperCorner.getX(); x++)
{ {
volData.setVoxel(x,y,z, MaterialDensityPair88(uValue, uValue > 0 ? maxDen : minDen)); volData.setVoxel(x, y, z, MaterialDensityPair88(uValue, uValue > 0 ? maxDen : minDen));
} }
} }
} }

View File

@ -42,12 +42,12 @@ float Perlin::noise1(float arg)
init(); init();
} }
setup(0, bx0,bx1, rx0,rx1); setup(0, bx0, bx1, rx0, rx1);
sx = s_curve(rx0); sx = s_curve(rx0);
u = rx0 * g1[ p[ bx0 ] ]; u = rx0 * g1[p[bx0]];
v = rx1 * g1[ p[ bx1 ] ]; v = rx1 * g1[p[bx1]];
return lerp(sx, u, v); return lerp(sx, u, v);
} }
@ -65,8 +65,8 @@ float Perlin::noise2(float vec[2])
init(); init();
} }
setup(0,bx0,bx1,rx0,rx1); setup(0, bx0, bx1, rx0, rx1);
setup(1,by0,by1,ry0,ry1); setup(1, by0, by1, ry0, ry1);
i = p[bx0]; i = p[bx0];
j = p[bx1]; j = p[bx1];
@ -79,18 +79,18 @@ float Perlin::noise2(float vec[2])
sx = s_curve(rx0); sx = s_curve(rx0);
sy = s_curve(ry0); sy = s_curve(ry0);
#define at2(rx,ry) ( rx * q[0] + ry * q[1] ) #define at2(rx,ry) ( rx * q[0] + ry * q[1] )
q = g2[b00]; q = g2[b00];
u = at2(rx0,ry0); u = at2(rx0, ry0);
q = g2[b10]; q = g2[b10];
v = at2(rx1,ry0); v = at2(rx1, ry0);
a = lerp(sx, u, v); a = lerp(sx, u, v);
q = g2[b01]; q = g2[b01];
u = at2(rx0,ry1); u = at2(rx0, ry1);
q = g2[b11]; q = g2[b11];
v = at2(rx1,ry1); v = at2(rx1, ry1);
b = lerp(sx, u, v); b = lerp(sx, u, v);
return lerp(sy, a, b); return lerp(sy, a, b);
@ -109,40 +109,40 @@ float Perlin::noise3(float vec[3])
init(); init();
} }
setup(0, bx0,bx1, rx0,rx1); setup(0, bx0, bx1, rx0, rx1);
setup(1, by0,by1, ry0,ry1); setup(1, by0, by1, ry0, ry1);
setup(2, bz0,bz1, rz0,rz1); setup(2, bz0, bz1, rz0, rz1);
i = p[ bx0 ]; i = p[bx0];
j = p[ bx1 ]; j = p[bx1];
b00 = p[ i + by0 ]; b00 = p[i + by0];
b10 = p[ j + by0 ]; b10 = p[j + by0];
b01 = p[ i + by1 ]; b01 = p[i + by1];
b11 = p[ j + by1 ]; b11 = p[j + by1];
t = s_curve(rx0); t = s_curve(rx0);
sy = s_curve(ry0); sy = s_curve(ry0);
sz = s_curve(rz0); sz = s_curve(rz0);
#define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] ) #define at3(rx,ry,rz) ( rx * q[0] + ry * q[1] + rz * q[2] )
q = g3[ b00 + bz0 ] ; u = at3(rx0,ry0,rz0); q = g3[b00 + bz0]; u = at3(rx0, ry0, rz0);
q = g3[ b10 + bz0 ] ; v = at3(rx1,ry0,rz0); q = g3[b10 + bz0]; v = at3(rx1, ry0, rz0);
a = lerp(t, u, v); a = lerp(t, u, v);
q = g3[ b01 + bz0 ] ; u = at3(rx0,ry1,rz0); q = g3[b01 + bz0]; u = at3(rx0, ry1, rz0);
q = g3[ b11 + bz0 ] ; v = at3(rx1,ry1,rz0); q = g3[b11 + bz0]; v = at3(rx1, ry1, rz0);
b = lerp(t, u, v); b = lerp(t, u, v);
c = lerp(sy, a, b); c = lerp(sy, a, b);
q = g3[ b00 + bz1 ] ; u = at3(rx0,ry0,rz1); q = g3[b00 + bz1]; u = at3(rx0, ry0, rz1);
q = g3[ b10 + bz1 ] ; v = at3(rx1,ry0,rz1); q = g3[b10 + bz1]; v = at3(rx1, ry0, rz1);
a = lerp(t, u, v); a = lerp(t, u, v);
q = g3[ b01 + bz1 ] ; u = at3(rx0,ry1,rz1); q = g3[b01 + bz1]; u = at3(rx0, ry1, rz1);
q = g3[ b11 + bz1 ] ; v = at3(rx1,ry1,rz1); q = g3[b11 + bz1]; v = at3(rx1, ry1, rz1);
b = lerp(t, u, v); b = lerp(t, u, v);
d = lerp(sy, a, b); d = lerp(sy, a, b);
@ -155,7 +155,7 @@ void Perlin::normalize2(float v[2])
float s; float s;
s = (float)sqrt(v[0] * v[0] + v[1] * v[1]); s = (float)sqrt(v[0] * v[0] + v[1] * v[1]);
s = 1.0f/s; s = 1.0f / s;
v[0] = v[0] * s; v[0] = v[0] * s;
v[1] = v[1] * s; v[1] = v[1] * s;
} }
@ -165,7 +165,7 @@ void Perlin::normalize3(float v[3])
float s; float s;
s = (float)sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); s = (float)sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
s = 1.0f/s; s = 1.0f / s;
v[0] = v[0] * s; v[0] = v[0] * s;
v[1] = v[1] * s; v[1] = v[1] * s;
@ -176,14 +176,14 @@ void Perlin::init(void)
{ {
int i, j, k; int i, j, k;
for (i = 0 ; i < B ; i++) for (i = 0; i < B; i++)
{ {
p[i] = i; p[i] = i;
g1[i] = (float)((rand() % (B + B)) - B) / B; g1[i] = (float)((rand() % (B + B)) - B) / B;
for (j = 0 ; j < 2 ; j++) for (j = 0; j < 2; j++)
g2[i][j] = (float)((rand() % (B + B)) - B) / B; g2[i][j] = (float)((rand() % (B + B)) - B) / B;
normalize2(g2[i]); normalize2(g2[i]);
for (j = 0 ; j < 3 ; j++) for (j = 0; j < 3; j++)
g3[i][j] = (float)((rand() % (B + B)) - B) / B; g3[i][j] = (float)((rand() % (B + B)) - B) / B;
normalize3(g3[i]); normalize3(g3[i]);
} }
@ -195,13 +195,13 @@ void Perlin::init(void)
p[j] = k; p[j] = k;
} }
for (i = 0 ; i < B + 2 ; i++) for (i = 0; i < B + 2; i++)
{ {
p[B + i] = p[i]; p[B + i] = p[i];
g1[B + i] = g1[i]; g1[B + i] = g1[i];
for (j = 0 ; j < 2 ; j++) for (j = 0; j < 2; j++)
g2[B + i][j] = g2[i][j]; g2[B + i][j] = g2[i][j];
for (j = 0 ; j < 3 ; j++) for (j = 0; j < 3; j++)
g3[B + i][j] = g3[i][j]; g3[B + i][j] = g3[i][j];
} }
@ -214,15 +214,15 @@ float Perlin::perlin_noise_2D(float vec[2])
float result = 0.0f; float result = 0.0f;
float amp = mAmplitude; float amp = mAmplitude;
vec[0]*=mFrequency; vec[0] *= mFrequency;
vec[1]*=mFrequency; vec[1] *= mFrequency;
for( int i=0; i<terms; i++ ) for (int i = 0; i < terms; i++)
{ {
result += noise2(vec)*amp; result += noise2(vec)*amp;
vec[0] *= 2.0f; vec[0] *= 2.0f;
vec[1] *= 2.0f; vec[1] *= 2.0f;
amp*=0.5f; amp *= 0.5f;
} }
@ -235,17 +235,17 @@ float Perlin::perlin_noise_3D(float vec[3])
float result = 0.0f; float result = 0.0f;
float amp = mAmplitude; float amp = mAmplitude;
vec[0]*=mFrequency; vec[0] *= mFrequency;
vec[1]*=mFrequency; vec[1] *= mFrequency;
vec[2]*=mFrequency; vec[2] *= mFrequency;
for( int i=0; i<terms; i++ ) for (int i = 0; i < terms; i++)
{ {
result += noise3(vec)*amp; result += noise3(vec)*amp;
vec[0] *= 2.0f; vec[0] *= 2.0f;
vec[1] *= 2.0f; vec[1] *= 2.0f;
vec[2] *= 2.0f; vec[2] *= 2.0f;
amp*=0.5f; amp *= 0.5f;
} }
@ -254,7 +254,7 @@ float Perlin::perlin_noise_3D(float vec[3])
Perlin::Perlin(int octaves,float freq,float amp,int seed) Perlin::Perlin(int octaves, float freq, float amp, int seed)
{ {
mOctaves = octaves; mOctaves = octaves;
mFrequency = freq; mFrequency = freq;

View File

@ -53,29 +53,30 @@ public:
virtual void pageIn(const PolyVox::Region& region, PagedVolume<MaterialDensityPair44>::Chunk* pChunk) virtual void pageIn(const PolyVox::Region& region, PagedVolume<MaterialDensityPair44>::Chunk* pChunk)
{ {
Perlin perlin(2,2,1,234); Perlin perlin(2, 2, 1, 234);
for(int x = region.getLowerX(); x <= region.getUpperX(); x++) for (int x = region.getLowerX(); x <= region.getUpperX(); x++)
{ {
for(int y = region.getLowerY(); y <= region.getUpperY(); y++) for (int y = region.getLowerY(); y <= region.getUpperY(); y++)
{ {
float perlinVal = perlin.Get(x / static_cast<float>(255-1), y / static_cast<float>(255-1)); float perlinVal = perlin.Get(x / static_cast<float>(255 - 1), y / static_cast<float>(255 - 1));
perlinVal += 1.0f; perlinVal += 1.0f;
perlinVal *= 0.5f; perlinVal *= 0.5f;
perlinVal *= 255; perlinVal *= 255;
for(int z = region.getLowerZ(); z <= region.getUpperZ(); z++) for (int z = region.getLowerZ(); z <= region.getUpperZ(); z++)
{ {
MaterialDensityPair44 voxel; MaterialDensityPair44 voxel;
if(z < perlinVal) if (z < perlinVal)
{ {
const int xpos = 50; const int xpos = 50;
const int zpos = 100; const int zpos = 100;
if((x-xpos)*(x-xpos) + (z-zpos)*(z-zpos) < 200) if ((x - xpos)*(x - xpos) + (z - zpos)*(z - zpos) < 200)
{ {
// tunnel // tunnel
voxel.setMaterial(0); voxel.setMaterial(0);
voxel.setDensity(MaterialDensityPair44::getMinDensity()); voxel.setDensity(MaterialDensityPair44::getMinDensity());
} else }
else
{ {
// solid // solid
voxel.setMaterial(245); voxel.setMaterial(245);

View File

@ -48,11 +48,11 @@ void createSphereInVolume(RawVolume<uint8_t>& volData, float fRadius)
for (int x = 0; x < volData.getWidth(); x++) for (int x = 0; x < volData.getWidth(); x++)
{ {
//Store our current position as a vector... //Store our current position as a vector...
Vector3DFloat v3dCurrentPos(x,y,z); Vector3DFloat v3dCurrentPos(x, y, z);
//And compute how far the current position is from the center of the volume //And compute how far the current position is from the center of the volume
float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length(); float fDistToCenter = (v3dCurrentPos - v3dVolCenter).length();
if(fDistToCenter <= fRadius) if (fDistToCenter <= fRadius)
{ {
//Our new density value //Our new density value
uint8_t uDensity = std::numeric_limits<uint8_t>::max(); uint8_t uDensity = std::numeric_limits<uint8_t>::max();

View File

@ -10,7 +10,7 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
template <typename QOpenGLFunctionsType> template <typename QOpenGLFunctionsType>
OpenGLWidget<QOpenGLFunctionsType>::OpenGLWidget(QWidget *parent) OpenGLWidget<QOpenGLFunctionsType>::OpenGLWidget(QWidget *parent)
:QGLWidget(parent) :QGLWidget(parent)
{ {
} }
@ -48,13 +48,13 @@ void OpenGLWidget<QOpenGLFunctionsType>::initializeGL()
//Print out some information about the OpenGL implementation. //Print out some information about the OpenGL implementation.
std::cout << "OpenGL Implementation Details:" << std::endl; std::cout << "OpenGL Implementation Details:" << std::endl;
if(this->glGetString(GL_VENDOR)) if (this->glGetString(GL_VENDOR))
std::cout << "\tGL_VENDOR: " << this->glGetString(GL_VENDOR) << std::endl; std::cout << "\tGL_VENDOR: " << this->glGetString(GL_VENDOR) << std::endl;
if(this->glGetString(GL_RENDERER)) if (this->glGetString(GL_RENDERER))
std::cout << "\tGL_RENDERER: " << this->glGetString(GL_RENDERER) << std::endl; std::cout << "\tGL_RENDERER: " << this->glGetString(GL_RENDERER) << std::endl;
if(this->glGetString(GL_VERSION)) if (this->glGetString(GL_VERSION))
std::cout << "\tGL_VERSION: " << this->glGetString(GL_VERSION) << std::endl; std::cout << "\tGL_VERSION: " << this->glGetString(GL_VERSION) << std::endl;
if(this->glGetString(GL_SHADING_LANGUAGE_VERSION)) if (this->glGetString(GL_SHADING_LANGUAGE_VERSION))
std::cout << "\tGL_SHADING_LANGUAGE_VERSION: " << this->glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl; std::cout << "\tGL_SHADING_LANGUAGE_VERSION: " << this->glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
//Set up the clear colour //Set up the clear colour
@ -148,7 +148,7 @@ void OpenGLWidget<QOpenGLFunctionsType>::paintGL()
// Check for errors. // Check for errors.
GLenum errCode = this->glGetError(); GLenum errCode = this->glGetError();
if(errCode != GL_NO_ERROR) if (errCode != GL_NO_ERROR)
{ {
std::cerr << "OpenGL Error: " << errCode << std::endl; std::cerr << "OpenGL Error: " << errCode << std::endl;
} }

View File

@ -105,18 +105,18 @@ namespace PolyVox
float fHBias = 1.0, float fHBias = 1.0,
uint32_t uMaxNoOfNodes = 10000, uint32_t uMaxNoOfNodes = 10000,
Connectivity requiredConnectivity = TwentySixConnected, Connectivity requiredConnectivity = TwentySixConnected,
std::function<bool (const VolumeType*, const Vector3DInt32&)> funcIsVoxelValidForPath = &aStarDefaultVoxelValidator, std::function<bool(const VolumeType*, const Vector3DInt32&)> funcIsVoxelValidForPath = &aStarDefaultVoxelValidator,
std::function<void (float)> funcProgressCallback = nullptr std::function<void(float)> funcProgressCallback = nullptr
) )
:volume(volData) :volume(volData)
,start(v3dStart) , start(v3dStart)
,end(v3dEnd) , end(v3dEnd)
,result(listResult) , result(listResult)
,connectivity(requiredConnectivity) , connectivity(requiredConnectivity)
,hBias(fHBias) , hBias(fHBias)
,maxNumberOfNodes(uMaxNoOfNodes) , maxNumberOfNodes(uMaxNoOfNodes)
,isVoxelValidForPath(funcIsVoxelValidForPath) , isVoxelValidForPath(funcIsVoxelValidForPath)
,progressCallback(funcProgressCallback) , progressCallback(funcProgressCallback)
{ {
} }
@ -160,14 +160,14 @@ namespace PolyVox
/// you could check to ensure that the voxel above is empty and the voxel below is solid. /// you could check to ensure that the voxel above is empty and the voxel below is solid.
/// ///
/// \sa aStarDefaultVoxelValidator /// \sa aStarDefaultVoxelValidator
std::function<bool (const VolumeType*, const Vector3DInt32&)> isVoxelValidForPath; std::function<bool(const VolumeType*, const Vector3DInt32&)> isVoxelValidForPath;
/// This function is called by the AStarPathfinder to report on its progress in getting to /// This function is called by the AStarPathfinder to report on its progress in getting to
/// the goal. The progress is reported by computing the distance from the closest node found /// the goal. The progress is reported by computing the distance from the closest node found
/// so far to the end node, and comparing this with the distance from the start node to the /// so far to the end node, and comparing this with the distance from the start node to the
/// end node. This progress value is guarenteed to never decrease, but it may stop increasing /// end node. This progress value is guarenteed to never decrease, but it may stop increasing
///for short periods of time. It may even stop increasing altogether if a path cannot be found. ///for short periods of time. It may even stop increasing altogether if a path cannot be found.
std::function<void (float)> progressCallback; std::function<void(float)> progressCallback;
}; };
/// The AStarPathfinder compute a path from one point in the volume to another. /// The AStarPathfinder compute a path from one point in the volume to another.

View File

@ -35,7 +35,7 @@ namespace PolyVox
bool aStarDefaultVoxelValidator(const VolumeType* volData, const Vector3DInt32& v3dPos) bool aStarDefaultVoxelValidator(const VolumeType* volData, const Vector3DInt32& v3dPos)
{ {
//Voxels are considered valid candidates for the path if they are inside the volume... //Voxels are considered valid candidates for the path if they are inside the volume...
if(volData->getEnclosingRegion().containsPoint(v3dPos) == false) if (volData->getEnclosingRegion().containsPoint(v3dPos) == false)
{ {
return false; return false;
} }
@ -83,12 +83,12 @@ namespace PolyVox
float fDistStartToEnd = (endNode->position - startNode->position).length(); float fDistStartToEnd = (endNode->position - startNode->position).length();
m_fProgress = 0.0f; m_fProgress = 0.0f;
if(m_params.progressCallback) if (m_params.progressCallback)
{ {
m_params.progressCallback(m_fProgress); m_params.progressCallback(m_fProgress);
} }
while((openNodes.empty() == false) && (openNodes.getFirst() != endNode)) while ((openNodes.empty() == false) && (openNodes.getFirst() != endNode))
{ {
//Move the first node from open to closed. //Move the first node from open to closed.
current = openNodes.getFirst(); current = openNodes.getFirst();
@ -96,13 +96,13 @@ namespace PolyVox
closedNodes.insert(current); closedNodes.insert(current);
//Update the user on our progress //Update the user on our progress
if(m_params.progressCallback) if (m_params.progressCallback)
{ {
const float fMinProgresIncreament = 0.001f; const float fMinProgresIncreament = 0.001f;
float fDistCurrentToEnd = (endNode->position - current->position).length(); float fDistCurrentToEnd = (endNode->position - current->position).length();
float fDistNormalised = fDistCurrentToEnd / fDistStartToEnd; float fDistNormalised = fDistCurrentToEnd / fDistStartToEnd;
float fProgress = 1.0f - fDistNormalised; float fProgress = 1.0f - fDistNormalised;
if(fProgress >= m_fProgress + fMinProgresIncreament) if (fProgress >= m_fProgress + fMinProgresIncreament)
{ {
m_fProgress = fProgress; m_fProgress = fProgress;
m_params.progressCallback(m_fProgress); m_params.progressCallback(m_fProgress);
@ -116,7 +116,7 @@ namespace PolyVox
//Process the neighbours. Note the deliberate lack of 'break' //Process the neighbours. Note the deliberate lack of 'break'
//statements, larger connectivities include smaller ones. //statements, larger connectivities include smaller ones.
switch(m_params.connectivity) switch (m_params.connectivity)
{ {
case TwentySixConnected: case TwentySixConnected:
processNeighbour(current->position + arrayPathfinderCorners[0], current->gVal + fCornerCost); processNeighbour(current->position + arrayPathfinderCorners[0], current->gVal + fCornerCost);
@ -129,16 +129,16 @@ namespace PolyVox
processNeighbour(current->position + arrayPathfinderCorners[7], current->gVal + fCornerCost); processNeighbour(current->position + arrayPathfinderCorners[7], current->gVal + fCornerCost);
case EighteenConnected: case EighteenConnected:
processNeighbour(current->position + arrayPathfinderEdges[ 0], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[0], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 1], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[1], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 2], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[2], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 3], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[3], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 4], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[4], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 5], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[5], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 6], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[6], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 7], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[7], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 8], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[8], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[ 9], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[9], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[10], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[10], current->gVal + fEdgeCost);
processNeighbour(current->position + arrayPathfinderEdges[11], current->gVal + fEdgeCost); processNeighbour(current->position + arrayPathfinderEdges[11], current->gVal + fEdgeCost);
@ -151,7 +151,7 @@ namespace PolyVox
processNeighbour(current->position + arrayPathfinderFaces[5], current->gVal + fFaceCost); processNeighbour(current->position + arrayPathfinderFaces[5], current->gVal + fFaceCost);
} }
if(allNodes.size() > m_params.maxNumberOfNodes) if (allNodes.size() > m_params.maxNumberOfNodes)
{ {
//We've reached the specified maximum number //We've reached the specified maximum number
//of nodes. Just give up on the search. //of nodes. Just give up on the search.
@ -159,7 +159,7 @@ namespace PolyVox
} }
} }
if((openNodes.empty()) || (openNodes.getFirst() != endNode)) if ((openNodes.empty()) || (openNodes.getFirst() != endNode))
{ {
//In this case we failed to find a valid path. //In this case we failed to find a valid path.
POLYVOX_THROW(std::runtime_error, "No path found"); POLYVOX_THROW(std::runtime_error, "No path found");
@ -172,14 +172,14 @@ namespace PolyVox
//custom sort operator for the set which we know only uses the position to sort. Hence we can safely //custom sort operator for the set which we know only uses the position to sort. Hence we can safely
//modify other properties of the object while it is in the set. //modify other properties of the object while it is in the set.
Node* n = const_cast<Node*>(&(*endNode)); Node* n = const_cast<Node*>(&(*endNode));
while(n != 0) while (n != 0)
{ {
m_params.result->push_front(n->position); m_params.result->push_front(n->position);
n = n->parent; n = n->parent;
} }
} }
if(m_params.progressCallback) if (m_params.progressCallback)
{ {
m_params.progressCallback(1.0f); m_params.progressCallback(1.0f);
} }
@ -189,7 +189,7 @@ namespace PolyVox
void AStarPathfinder<VolumeType>::processNeighbour(const Vector3DInt32& neighbourPos, float neighbourGVal) void AStarPathfinder<VolumeType>::processNeighbour(const Vector3DInt32& neighbourPos, float neighbourGVal)
{ {
bool bIsVoxelValidForPath = m_params.isVoxelValidForPath(m_params.volume, neighbourPos); bool bIsVoxelValidForPath = m_params.isVoxelValidForPath(m_params.volume, neighbourPos);
if(!bIsVoxelValidForPath) if (!bIsVoxelValidForPath)
{ {
return; return;
} }
@ -199,16 +199,16 @@ namespace PolyVox
std::pair<AllNodesContainer::iterator, bool> insertResult = allNodes.insert(Node(neighbourPos.getX(), neighbourPos.getY(), neighbourPos.getZ())); std::pair<AllNodesContainer::iterator, bool> insertResult = allNodes.insert(Node(neighbourPos.getX(), neighbourPos.getY(), neighbourPos.getZ()));
AllNodesContainer::iterator neighbour = insertResult.first; AllNodesContainer::iterator neighbour = insertResult.first;
if(insertResult.second == true) //New node, compute h. if (insertResult.second == true) //New node, compute h.
{ {
Node* tempNeighbour = const_cast<Node*>(&(*neighbour)); Node* tempNeighbour = const_cast<Node*>(&(*neighbour));
tempNeighbour -> hVal = computeH(neighbour->position, m_params.end); tempNeighbour->hVal = computeH(neighbour->position, m_params.end);
} }
OpenNodesContainer::iterator openIter = openNodes.find(neighbour); OpenNodesContainer::iterator openIter = openNodes.find(neighbour);
if(openIter != openNodes.end()) if (openIter != openNodes.end())
{ {
if(cost < neighbour->gVal) if (cost < neighbour->gVal)
{ {
openNodes.remove(openIter); openNodes.remove(openIter);
openIter = openNodes.end(); openIter = openNodes.end();
@ -217,9 +217,9 @@ namespace PolyVox
//TODO - Nodes could keep track of if they are in open or closed? And a pointer to where they are? //TODO - Nodes could keep track of if they are in open or closed? And a pointer to where they are?
ClosedNodesContainer::iterator closedIter = closedNodes.find(neighbour); ClosedNodesContainer::iterator closedIter = closedNodes.find(neighbour);
if(closedIter != closedNodes.end()) if (closedIter != closedNodes.end())
{ {
if(cost < neighbour->gVal) if (cost < neighbour->gVal)
{ {
//Probably shouldn't happen? //Probably shouldn't happen?
closedNodes.remove(closedIter); closedNodes.remove(closedIter);
@ -227,7 +227,7 @@ namespace PolyVox
} }
} }
if((openIter == openNodes.end()) && (closedIter == closedNodes.end())) if ((openIter == openNodes.end()) && (closedIter == closedNodes.end()))
{ {
//Regarding the const_cast - normally you should not modify an object which is in an sdt::set. //Regarding the const_cast - normally you should not modify an object which is in an sdt::set.
//The reason is that objects in a set are stored sorted in a tree so they can be accessed quickly, //The reason is that objects in a set are stored sorted in a tree so they can be accessed quickly,
@ -245,7 +245,7 @@ namespace PolyVox
float AStarPathfinder<VolumeType>::SixConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b) float AStarPathfinder<VolumeType>::SixConnectedCost(const Vector3DInt32& a, const Vector3DInt32& b)
{ {
//This is the only heuristic I'm sure of - just use the manhatten distance for the 6-connected case. //This is the only heuristic I'm sure of - just use the manhatten distance for the 6-connected case.
uint32_t faceSteps = std::abs(a.getX()-b.getX()) + std::abs(a.getY()-b.getY()) + std::abs(a.getZ()-b.getZ()); uint32_t faceSteps = std::abs(a.getX() - b.getX()) + std::abs(a.getY() - b.getY()) + std::abs(a.getZ() - b.getZ());
return faceSteps * 1.0f; return faceSteps * 1.0f;
} }
@ -257,7 +257,7 @@ namespace PolyVox
//6-connected case. This means 'h' will be bigger than it should be, resulting in a faster path which may not //6-connected case. This means 'h' will be bigger than it should be, resulting in a faster path which may not
//actually be the shortest one. If you have a correct heuristic for the 18-connected case then please let me know. //actually be the shortest one. If you have a correct heuristic for the 18-connected case then please let me know.
return SixConnectedCost(a,b); return SixConnectedCost(a, b);
} }
template<typename VolumeType> template<typename VolumeType>
@ -287,7 +287,7 @@ namespace PolyVox
{ {
float hVal; float hVal;
switch(m_params.connectivity) switch (m_params.connectivity)
{ {
case TwentySixConnected: case TwentySixConnected:
hVal = TwentySixConnectedCost(a, b); hVal = TwentySixConnectedCost(a, b);
@ -304,9 +304,9 @@ namespace PolyVox
//Sanity checks in debug mode. These can come out eventually, but I //Sanity checks in debug mode. These can come out eventually, but I
//want to make sure that the heuristics I've come up with make sense. //want to make sure that the heuristics I've come up with make sense.
POLYVOX_ASSERT((a-b).length() <= TwentySixConnectedCost(a,b), "A* heuristic error."); POLYVOX_ASSERT((a - b).length() <= TwentySixConnectedCost(a, b), "A* heuristic error.");
POLYVOX_ASSERT(TwentySixConnectedCost(a,b) <= EighteenConnectedCost(a,b), "A* heuristic error."); POLYVOX_ASSERT(TwentySixConnectedCost(a, b) <= EighteenConnectedCost(a, b), "A* heuristic error.");
POLYVOX_ASSERT(EighteenConnectedCost(a,b) <= SixConnectedCost(a,b), "A* heuristic error."); POLYVOX_ASSERT(EighteenConnectedCost(a, b) <= SixConnectedCost(a, b), "A* heuristic error.");
//Apply the bias to the computed h value; //Apply the bias to the computed h value;
hVal *= m_params.hBias; hVal *= m_params.hBias;
@ -324,7 +324,7 @@ namespace PolyVox
//to make sure that position (x,y,z) has a differnt hash from e.g. position (x,z,y). //to make sure that position (x,y,z) has a differnt hash from e.g. position (x,z,y).
uint32_t aX = (a.getX() << 16) & 0x00FF0000; uint32_t aX = (a.getX() << 16) & 0x00FF0000;
uint32_t aY = (a.getY() << 8) & 0x0000FF00; uint32_t aY = (a.getY() << 8) & 0x0000FF00;
uint32_t aZ = (a.getZ() ) & 0x000000FF; uint32_t aZ = (a.getZ()) & 0x000000FF;
uint32_t hashVal = hash(aX | aY | aZ); uint32_t hashVal = hash(aX | aY | aZ);
//Stop hashVal going over 65535, and divide by 1000000 to make sure it is small. //Stop hashVal going over 65535, and divide by 1000000 to make sure it is small.
@ -339,14 +339,14 @@ namespace PolyVox
// Robert Jenkins' 32 bit integer hash function // Robert Jenkins' 32 bit integer hash function
// http://www.burtleburtle.net/bob/hash/integer.html // http://www.burtleburtle.net/bob/hash/integer.html
template<typename VolumeType> template<typename VolumeType>
uint32_t AStarPathfinder<VolumeType>::hash( uint32_t a) uint32_t AStarPathfinder<VolumeType>::hash(uint32_t a)
{ {
a = (a+0x7ed55d16) + (a<<12); a = (a + 0x7ed55d16) + (a << 12);
a = (a^0xc761c23c) ^ (a>>19); a = (a ^ 0xc761c23c) ^ (a >> 19);
a = (a+0x165667b1) + (a<<5); a = (a + 0x165667b1) + (a << 5);
a = (a+0xd3a2646c) ^ (a<<9); a = (a + 0xd3a2646c) ^ (a << 9);
a = (a+0xfd7046c5) + (a<<3); a = (a + 0xfd7046c5) + (a << 3);
a = (a^0xb55a4f09) ^ (a>>16); a = (a ^ 0xb55a4f09) ^ (a >> 16);
return a; return a;
} }
} }

View File

@ -76,14 +76,14 @@ namespace PolyVox
const float fHalfRatioZ = fRatioZ * 0.5f; const float fHalfRatioZ = fRatioZ * 0.5f;
const Vector3DFloat v3dHalfRatio(fHalfRatioX, fHalfRatioY, fHalfRatioZ); const Vector3DFloat v3dHalfRatio(fHalfRatioX, fHalfRatioY, fHalfRatioZ);
const Vector3DFloat v3dOffset(0.5f,0.5f,0.5f); const Vector3DFloat v3dOffset(0.5f, 0.5f, 0.5f);
//This loop iterates over the bottom-lower-left voxel in each of the cells in the output array //This loop iterates over the bottom-lower-left voxel in each of the cells in the output array
for(uint16_t z = region.getLowerZ(); z <= region.getUpperZ(); z += iRatioZ) for (uint16_t z = region.getLowerZ(); z <= region.getUpperZ(); z += iRatioZ)
{ {
for(uint16_t y = region.getLowerY(); y <= region.getUpperY(); y += iRatioY) for (uint16_t y = region.getLowerY(); y <= region.getUpperY(); y += iRatioY)
{ {
for(uint16_t x = region.getLowerX(); x <= region.getUpperX(); x += iRatioX) for (uint16_t x = region.getLowerX(); x <= region.getUpperX(); x += iRatioX)
{ {
//Compute a start position corresponding to //Compute a start position corresponding to
//the centre of the cell in the output array. //the centre of the cell in the output array.
@ -94,7 +94,7 @@ namespace PolyVox
//Keep track of how many rays did not hit anything //Keep track of how many rays did not hit anything
uint8_t uVisibleDirections = 0; uint8_t uVisibleDirections = 0;
for(int ct = 0; ct < uNoOfSamplesPerOutputElement; ct++) for (int ct = 0; ct < uNoOfSamplesPerOutputElement; ct++)
{ {
//We take a random vector with components going from -1 to 1 and scale it to go from -halfRatio to +halfRatio. //We take a random vector with components going from -1 to 1 and scale it to go from -halfRatio to +halfRatio.
//This jitter value moves our sample point from the centre of the array cell to somewhere else in the array cell //This jitter value moves our sample point from the centre of the array cell to somewhere else in the array cell
@ -110,14 +110,14 @@ namespace PolyVox
// Note - The performance of this could actually be improved it we exited as soon // Note - The performance of this could actually be improved it we exited as soon
// as the ray left the volume. The raycast test has an example of how to do this. // as the ray left the volume. The raycast test has an example of how to do this.
if(result == RaycastResults::Completed) if (result == RaycastResults::Completed)
{ {
++uVisibleDirections; ++uVisibleDirections;
} }
} }
float fVisibility; float fVisibility;
if(uNoOfSamplesPerOutputElement == 0) if (uNoOfSamplesPerOutputElement == 0)
{ {
//The user might request zero samples (I've done this in the past while debugging - I don't want to //The user might request zero samples (I've done this in the past while debugging - I don't want to
//wait for ambient occlusion but I do want as valid result for rendering). Avoid the divide by zero. //wait for ambient occlusion but I do want as valid result for rendering). Avoid the divide by zero.

View File

@ -43,7 +43,7 @@ namespace PolyVox
public: public:
typedef _VoxelType VoxelType; typedef _VoxelType VoxelType;
#ifndef SWIG #ifndef SWIG
template <typename DerivedVolumeType> template <typename DerivedVolumeType>
class Sampler class Sampler
{ {
@ -105,7 +105,7 @@ namespace PolyVox
int32_t mYPosInVolume; int32_t mYPosInVolume;
int32_t mZPosInVolume; int32_t mZPosInVolume;
}; };
#endif // SWIG #endif // SWIG
public: public:
/// Gets a voxel at the position given by <tt>x,y,z</tt> coordinates /// Gets a voxel at the position given by <tt>x,y,z</tt> coordinates

View File

@ -30,9 +30,9 @@ namespace PolyVox
template <typename DerivedVolumeType> template <typename DerivedVolumeType>
BaseVolume<VoxelType>::Sampler<DerivedVolumeType>::Sampler(DerivedVolumeType* volume) BaseVolume<VoxelType>::Sampler<DerivedVolumeType>::Sampler(DerivedVolumeType* volume)
:mVolume(volume) :mVolume(volume)
,mXPosInVolume(0) , mXPosInVolume(0)
,mYPosInVolume(0) , mYPosInVolume(0)
,mZPosInVolume(0) , mZPosInVolume(0)
{ {
} }

View File

@ -37,7 +37,7 @@ namespace PolyVox
public: public:
bool operator()(VoxelType back, VoxelType front, VoxelType& materialToUse) bool operator()(VoxelType back, VoxelType front, VoxelType& materialToUse)
{ {
if((back > 0) && (front == 0)) if ((back > 0) && (front == 0))
{ {
materialToUse = static_cast<VoxelType>(back); materialToUse = static_cast<VoxelType>(back);
return true; return true;

View File

@ -119,7 +119,7 @@ namespace PolyVox
*/ */
MaterialType blendMaterials(VoxelType a, VoxelType b, float /*weight*/) MaterialType blendMaterials(VoxelType a, VoxelType b, float /*weight*/)
{ {
if(convertToDensity(a) > convertToDensity(b)) if (convertToDensity(a) > convertToDensity(b))
{ {
return convertToMaterial(a); return convertToMaterial(a);
} }

View File

@ -49,7 +49,7 @@ namespace PolyVox
/// Constructor /// Constructor
FilePager(const std::string& strFolderName = ".") FilePager(const std::string& strFolderName = ".")
:PagedVolume<VoxelType>::Pager() :PagedVolume<VoxelType>::Pager()
,m_strFolderName(strFolderName) , m_strFolderName(strFolderName)
{ {
// Add the trailing slash, assuming the user dind't already do it. // Add the trailing slash, assuming the user dind't already do it.
if ((m_strFolderName.back() != '/') && (m_strFolderName.back() != '\\')) if ((m_strFolderName.back() != '/') && (m_strFolderName.back() != '\\'))
@ -68,7 +68,7 @@ namespace PolyVox
/// Destructor /// Destructor
virtual ~FilePager() virtual ~FilePager()
{ {
for(std::vector<std::string>::iterator iter = m_vecCreatedFiles.begin(); iter < m_vecCreatedFiles.end(); iter++) for (std::vector<std::string>::iterator iter = m_vecCreatedFiles.begin(); iter < m_vecCreatedFiles.end(); iter++)
{ {
POLYVOX_LOG_WARNING_IF(std::remove(iter->c_str()) != 0, "Failed to delete '", *iter, "' when destroying FilePager"); POLYVOX_LOG_WARNING_IF(std::remove(iter->c_str()) != 0, "Failed to delete '", *iter, "' when destroying FilePager");
} }
@ -93,7 +93,7 @@ namespace PolyVox
// the gameplay-cubiquity integration. See: https://github.com/blackberry/GamePlay/issues/919 // the gameplay-cubiquity integration. See: https://github.com/blackberry/GamePlay/issues/919
FILE* pFile = fopen(filename.c_str(), "rb"); FILE* pFile = fopen(filename.c_str(), "rb");
if(pFile) if (pFile)
{ {
POLYVOX_LOG_TRACE("Paging in data for ", region); POLYVOX_LOG_TRACE("Paging in data for ", region);
@ -108,7 +108,7 @@ namespace PolyVox
fread(pChunk->getData(), sizeof(uint8_t), pChunk->getDataSizeInBytes(), pFile); fread(pChunk->getData(), sizeof(uint8_t), pChunk->getDataSizeInBytes(), pFile);
if(ferror(pFile)) if (ferror(pFile))
{ {
POLYVOX_THROW(std::runtime_error, "Error reading in chunk data, even though a file exists."); POLYVOX_THROW(std::runtime_error, "Error reading in chunk data, even though a file exists.");
} }
@ -145,7 +145,7 @@ namespace PolyVox
// the gameplay-cubiquity integration. See: https://github.com/blackberry/GamePlay/issues/919 // the gameplay-cubiquity integration. See: https://github.com/blackberry/GamePlay/issues/919
FILE* pFile = fopen(filename.c_str(), "wb"); FILE* pFile = fopen(filename.c_str(), "wb");
if(!pFile) if (!pFile)
{ {
POLYVOX_THROW(std::runtime_error, "Unable to open file to write out chunk data."); POLYVOX_THROW(std::runtime_error, "Unable to open file to write out chunk data.");
} }
@ -155,7 +155,7 @@ namespace PolyVox
fwrite(pChunk->getData(), sizeof(uint8_t), pChunk->getDataSizeInBytes(), pFile); fwrite(pChunk->getData(), sizeof(uint8_t), pChunk->getDataSizeInBytes(), pFile);
if(ferror(pFile)) if (ferror(pFile))
{ {
POLYVOX_THROW(std::runtime_error, "Error writing out chunk data."); POLYVOX_THROW(std::runtime_error, "Error writing out chunk data.");
} }

View File

@ -53,8 +53,8 @@ namespace PolyVox
{ {
Node(int x, int y, int z) Node(int x, int y, int z)
:gVal(std::numeric_limits<float>::quiet_NaN()) //Initilise with NaNs so that we will :gVal(std::numeric_limits<float>::quiet_NaN()) //Initilise with NaNs so that we will
,hVal(std::numeric_limits<float>::quiet_NaN()) //know if we forget to set these properly. , hVal(std::numeric_limits<float>::quiet_NaN()) //know if we forget to set these properly.
,parent(0) , parent(0)
{ {
position.setX(x); position.setX(x);
position.setY(y); position.setY(y);

View File

@ -29,7 +29,7 @@ namespace PolyVox
{ {
template <typename Type> template <typename Type>
Type lerp( Type lerp(
const Type& v0,const Type& v1, const Type& v0, const Type& v1,
const float x) const float x)
{ {
//Interpolate along X //Interpolate along X
@ -40,7 +40,7 @@ namespace PolyVox
template <typename Type> template <typename Type>
Type bilerp( Type bilerp(
const Type& v00,const Type& v10,const Type& v01,const Type& v11, const Type& v00, const Type& v10, const Type& v01, const Type& v11,
const float x, const float y) const float x, const float y)
{ {
// Linearly interpolate along x // Linearly interpolate along x
@ -55,8 +55,8 @@ namespace PolyVox
template <typename Type> template <typename Type>
Type trilerp( Type trilerp(
const Type& v000,const Type& v100,const Type& v010,const Type& v110, const Type& v000, const Type& v100, const Type& v010, const Type& v110,
const Type& v001,const Type& v101,const Type& v011,const Type& v111, const Type& v001, const Type& v101, const Type& v011, const Type& v111,
const float x, const float y, const float z) const float x, const float y, const float z)
{ {
// Bilinearly interpolate along Y // Bilinearly interpolate along Y

View File

@ -35,7 +35,7 @@ namespace PolyVox
{ {
Vector3DInt32 v3dInitialPosition(m_Iter->getPosition().getX(), m_Iter->getPosition().getY(), m_Iter->getPosition().getZ()); Vector3DInt32 v3dInitialPosition(m_Iter->getPosition().getX(), m_Iter->getPosition().getY(), m_Iter->getPosition().getZ());
if(v3dInitialPosition.getX() < m_regValid.getUpperX()) if (v3dInitialPosition.getX() < m_regValid.getUpperX())
{ {
m_Iter->movePositiveX(); m_Iter->movePositiveX();
return true; return true;
@ -43,7 +43,7 @@ namespace PolyVox
v3dInitialPosition.setX(m_regValid.getLowerX()); v3dInitialPosition.setX(m_regValid.getLowerX());
if(v3dInitialPosition.getY() < m_regValid.getUpperY()) if (v3dInitialPosition.getY() < m_regValid.getUpperY())
{ {
v3dInitialPosition.setY(v3dInitialPosition.getY() + 1); v3dInitialPosition.setY(v3dInitialPosition.getY() + 1);
m_Iter->setPosition(v3dInitialPosition); m_Iter->setPosition(v3dInitialPosition);
@ -52,7 +52,7 @@ namespace PolyVox
v3dInitialPosition.setY(m_regValid.getLowerY()); v3dInitialPosition.setY(m_regValid.getLowerY());
if(v3dInitialPosition.getZ() < m_regValid.getUpperZ()) if (v3dInitialPosition.getZ() < m_regValid.getUpperZ())
{ {
v3dInitialPosition.setZ(v3dInitialPosition.getZ() + 1); v3dInitialPosition.setZ(v3dInitialPosition.getZ() + 1);
m_Iter->setPosition(v3dInitialPosition); m_Iter->setPosition(v3dInitialPosition);

View File

@ -34,19 +34,19 @@ namespace PolyVox
template< typename SrcVolumeType, typename DstVolumeType, typename AccumulationType> template< typename SrcVolumeType, typename DstVolumeType, typename AccumulationType>
LowPassFilter<SrcVolumeType, DstVolumeType, AccumulationType>::LowPassFilter(SrcVolumeType* pVolSrc, Region regSrc, DstVolumeType* pVolDst, Region regDst, uint32_t uKernelSize) LowPassFilter<SrcVolumeType, DstVolumeType, AccumulationType>::LowPassFilter(SrcVolumeType* pVolSrc, Region regSrc, DstVolumeType* pVolDst, Region regDst, uint32_t uKernelSize)
:m_pVolSrc(pVolSrc) :m_pVolSrc(pVolSrc)
,m_regSrc(regSrc) , m_regSrc(regSrc)
,m_pVolDst(pVolDst) , m_pVolDst(pVolDst)
,m_regDst(regDst) , m_regDst(regDst)
,m_uKernelSize(uKernelSize) , m_uKernelSize(uKernelSize)
{ {
//Kernel size must be at least three //Kernel size must be at least three
if(m_uKernelSize < 3) if (m_uKernelSize < 3)
{ {
POLYVOX_THROW(std::invalid_argument, "Kernel size must be at least three"); POLYVOX_THROW(std::invalid_argument, "Kernel size must be at least three");
} }
//Kernel size must be odd //Kernel size must be odd
if(m_uKernelSize % 2 == 0) if (m_uKernelSize % 2 == 0)
{ {
POLYVOX_THROW(std::invalid_argument, "Kernel size must be odd"); POLYVOX_THROW(std::invalid_argument, "Kernel size must be odd");
} }
@ -73,11 +73,11 @@ namespace PolyVox
typename SrcVolumeType::Sampler srcSampler(m_pVolSrc); typename SrcVolumeType::Sampler srcSampler(m_pVolSrc);
for(int32_t iSrcZ = iSrcMinZ, iDstZ = iDstMinZ; iSrcZ <= iSrcMaxZ; iSrcZ++, iDstZ++) for (int32_t iSrcZ = iSrcMinZ, iDstZ = iDstMinZ; iSrcZ <= iSrcMaxZ; iSrcZ++, iDstZ++)
{ {
for(int32_t iSrcY = iSrcMinY, iDstY = iDstMinY; iSrcY <= iSrcMaxY; iSrcY++, iDstY++) for (int32_t iSrcY = iSrcMinY, iDstY = iDstMinY; iSrcY <= iSrcMaxY; iSrcY++, iDstY++)
{ {
for(int32_t iSrcX = iSrcMinX, iDstX = iDstMinX; iSrcX <= iSrcMaxX; iSrcX++, iDstX++) for (int32_t iSrcX = iSrcMinX, iDstX = iDstMinX; iSrcX <= iSrcMaxX; iSrcX++, iDstX++)
{ {
AccumulationType tSrcVoxel(0); AccumulationType tSrcVoxel(0);
srcSampler.setPosition(iSrcX, iSrcY, iSrcZ); srcSampler.setPosition(iSrcX, iSrcY, iSrcZ);
@ -136,13 +136,13 @@ namespace PolyVox
//Clear to zeros (necessary?) //Clear to zeros (necessary?)
//FIXME - use Volume::fill() method. Implemented in base class as below //FIXME - use Volume::fill() method. Implemented in base class as below
//but with optimised implementations in subclasses? //but with optimised implementations in subclasses?
for(int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++) for (int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++)
{ {
for(int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++) for (int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++)
{ {
for(int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++) for (int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++)
{ {
satVolume.setVoxel(x,y,z,0); satVolume.setVoxel(x, y, z, 0);
} }
} }
} }
@ -170,7 +170,7 @@ namespace PolyVox
srcIterCont.moveForward(); srcIterCont.moveForward();
}while(satIterCont.moveForward()); } while (satIterCont.moveForward());
//Build SAT in three passes //Build SAT in three passes
/*for(int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++) /*for(int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++)
@ -187,30 +187,30 @@ namespace PolyVox
} }
}*/ }*/
for(int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++) for (int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++)
{ {
for(int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++) for (int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++)
{ {
for(int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++) for (int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++)
{ {
AccumulationType previousSum = static_cast<AccumulationType>(satVolume.getVoxel(x,y-1,z)); AccumulationType previousSum = static_cast<AccumulationType>(satVolume.getVoxel(x, y - 1, z));
AccumulationType currentSum = static_cast<AccumulationType>(satVolume.getVoxel(x,y,z)); AccumulationType currentSum = static_cast<AccumulationType>(satVolume.getVoxel(x, y, z));
satVolume.setVoxel(x,y,z,previousSum + currentSum); satVolume.setVoxel(x, y, z, previousSum + currentSum);
} }
} }
} }
for(int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++) for (int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++)
{ {
for(int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++) for (int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++)
{ {
for(int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++) for (int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++)
{ {
AccumulationType previousSum = static_cast<AccumulationType>(satVolume.getVoxel(x,y,z-1)); AccumulationType previousSum = static_cast<AccumulationType>(satVolume.getVoxel(x, y, z - 1));
AccumulationType currentSum = static_cast<AccumulationType>(satVolume.getVoxel(x,y,z)); AccumulationType currentSum = static_cast<AccumulationType>(satVolume.getVoxel(x, y, z));
satVolume.setVoxel(x,y,z,previousSum + currentSum); satVolume.setVoxel(x, y, z, previousSum + currentSum);
} }
} }
} }
@ -221,11 +221,11 @@ namespace PolyVox
const Vector3DInt32& v3dSrcLowerCorner = m_regSrc.getLowerCorner(); const Vector3DInt32& v3dSrcLowerCorner = m_regSrc.getLowerCorner();
for(int32_t iDstZ = v3dDstLowerCorner.getZ(), iSrcZ = v3dSrcLowerCorner.getZ(); iDstZ <= v3dDstUpperCorner.getZ(); iDstZ++, iSrcZ++) for (int32_t iDstZ = v3dDstLowerCorner.getZ(), iSrcZ = v3dSrcLowerCorner.getZ(); iDstZ <= v3dDstUpperCorner.getZ(); iDstZ++, iSrcZ++)
{ {
for(int32_t iDstY = v3dDstLowerCorner.getY(), iSrcY = v3dSrcLowerCorner.getY(); iDstY <= v3dDstUpperCorner.getY(); iDstY++, iSrcY++) for (int32_t iDstY = v3dDstLowerCorner.getY(), iSrcY = v3dSrcLowerCorner.getY(); iDstY <= v3dDstUpperCorner.getY(); iDstY++, iSrcY++)
{ {
for(int32_t iDstX = v3dDstLowerCorner.getX(), iSrcX = v3dSrcLowerCorner.getX(); iDstX <= v3dDstUpperCorner.getX(); iDstX++, iSrcX++) for (int32_t iDstX = v3dDstLowerCorner.getX(), iSrcX = v3dSrcLowerCorner.getX(); iDstX <= v3dDstUpperCorner.getX(); iDstX++, iSrcX++)
{ {
int32_t satLowerX = iSrcX - border - 1; int32_t satLowerX = iSrcX - border - 1;
int32_t satLowerY = iSrcY - border - 1; int32_t satLowerY = iSrcY - border - 1;
@ -235,16 +235,16 @@ namespace PolyVox
int32_t satUpperY = iSrcY + border; int32_t satUpperY = iSrcY + border;
int32_t satUpperZ = iSrcZ + border; int32_t satUpperZ = iSrcZ + border;
AccumulationType a = satVolume.getVoxel(satLowerX,satLowerY,satLowerZ); AccumulationType a = satVolume.getVoxel(satLowerX, satLowerY, satLowerZ);
AccumulationType b = satVolume.getVoxel(satUpperX,satLowerY,satLowerZ); AccumulationType b = satVolume.getVoxel(satUpperX, satLowerY, satLowerZ);
AccumulationType c = satVolume.getVoxel(satLowerX,satUpperY,satLowerZ); AccumulationType c = satVolume.getVoxel(satLowerX, satUpperY, satLowerZ);
AccumulationType d = satVolume.getVoxel(satUpperX,satUpperY,satLowerZ); AccumulationType d = satVolume.getVoxel(satUpperX, satUpperY, satLowerZ);
AccumulationType e = satVolume.getVoxel(satLowerX,satLowerY,satUpperZ); AccumulationType e = satVolume.getVoxel(satLowerX, satLowerY, satUpperZ);
AccumulationType f = satVolume.getVoxel(satUpperX,satLowerY,satUpperZ); AccumulationType f = satVolume.getVoxel(satUpperX, satLowerY, satUpperZ);
AccumulationType g = satVolume.getVoxel(satLowerX,satUpperY,satUpperZ); AccumulationType g = satVolume.getVoxel(satLowerX, satUpperY, satUpperZ);
AccumulationType h = satVolume.getVoxel(satUpperX,satUpperY,satUpperZ); AccumulationType h = satVolume.getVoxel(satUpperX, satUpperY, satUpperZ);
AccumulationType sum = h+c-d-g-f-a+b+e; AccumulationType sum = h + c - d - g - f - a + b + e;
uint32_t sideLength = border * 2 + 1; uint32_t sideLength = border * 2 + 1;
AccumulationType average = sum / (sideLength*sideLength*sideLength); AccumulationType average = sum / (sideLength*sideLength*sideLength);

View File

@ -112,7 +112,7 @@ namespace PolyVox
{ {
// Extract the two bytes from the uint16_t. // Extract the two bytes from the uint16_t.
uint16_t ux = (encodedNormal >> 8) & 0xFF; uint16_t ux = (encodedNormal >> 8) & 0xFF;
uint16_t uy = (encodedNormal ) & 0xFF; uint16_t uy = (encodedNormal)& 0xFF;
// Convert to floats in the range [-1.0f, +1.0f]. // Convert to floats in the range [-1.0f, +1.0f].
float ex = ux / 127.5f - 1.0f; float ex = ux / 127.5f - 1.0f;

View File

@ -76,7 +76,7 @@ namespace PolyVox
public: public:
bool operator()(Material<Type> back, Material<Type> front, Material<Type>& materialToUse) bool operator()(Material<Type> back, Material<Type> front, Material<Type>& materialToUse)
{ {
if((back.getMaterial() > 0) && (front.getMaterial() == 0)) if ((back.getMaterial() > 0) && (front.getMaterial() == 0))
{ {
materialToUse = back; materialToUse = back;
return true; return true;

View File

@ -93,7 +93,7 @@ namespace PolyVox
public: public:
bool operator()(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> back, MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> front, MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>& materialToUse) bool operator()(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> back, MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> front, MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits>& materialToUse)
{ {
if((back.getMaterial() > 0) && (front.getMaterial() == 0)) if ((back.getMaterial() > 0) && (front.getMaterial() == 0))
{ {
materialToUse = back; materialToUse = back;
return true; return true;
@ -135,7 +135,7 @@ namespace PolyVox
MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> blendMaterials(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> a, MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> b, float /*weight*/) MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> blendMaterials(MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> a, MaterialDensityPair<Type, NoOfMaterialBits, NoOfDensityBits> b, float /*weight*/)
{ {
if(convertToDensity(a) > convertToDensity(b)) if (convertToDensity(a) > convertToDensity(b))
{ {
return a; return a;
} }

View File

@ -136,7 +136,7 @@ namespace PolyVox
std::vector<bool> isVertexUsed(m_vecVertices.size()); std::vector<bool> isVertexUsed(m_vecVertices.size());
std::fill(isVertexUsed.begin(), isVertexUsed.end(), false); std::fill(isVertexUsed.begin(), isVertexUsed.end(), false);
for(uint32_t triCt = 0; triCt < m_vecIndices.size(); triCt++) for (uint32_t triCt = 0; triCt < m_vecIndices.size(); triCt++)
{ {
int v = m_vecIndices[triCt]; int v = m_vecIndices[triCt];
isVertexUsed[v] = true; isVertexUsed[v] = true;
@ -144,9 +144,9 @@ namespace PolyVox
int noOfUsedVertices = 0; int noOfUsedVertices = 0;
std::vector<uint32_t> newPos(m_vecVertices.size()); std::vector<uint32_t> newPos(m_vecVertices.size());
for(IndexType vertCt = 0; vertCt < m_vecVertices.size(); vertCt++) for (IndexType vertCt = 0; vertCt < m_vecVertices.size(); vertCt++)
{ {
if(isVertexUsed[vertCt]) if (isVertexUsed[vertCt])
{ {
m_vecVertices[noOfUsedVertices] = m_vecVertices[vertCt]; m_vecVertices[noOfUsedVertices] = m_vecVertices[vertCt];
newPos[vertCt] = noOfUsedVertices; newPos[vertCt] = noOfUsedVertices;
@ -156,7 +156,7 @@ namespace PolyVox
m_vecVertices.resize(noOfUsedVertices); m_vecVertices.resize(noOfUsedVertices);
for(uint32_t triCt = 0; triCt < m_vecIndices.size(); triCt++) for (uint32_t triCt = 0; triCt < m_vecIndices.size(); triCt++)
{ {
m_vecIndices[triCt] = newPos[m_vecIndices[triCt]]; m_vecIndices[triCt] = newPos[m_vecIndices[triCt]];
} }

View File

@ -187,7 +187,7 @@ namespace PolyVox
//in the future //in the future
//typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. //typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences.
//class Sampler : public VolumeOfVoxelType::template Sampler< PagedVolume<VoxelType> > //class Sampler : public VolumeOfVoxelType::template Sampler< PagedVolume<VoxelType> >
#ifndef SWIG #ifndef SWIG
#if defined(_MSC_VER) #if defined(_MSC_VER)
class Sampler : public BaseVolume<VoxelType>::Sampler< PagedVolume<VoxelType> > //This line works on VS2010 class Sampler : public BaseVolume<VoxelType>::Sampler< PagedVolume<VoxelType> > //This line works on VS2010
#else #else
@ -256,7 +256,7 @@ namespace PolyVox
uint16_t m_uChunkSideLengthMinusOne; uint16_t m_uChunkSideLengthMinusOne;
}; };
#endif // SWIG #endif // SWIG
public: public:
/// Constructor for creating a fixed size volume. /// Constructor for creating a fixed size volume.

View File

@ -181,13 +181,13 @@ namespace PolyVox
{ {
// Convert the start and end positions into chunk space coordinates // Convert the start and end positions into chunk space coordinates
Vector3DInt32 v3dStart; Vector3DInt32 v3dStart;
for(int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
v3dStart.setElement(i, regPrefetch.getLowerCorner().getElement(i) >> m_uChunkSideLengthPower); v3dStart.setElement(i, regPrefetch.getLowerCorner().getElement(i) >> m_uChunkSideLengthPower);
} }
Vector3DInt32 v3dEnd; Vector3DInt32 v3dEnd;
for(int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
v3dEnd.setElement(i, regPrefetch.getUpperCorner().getElement(i) >> m_uChunkSideLengthPower); v3dEnd.setElement(i, regPrefetch.getUpperCorner().getElement(i) >> m_uChunkSideLengthPower);
} }
@ -199,13 +199,13 @@ namespace PolyVox
uNoOfChunks = (std::min)(uNoOfChunks, m_uChunkCountLimit); uNoOfChunks = (std::min)(uNoOfChunks, m_uChunkCountLimit);
// Loops over the specified positions and touch the corresponding chunks. // Loops over the specified positions and touch the corresponding chunks.
for(int32_t x = v3dStart.getX(); x <= v3dEnd.getX(); x++) for (int32_t x = v3dStart.getX(); x <= v3dEnd.getX(); x++)
{ {
for(int32_t y = v3dStart.getY(); y <= v3dEnd.getY(); y++) for (int32_t y = v3dStart.getY(); y <= v3dEnd.getY(); y++)
{ {
for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++) for (int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++)
{ {
getChunk(x,y,z); getChunk(x, y, z);
} }
} }
} }

View File

@ -30,12 +30,12 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
PagedVolume<VoxelType>::Chunk::Chunk(Vector3DInt32 v3dPosition, uint16_t uSideLength, Pager* pPager) PagedVolume<VoxelType>::Chunk::Chunk(Vector3DInt32 v3dPosition, uint16_t uSideLength, Pager* pPager)
:m_uChunkLastAccessed(0) :m_uChunkLastAccessed(0)
,m_bDataModified(true) , m_bDataModified(true)
,m_tData(0) , m_tData(0)
,m_uSideLength(0) , m_uSideLength(0)
,m_uSideLengthPower(0) , m_uSideLengthPower(0)
,m_pPager(pPager) , m_pPager(pPager)
,m_v3dChunkSpacePosition(v3dPosition) , m_v3dChunkSpacePosition(v3dPosition)
{ {
POLYVOX_ASSERT(m_pPager, "No valid pager supplied to chunk constructor."); POLYVOX_ASSERT(m_pPager, "No valid pager supplied to chunk constructor.");
POLYVOX_ASSERT(uSideLength <= 256, "Chunk side length cannot be greater than 256."); POLYVOX_ASSERT(uSideLength <= 256, "Chunk side length cannot be greater than 256.");

View File

@ -107,7 +107,7 @@ namespace PolyVox
BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::movePositiveX(); BaseVolume<VoxelType>::template Sampler< PagedVolume<VoxelType> >::movePositiveX();
// Then we update the voxel pointer // Then we update the voxel pointer
if(CAN_GO_POS_X(this->m_uXPosInChunk)) if (CAN_GO_POS_X(this->m_uXPosInChunk))
{ {
//No need to compute new chunk. //No need to compute new chunk.
mCurrentVoxel += POS_X_DELTA; mCurrentVoxel += POS_X_DELTA;
@ -227,7 +227,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_X_DELTA + NEG_Y_DELTA + NEG_Z_DELTA); return *(mCurrentVoxel + NEG_X_DELTA + NEG_Y_DELTA + NEG_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume - 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -237,7 +237,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_X_DELTA + NEG_Y_DELTA); return *(mCurrentVoxel + NEG_X_DELTA + NEG_Y_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume - 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
@ -247,7 +247,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_X_DELTA + NEG_Y_DELTA + POS_Z_DELTA); return *(mCurrentVoxel + NEG_X_DELTA + NEG_Y_DELTA + POS_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume - 1, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -257,7 +257,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_X_DELTA + NEG_Z_DELTA); return *(mCurrentVoxel + NEG_X_DELTA + NEG_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -267,7 +267,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_X_DELTA); return *(mCurrentVoxel + NEG_X_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
@ -277,7 +277,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_X_DELTA + POS_Z_DELTA); return *(mCurrentVoxel + NEG_X_DELTA + POS_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -287,7 +287,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_X_DELTA + POS_Y_DELTA + NEG_Z_DELTA); return *(mCurrentVoxel + NEG_X_DELTA + POS_Y_DELTA + NEG_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume + 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -297,7 +297,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_X_DELTA + POS_Y_DELTA); return *(mCurrentVoxel + NEG_X_DELTA + POS_Y_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume + 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
@ -307,7 +307,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_X_DELTA + POS_Y_DELTA + POS_Z_DELTA); return *(mCurrentVoxel + NEG_X_DELTA + POS_Y_DELTA + POS_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume + 1, this->mZPosInVolume + 1);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -319,7 +319,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_Y_DELTA + NEG_Z_DELTA); return *(mCurrentVoxel + NEG_Y_DELTA + NEG_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume - 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -329,7 +329,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_Y_DELTA); return *(mCurrentVoxel + NEG_Y_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume - 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
@ -339,7 +339,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_Y_DELTA + POS_Z_DELTA); return *(mCurrentVoxel + NEG_Y_DELTA + POS_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume - 1, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -349,7 +349,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + NEG_Z_DELTA); return *(mCurrentVoxel + NEG_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -365,7 +365,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_Z_DELTA); return *(mCurrentVoxel + POS_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -375,7 +375,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_Y_DELTA + NEG_Z_DELTA); return *(mCurrentVoxel + POS_Y_DELTA + NEG_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume + 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -385,7 +385,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_Y_DELTA); return *(mCurrentVoxel + POS_Y_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume + 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
@ -395,7 +395,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_Y_DELTA + POS_Z_DELTA); return *(mCurrentVoxel + POS_Y_DELTA + POS_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume + 1, this->mZPosInVolume + 1);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -407,7 +407,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_X_DELTA + NEG_Y_DELTA + NEG_Z_DELTA); return *(mCurrentVoxel + POS_X_DELTA + NEG_Y_DELTA + NEG_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume - 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -417,7 +417,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_X_DELTA + NEG_Y_DELTA); return *(mCurrentVoxel + POS_X_DELTA + NEG_Y_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume - 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
@ -427,7 +427,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_X_DELTA + NEG_Y_DELTA + POS_Z_DELTA); return *(mCurrentVoxel + POS_X_DELTA + NEG_Y_DELTA + POS_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume - 1, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -437,7 +437,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_X_DELTA + NEG_Z_DELTA); return *(mCurrentVoxel + POS_X_DELTA + NEG_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -447,7 +447,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_X_DELTA); return *(mCurrentVoxel + POS_X_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
@ -457,7 +457,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_X_DELTA + POS_Z_DELTA); return *(mCurrentVoxel + POS_X_DELTA + POS_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -467,7 +467,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_X_DELTA + POS_Y_DELTA + NEG_Z_DELTA); return *(mCurrentVoxel + POS_X_DELTA + POS_Y_DELTA + NEG_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume + 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
@ -477,7 +477,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_X_DELTA + POS_Y_DELTA); return *(mCurrentVoxel + POS_X_DELTA + POS_Y_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume + 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
@ -487,7 +487,7 @@ namespace PolyVox
{ {
return *(mCurrentVoxel + POS_X_DELTA + POS_Y_DELTA + POS_Z_DELTA); return *(mCurrentVoxel + POS_X_DELTA + POS_Y_DELTA + POS_Z_DELTA);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume + 1, this->mZPosInVolume + 1);
} }
} }

View File

@ -43,13 +43,13 @@ namespace PolyVox
public: public:
RaycastPickingFunctor(const typename VolumeType::VoxelType& emptyVoxelExample) RaycastPickingFunctor(const typename VolumeType::VoxelType& emptyVoxelExample)
:m_emptyVoxelExample(emptyVoxelExample) :m_emptyVoxelExample(emptyVoxelExample)
,m_result() , m_result()
{ {
} }
bool operator()(const typename VolumeType::Sampler& sampler) bool operator()(const typename VolumeType::Sampler& sampler)
{ {
if(sampler.getVoxel() != m_emptyVoxelExample) //If we've hit something if (sampler.getVoxel() != m_emptyVoxelExample) //If we've hit something
{ {
m_result.didHit = true; m_result.didHit = true;
m_result.hitVoxel = sampler.getPosition(); m_result.hitVoxel = sampler.getPosition();

View File

@ -40,7 +40,7 @@ namespace PolyVox
class RawVolume : public BaseVolume<VoxelType> class RawVolume : public BaseVolume<VoxelType>
{ {
public: public:
#ifndef SWIG #ifndef SWIG
//There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared. //There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared.
//There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but //There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but
//which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler //which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler
@ -115,7 +115,7 @@ namespace PolyVox
bool m_bIsCurrentPositionValidInY; bool m_bIsCurrentPositionValidInY;
bool m_bIsCurrentPositionValidInZ; bool m_bIsCurrentPositionValidInZ;
}; };
#endif // SWIG #endif // SWIG
public: public:
/// Constructor for creating a fixed size volume. /// Constructor for creating a fixed size volume.

View File

@ -223,15 +223,15 @@ namespace PolyVox
{ {
this->m_regValidRegion = regValidRegion; this->m_regValidRegion = regValidRegion;
if(this->getWidth() <= 0) if (this->getWidth() <= 0)
{ {
POLYVOX_THROW(std::invalid_argument, "Volume width must be greater than zero."); POLYVOX_THROW(std::invalid_argument, "Volume width must be greater than zero.");
} }
if(this->getHeight() <= 0) if (this->getHeight() <= 0)
{ {
POLYVOX_THROW(std::invalid_argument, "Volume height must be greater than zero."); POLYVOX_THROW(std::invalid_argument, "Volume height must be greater than zero.");
} }
if(this->getDepth() <= 0) if (this->getDepth() <= 0)
{ {
POLYVOX_THROW(std::invalid_argument, "Volume depth must be greater than zero."); POLYVOX_THROW(std::invalid_argument, "Volume depth must be greater than zero.");
} }

View File

@ -34,7 +34,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
RawVolume<VoxelType>::Sampler::Sampler(RawVolume<VoxelType>* volume) RawVolume<VoxelType>::Sampler::Sampler(RawVolume<VoxelType>* volume)
:BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >(volume) :BaseVolume<VoxelType>::template Sampler< RawVolume<VoxelType> >(volume)
,mCurrentVoxel(0) , mCurrentVoxel(0)
, m_bIsCurrentPositionValidInX(false) , m_bIsCurrentPositionValidInX(false)
, m_bIsCurrentPositionValidInY(false) , m_bIsCurrentPositionValidInY(false)
, m_bIsCurrentPositionValidInZ(false) , m_bIsCurrentPositionValidInZ(false)
@ -49,7 +49,7 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::getVoxel(void) const VoxelType RawVolume<VoxelType>::Sampler::getVoxel(void) const
{ {
if(this->isCurrentPositionValid()) if (this->isCurrentPositionValid())
{ {
return *mCurrentVoxel; return *mCurrentVoxel;
} }
@ -82,7 +82,7 @@ namespace PolyVox
m_bIsCurrentPositionValidInZ = this->mVolume->getEnclosingRegion().containsPointInZ(zPos); m_bIsCurrentPositionValidInZ = this->mVolume->getEnclosingRegion().containsPointInZ(zPos);
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid()) if (this->isCurrentPositionValid())
{ {
const Vector3DInt32& v3dLowerCorner = this->mVolume->m_regValidRegion.getLowerCorner(); const Vector3DInt32& v3dLowerCorner = this->mVolume->m_regValidRegion.getLowerCorner();
int32_t iLocalXPos = xPos - v3dLowerCorner.getX(); int32_t iLocalXPos = xPos - v3dLowerCorner.getX();
@ -105,7 +105,7 @@ namespace PolyVox
bool RawVolume<VoxelType>::Sampler::setVoxel(VoxelType tValue) bool RawVolume<VoxelType>::Sampler::setVoxel(VoxelType tValue)
{ {
//return m_bIsCurrentPositionValid ? *mCurrentVoxel : this->mVolume->getBorderValue(); //return m_bIsCurrentPositionValid ? *mCurrentVoxel : this->mVolume->getBorderValue();
if(this->m_bIsCurrentPositionValidInX && this->m_bIsCurrentPositionValidInY && this->m_bIsCurrentPositionValidInZ) if (this->m_bIsCurrentPositionValidInX && this->m_bIsCurrentPositionValidInY && this->m_bIsCurrentPositionValidInZ)
{ {
*mCurrentVoxel = tValue; *mCurrentVoxel = tValue;
return true; return true;
@ -128,7 +128,7 @@ namespace PolyVox
m_bIsCurrentPositionValidInX = this->mVolume->getEnclosingRegion().containsPointInX(this->mXPosInVolume); m_bIsCurrentPositionValidInX = this->mVolume->getEnclosingRegion().containsPointInX(this->mXPosInVolume);
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid() && bIsOldPositionValid ) if (this->isCurrentPositionValid() && bIsOldPositionValid)
{ {
++mCurrentVoxel; ++mCurrentVoxel;
} }
@ -150,7 +150,7 @@ namespace PolyVox
m_bIsCurrentPositionValidInY = this->mVolume->getEnclosingRegion().containsPointInY(this->mYPosInVolume); m_bIsCurrentPositionValidInY = this->mVolume->getEnclosingRegion().containsPointInY(this->mYPosInVolume);
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid() && bIsOldPositionValid ) if (this->isCurrentPositionValid() && bIsOldPositionValid)
{ {
mCurrentVoxel += this->mVolume->getWidth(); mCurrentVoxel += this->mVolume->getWidth();
} }
@ -172,7 +172,7 @@ namespace PolyVox
m_bIsCurrentPositionValidInZ = this->mVolume->getEnclosingRegion().containsPointInZ(this->mZPosInVolume); m_bIsCurrentPositionValidInZ = this->mVolume->getEnclosingRegion().containsPointInZ(this->mZPosInVolume);
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid() && bIsOldPositionValid ) if (this->isCurrentPositionValid() && bIsOldPositionValid)
{ {
mCurrentVoxel += this->mVolume->getWidth() * this->mVolume->getHeight(); mCurrentVoxel += this->mVolume->getWidth() * this->mVolume->getHeight();
} }
@ -194,7 +194,7 @@ namespace PolyVox
m_bIsCurrentPositionValidInX = this->mVolume->getEnclosingRegion().containsPointInX(this->mXPosInVolume); m_bIsCurrentPositionValidInX = this->mVolume->getEnclosingRegion().containsPointInX(this->mXPosInVolume);
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid() && bIsOldPositionValid ) if (this->isCurrentPositionValid() && bIsOldPositionValid)
{ {
--mCurrentVoxel; --mCurrentVoxel;
} }
@ -216,7 +216,7 @@ namespace PolyVox
m_bIsCurrentPositionValidInY = this->mVolume->getEnclosingRegion().containsPointInY(this->mYPosInVolume); m_bIsCurrentPositionValidInY = this->mVolume->getEnclosingRegion().containsPointInY(this->mYPosInVolume);
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid() && bIsOldPositionValid ) if (this->isCurrentPositionValid() && bIsOldPositionValid)
{ {
mCurrentVoxel -= this->mVolume->getWidth(); mCurrentVoxel -= this->mVolume->getWidth();
} }
@ -238,7 +238,7 @@ namespace PolyVox
m_bIsCurrentPositionValidInZ = this->mVolume->getEnclosingRegion().containsPointInZ(this->mZPosInVolume); m_bIsCurrentPositionValidInZ = this->mVolume->getEnclosingRegion().containsPointInZ(this->mZPosInVolume);
// Then we update the voxel pointer // Then we update the voxel pointer
if(this->isCurrentPositionValid() && bIsOldPositionValid ) if (this->isCurrentPositionValid() && bIsOldPositionValid)
{ {
mCurrentVoxel -= this->mVolume->getWidth() * this->mVolume->getHeight(); mCurrentVoxel -= this->mVolume->getWidth() * this->mVolume->getHeight();
} }
@ -251,91 +251,91 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel - 1 - this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel - 1 - this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume - 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume))
{ {
return *(mCurrentVoxel - 1 - this->mVolume->getWidth()); return *(mCurrentVoxel - 1 - this->mVolume->getWidth());
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume - 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel - 1 - this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel - 1 - this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume - 1, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel - 1 - this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel - 1 - this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume))
{ {
return *(mCurrentVoxel - 1); return *(mCurrentVoxel - 1);
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel - 1 + this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel - 1 + this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel - 1 + this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel - 1 + this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume + 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume))
{ {
return *(mCurrentVoxel - 1 + this->mVolume->getWidth()); return *(mCurrentVoxel - 1 + this->mVolume->getWidth());
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume + 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel - 1 + this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel - 1 + this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume - 1, this->mYPosInVolume + 1, this->mZPosInVolume + 1);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -343,47 +343,47 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel - this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel - this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume - 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume))
{ {
return *(mCurrentVoxel - this->mVolume->getWidth()); return *(mCurrentVoxel - this->mVolume->getWidth());
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume - 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel - this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel - this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume - 1, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_NEG_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel - this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel - this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py0pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py0pz(void) const
{ {
if((this->isCurrentPositionValid())) if ((this->isCurrentPositionValid()))
{ {
return *mCurrentVoxel; return *mCurrentVoxel;
} }
@ -393,41 +393,41 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel + this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel + this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel + this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel + this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume + 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume))
{ {
return *(mCurrentVoxel + this->mVolume->getWidth()); return *(mCurrentVoxel + this->mVolume->getWidth());
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume + 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel + this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel + this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume, this->mYPosInVolume + 1, this->mZPosInVolume + 1);
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -435,91 +435,91 @@ namespace PolyVox
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel + 1 - this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel + 1 - this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume - 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume))
{ {
return *(mCurrentVoxel + 1 - this->mVolume->getWidth()); return *(mCurrentVoxel + 1 - this->mVolume->getWidth());
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume - 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel + 1 - this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel + 1 - this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume - 1, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel + 1 - this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel + 1 - this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume))
{ {
return *(mCurrentVoxel + 1); return *(mCurrentVoxel + 1);
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel + 1 + this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel + 1 + this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume, this->mZPosInVolume + 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_NEG_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel + 1 + this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel + 1 + this->mVolume->getWidth() - this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume-1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume + 1, this->mZPosInVolume - 1);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume))
{ {
return *(mCurrentVoxel + 1 + this->mVolume->getWidth()); return *(mCurrentVoxel + 1 + this->mVolume->getWidth());
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume + 1, this->mZPosInVolume);
} }
template <typename VoxelType> template <typename VoxelType>
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
{ {
if((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume) ) if ((this->isCurrentPositionValid()) && CAN_GO_POS_X(this->mXPosInVolume) && CAN_GO_POS_Y(this->mYPosInVolume) && CAN_GO_POS_Z(this->mZPosInVolume))
{ {
return *(mCurrentVoxel + 1 + this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight()); return *(mCurrentVoxel + 1 + this->mVolume->getWidth() + this->mVolume->getWidth() * this->mVolume->getHeight());
} }
return this->mVolume->getVoxel(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1); return this->mVolume->getVoxel(this->mXPosInVolume + 1, this->mYPosInVolume + 1, this->mZPosInVolume + 1);
} }
} }

View File

@ -107,39 +107,41 @@ namespace PolyVox
const float minz = floorf(z1), maxz = minz + 1.0f; const float minz = floorf(z1), maxz = minz + 1.0f;
float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) * deltatz; float tz = ((z1 > z2) ? (z1 - minz) : (maxz - z1)) * deltatz;
sampler.setPosition(i,j,k); sampler.setPosition(i, j, k);
for(;;) for (;;)
{ {
if(!callback(sampler)) if (!callback(sampler))
{ {
return RaycastResults::Interupted; return RaycastResults::Interupted;
} }
if(tx <= ty && tx <= tz) if (tx <= ty && tx <= tz)
{ {
if(i == iend) break; if (i == iend) break;
tx += deltatx; tx += deltatx;
i += di; i += di;
if(di == 1) sampler.movePositiveX(); if (di == 1) sampler.movePositiveX();
if(di == -1) sampler.moveNegativeX(); if (di == -1) sampler.moveNegativeX();
} else if (ty <= tz) }
else if (ty <= tz)
{ {
if(j == jend) break; if (j == jend) break;
ty += deltaty; ty += deltaty;
j += dj; j += dj;
if(dj == 1) sampler.movePositiveY(); if (dj == 1) sampler.movePositiveY();
if(dj == -1) sampler.moveNegativeY(); if (dj == -1) sampler.moveNegativeY();
} else }
else
{ {
if(k == kend) break; if (k == kend) break;
tz += deltatz; tz += deltatz;
k += dk; k += dk;
if(dk == 1) sampler.movePositiveZ(); if (dk == 1) sampler.movePositiveZ();
if(dk == -1) sampler.moveNegativeZ(); if (dk == -1) sampler.moveNegativeZ();
} }
} }

View File

@ -80,7 +80,7 @@ namespace PolyVox
*/ */
inline void Region::accumulate(const Region& reg) inline void Region::accumulate(const Region& reg)
{ {
if(!reg.isValid()) if (!reg.isValid())
{ {
POLYVOX_THROW(invalid_operation, "You cannot accumulate an invalid region."); //The result of accumulating an invalid region is not defined. POLYVOX_THROW(invalid_operation, "You cannot accumulate an invalid region."); //The result of accumulating an invalid region is not defined.
} }
@ -98,11 +98,11 @@ namespace PolyVox
*/ */
inline Region::Region() inline Region::Region()
:m_iLowerX(0) :m_iLowerX(0)
,m_iLowerY(0) , m_iLowerY(0)
,m_iLowerZ(0) , m_iLowerZ(0)
,m_iUpperX(0) , m_iUpperX(0)
,m_iUpperY(0) , m_iUpperY(0)
,m_iUpperZ(0) , m_iUpperZ(0)
{ {
} }
@ -113,11 +113,11 @@ namespace PolyVox
*/ */
inline Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner) inline Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner)
:m_iLowerX(v3dLowerCorner.getX()) :m_iLowerX(v3dLowerCorner.getX())
,m_iLowerY(v3dLowerCorner.getY()) , m_iLowerY(v3dLowerCorner.getY())
,m_iLowerZ(v3dLowerCorner.getZ()) , m_iLowerZ(v3dLowerCorner.getZ())
,m_iUpperX(v3dUpperCorner.getX()) , m_iUpperX(v3dUpperCorner.getX())
,m_iUpperY(v3dUpperCorner.getY()) , m_iUpperY(v3dUpperCorner.getY())
,m_iUpperZ(v3dUpperCorner.getZ()) , m_iUpperZ(v3dUpperCorner.getZ())
{ {
} }
@ -132,11 +132,11 @@ namespace PolyVox
*/ */
inline Region::Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ) inline Region::Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ)
:m_iLowerX(iLowerX) :m_iLowerX(iLowerX)
,m_iLowerY(iLowerY) , m_iLowerY(iLowerY)
,m_iLowerZ(iLowerZ) , m_iLowerZ(iLowerZ)
,m_iUpperX(iUpperX) , m_iUpperX(iUpperX)
,m_iUpperY(iUpperY) , m_iUpperY(iUpperY)
,m_iUpperZ(iUpperZ) , m_iUpperZ(iUpperZ)
{ {
} }
@ -496,9 +496,9 @@ namespace PolyVox
inline bool intersects(const Region& a, const Region& b) inline bool intersects(const Region& a, const Region& b)
{ {
// No intersection if seperated along an axis. // No intersection if seperated along an axis.
if(a.getUpperX() < b.getLowerX() || a.getLowerX() > b.getUpperX()) return false; if (a.getUpperX() < b.getLowerX() || a.getLowerX() > b.getUpperX()) return false;
if(a.getUpperY() < b.getLowerY() || a.getLowerY() > b.getUpperY()) return false; if (a.getUpperY() < b.getLowerY() || a.getLowerY() > b.getUpperY()) return false;
if(a.getUpperZ() < b.getLowerZ() || a.getLowerZ() > b.getUpperZ()) return false; if (a.getUpperZ() < b.getLowerZ() || a.getLowerZ() > b.getUpperZ()) return false;
// Overlapping on all axes means Regions are intersecting. // Overlapping on all axes means Regions are intersecting.
return true; return true;

View File

@ -78,30 +78,30 @@ namespace PolyVox
/// Constructor. /// Constructor.
Vector(StorageType x, StorageType y, StorageType z, StorageType w); Vector(StorageType x, StorageType y, StorageType z, StorageType w);
/// Copy Constructor. /// Copy Constructor.
Vector(const Vector<Size,StorageType,OperationType>& vector); Vector(const Vector<Size, StorageType, OperationType>& vector);
/// Copy Constructor which performs casting. /// Copy Constructor which performs casting.
template <typename CastType> explicit Vector(const Vector<Size,CastType>& vector); template <typename CastType> explicit Vector(const Vector<Size, CastType>& vector);
/// Destructor. /// Destructor.
~Vector(void); ~Vector(void);
/// Assignment Operator. /// Assignment Operator.
Vector<Size,StorageType,OperationType>& operator=(const Vector<Size,StorageType,OperationType>& rhs); Vector<Size, StorageType, OperationType>& operator=(const Vector<Size, StorageType, OperationType>& rhs);
/// Equality Operator. /// Equality Operator.
bool operator==(const Vector<Size,StorageType,OperationType>& rhs) const; bool operator==(const Vector<Size, StorageType, OperationType>& rhs) const;
/// Inequality Operator. /// Inequality Operator.
bool operator!=(const Vector<Size,StorageType,OperationType>& rhs) const; bool operator!=(const Vector<Size, StorageType, OperationType>& rhs) const;
/// Addition and Assignment Operator. /// Addition and Assignment Operator.
Vector<Size,StorageType,OperationType>& operator+=(const Vector<Size,StorageType,OperationType> &rhs); Vector<Size, StorageType, OperationType>& operator+=(const Vector<Size, StorageType, OperationType> &rhs);
/// Subtraction and Assignment Operator. /// Subtraction and Assignment Operator.
Vector<Size,StorageType,OperationType>& operator-=(const Vector<Size,StorageType,OperationType> &rhs); Vector<Size, StorageType, OperationType>& operator-=(const Vector<Size, StorageType, OperationType> &rhs);
/// Multiplication and Assignment Operator. /// Multiplication and Assignment Operator.
Vector<Size,StorageType,OperationType>& operator*=(const Vector<Size,StorageType,OperationType> &rhs); Vector<Size, StorageType, OperationType>& operator*=(const Vector<Size, StorageType, OperationType> &rhs);
/// Division and Assignment Operator. /// Division and Assignment Operator.
Vector<Size,StorageType,OperationType>& operator/=(const Vector<Size,StorageType,OperationType> &rhs); Vector<Size, StorageType, OperationType>& operator/=(const Vector<Size, StorageType, OperationType> &rhs);
/// Multiplication and Assignment Operator. /// Multiplication and Assignment Operator.
Vector<Size,StorageType,OperationType>& operator*=(const StorageType& rhs); Vector<Size, StorageType, OperationType>& operator*=(const StorageType& rhs);
/// Division and Assignment Operator. /// Division and Assignment Operator.
Vector<Size,StorageType,OperationType>& operator/=(const StorageType& rhs); Vector<Size, StorageType, OperationType>& operator/=(const StorageType& rhs);
/// Element Access. /// Element Access.
StorageType getElement(uint32_t index) const; StorageType getElement(uint32_t index) const;
@ -136,11 +136,11 @@ namespace PolyVox
/// Get the squared length of the vector. /// Get the squared length of the vector.
OperationType lengthSquared(void) const; OperationType lengthSquared(void) const;
/// Find the angle between this vector and that which is passed as a parameter. /// Find the angle between this vector and that which is passed as a parameter.
float angleTo(const Vector<Size,StorageType,OperationType>& vector) const; float angleTo(const Vector<Size, StorageType, OperationType>& vector) const;
/// Find the cross product between this vector and the vector passed as a parameter. /// Find the cross product between this vector and the vector passed as a parameter.
Vector<Size,StorageType,OperationType> cross(const Vector<Size,StorageType,OperationType>& vector) const; Vector<Size, StorageType, OperationType> cross(const Vector<Size, StorageType, OperationType>& vector) const;
/// Find the dot product between this vector and the vector passed as a parameter. /// Find the dot product between this vector and the vector passed as a parameter.
OperationType dot(const Vector<Size,StorageType,OperationType>& rhs) const; OperationType dot(const Vector<Size, StorageType, OperationType>& rhs) const;
/// Normalise the vector. /// Normalise the vector.
void normalise(void); void normalise(void);
@ -151,79 +151,79 @@ namespace PolyVox
// Non-member overloaded operators. // Non-member overloaded operators.
/// Addition operator. /// Addition operator.
template <uint32_t Size,typename StorageType,typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator+(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs); Vector<Size, StorageType, OperationType> operator+(const Vector<Size, StorageType, OperationType>& lhs, const Vector<Size, StorageType, OperationType>& rhs);
/// Subtraction operator. /// Subtraction operator.
template <uint32_t Size,typename StorageType,typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator-(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs); Vector<Size, StorageType, OperationType> operator-(const Vector<Size, StorageType, OperationType>& lhs, const Vector<Size, StorageType, OperationType>& rhs);
/// Multiplication operator. /// Multiplication operator.
template <uint32_t Size,typename StorageType,typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs); Vector<Size, StorageType, OperationType> operator*(const Vector<Size, StorageType, OperationType>& lhs, const Vector<Size, StorageType, OperationType>& rhs);
/// Division operator. /// Division operator.
template <uint32_t Size,typename StorageType,typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs); Vector<Size, StorageType, OperationType> operator/(const Vector<Size, StorageType, OperationType>& lhs, const Vector<Size, StorageType, OperationType>& rhs);
/// Multiplication operator. /// Multiplication operator.
template <uint32_t Size,typename StorageType,typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs); Vector<Size, StorageType, OperationType> operator*(const Vector<Size, StorageType, OperationType>& lhs, const StorageType& rhs);
/// Division operator. /// Division operator.
template <uint32_t Size,typename StorageType,typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs); Vector<Size, StorageType, OperationType> operator/(const Vector<Size, StorageType, OperationType>& lhs, const StorageType& rhs);
/// Stream insertion operator. /// Stream insertion operator.
template <uint32_t Size, typename StorageType,typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
std::ostream& operator<<(std::ostream& os, const Vector<Size,StorageType,OperationType>& vector); std::ostream& operator<<(std::ostream& os, const Vector<Size, StorageType, OperationType>& vector);
//Some handy typedefs //Some handy typedefs
/// A 2D Vector of floats. /// A 2D Vector of floats.
typedef Vector<2,float,float> Vector2DFloat; typedef Vector<2, float, float> Vector2DFloat;
/// A 2D Vector of doubles. /// A 2D Vector of doubles.
typedef Vector<2,double,double> Vector2DDouble; typedef Vector<2, double, double> Vector2DDouble;
/// A 2D Vector of signed 8-bit values. /// A 2D Vector of signed 8-bit values.
typedef Vector<2,int8_t,int32_t> Vector2DInt8; typedef Vector<2, int8_t, int32_t> Vector2DInt8;
/// A 2D Vector of unsigned 8-bit values. /// A 2D Vector of unsigned 8-bit values.
typedef Vector<2,uint8_t,int32_t> Vector2DUint8; typedef Vector<2, uint8_t, int32_t> Vector2DUint8;
/// A 2D Vector of signed 16-bit values. /// A 2D Vector of signed 16-bit values.
typedef Vector<2,int16_t,int32_t> Vector2DInt16; typedef Vector<2, int16_t, int32_t> Vector2DInt16;
/// A 2D Vector of unsigned 16-bit values. /// A 2D Vector of unsigned 16-bit values.
typedef Vector<2,uint16_t,int32_t> Vector2DUint16; typedef Vector<2, uint16_t, int32_t> Vector2DUint16;
/// A 2D Vector of signed 32-bit values. /// A 2D Vector of signed 32-bit values.
typedef Vector<2,int32_t,int32_t> Vector2DInt32; typedef Vector<2, int32_t, int32_t> Vector2DInt32;
/// A 2D Vector of unsigned 32-bit values. /// A 2D Vector of unsigned 32-bit values.
typedef Vector<2,uint32_t,int32_t> Vector2DUint32; typedef Vector<2, uint32_t, int32_t> Vector2DUint32;
/// A 3D Vector of floats. /// A 3D Vector of floats.
typedef Vector<3,float,float> Vector3DFloat; typedef Vector<3, float, float> Vector3DFloat;
/// A 3D Vector of doubles. /// A 3D Vector of doubles.
typedef Vector<3,double,double> Vector3DDouble; typedef Vector<3, double, double> Vector3DDouble;
/// A 3D Vector of signed 8-bit values. /// A 3D Vector of signed 8-bit values.
typedef Vector<3,int8_t,int32_t> Vector3DInt8; typedef Vector<3, int8_t, int32_t> Vector3DInt8;
/// A 3D Vector of unsigned 8-bit values. /// A 3D Vector of unsigned 8-bit values.
typedef Vector<3,uint8_t,int32_t> Vector3DUint8; typedef Vector<3, uint8_t, int32_t> Vector3DUint8;
/// A 3D Vector of signed 16-bit values. /// A 3D Vector of signed 16-bit values.
typedef Vector<3,int16_t,int32_t> Vector3DInt16; typedef Vector<3, int16_t, int32_t> Vector3DInt16;
/// A 3D Vector of unsigned 16-bit values. /// A 3D Vector of unsigned 16-bit values.
typedef Vector<3,uint16_t,int32_t> Vector3DUint16; typedef Vector<3, uint16_t, int32_t> Vector3DUint16;
/// A 3D Vector of signed 32-bit values. /// A 3D Vector of signed 32-bit values.
typedef Vector<3,int32_t,int32_t> Vector3DInt32; typedef Vector<3, int32_t, int32_t> Vector3DInt32;
/// A 3D Vector of unsigned 32-bit values. /// A 3D Vector of unsigned 32-bit values.
typedef Vector<3,uint32_t,int32_t> Vector3DUint32; typedef Vector<3, uint32_t, int32_t> Vector3DUint32;
/// A 4D Vector of floats. /// A 4D Vector of floats.
typedef Vector<4,float,float> Vector4DFloat; typedef Vector<4, float, float> Vector4DFloat;
/// A 4D Vector of doubles. /// A 4D Vector of doubles.
typedef Vector<4,double,double> Vector4DDouble; typedef Vector<4, double, double> Vector4DDouble;
/// A 4D Vector of signed 8-bit values. /// A 4D Vector of signed 8-bit values.
typedef Vector<4,int8_t,int32_t> Vector4DInt8; typedef Vector<4, int8_t, int32_t> Vector4DInt8;
/// A 4D Vector of unsigned 8-bit values. /// A 4D Vector of unsigned 8-bit values.
typedef Vector<4,uint8_t,int32_t> Vector4DUint8; typedef Vector<4, uint8_t, int32_t> Vector4DUint8;
/// A 4D Vector of signed 16-bit values. /// A 4D Vector of signed 16-bit values.
typedef Vector<4,int16_t,int32_t> Vector4DInt16; typedef Vector<4, int16_t, int32_t> Vector4DInt16;
/// A 4D Vector of unsigned 16-bit values. /// A 4D Vector of unsigned 16-bit values.
typedef Vector<4,uint16_t,int32_t> Vector4DUint16; typedef Vector<4, uint16_t, int32_t> Vector4DUint16;
/// A 4D Vector of signed 32-bit values. /// A 4D Vector of signed 32-bit values.
typedef Vector<4,int32_t,int32_t> Vector4DInt32; typedef Vector<4, int32_t, int32_t> Vector4DInt32;
/// A 4D Vector of unsigned 32-bit values. /// A 4D Vector of unsigned 32-bit values.
typedef Vector<4,uint32_t,int32_t> Vector4DUint32; typedef Vector<4, uint32_t, int32_t> Vector4DUint32;
}//namespace PolyVox }//namespace PolyVox

View File

@ -37,8 +37,8 @@ namespace PolyVox
* Creates a Vector object and initialises all components with the given value. * Creates a Vector object and initialises all components with the given value.
* \param tFillValue The value to write to every component. * \param tFillValue The value to write to every component.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType>::Vector(StorageType tFillValue) Vector<Size, StorageType, OperationType>::Vector(StorageType tFillValue)
{ {
std::fill(m_tElements, m_tElements + Size, tFillValue); std::fill(m_tElements, m_tElements + Size, tFillValue);
} }
@ -48,8 +48,8 @@ namespace PolyVox
* \param x The X component to set. * \param x The X component to set.
* \param y The Y component to set. * \param y The Y component to set.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y) Vector<Size, StorageType, OperationType>::Vector(StorageType x, StorageType y)
{ {
static_assert(Size == 2, "This constructor should only be used for vectors with two elements."); static_assert(Size == 2, "This constructor should only be used for vectors with two elements.");
@ -63,8 +63,8 @@ namespace PolyVox
* \param y The Y component to set. * \param y The Y component to set.
* \param z the Z component to set. * \param z the Z component to set.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z) Vector<Size, StorageType, OperationType>::Vector(StorageType x, StorageType y, StorageType z)
{ {
static_assert(Size == 3, "This constructor should only be used for vectors with three elements."); static_assert(Size == 3, "This constructor should only be used for vectors with three elements.");
@ -81,8 +81,8 @@ namespace PolyVox
* \param z The Z component to set. * \param z The Z component to set.
* \param w The W component to set. * \param w The W component to set.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z, StorageType w) Vector<Size, StorageType, OperationType>::Vector(StorageType x, StorageType y, StorageType z, StorageType w)
{ {
static_assert(Size == 4, "This constructor should only be used for vectors with four elements."); static_assert(Size == 4, "This constructor should only be used for vectors with four elements.");
@ -99,7 +99,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size, StorageType, OperationType>::Vector(const Vector<Size, StorageType, OperationType>& vector) Vector<Size, StorageType, OperationType>::Vector(const Vector<Size, StorageType, OperationType>& vector)
{ {
std::memcpy(m_tElements, vector.m_tElements, sizeof(StorageType) * Size); std::memcpy(m_tElements, vector.m_tElements, sizeof(StorageType)* Size);
} }
/** /**
@ -115,7 +115,7 @@ namespace PolyVox
template <typename CastType> template <typename CastType>
Vector<Size, StorageType, OperationType>::Vector(const Vector<Size, CastType>& vector) Vector<Size, StorageType, OperationType>::Vector(const Vector<Size, CastType>& vector)
{ {
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
m_tElements[ct] = static_cast<StorageType>(vector.getElement(ct)); m_tElements[ct] = static_cast<StorageType>(vector.getElement(ct));
} }
@ -145,11 +145,11 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator=(const Vector<Size, StorageType, OperationType>& rhs) Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator=(const Vector<Size, StorageType, OperationType>& rhs)
{ {
if(this == &rhs) if (this == &rhs)
{ {
return *this; return *this;
} }
std::memcpy(m_tElements, rhs.m_tElements, sizeof(StorageType) * Size); std::memcpy(m_tElements, rhs.m_tElements, sizeof(StorageType)* Size);
return *this; return *this;
} }
@ -163,9 +163,9 @@ namespace PolyVox
inline bool Vector<Size, StorageType, OperationType>::operator==(const Vector<Size, StorageType, OperationType> &rhs) const inline bool Vector<Size, StorageType, OperationType>::operator==(const Vector<Size, StorageType, OperationType> &rhs) const
{ {
bool equal = true; bool equal = true;
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
if(m_tElements[ct] != rhs.m_tElements[ct]) if (m_tElements[ct] != rhs.m_tElements[ct])
{ {
equal = false; equal = false;
break; break;
@ -194,7 +194,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator+=(const Vector<Size, StorageType, OperationType>& rhs) inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator+=(const Vector<Size, StorageType, OperationType>& rhs)
{ {
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
m_tElements[ct] += rhs.m_tElements[ct]; m_tElements[ct] += rhs.m_tElements[ct];
} }
@ -209,7 +209,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator-=(const Vector<Size, StorageType, OperationType>& rhs) inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator-=(const Vector<Size, StorageType, OperationType>& rhs)
{ {
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
m_tElements[ct] -= rhs.m_tElements[ct]; m_tElements[ct] -= rhs.m_tElements[ct];
} }
@ -224,7 +224,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const Vector<Size, StorageType, OperationType>& rhs) inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const Vector<Size, StorageType, OperationType>& rhs)
{ {
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
m_tElements[ct] *= rhs.m_tElements[ct]; m_tElements[ct] *= rhs.m_tElements[ct];
} }
@ -239,7 +239,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const Vector<Size, StorageType, OperationType>& rhs) inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const Vector<Size, StorageType, OperationType>& rhs)
{ {
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
m_tElements[ct] /= rhs.m_tElements[ct]; m_tElements[ct] /= rhs.m_tElements[ct];
} }
@ -254,7 +254,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const StorageType& rhs) inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const StorageType& rhs)
{ {
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
m_tElements[ct] *= rhs; m_tElements[ct] *= rhs;
} }
@ -269,7 +269,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const StorageType& rhs) inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const StorageType& rhs)
{ {
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
m_tElements[ct] /= rhs; m_tElements[ct] /= rhs;
} }
@ -282,10 +282,10 @@ namespace PolyVox
* \param rhs The Vector to add. * \param rhs The Vector to add.
* \return The resulting Vector. * \return The resulting Vector.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator+(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs) Vector<Size, StorageType, OperationType> operator+(const Vector<Size, StorageType, OperationType>& lhs, const Vector<Size, StorageType, OperationType>& rhs)
{ {
Vector<Size,StorageType,OperationType> result = lhs; Vector<Size, StorageType, OperationType> result = lhs;
result += rhs; result += rhs;
return result; return result;
} }
@ -296,10 +296,10 @@ namespace PolyVox
* \param rhs The Vector to subtract. * \param rhs The Vector to subtract.
* \return The resulting Vector. * \return The resulting Vector.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator-(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs) Vector<Size, StorageType, OperationType> operator-(const Vector<Size, StorageType, OperationType>& lhs, const Vector<Size, StorageType, OperationType>& rhs)
{ {
Vector<Size,StorageType,OperationType> result = lhs; Vector<Size, StorageType, OperationType> result = lhs;
result -= rhs; result -= rhs;
return result; return result;
} }
@ -310,10 +310,10 @@ namespace PolyVox
* \param rhs The Vector to multiply by. * \param rhs The Vector to multiply by.
* \return The resulting Vector. * \return The resulting Vector.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs) Vector<Size, StorageType, OperationType> operator*(const Vector<Size, StorageType, OperationType>& lhs, const Vector<Size, StorageType, OperationType>& rhs)
{ {
Vector<Size,StorageType,OperationType> result = lhs; Vector<Size, StorageType, OperationType> result = lhs;
result *= rhs; result *= rhs;
return result; return result;
} }
@ -324,10 +324,10 @@ namespace PolyVox
* \param rhs The Vector to divide by. * \param rhs The Vector to divide by.
* \return The resulting Vector. * \return The resulting Vector.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs) Vector<Size, StorageType, OperationType> operator/(const Vector<Size, StorageType, OperationType>& lhs, const Vector<Size, StorageType, OperationType>& rhs)
{ {
Vector<Size,StorageType,OperationType> result = lhs; Vector<Size, StorageType, OperationType> result = lhs;
result /= rhs; result /= rhs;
return result; return result;
} }
@ -338,10 +338,10 @@ namespace PolyVox
* \param rhs The number the Vector is multiplied by. * \param rhs The number the Vector is multiplied by.
* \return The resulting Vector. * \return The resulting Vector.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs) Vector<Size, StorageType, OperationType> operator*(const Vector<Size, StorageType, OperationType>& lhs, const StorageType& rhs)
{ {
Vector<Size,StorageType,OperationType> result = lhs; Vector<Size, StorageType, OperationType> result = lhs;
result *= rhs; result *= rhs;
return result; return result;
} }
@ -352,10 +352,10 @@ namespace PolyVox
* \param rhs The number the Vector is divided by. * \param rhs The number the Vector is divided by.
* \return The resulting Vector. * \return The resulting Vector.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs) Vector<Size, StorageType, OperationType> operator/(const Vector<Size, StorageType, OperationType>& lhs, const StorageType& rhs)
{ {
Vector<Size,StorageType,OperationType> result = lhs; Vector<Size, StorageType, OperationType> result = lhs;
result /= rhs; result /= rhs;
return result; return result;
} }
@ -370,10 +370,10 @@ namespace PolyVox
std::ostream& operator<<(std::ostream& os, const Vector<Size, StorageType, OperationType>& vector) std::ostream& operator<<(std::ostream& os, const Vector<Size, StorageType, OperationType>& vector)
{ {
os << "("; os << "(";
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
os << vector.getElement(ct); os << vector.getElement(ct);
if(ct < (Size-1)) if (ct < (Size - 1))
{ {
os << ","; os << ",";
} }
@ -390,7 +390,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline StorageType Vector<Size, StorageType, OperationType>::getElement(uint32_t index) const inline StorageType Vector<Size, StorageType, OperationType>::getElement(uint32_t index) const
{ {
if(index >= Size) if (index >= Size)
{ {
POLYVOX_THROW(std::out_of_range, "Attempted to access invalid vector element."); POLYVOX_THROW(std::out_of_range, "Attempted to access invalid vector element.");
} }
@ -445,7 +445,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline void Vector<Size, StorageType, OperationType>::setElement(uint32_t index, StorageType tValue) inline void Vector<Size, StorageType, OperationType>::setElement(uint32_t index, StorageType tValue)
{ {
if(index >= Size) if (index >= Size)
{ {
POLYVOX_THROW(std::out_of_range, "Attempted to access invalid vector element."); POLYVOX_THROW(std::out_of_range, "Attempted to access invalid vector element.");
} }
@ -458,8 +458,8 @@ namespace PolyVox
* \param x The X component to set. * \param x The X component to set.
* \param y The Y component to set. * \param y The Y component to set.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y) inline void Vector<Size, StorageType, OperationType>::setElements(StorageType x, StorageType y)
{ {
// This is fine, a Vector always contains at least two elements. // This is fine, a Vector always contains at least two elements.
m_tElements[0] = x; m_tElements[0] = x;
@ -472,8 +472,8 @@ namespace PolyVox
* \param y The Y component to set. * \param y The Y component to set.
* \param z The Z component to set. * \param z The Z component to set.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z) inline void Vector<Size, StorageType, OperationType>::setElements(StorageType x, StorageType y, StorageType z)
{ {
static_assert(Size >= 3, "You can only use this version of setElements() on a vector with at least three elements."); static_assert(Size >= 3, "You can only use this version of setElements() on a vector with at least three elements.");
@ -489,8 +489,8 @@ namespace PolyVox
* \param z The Z component to set. * \param z The Z component to set.
* \param w The W component to set. * \param w The W component to set.
*/ */
template <uint32_t Size,typename StorageType, typename OperationType> template <uint32_t Size, typename StorageType, typename OperationType>
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z, StorageType w) inline void Vector<Size, StorageType, OperationType>::setElements(StorageType x, StorageType y, StorageType z, StorageType w)
{ {
static_assert(Size >= 4, "You can only use this version of setElements() on a vector with at least four elements."); static_assert(Size >= 4, "You can only use this version of setElements() on a vector with at least four elements.");
@ -557,7 +557,7 @@ namespace PolyVox
inline OperationType Vector<Size, StorageType, OperationType>::lengthSquared(void) const inline OperationType Vector<Size, StorageType, OperationType>::lengthSquared(void) const
{ {
OperationType tLengthSquared = static_cast<OperationType>(0); OperationType tLengthSquared = static_cast<OperationType>(0);
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
tLengthSquared += static_cast<OperationType>(m_tElements[ct]) * static_cast<OperationType>(m_tElements[ct]); tLengthSquared += static_cast<OperationType>(m_tElements[ct]) * static_cast<OperationType>(m_tElements[ct]);
} }
@ -597,7 +597,7 @@ namespace PolyVox
StorageType i = vector.getZ() * this->getY() - vector.getY() * this->getZ(); StorageType i = vector.getZ() * this->getY() - vector.getY() * this->getZ();
StorageType j = vector.getX() * this->getZ() - vector.getZ() * this->getX(); StorageType j = vector.getX() * this->getZ() - vector.getZ() * this->getX();
StorageType k = vector.getY() * this->getX() - vector.getX() * this->getY(); StorageType k = vector.getY() * this->getX() - vector.getX() * this->getY();
return Vector<Size, StorageType, OperationType>(i,j,k); return Vector<Size, StorageType, OperationType>(i, j, k);
} }
/** /**
@ -611,7 +611,7 @@ namespace PolyVox
inline OperationType Vector<Size, StorageType, OperationType>::dot(const Vector<Size, StorageType, OperationType>& rhs) const inline OperationType Vector<Size, StorageType, OperationType>::dot(const Vector<Size, StorageType, OperationType>& rhs) const
{ {
OperationType dotProduct = static_cast<OperationType>(0); OperationType dotProduct = static_cast<OperationType>(0);
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
dotProduct += static_cast<OperationType>(m_tElements[ct]) * static_cast<OperationType>(rhs.m_tElements[ct]); dotProduct += static_cast<OperationType>(m_tElements[ct]) * static_cast<OperationType>(rhs.m_tElements[ct]);
} }
@ -632,12 +632,12 @@ namespace PolyVox
// We could wait until the NAN occurs before throwing, but then we'd have to add some roll-back code. // We could wait until the NAN occurs before throwing, but then we'd have to add some roll-back code.
// This seems like a lot of overhead for a common operation which should rarely go wrong. // This seems like a lot of overhead for a common operation which should rarely go wrong.
if(fLength <= 0.0001) if (fLength <= 0.0001)
{ {
POLYVOX_THROW(invalid_operation, "Cannot normalise a vector with a length of zero"); POLYVOX_THROW(invalid_operation, "Cannot normalise a vector with a length of zero");
} }
for(uint32_t ct = 0; ct < Size; ++ct) for (uint32_t ct = 0; ct < Size; ++ct)
{ {
// Standard float rules apply for divide-by-zero // Standard float rules apply for divide-by-zero
m_tElements[ct] /= fLength; m_tElements[ct] /= fLength;

View File

@ -37,9 +37,9 @@ namespace PolyVox
template< typename SrcVolumeType, typename DstVolumeType> template< typename SrcVolumeType, typename DstVolumeType>
VolumeResampler<SrcVolumeType, DstVolumeType>::VolumeResampler(SrcVolumeType* pVolSrc, const Region &regSrc, DstVolumeType* pVolDst, const Region& regDst) VolumeResampler<SrcVolumeType, DstVolumeType>::VolumeResampler(SrcVolumeType* pVolSrc, const Region &regSrc, DstVolumeType* pVolDst, const Region& regDst)
:m_pVolSrc(pVolSrc) :m_pVolSrc(pVolSrc)
,m_regSrc(regSrc) , m_regSrc(regSrc)
,m_pVolDst(pVolDst) , m_pVolDst(pVolDst)
,m_regDst(regDst) , m_regDst(regDst)
{ {
} }
@ -54,7 +54,7 @@ namespace PolyVox
int32_t uDstHeight = m_regDst.getUpperY() - m_regDst.getLowerY() + 1; int32_t uDstHeight = m_regDst.getUpperY() - m_regDst.getLowerY() + 1;
int32_t uDstDepth = m_regDst.getUpperZ() - m_regDst.getLowerZ() + 1; int32_t uDstDepth = m_regDst.getUpperZ() - m_regDst.getLowerZ() + 1;
if((uSrcWidth == uDstWidth) && (uSrcHeight == uDstHeight) && (uSrcDepth == uDstDepth)) if ((uSrcWidth == uDstWidth) && (uSrcHeight == uDstHeight) && (uSrcDepth == uDstDepth))
{ {
resampleSameSize(); resampleSameSize();
} }
@ -67,15 +67,15 @@ namespace PolyVox
template< typename SrcVolumeType, typename DstVolumeType> template< typename SrcVolumeType, typename DstVolumeType>
void VolumeResampler<SrcVolumeType, DstVolumeType>::resampleSameSize() void VolumeResampler<SrcVolumeType, DstVolumeType>::resampleSameSize()
{ {
for(int32_t sz = m_regSrc.getLowerZ(), dz = m_regDst.getLowerZ(); dz <= m_regDst.getUpperZ(); sz++, dz++) for (int32_t sz = m_regSrc.getLowerZ(), dz = m_regDst.getLowerZ(); dz <= m_regDst.getUpperZ(); sz++, dz++)
{ {
for(int32_t sy = m_regSrc.getLowerY(), dy = m_regDst.getLowerY(); dy <= m_regDst.getUpperY(); sy++, dy++) for (int32_t sy = m_regSrc.getLowerY(), dy = m_regDst.getLowerY(); dy <= m_regDst.getUpperY(); sy++, dy++)
{ {
for(int32_t sx = m_regSrc.getLowerX(), dx = m_regDst.getLowerX(); dx <= m_regDst.getUpperX(); sx++,dx++) for (int32_t sx = m_regSrc.getLowerX(), dx = m_regDst.getLowerX(); dx <= m_regDst.getUpperX(); sx++, dx++)
{ {
const typename SrcVolumeType::VoxelType& tSrcVoxel = m_pVolSrc->getVoxel(sx,sy,sz); const typename SrcVolumeType::VoxelType& tSrcVoxel = m_pVolSrc->getVoxel(sx, sy, sz);
const typename DstVolumeType::VoxelType& tDstVoxel = static_cast<typename DstVolumeType::VoxelType>(tSrcVoxel); const typename DstVolumeType::VoxelType& tDstVoxel = static_cast<typename DstVolumeType::VoxelType>(tSrcVoxel);
m_pVolDst->setVoxel(dx,dy,dz,tDstVoxel); m_pVolDst->setVoxel(dx, dy, dz, tDstVoxel);
} }
} }
} }
@ -98,11 +98,11 @@ namespace PolyVox
typename SrcVolumeType::Sampler sampler(m_pVolSrc); typename SrcVolumeType::Sampler sampler(m_pVolSrc);
for(int32_t dz = m_regDst.getLowerZ(); dz <= m_regDst.getUpperZ(); dz++) for (int32_t dz = m_regDst.getLowerZ(); dz <= m_regDst.getUpperZ(); dz++)
{ {
for(int32_t dy = m_regDst.getLowerY(); dy <= m_regDst.getUpperY(); dy++) for (int32_t dy = m_regDst.getLowerY(); dy <= m_regDst.getUpperY(); dy++)
{ {
for(int32_t dx = m_regDst.getLowerX(); dx <= m_regDst.getUpperX(); dx++) for (int32_t dx = m_regDst.getLowerX(); dx <= m_regDst.getUpperX(); dx++)
{ {
float sx = (dx - m_regDst.getLowerX()) * fScaleX; float sx = (dx - m_regDst.getLowerX()) * fScaleX;
float sy = (dy - m_regDst.getLowerY()) * fScaleY; float sy = (dy - m_regDst.getLowerY()) * fScaleY;
@ -112,7 +112,7 @@ namespace PolyVox
sy += m_regSrc.getLowerY(); sy += m_regSrc.getLowerY();
sz += m_regSrc.getLowerZ(); sz += m_regSrc.getLowerZ();
sampler.setPosition(sx,sy,sz); sampler.setPosition(sx, sy, sz);
const typename SrcVolumeType::VoxelType& voxel000 = sampler.peekVoxel0px0py0pz(); const typename SrcVolumeType::VoxelType& voxel000 = sampler.peekVoxel0px0py0pz();
const typename SrcVolumeType::VoxelType& voxel001 = sampler.peekVoxel0px0py1pz(); const typename SrcVolumeType::VoxelType& voxel001 = sampler.peekVoxel0px0py1pz();
const typename SrcVolumeType::VoxelType& voxel010 = sampler.peekVoxel0px1py0pz(); const typename SrcVolumeType::VoxelType& voxel010 = sampler.peekVoxel0px1py0pz();
@ -128,10 +128,10 @@ namespace PolyVox
sy = modf(sy, &dummy); sy = modf(sy, &dummy);
sz = modf(sz, &dummy); sz = modf(sz, &dummy);
typename SrcVolumeType::VoxelType tInterpolatedValue = trilerp<float>(voxel000,voxel100,voxel010,voxel110,voxel001,voxel101,voxel011,voxel111,sx,sy,sz); typename SrcVolumeType::VoxelType tInterpolatedValue = trilerp<float>(voxel000, voxel100, voxel010, voxel110, voxel001, voxel101, voxel011, voxel111, sx, sy, sz);
typename DstVolumeType::VoxelType result = static_cast<typename DstVolumeType::VoxelType>(tInterpolatedValue); typename DstVolumeType::VoxelType result = static_cast<typename DstVolumeType::VoxelType>(tInterpolatedValue);
m_pVolDst->setVoxel(dx,dy,dz,result); m_pVolDst->setVoxel(dx, dy, dz, result);
} }
} }
} }

View File

@ -36,13 +36,13 @@ template< typename VolumeType>
bool testVoxelValidator(const VolumeType* volData, const Vector3DInt32& v3dPos) bool testVoxelValidator(const VolumeType* volData, const Vector3DInt32& v3dPos)
{ {
//Voxels are considered valid candidates for the path if they are inside the volume... //Voxels are considered valid candidates for the path if they are inside the volume...
if(volData->getEnclosingRegion().containsPoint(v3dPos) == false) if (volData->getEnclosingRegion().containsPoint(v3dPos) == false)
{ {
return false; return false;
} }
typename VolumeType::VoxelType voxel = volData->getVoxel(v3dPos); typename VolumeType::VoxelType voxel = volData->getVoxel(v3dPos);
if(voxel != 0) if (voxel != 0)
{ {
return false; return false;
} }
@ -54,59 +54,59 @@ void TestAStarPathfinder::testExecute()
{ {
const Vector3DInt32 expectedResult[] = const Vector3DInt32 expectedResult[] =
{ {
Vector3DInt32(0,0,0), Vector3DInt32(0, 0, 0),
Vector3DInt32(1,1,1), Vector3DInt32(1, 1, 1),
Vector3DInt32(2,1,2), Vector3DInt32(2, 1, 2),
Vector3DInt32(3,1,3), Vector3DInt32(3, 1, 3),
Vector3DInt32(3,1,4), Vector3DInt32(3, 1, 4),
Vector3DInt32(3,1,5), Vector3DInt32(3, 1, 5),
Vector3DInt32(3,1,6), Vector3DInt32(3, 1, 6),
Vector3DInt32(3,1,7), Vector3DInt32(3, 1, 7),
Vector3DInt32(4,2,8), Vector3DInt32(4, 2, 8),
Vector3DInt32(5,3,9), Vector3DInt32(5, 3, 9),
Vector3DInt32(5,3,10), Vector3DInt32(5, 3, 10),
Vector3DInt32(5,3,11), Vector3DInt32(5, 3, 11),
Vector3DInt32(6,4,12), Vector3DInt32(6, 4, 12),
Vector3DInt32(7,5,13), Vector3DInt32(7, 5, 13),
Vector3DInt32(8,6,13), Vector3DInt32(8, 6, 13),
Vector3DInt32(9,7,13), Vector3DInt32(9, 7, 13),
Vector3DInt32(9,8,13), Vector3DInt32(9, 8, 13),
Vector3DInt32(10,9,13), Vector3DInt32(10, 9, 13),
Vector3DInt32(11,10,14), Vector3DInt32(11, 10, 14),
Vector3DInt32(12,11,15), Vector3DInt32(12, 11, 15),
Vector3DInt32(13,12,15), Vector3DInt32(13, 12, 15),
Vector3DInt32(14,13,15), Vector3DInt32(14, 13, 15),
Vector3DInt32(14,14,15), Vector3DInt32(14, 14, 15),
Vector3DInt32(15,15,15) Vector3DInt32(15, 15, 15)
}; };
const int32_t uVolumeSideLength = 16; const int32_t uVolumeSideLength = 16;
//Create a volume //Create a volume
RawVolume<uint8_t> volData(Region(Vector3DInt32(0,0,0), Vector3DInt32(uVolumeSideLength-1, uVolumeSideLength-1, uVolumeSideLength-1))); RawVolume<uint8_t> volData(Region(Vector3DInt32(0, 0, 0), Vector3DInt32(uVolumeSideLength - 1, uVolumeSideLength - 1, uVolumeSideLength - 1)));
//Clear the volume //Clear the volume
for(int z = 0; z < uVolumeSideLength; z++) for (int z = 0; z < uVolumeSideLength; z++)
{ {
for(int y = 0; y < uVolumeSideLength; y++) for (int y = 0; y < uVolumeSideLength; y++)
{ {
for(int x = 0; x < uVolumeSideLength; x++) for (int x = 0; x < uVolumeSideLength; x++)
{ {
uint8_t solidVoxel(0); uint8_t solidVoxel(0);
volData.setVoxel(x,y,z,solidVoxel); volData.setVoxel(x, y, z, solidVoxel);
} }
} }
} }
//Place a solid cube in the middle of it //Place a solid cube in the middle of it
for(int z = 4; z < 12; z++) for (int z = 4; z < 12; z++)
{ {
for(int y = 4; y < 12; y++) for (int y = 4; y < 12; y++)
{ {
for(int x = 4; x < 12; x++) for (int x = 4; x < 12; x++)
{ {
uint8_t solidVoxel(1); uint8_t solidVoxel(1);
volData.setVoxel(x,y,z,solidVoxel); volData.setVoxel(x, y, z, solidVoxel);
} }
} }
} }
@ -115,11 +115,11 @@ void TestAStarPathfinder::testExecute()
std::list<Vector3DInt32> result; std::list<Vector3DInt32> result;
//Create an AStarPathfinder //Create an AStarPathfinder
AStarPathfinderParams< RawVolume<uint8_t> > params(&volData, Vector3DInt32(0,0,0), Vector3DInt32(15,15,15), &result, 1.0f, 10000, TwentySixConnected, &testVoxelValidator<RawVolume<uint8_t> >); AStarPathfinderParams< RawVolume<uint8_t> > params(&volData, Vector3DInt32(0, 0, 0), Vector3DInt32(15, 15, 15), &result, 1.0f, 10000, TwentySixConnected, &testVoxelValidator<RawVolume<uint8_t> >);
AStarPathfinder< RawVolume<uint8_t> > pathfinder(params); AStarPathfinder< RawVolume<uint8_t> > pathfinder(params);
//Execute the pathfinder. //Execute the pathfinder.
QBENCHMARK { QBENCHMARK{
pathfinder.execute(); pathfinder.execute();
} }
@ -128,7 +128,7 @@ void TestAStarPathfinder::testExecute()
//Make sure that each step is correct. //Make sure that each step is correct.
uint32_t uExpectedIndex = 0; uint32_t uExpectedIndex = 0;
for(std::list<Vector3DInt32>::iterator iterResult = result.begin(); iterResult != result.end(); iterResult++) for (std::list<Vector3DInt32>::iterator iterResult = result.begin(); iterResult != result.end(); iterResult++)
{ {
Vector3DInt32 res = *iterResult; Vector3DInt32 res = *iterResult;
Vector3DInt32 exp = expectedResult[uExpectedIndex]; Vector3DInt32 exp = expectedResult[uExpectedIndex];

View File

@ -62,7 +62,7 @@ void TestAmbientOcclusionGenerator::testExecute()
//Create two solid walls at opposite sides of the volume //Create two solid walls at opposite sides of the volume
for (int32_t z = 0; z < g_uVolumeSideLength; z++) for (int32_t z = 0; z < g_uVolumeSideLength; z++)
{ {
if((z < 20) || (z > g_uVolumeSideLength - 20)) if ((z < 20) || (z > g_uVolumeSideLength - 20))
{ {
for (int32_t y = 0; y < g_uVolumeSideLength; y++) for (int32_t y = 0; y < g_uVolumeSideLength; y++)
{ {
@ -80,7 +80,7 @@ void TestAmbientOcclusionGenerator::testExecute()
// Calculate the ambient occlusion values // Calculate the ambient occlusion values
IsVoxelTransparent isVoxelTransparent; IsVoxelTransparent isVoxelTransparent;
QBENCHMARK { QBENCHMARK{
calculateAmbientOcclusion(&volData, &ambientOcclusionResult, region, 32.0f, 255, isVoxelTransparent); calculateAmbientOcclusion(&volData, &ambientOcclusionResult, region, 32.0f, 255, isVoxelTransparent);
} }

View File

@ -94,11 +94,11 @@ void TestArray::testReadWrite()
int ct = 1; int ct = 1;
int expectedTotal = 0; int expectedTotal = 0;
for(int z = 0; z < depth; z++) for (int z = 0; z < depth; z++)
{ {
for(int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
for(int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
myArray(x, y, z) = ct; myArray(x, y, z) = ct;
expectedTotal += myArray(x, y, z); expectedTotal += myArray(x, y, z);
@ -109,11 +109,11 @@ void TestArray::testReadWrite()
ct = 1; ct = 1;
int total = 0; int total = 0;
for(int z = 0; z < depth; z++) for (int z = 0; z < depth; z++)
{ {
for(int y = 0; y < height; y++) for (int y = 0; y < height; y++)
{ {
for(int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
QCOMPARE(myArray(x, y, z), ct); QCOMPARE(myArray(x, y, z), ct);
total += myArray(x, y, z); total += myArray(x, y, z);

View File

@ -36,7 +36,7 @@ void TestLowPassFilter::testExecute()
{ {
const int32_t g_uVolumeSideLength = 8; const int32_t g_uVolumeSideLength = 8;
Region reg(Vector3DInt32(0,0,0), Vector3DInt32(g_uVolumeSideLength-1, g_uVolumeSideLength-1, g_uVolumeSideLength-1)); Region reg(Vector3DInt32(0, 0, 0), Vector3DInt32(g_uVolumeSideLength - 1, g_uVolumeSideLength - 1, g_uVolumeSideLength - 1));
//Create empty volume //Create empty volume
RawVolume<Density8> volData(reg); RawVolume<Density8> volData(reg);
@ -48,7 +48,7 @@ void TestLowPassFilter::testExecute()
{ {
for (int32_t x = 0; x < g_uVolumeSideLength; x++) for (int32_t x = 0; x < g_uVolumeSideLength; x++)
{ {
if(x % 2 == 0) if (x % 2 == 0)
{ {
Density8 voxel(32); Density8 voxel(32);
volData.setVoxel(x, y, z, voxel); volData.setVoxel(x, y, z, voxel);
@ -62,30 +62,30 @@ void TestLowPassFilter::testExecute()
LowPassFilter< RawVolume<Density8>, RawVolume<Density8>, Density16 > lowPassfilter(&volData, reg, &resultVolume, reg, 3); LowPassFilter< RawVolume<Density8>, RawVolume<Density8>, Density16 > lowPassfilter(&volData, reg, &resultVolume, reg, 3);
//Test the normal implementation //Test the normal implementation
QBENCHMARK { QBENCHMARK{
lowPassfilter.execute(); lowPassfilter.execute();
} }
QCOMPARE(resultVolume.getVoxel(0,0,0), Density8(4)); QCOMPARE(resultVolume.getVoxel(0, 0, 0), Density8(4));
QCOMPARE(resultVolume.getVoxel(1,1,1), Density8(21)); QCOMPARE(resultVolume.getVoxel(1, 1, 1), Density8(21));
QCOMPARE(resultVolume.getVoxel(2,2,2), Density8(10)); QCOMPARE(resultVolume.getVoxel(2, 2, 2), Density8(10));
QCOMPARE(resultVolume.getVoxel(3,3,3), Density8(21)); QCOMPARE(resultVolume.getVoxel(3, 3, 3), Density8(21));
QCOMPARE(resultVolume.getVoxel(4,4,4), Density8(10)); QCOMPARE(resultVolume.getVoxel(4, 4, 4), Density8(10));
QCOMPARE(resultVolume.getVoxel(5,5,5), Density8(21)); QCOMPARE(resultVolume.getVoxel(5, 5, 5), Density8(21));
QCOMPARE(resultVolume.getVoxel(6,6,6), Density8(10)); QCOMPARE(resultVolume.getVoxel(6, 6, 6), Density8(10));
QCOMPARE(resultVolume.getVoxel(7,7,7), Density8(4)); QCOMPARE(resultVolume.getVoxel(7, 7, 7), Density8(4));
//Test the SAT implmentation //Test the SAT implmentation
QBENCHMARK { QBENCHMARK{
lowPassfilter.executeSAT(); lowPassfilter.executeSAT();
} }
QCOMPARE(resultVolume.getVoxel(0,0,0), Density8(4)); QCOMPARE(resultVolume.getVoxel(0, 0, 0), Density8(4));
QCOMPARE(resultVolume.getVoxel(1,1,1), Density8(21)); QCOMPARE(resultVolume.getVoxel(1, 1, 1), Density8(21));
QCOMPARE(resultVolume.getVoxel(2,2,2), Density8(10)); QCOMPARE(resultVolume.getVoxel(2, 2, 2), Density8(10));
QCOMPARE(resultVolume.getVoxel(3,3,3), Density8(21)); QCOMPARE(resultVolume.getVoxel(3, 3, 3), Density8(21));
QCOMPARE(resultVolume.getVoxel(4,4,4), Density8(10)); QCOMPARE(resultVolume.getVoxel(4, 4, 4), Density8(10));
QCOMPARE(resultVolume.getVoxel(5,5,5), Density8(21)); QCOMPARE(resultVolume.getVoxel(5, 5, 5), Density8(21));
QCOMPARE(resultVolume.getVoxel(6,6,6), Density8(10)); QCOMPARE(resultVolume.getVoxel(6, 6, 6), Density8(10));
QCOMPARE(resultVolume.getVoxel(7,7,7), Density8(4)); QCOMPARE(resultVolume.getVoxel(7, 7, 7), Density8(4));
} }
QTEST_MAIN(TestLowPassFilter) QTEST_MAIN(TestLowPassFilter)

View File

@ -42,7 +42,7 @@ void TestPicking::testExecute()
{ {
for (int32_t x = 0; x < uVolumeSideLength; x++) for (int32_t x = 0; x < uVolumeSideLength; x++)
{ {
if((x > uVolumeSideLength/2)) //x > 16 is filled if ((x > uVolumeSideLength / 2)) //x > 16 is filled
{ {
volData.setVoxel(x, y, z, 100); volData.setVoxel(x, y, z, 100);
} }

View File

@ -44,7 +44,7 @@ class RaycastTestFunctor
public: public:
RaycastTestFunctor() RaycastTestFunctor()
:m_uVoxelsTouched(0) :m_uVoxelsTouched(0)
,m_bRayLeftVolume(false) , m_bRayLeftVolume(false)
{ {
} }
@ -55,7 +55,7 @@ public:
// For this particular test we know that we are always starting a ray inside the volume, // For this particular test we know that we are always starting a ray inside the volume,
// so if it ever leaves the volume we know it can't go back in and so we can terminate early. // so if it ever leaves the volume we know it can't go back in and so we can terminate early.
// This optimisation is worthwhile because samplers get slow once outside the volume. // This optimisation is worthwhile because samplers get slow once outside the volume.
if(!sampler.isCurrentPositionValid()) if (!sampler.isCurrentPositionValid())
{ {
m_bRayLeftVolume = true; m_bRayLeftVolume = true;
return false; return false;
@ -81,7 +81,7 @@ void TestRaycast::testExecute()
{ {
for (int32_t x = 0; x < uVolumeSideLength; x++) for (int32_t x = 0; x < uVolumeSideLength; x++)
{ {
if((x == 0) || (x == uVolumeSideLength-1) || (y == 0) || (y == uVolumeSideLength-1)) if ((x == 0) || (x == uVolumeSideLength - 1) || (y == 0) || (y == uVolumeSideLength - 1))
{ {
volData.setVoxel(x, y, z, 100); volData.setVoxel(x, y, z, 100);
} }
@ -94,7 +94,7 @@ void TestRaycast::testExecute()
} }
//Cast rays from the centre. Roughly 2/3 should escape. //Cast rays from the centre. Roughly 2/3 should escape.
Vector3DFloat start (uVolumeSideLength / 2, uVolumeSideLength / 2, uVolumeSideLength / 2); Vector3DFloat start(uVolumeSideLength / 2, uVolumeSideLength / 2, uVolumeSideLength / 2);
// We could have counted the total number of hits in the same way as the total number of voxels // We could have counted the total number of hits in the same way as the total number of voxels
// touched, but for demonstration and testing purposes we are making use of the raycast return value // touched, but for demonstration and testing purposes we are making use of the raycast return value
@ -103,7 +103,7 @@ void TestRaycast::testExecute()
uint32_t uTotalVoxelsTouched = 0; uint32_t uTotalVoxelsTouched = 0;
// Cast a large number of random rays // Cast a large number of random rays
for(int ct = 0; ct < 1000000; ct++) for (int ct = 0; ct < 1000000; ct++)
{ {
RaycastTestFunctor raycastTestFunctor; RaycastTestFunctor raycastTestFunctor;
RaycastResult result = raycastWithDirection(&volData, start, randomUnitVectors[ct % 1024] * 1000.0f, raycastTestFunctor); RaycastResult result = raycastWithDirection(&volData, start, randomUnitVectors[ct % 1024] * 1000.0f, raycastTestFunctor);
@ -112,7 +112,7 @@ void TestRaycast::testExecute()
// If the raycast completed then we know it did not hit anything.If it was interupted then it // If the raycast completed then we know it did not hit anything.If it was interupted then it
// probably hit something, unless we noted that the reason it was interupted was that it left the volume. // probably hit something, unless we noted that the reason it was interupted was that it left the volume.
if((result == RaycastResults::Interupted) && (raycastTestFunctor.m_bRayLeftVolume == false)) if ((result == RaycastResults::Interupted) && (raycastTestFunctor.m_bRayLeftVolume == false))
{ {
hits++; hits++;
} }

View File

@ -32,9 +32,9 @@ using namespace PolyVox;
void TestRegion::testEquality() void TestRegion::testEquality()
{ {
Region reg1(1,2,3,4,5,6); Region reg1(1, 2, 3, 4, 5, 6);
Region reg2(0,0,0,10,20,30); Region reg2(0, 0, 0, 10, 20, 30);
Region reg3(Vector3DInt32(1,2,3), Vector3DInt32(4,5,6)); Region reg3(Vector3DInt32(1, 2, 3), Vector3DInt32(4, 5, 6));
QCOMPARE(reg1 != reg2, true); QCOMPARE(reg1 != reg2, true);
QCOMPARE(reg1 == reg3, true); QCOMPARE(reg1 == reg3, true);

View File

@ -46,11 +46,11 @@ public:
//in the future //in the future
//typedef BaseVolume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn //typedef BaseVolume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn
//class Sampler : public VolumeOfVoxelType::template Sampler< VolumeSubclass<VoxelType> > //class Sampler : public VolumeOfVoxelType::template Sampler< VolumeSubclass<VoxelType> >
#if defined(_MSC_VER) #if defined(_MSC_VER)
class Sampler : public BaseVolume<VoxelType>::Sampler< VolumeSubclass<VoxelType> > //This line works on VS2010 class Sampler : public BaseVolume<VoxelType>::Sampler< VolumeSubclass<VoxelType> > //This line works on VS2010
#else #else
class Sampler : public BaseVolume<VoxelType>::template Sampler< VolumeSubclass<VoxelType> > //This line works on GCC class Sampler : public BaseVolume<VoxelType>::template Sampler< VolumeSubclass<VoxelType> > //This line works on GCC
#endif #endif
{ {
public: public:
Sampler(VolumeSubclass<VoxelType>* volume) Sampler(VolumeSubclass<VoxelType>* volume)
@ -97,7 +97,7 @@ public:
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates /// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
bool setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) bool setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue)
{ {
if( (uXPos >= 0) && (uXPos < static_cast<int32_t>(mVolumeData.getDimension(0))) && if ((uXPos >= 0) && (uXPos < static_cast<int32_t>(mVolumeData.getDimension(0))) &&
(uYPos >= 0) && (uYPos < static_cast<int32_t>(mVolumeData.getDimension(1))) && (uYPos >= 0) && (uYPos < static_cast<int32_t>(mVolumeData.getDimension(1))) &&
(uZPos >= 0) && (uZPos < static_cast<int32_t>(mVolumeData.getDimension(2)))) (uZPos >= 0) && (uZPos < static_cast<int32_t>(mVolumeData.getDimension(2))))
{ {
@ -131,7 +131,7 @@ void TestVolumeSubclass::testExtractSurface()
for (int32_t x = 0; x < region.getWidthInVoxels(); x++) for (int32_t x = 0; x < region.getWidthInVoxels(); x++)
{ {
Material8 mat(1); Material8 mat(1);
volumeSubclass.setVoxel(Vector3DInt32(x,y,z),mat); volumeSubclass.setVoxel(Vector3DInt32(x, y, z), mat);
} }
} }
} }

View File

@ -39,7 +39,7 @@ Vector3DFloat incrementVector(Vector3DFloat input)
void TestVector::testLength() void TestVector::testLength()
{ {
Vector3DInt8 vec(3, 4, 5); Vector3DInt8 vec(3, 4, 5);
QCOMPARE(vec.lengthSquared(), int32_t(3*3+4*4+5*5)); // QCOMPARE is strict on types. For an int8 vector, the OperationType is int32_t. QCOMPARE(vec.lengthSquared(), int32_t(3 * 3 + 4 * 4 + 5 * 5)); // QCOMPARE is strict on types. For an int8 vector, the OperationType is int32_t.
} }
void TestVector::testDotProduct() void TestVector::testDotProduct()
@ -64,7 +64,7 @@ void TestVector::testPerformance()
QBENCHMARK QBENCHMARK
{ {
for(uint32_t ct = 0; ct < 10000000; ct++) for (uint32_t ct = 0; ct < 10000000; ct++)
{ {
vec = incrementVector(vec); vec = incrementVector(vec);
} }

View File

@ -39,7 +39,7 @@ using namespace PolyVox;
// make sure we get the expected result from a series of volume accesses. // make sure we get the expected result from a series of volume accesses.
inline int32_t cantorTupleFunction(int32_t previousResult, int32_t value) inline int32_t cantorTupleFunction(int32_t previousResult, int32_t value)
{ {
return (( previousResult + value ) * ( previousResult + value + 1 ) + value ) / 2; return ((previousResult + value) * (previousResult + value + 1) + value) / 2;
} }
/* /*
@ -60,11 +60,11 @@ int32_t testDirectAccessWithWrappingForwards(const VolumeType* volume, Region re
for (int x = region.getLowerX(); x <= region.getUpperX(); x++) for (int x = region.getLowerX(); x <= region.getUpperX(); x++)
{ {
//Three level loop now processes 27 voxel neighbourhood //Three level loop now processes 27 voxel neighbourhood
for(int innerZ = -1; innerZ <=1; innerZ++) for (int innerZ = -1; innerZ <= 1; innerZ++)
{ {
for(int innerY = -1; innerY <=1; innerY++) for (int innerY = -1; innerY <= 1; innerY++)
{ {
for(int innerX = -1; innerX <=1; innerX++) for (int innerX = -1; innerX <= 1; innerX++)
{ {
result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ)); result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ));
} }
@ -149,11 +149,11 @@ int32_t testDirectAccessWithWrappingBackwards(const VolumeType* volume, Region r
for (int x = region.getUpperX(); x >= region.getLowerX(); x--) for (int x = region.getUpperX(); x >= region.getLowerX(); x--)
{ {
//Three level loop now processes 27 voxel neighbourhood //Three level loop now processes 27 voxel neighbourhood
for(int innerZ = -1; innerZ <=1; innerZ++) for (int innerZ = -1; innerZ <= 1; innerZ++)
{ {
for(int innerY = -1; innerY <=1; innerY++) for (int innerY = -1; innerY <= 1; innerY++)
{ {
for(int innerX = -1; innerX <=1; innerX++) for (int innerX = -1; innerX <= 1; innerX++)
{ {
result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ)); result = cantorTupleFunction(result, volume->getVoxel(x + innerX, y + innerY, z + innerZ));
} }