Reverted some of ker's changes to bring back the concepts of width, height, and depth.

This commit is contained in:
David Williams
2011-03-11 22:14:51 +00:00
parent 624a192be4
commit 596dcf507e
10 changed files with 338 additions and 24 deletions

View File

@ -41,15 +41,22 @@ namespace PolyVox
VolumeSampler<uint8_t> volIter(volumeData);
Vector3DFloat v3dGradient = computeNormal(volumeData, v3dPos, normalGenerationMethod);
//Check all corners are within the volume, allowing a boundary for gradient estimation
bool lowerCornerInside = volumeData->getEnclosingRegion().containsPoint(v3dFloor,2);
bool upperCornerInside = volumeData->getEnclosingRegion().containsPoint(v3dFloor+Vector3DInt32(1,1,1),2);
if(v3dGradient.lengthSquared() > 0.0001)
if(lowerCornerInside && upperCornerInside) //If this test fails the vertex will be left as it was
{
//If we got a normal of significant length then update it.
//Otherwise leave it as it was (should be the 'simple' version)
v3dGradient.normalise();
iterSurfaceVertex->setNormal(v3dGradient);
}
Vector3DFloat v3dGradient = computeNormal(volumeData, v3dPos, normalGenerationMethod);
if(v3dGradient.lengthSquared() > 0.0001)
{
//If we got a normal of significant length then update it.
//Otherwise leave it as it was (should be the 'simple' version)
v3dGradient.normalise();
iterSurfaceVertex->setNormal(v3dGradient);
}
} //(lowerCornerInside && upperCornerInside)
++iterSurfaceVertex;
}
}

View File

@ -57,6 +57,14 @@ namespace PolyVox
m_v3dUpperCorner = v3dUpperCorner;
}
void Region::setToMaxSize(void)
{
int32_t iMin = (std::numeric_limits<int32_t>::min)();
int32_t iMax = (std::numeric_limits<int32_t>::max)();
m_v3dLowerCorner = Vector3DInt32(iMin, iMin,iMin);
m_v3dUpperCorner = Vector3DInt32(iMax, iMax,iMax);
}
bool Region::containsPoint(const Vector3DFloat& pos, float boundary) const
{
return (pos.getX() <= m_v3dUpperCorner.getX() - boundary)

View File

@ -29,6 +29,13 @@ namespace PolyVox
{
float computeSmoothedVoxel(VolumeSampler<uint8_t>& volIter)
{
assert(volIter.getPosX() >= 1);
assert(volIter.getPosY() >= 1);
assert(volIter.getPosZ() >= 1);
assert(volIter.getPosX() <= volIter.getVolume()->getWidth() - 2);
assert(volIter.getPosY() <= volIter.getVolume()->getHeight() - 2);
assert(volIter.getPosZ() <= volIter.getVolume()->getDepth() - 2);
float sum = 0.0;
if(volIter.peekVoxel1nx1ny1nz() != 0) sum += 1.0f;