Switched to integer naming conventions from C++0x (e.g. uint16_t)
This commit is contained in:
@ -34,12 +34,12 @@ using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
uint32 getDecimatedIndex(uint32 x, uint32 y , uint32 regionWidth)
|
||||
uint32_t getDecimatedIndex(uint32_t x, uint32_t y , uint32_t regionWidth)
|
||||
{
|
||||
return x + (y * (regionWidth+1));
|
||||
}
|
||||
|
||||
void extractDecimatedSurfaceImpl(Volume<uint8>* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void extractDecimatedSurfaceImpl(Volume<uint8_t>* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
{
|
||||
singleMaterialPatch->clear();
|
||||
|
||||
@ -48,18 +48,18 @@ namespace PolyVox
|
||||
//FIXME - Instead of region.width()+2 we used to use POLYVOX_REGION_SIDE_LENGTH+1
|
||||
//Normally POLYVOX_REGION_SIDE_LENGTH is the same as region.width() (often 32) but at the
|
||||
//edges of the volume it is 1 smaller. Need to think what values really belong here.
|
||||
int32* vertexIndicesX0 = new int32[(region.width()+2) * (region.height()+2)];
|
||||
int32* vertexIndicesY0 = new int32[(region.width()+2) * (region.height()+2)];
|
||||
int32* vertexIndicesZ0 = new int32[(region.width()+2) * (region.height()+2)];
|
||||
int32* vertexIndicesX1 = new int32[(region.width()+2) * (region.height()+2)];
|
||||
int32* vertexIndicesY1 = new int32[(region.width()+2) * (region.height()+2)];
|
||||
int32* vertexIndicesZ1 = new int32[(region.width()+2) * (region.height()+2)];
|
||||
int32_t* vertexIndicesX0 = new int32_t[(region.width()+2) * (region.height()+2)];
|
||||
int32_t* vertexIndicesY0 = new int32_t[(region.width()+2) * (region.height()+2)];
|
||||
int32_t* vertexIndicesZ0 = new int32_t[(region.width()+2) * (region.height()+2)];
|
||||
int32_t* vertexIndicesX1 = new int32_t[(region.width()+2) * (region.height()+2)];
|
||||
int32_t* vertexIndicesY1 = new int32_t[(region.width()+2) * (region.height()+2)];
|
||||
int32_t* vertexIndicesZ1 = new int32_t[(region.width()+2) * (region.height()+2)];
|
||||
|
||||
//Cell bitmasks
|
||||
uint8* bitmask0 = new uint8[(region.width()+2) * (region.height()+2)];
|
||||
uint8* bitmask1 = new uint8[(region.width()+2) * (region.height()+2)];
|
||||
uint8_t* bitmask0 = new uint8_t[(region.width()+2) * (region.height()+2)];
|
||||
uint8_t* bitmask1 = new uint8_t[(region.width()+2) * (region.height()+2)];
|
||||
|
||||
const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
|
||||
//When generating the mesh for a region we actually look outside it in the
|
||||
// back, bottom, right direction. Protect against access violations by cropping region here
|
||||
@ -77,22 +77,22 @@ namespace PolyVox
|
||||
regSlice0.setUpperCorner(v3dUpperCorner);
|
||||
|
||||
//Iterator to access the volume data
|
||||
VolumeIterator<uint8> volIter(*volumeData);
|
||||
VolumeIterator<uint8_t> volIter(*volumeData);
|
||||
|
||||
//Compute bitmask for initial slice
|
||||
uint32 uNoOfNonEmptyCellsForSlice0 = computeInitialDecimatedBitmaskForSlice(volIter, uLevel, regSlice0, offset, bitmask0);
|
||||
uint32_t uNoOfNonEmptyCellsForSlice0 = computeInitialDecimatedBitmaskForSlice(volIter, uLevel, regSlice0, offset, bitmask0);
|
||||
if(uNoOfNonEmptyCellsForSlice0 != 0)
|
||||
{
|
||||
//If there were some non-empty cells then generate initial slice vertices for them
|
||||
generateDecimatedVerticesForSlice(volIter, uLevel, regSlice0, offset, bitmask0, singleMaterialPatch, vertexIndicesX0, vertexIndicesY0, vertexIndicesZ0);
|
||||
}
|
||||
|
||||
for(uint32 uSlice = 1; ((uSlice <= region.depth()) && (uSlice + offset.getZ() <= regVolume.getUpperCorner().getZ())); uSlice += uStepSize)
|
||||
for(uint32_t uSlice = 1; ((uSlice <= region.depth()) && (uSlice + offset.getZ() <= regVolume.getUpperCorner().getZ())); uSlice += uStepSize)
|
||||
{
|
||||
Region regSlice1(regSlice0);
|
||||
regSlice1.shift(Vector3DInt32(0,0,uStepSize));
|
||||
|
||||
uint32 uNoOfNonEmptyCellsForSlice1 = computeDecimatedBitmaskForSliceFromPrevious(volIter, uLevel, regSlice1, offset, bitmask1, bitmask0);
|
||||
uint32_t uNoOfNonEmptyCellsForSlice1 = computeDecimatedBitmaskForSliceFromPrevious(volIter, uLevel, regSlice1, offset, bitmask1, bitmask0);
|
||||
|
||||
if(uNoOfNonEmptyCellsForSlice1 != 0)
|
||||
{
|
||||
@ -132,41 +132,41 @@ namespace PolyVox
|
||||
}*/
|
||||
}
|
||||
|
||||
uint32 computeInitialDecimatedBitmaskForSlice(VolumeIterator<uint8>& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask)
|
||||
uint32_t computeInitialDecimatedBitmaskForSlice(VolumeIterator<uint8_t>& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask)
|
||||
{
|
||||
const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
uint32 uNoOfNonEmptyCells = 0;
|
||||
const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
uint32_t uNoOfNonEmptyCells = 0;
|
||||
|
||||
//Iterate over each cell in the region
|
||||
for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize)
|
||||
for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize)
|
||||
{
|
||||
for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize)
|
||||
for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize)
|
||||
{
|
||||
//Current position
|
||||
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ());
|
||||
|
||||
//Determine the index into the edge table which tells us which vertices are inside of the surface
|
||||
uint8 iCubeIndex = 0;
|
||||
uint8_t iCubeIndex = 0;
|
||||
|
||||
if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY()))
|
||||
{
|
||||
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ());
|
||||
const uint8 v000 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v000 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ());
|
||||
const uint8 v100 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v100 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||
const uint8 v010 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v010 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||
const uint8 v110 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v110 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v001 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v001 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v101 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v101 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v011 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v011 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
if (v000 == 0) iCubeIndex |= 1;
|
||||
if (v100 == 0) iCubeIndex |= 2;
|
||||
@ -180,28 +180,28 @@ namespace PolyVox
|
||||
else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY())
|
||||
{
|
||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ());
|
||||
const uint8 v100 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v100 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||
const uint8 v110 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v110 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v101 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v101 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
//x
|
||||
uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
uint8 srcBit6 = iPreviousCubeIndexX & 64;
|
||||
uint8 destBit7 = srcBit6 << 1;
|
||||
uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
uint8_t srcBit6 = iPreviousCubeIndexX & 64;
|
||||
uint8_t destBit7 = srcBit6 << 1;
|
||||
|
||||
uint8 srcBit5 = iPreviousCubeIndexX & 32;
|
||||
uint8 destBit4 = srcBit5 >> 1;
|
||||
uint8_t srcBit5 = iPreviousCubeIndexX & 32;
|
||||
uint8_t destBit4 = srcBit5 >> 1;
|
||||
|
||||
uint8 srcBit2 = iPreviousCubeIndexX & 4;
|
||||
uint8 destBit3 = srcBit2 << 1;
|
||||
uint8_t srcBit2 = iPreviousCubeIndexX & 4;
|
||||
uint8_t destBit3 = srcBit2 << 1;
|
||||
|
||||
uint8 srcBit1 = iPreviousCubeIndexX & 2;
|
||||
uint8 destBit0 = srcBit1 >> 1;
|
||||
uint8_t srcBit1 = iPreviousCubeIndexX & 2;
|
||||
uint8_t destBit0 = srcBit1 >> 1;
|
||||
|
||||
iCubeIndex |= destBit0;
|
||||
if (v100 == 0) iCubeIndex |= 2;
|
||||
@ -215,28 +215,28 @@ namespace PolyVox
|
||||
else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY()))
|
||||
{
|
||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||
const uint8 v010 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v010 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||
const uint8 v110 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v110 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v011 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v011 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
//y
|
||||
uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)];
|
||||
uint8 srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8 destBit4 = srcBit7 >> 3;
|
||||
uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)];
|
||||
uint8_t srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8_t destBit4 = srcBit7 >> 3;
|
||||
|
||||
uint8 srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8 destBit5 = srcBit6 >> 1;
|
||||
uint8_t srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8_t destBit5 = srcBit6 >> 1;
|
||||
|
||||
uint8 srcBit3 = iPreviousCubeIndexY & 8;
|
||||
uint8 destBit0 = srcBit3 >> 3;
|
||||
uint8_t srcBit3 = iPreviousCubeIndexY & 8;
|
||||
uint8_t destBit0 = srcBit3 >> 3;
|
||||
|
||||
uint8 srcBit2 = iPreviousCubeIndexY & 4;
|
||||
uint8 destBit1 = srcBit2 >> 1;
|
||||
uint8_t srcBit2 = iPreviousCubeIndexY & 4;
|
||||
uint8_t destBit1 = srcBit2 >> 1;
|
||||
|
||||
iCubeIndex |= destBit0;
|
||||
iCubeIndex |= destBit1;
|
||||
@ -250,32 +250,32 @@ namespace PolyVox
|
||||
else
|
||||
{
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||
const uint8 v110 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v110 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
//y
|
||||
uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)];
|
||||
uint8 srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8 destBit4 = srcBit7 >> 3;
|
||||
uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)];
|
||||
uint8_t srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8_t destBit4 = srcBit7 >> 3;
|
||||
|
||||
uint8 srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8 destBit5 = srcBit6 >> 1;
|
||||
uint8_t srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8_t destBit5 = srcBit6 >> 1;
|
||||
|
||||
uint8 srcBit3 = iPreviousCubeIndexY & 8;
|
||||
uint8 destBit0 = srcBit3 >> 3;
|
||||
uint8_t srcBit3 = iPreviousCubeIndexY & 8;
|
||||
uint8_t destBit0 = srcBit3 >> 3;
|
||||
|
||||
uint8 srcBit2 = iPreviousCubeIndexY & 4;
|
||||
uint8 destBit1 = srcBit2 >> 1;
|
||||
uint8_t srcBit2 = iPreviousCubeIndexY & 4;
|
||||
uint8_t destBit1 = srcBit2 >> 1;
|
||||
|
||||
//x
|
||||
uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
srcBit6 = iPreviousCubeIndexX & 64;
|
||||
uint8 destBit7 = srcBit6 << 1;
|
||||
uint8_t destBit7 = srcBit6 << 1;
|
||||
|
||||
srcBit2 = iPreviousCubeIndexX & 4;
|
||||
uint8 destBit3 = srcBit2 << 1;
|
||||
uint8_t destBit3 = srcBit2 << 1;
|
||||
|
||||
iCubeIndex |= destBit0;
|
||||
iCubeIndex |= destBit1;
|
||||
@ -301,35 +301,35 @@ namespace PolyVox
|
||||
return uNoOfNonEmptyCells;
|
||||
}
|
||||
|
||||
uint32 computeDecimatedBitmaskForSliceFromPrevious(VolumeIterator<uint8>& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, uint8* previousBitmask)
|
||||
uint32_t computeDecimatedBitmaskForSliceFromPrevious(VolumeIterator<uint8_t>& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, uint8_t* previousBitmask)
|
||||
{
|
||||
const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
uint32 uNoOfNonEmptyCells = 0;
|
||||
const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
uint32_t uNoOfNonEmptyCells = 0;
|
||||
|
||||
//Iterate over each cell in the region
|
||||
for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize)
|
||||
for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize)
|
||||
{
|
||||
for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize)
|
||||
for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize)
|
||||
{
|
||||
//Current position
|
||||
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ());
|
||||
|
||||
//Determine the index into the edge table which tells us which vertices are inside of the surface
|
||||
uint8 iCubeIndex = 0;
|
||||
uint8_t iCubeIndex = 0;
|
||||
|
||||
if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY()))
|
||||
{
|
||||
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v001 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v001 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v101 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v101 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v011 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v011 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
//z
|
||||
uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)];
|
||||
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)];
|
||||
iCubeIndex = iPreviousCubeIndexZ >> 4;
|
||||
|
||||
if (v001 == 0) iCubeIndex |= 16;
|
||||
@ -340,21 +340,21 @@ namespace PolyVox
|
||||
else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY())
|
||||
{
|
||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v101 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v101 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
//z
|
||||
uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)];
|
||||
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)];
|
||||
iCubeIndex = iPreviousCubeIndexZ >> 4;
|
||||
|
||||
//x
|
||||
uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
uint8 srcBit6 = iPreviousCubeIndexX & 64;
|
||||
uint8 destBit7 = srcBit6 << 1;
|
||||
uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
uint8_t srcBit6 = iPreviousCubeIndexX & 64;
|
||||
uint8_t destBit7 = srcBit6 << 1;
|
||||
|
||||
uint8 srcBit5 = iPreviousCubeIndexX & 32;
|
||||
uint8 destBit4 = srcBit5 >> 1;
|
||||
uint8_t srcBit5 = iPreviousCubeIndexX & 32;
|
||||
uint8_t destBit4 = srcBit5 >> 1;
|
||||
|
||||
iCubeIndex |= destBit4;
|
||||
if (v101 == 0) iCubeIndex |= 32;
|
||||
@ -364,21 +364,21 @@ namespace PolyVox
|
||||
else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY()))
|
||||
{
|
||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v011 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v011 = volIter.getSubSampledVoxel(uLevel);
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
//z
|
||||
uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)];
|
||||
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)];
|
||||
iCubeIndex = iPreviousCubeIndexZ >> 4;
|
||||
|
||||
//y
|
||||
uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)];
|
||||
uint8 srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8 destBit4 = srcBit7 >> 3;
|
||||
uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)];
|
||||
uint8_t srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8_t destBit4 = srcBit7 >> 3;
|
||||
|
||||
uint8 srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8 destBit5 = srcBit6 >> 1;
|
||||
uint8_t srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8_t destBit5 = srcBit6 >> 1;
|
||||
|
||||
iCubeIndex |= destBit4;
|
||||
iCubeIndex |= destBit5;
|
||||
@ -388,24 +388,24 @@ namespace PolyVox
|
||||
else
|
||||
{
|
||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||
const uint8 v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
//z
|
||||
uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)];
|
||||
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY(), regSlice.width()+1)];
|
||||
iCubeIndex = iPreviousCubeIndexZ >> 4;
|
||||
|
||||
//y
|
||||
uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)];
|
||||
uint8 srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8 destBit4 = srcBit7 >> 3;
|
||||
uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize, regSlice.width()+1)];
|
||||
uint8_t srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8_t destBit4 = srcBit7 >> 3;
|
||||
|
||||
uint8 srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8 destBit5 = srcBit6 >> 1;
|
||||
uint8_t srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8_t destBit5 = srcBit6 >> 1;
|
||||
|
||||
//x
|
||||
uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
srcBit6 = iPreviousCubeIndexX & 64;
|
||||
uint8 destBit7 = srcBit6 << 1;
|
||||
uint8_t destBit7 = srcBit6 << 1;
|
||||
|
||||
iCubeIndex |= destBit4;
|
||||
iCubeIndex |= destBit5;
|
||||
@ -427,23 +427,23 @@ namespace PolyVox
|
||||
return uNoOfNonEmptyCells;
|
||||
}
|
||||
|
||||
void generateDecimatedVerticesForSlice(VolumeIterator<uint8>& volIter, uint8 uLevel, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[])
|
||||
void generateDecimatedVerticesForSlice(VolumeIterator<uint8_t>& volIter, uint8_t uLevel, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32_t vertexIndicesX[],int32_t vertexIndicesY[],int32_t vertexIndicesZ[])
|
||||
{
|
||||
const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
|
||||
//Iterate over each cell in the region
|
||||
for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize)
|
||||
for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize)
|
||||
{
|
||||
for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize)
|
||||
for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize)
|
||||
{
|
||||
//Current position
|
||||
const uint16 z = regSlice.getLowerCorner().getZ();
|
||||
const uint16_t z = regSlice.getLowerCorner().getZ();
|
||||
|
||||
volIter.setPosition(x,y,z);
|
||||
const uint8 v000 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v000 = volIter.getSubSampledVoxel(uLevel);
|
||||
|
||||
//Determine the index into the edge table which tells us which vertices are inside of the surface
|
||||
uint8 iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)];
|
||||
uint8_t iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)];
|
||||
|
||||
/* Cube is entirely in/out of the surface */
|
||||
if (edgeTable[iCubeIndex] == 0)
|
||||
@ -457,12 +457,12 @@ namespace PolyVox
|
||||
if(x != regSlice.getUpperCorner().getX())
|
||||
{
|
||||
volIter.setPosition(x + uStepSize,y,z);
|
||||
const uint8 v100 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v100 = volIter.getSubSampledVoxel(uLevel);
|
||||
const Vector3DFloat v3dPosition(x - offset.getX() + 0.5f * uStepSize, y - offset.getY(), z - offset.getZ());
|
||||
const Vector3DFloat v3dNormal(v000 > v100 ? 1.0f : -1.0f,0.0,0.0);
|
||||
const uint8 uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max.
|
||||
const uint8_t uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max.
|
||||
SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial);
|
||||
uint32 uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex);
|
||||
uint32_t uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex);
|
||||
vertexIndicesX[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)] = uLastVertexIndex;
|
||||
}
|
||||
}
|
||||
@ -471,12 +471,12 @@ namespace PolyVox
|
||||
if(y != regSlice.getUpperCorner().getY())
|
||||
{
|
||||
volIter.setPosition(x,y + uStepSize,z);
|
||||
const uint8 v010 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v010 = volIter.getSubSampledVoxel(uLevel);
|
||||
const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY() + 0.5f * uStepSize, z - offset.getZ());
|
||||
const Vector3DFloat v3dNormal(0.0,v000 > v010 ? 1.0f : -1.0f,0.0);
|
||||
const uint8 uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max.
|
||||
const uint8_t uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max.
|
||||
SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial);
|
||||
uint32 uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex);
|
||||
uint32_t uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex);
|
||||
vertexIndicesY[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)] = uLastVertexIndex;
|
||||
}
|
||||
}
|
||||
@ -485,12 +485,12 @@ namespace PolyVox
|
||||
//if(z != regSlice.getUpperCorner.getZ())
|
||||
{
|
||||
volIter.setPosition(x,y,z + uStepSize);
|
||||
const uint8 v001 = volIter.getSubSampledVoxel(uLevel);
|
||||
const uint8_t v001 = volIter.getSubSampledVoxel(uLevel);
|
||||
const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY(), z - offset.getZ() + 0.5f * uStepSize);
|
||||
const Vector3DFloat v3dNormal(0.0,0.0,v000 > v001 ? 1.0f : -1.0f);
|
||||
const uint8 uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max.
|
||||
const uint8_t uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max.
|
||||
const SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial);
|
||||
uint32 uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex);
|
||||
uint32_t uLastVertexIndex = singleMaterialPatch->addVertex(surfaceVertex);
|
||||
vertexIndicesZ[getDecimatedIndex(x - offset.getX(),y - offset.getY(), regSlice.width()+1)] = uLastVertexIndex;
|
||||
}
|
||||
}
|
||||
@ -498,20 +498,20 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
void generateDecimatedIndicesForSlice(VolumeIterator<uint8>& volIter, uint8 uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[])
|
||||
void generateDecimatedIndicesForSlice(VolumeIterator<uint8_t>& volIter, uint8_t uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8_t* bitmask0, uint8_t* bitmask1, int32_t vertexIndicesX0[],int32_t vertexIndicesY0[],int32_t vertexIndicesZ0[], int32_t vertexIndicesX1[],int32_t vertexIndicesY1[],int32_t vertexIndicesZ1[])
|
||||
{
|
||||
const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
uint32 indlist[12];
|
||||
const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel;
|
||||
uint32_t indlist[12];
|
||||
|
||||
for(uint16 y = regSlice.getLowerCorner().getY() - offset.getY(); y < regSlice.getUpperCorner().getY() - offset.getY(); y += uStepSize)
|
||||
for(uint16_t y = regSlice.getLowerCorner().getY() - offset.getY(); y < regSlice.getUpperCorner().getY() - offset.getY(); y += uStepSize)
|
||||
{
|
||||
for(uint16 x = regSlice.getLowerCorner().getX() - offset.getX(); x < regSlice.getUpperCorner().getX() - offset.getX(); x += uStepSize)
|
||||
for(uint16_t x = regSlice.getLowerCorner().getX() - offset.getX(); x < regSlice.getUpperCorner().getX() - offset.getX(); x += uStepSize)
|
||||
{
|
||||
//Current position
|
||||
const uint16 z = regSlice.getLowerCorner().getZ() - offset.getZ();
|
||||
const uint16_t z = regSlice.getLowerCorner().getZ() - offset.getZ();
|
||||
|
||||
//Determine the index into the edge table which tells us which vertices are inside of the surface
|
||||
uint8 iCubeIndex = bitmask0[getDecimatedIndex(x,y, regSlice.width()+1)];
|
||||
uint8_t iCubeIndex = bitmask0[getDecimatedIndex(x,y, regSlice.width()+1)];
|
||||
|
||||
/* Cube is entirely in/out of the surface */
|
||||
if (edgeTable[iCubeIndex] == 0)
|
||||
@ -583,9 +583,9 @@ namespace PolyVox
|
||||
|
||||
for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3)
|
||||
{
|
||||
uint32 ind0 = indlist[triTable[iCubeIndex][i ]];
|
||||
uint32 ind1 = indlist[triTable[iCubeIndex][i+1]];
|
||||
uint32 ind2 = indlist[triTable[iCubeIndex][i+2]];
|
||||
uint32_t ind0 = indlist[triTable[iCubeIndex][i ]];
|
||||
uint32_t ind1 = indlist[triTable[iCubeIndex][i+1]];
|
||||
uint32_t ind2 = indlist[triTable[iCubeIndex][i+2]];
|
||||
|
||||
singleMaterialPatch->addTriangle(ind0, ind1, ind2);
|
||||
}//For each triangle
|
||||
|
Reference in New Issue
Block a user