Applied patch from ker such that int32_t's are now used instead of uint16_t's for addressing voxel positions.
This commit is contained in:
@ -29,41 +29,41 @@ using namespace PolyVox;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
const Vector3DInt16 arrayPathfinderFaces[6] =
|
||||
const Vector3DInt32 arrayPathfinderFaces[6] =
|
||||
{
|
||||
Vector3DInt16(0, 0, -1),
|
||||
Vector3DInt16(0, 0, +1),
|
||||
Vector3DInt16(0, -1, 0),
|
||||
Vector3DInt16(0, +1, 0),
|
||||
Vector3DInt16(-1, 0, 0),
|
||||
Vector3DInt16(+1, 0, 0)
|
||||
Vector3DInt32(0, 0, -1),
|
||||
Vector3DInt32(0, 0, +1),
|
||||
Vector3DInt32(0, -1, 0),
|
||||
Vector3DInt32(0, +1, 0),
|
||||
Vector3DInt32(-1, 0, 0),
|
||||
Vector3DInt32(+1, 0, 0)
|
||||
};
|
||||
|
||||
const Vector3DInt16 arrayPathfinderEdges[12] =
|
||||
const Vector3DInt32 arrayPathfinderEdges[12] =
|
||||
{
|
||||
Vector3DInt16(0, -1, -1),
|
||||
Vector3DInt16(0, -1, +1),
|
||||
Vector3DInt16(0, +1, -1),
|
||||
Vector3DInt16(0, +1, +1),
|
||||
Vector3DInt16(-1, 0, -1),
|
||||
Vector3DInt16(-1, 0, +1),
|
||||
Vector3DInt16(+1, 0, -1),
|
||||
Vector3DInt16(+1, 0, +1),
|
||||
Vector3DInt16(-1, -1, 0),
|
||||
Vector3DInt16(-1, +1, 0),
|
||||
Vector3DInt16(+1, -1, 0),
|
||||
Vector3DInt16(+1, +1, 0)
|
||||
Vector3DInt32(0, -1, -1),
|
||||
Vector3DInt32(0, -1, +1),
|
||||
Vector3DInt32(0, +1, -1),
|
||||
Vector3DInt32(0, +1, +1),
|
||||
Vector3DInt32(-1, 0, -1),
|
||||
Vector3DInt32(-1, 0, +1),
|
||||
Vector3DInt32(+1, 0, -1),
|
||||
Vector3DInt32(+1, 0, +1),
|
||||
Vector3DInt32(-1, -1, 0),
|
||||
Vector3DInt32(-1, +1, 0),
|
||||
Vector3DInt32(+1, -1, 0),
|
||||
Vector3DInt32(+1, +1, 0)
|
||||
};
|
||||
|
||||
const Vector3DInt16 arrayPathfinderCorners[8] =
|
||||
const Vector3DInt32 arrayPathfinderCorners[8] =
|
||||
{
|
||||
Vector3DInt16(-1, -1, -1),
|
||||
Vector3DInt16(-1, -1, +1),
|
||||
Vector3DInt16(-1, +1, -1),
|
||||
Vector3DInt16(-1, +1, +1),
|
||||
Vector3DInt16(+1, -1, -1),
|
||||
Vector3DInt16(+1, -1, +1),
|
||||
Vector3DInt16(+1, +1, -1),
|
||||
Vector3DInt16(+1, +1, +1)
|
||||
Vector3DInt32(-1, -1, -1),
|
||||
Vector3DInt32(-1, -1, +1),
|
||||
Vector3DInt32(-1, +1, -1),
|
||||
Vector3DInt32(-1, +1, +1),
|
||||
Vector3DInt32(+1, -1, -1),
|
||||
Vector3DInt32(+1, -1, +1),
|
||||
Vector3DInt32(+1, +1, -1),
|
||||
Vector3DInt32(+1, +1, +1)
|
||||
};
|
||||
}
|
@ -37,13 +37,13 @@ namespace PolyVox
|
||||
while(iterSurfaceVertex != vecVertices.end())
|
||||
{
|
||||
const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast<Vector3DFloat>(mesh.m_Region.getLowerCorner());
|
||||
const Vector3DInt16 v3dFloor = static_cast<Vector3DInt16>(v3dPos);
|
||||
const Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos);
|
||||
|
||||
VolumeSampler<uint8_t> volIter(volumeData);
|
||||
|
||||
//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+Vector3DInt16(1,1,1),2);
|
||||
bool upperCornerInside = volumeData->getEnclosingRegion().containsPoint(v3dFloor+Vector3DInt32(1,1,1),2);
|
||||
|
||||
if(lowerCornerInside && upperCornerInside) //If this test fails the vertex will be left as it was
|
||||
{
|
||||
@ -69,7 +69,7 @@ namespace PolyVox
|
||||
|
||||
const Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos);
|
||||
|
||||
volIter.setPosition(static_cast<Vector3DInt16>(v3dFloor));
|
||||
volIter.setPosition(static_cast<Vector3DInt32>(v3dFloor));
|
||||
Vector3DFloat gradFloor;
|
||||
switch(normalGenerationMethod)
|
||||
{
|
||||
@ -89,15 +89,15 @@ namespace PolyVox
|
||||
|
||||
if((v3dPos.getX() - v3dFloor.getX()) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<Vector3DInt16>(v3dFloor+Vector3DInt32(1,0,0)));
|
||||
volIter.setPosition(static_cast<Vector3DInt32>(v3dFloor+Vector3DInt32(1,0,0)));
|
||||
}
|
||||
if((v3dPos.getY() - v3dFloor.getY()) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<Vector3DInt16>(v3dFloor+Vector3DInt32(0,1,0)));
|
||||
volIter.setPosition(static_cast<Vector3DInt32>(v3dFloor+Vector3DInt32(0,1,0)));
|
||||
}
|
||||
if((v3dPos.getZ() - v3dFloor.getZ()) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<Vector3DInt16>(v3dFloor+Vector3DInt32(0,0,1)));
|
||||
volIter.setPosition(static_cast<Vector3DInt32>(v3dFloor+Vector3DInt32(0,0,1)));
|
||||
}
|
||||
|
||||
Vector3DFloat gradCeil;
|
||||
@ -126,7 +126,7 @@ namespace PolyVox
|
||||
|
||||
if(normalGenerationMethod == SIMPLE)
|
||||
{
|
||||
volIter.setPosition(static_cast<Vector3DInt16>(v3dFloor));
|
||||
volIter.setPosition(static_cast<Vector3DInt32>(v3dFloor));
|
||||
const uint8_t uFloor = volIter.getVoxel() > 0 ? 1 : 0;
|
||||
if((v3dPos.getX() - v3dFloor.getX()) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
|
@ -31,28 +31,28 @@ namespace PolyVox
|
||||
{
|
||||
}
|
||||
|
||||
Region::Region(const Vector3DInt16& v3dLowerCorner, const Vector3DInt16& v3dUpperCorner)
|
||||
Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner)
|
||||
:m_v3dLowerCorner(v3dLowerCorner)
|
||||
,m_v3dUpperCorner(v3dUpperCorner)
|
||||
{
|
||||
}
|
||||
|
||||
const Vector3DInt16& Region::getLowerCorner(void) const
|
||||
const Vector3DInt32& Region::getLowerCorner(void) const
|
||||
{
|
||||
return m_v3dLowerCorner;
|
||||
}
|
||||
|
||||
const Vector3DInt16& Region::getUpperCorner(void) const
|
||||
const Vector3DInt32& Region::getUpperCorner(void) const
|
||||
{
|
||||
return m_v3dUpperCorner;
|
||||
}
|
||||
|
||||
void Region::setLowerCorner(const Vector3DInt16& v3dLowerCorner)
|
||||
void Region::setLowerCorner(const Vector3DInt32& v3dLowerCorner)
|
||||
{
|
||||
m_v3dLowerCorner = v3dLowerCorner;
|
||||
}
|
||||
|
||||
void Region::setUpperCorner(const Vector3DInt16& v3dUpperCorner)
|
||||
void Region::setUpperCorner(const Vector3DInt32& v3dUpperCorner)
|
||||
{
|
||||
m_v3dUpperCorner = v3dUpperCorner;
|
||||
}
|
||||
@ -67,7 +67,7 @@ namespace PolyVox
|
||||
&& (pos.getZ() >= m_v3dLowerCorner.getZ() + boundary);
|
||||
}
|
||||
|
||||
bool Region::containsPoint(const Vector3DInt16& pos, uint8_t boundary) const
|
||||
bool Region::containsPoint(const Vector3DInt32& pos, uint8_t boundary) const
|
||||
{
|
||||
return (pos.getX() <= m_v3dUpperCorner.getX() - boundary)
|
||||
&& (pos.getY() <= m_v3dUpperCorner.getY() - boundary)
|
||||
@ -87,38 +87,38 @@ namespace PolyVox
|
||||
m_v3dUpperCorner.setZ((std::min)(m_v3dUpperCorner.getZ(), other.m_v3dUpperCorner.getZ()));
|
||||
}
|
||||
|
||||
int16_t Region::depth(void) const
|
||||
int32_t Region::depth(void) const
|
||||
{
|
||||
return m_v3dUpperCorner.getZ() - m_v3dLowerCorner.getZ();
|
||||
}
|
||||
|
||||
int16_t Region::height(void) const
|
||||
int32_t Region::height(void) const
|
||||
{
|
||||
return m_v3dUpperCorner.getY() - m_v3dLowerCorner.getY();
|
||||
}
|
||||
|
||||
void Region::shift(const Vector3DInt16& amount)
|
||||
void Region::shift(const Vector3DInt32& amount)
|
||||
{
|
||||
m_v3dLowerCorner += amount;
|
||||
m_v3dUpperCorner += amount;
|
||||
}
|
||||
|
||||
void Region::shiftLowerCorner(const Vector3DInt16& amount)
|
||||
void Region::shiftLowerCorner(const Vector3DInt32& amount)
|
||||
{
|
||||
m_v3dLowerCorner += amount;
|
||||
}
|
||||
|
||||
void Region::shiftUpperCorner(const Vector3DInt16& amount)
|
||||
void Region::shiftUpperCorner(const Vector3DInt32& amount)
|
||||
{
|
||||
m_v3dUpperCorner += amount;
|
||||
}
|
||||
|
||||
Vector3DInt16 Region::dimensions(void)
|
||||
Vector3DInt32 Region::dimensions(void)
|
||||
{
|
||||
return m_v3dUpperCorner - m_v3dLowerCorner;
|
||||
}
|
||||
|
||||
int16_t Region::width(void) const
|
||||
int32_t Region::width(void) const
|
||||
{
|
||||
return m_v3dUpperCorner.getX() - m_v3dLowerCorner.getX();
|
||||
}
|
||||
|
Reference in New Issue
Block a user