Reorganised Marching Cubes tables to simplify bitwise operations.
This commit is contained in:
@ -170,12 +170,12 @@ namespace PolyVox
|
||||
|
||||
if (v000 == 0) iCubeIndex |= 1;
|
||||
if (v100 == 0) iCubeIndex |= 2;
|
||||
if (v110 == 0) iCubeIndex |= 4;
|
||||
if (v010 == 0) iCubeIndex |= 8;
|
||||
if (v010 == 0) iCubeIndex |= 4;
|
||||
if (v110 == 0) iCubeIndex |= 8;
|
||||
if (v001 == 0) iCubeIndex |= 16;
|
||||
if (v101 == 0) iCubeIndex |= 32;
|
||||
if (v111 == 0) iCubeIndex |= 64;
|
||||
if (v011 == 0) iCubeIndex |= 128;
|
||||
if (v011 == 0) iCubeIndex |= 64;
|
||||
if (v111 == 0) iCubeIndex |= 128;
|
||||
}
|
||||
else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY())
|
||||
{
|
||||
@ -191,26 +191,26 @@ namespace PolyVox
|
||||
|
||||
//x
|
||||
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_t srcBit7 = iPreviousCubeIndexX & 128;
|
||||
uint8_t destBit6 = srcBit7 >> 1;
|
||||
|
||||
uint8_t srcBit5 = iPreviousCubeIndexX & 32;
|
||||
uint8_t destBit4 = srcBit5 >> 1;
|
||||
|
||||
uint8_t srcBit2 = iPreviousCubeIndexX & 4;
|
||||
uint8_t destBit3 = srcBit2 << 1;
|
||||
|
||||
uint8_t srcBit3 = iPreviousCubeIndexX & 8;
|
||||
uint8_t destBit2 = srcBit3 >> 1;
|
||||
|
||||
uint8_t srcBit1 = iPreviousCubeIndexX & 2;
|
||||
uint8_t destBit0 = srcBit1 >> 1;
|
||||
|
||||
iCubeIndex |= destBit0;
|
||||
if (v100 == 0) iCubeIndex |= 2;
|
||||
if (v110 == 0) iCubeIndex |= 4;
|
||||
iCubeIndex |= destBit3;
|
||||
if (v100 == 0) iCubeIndex |= 2;
|
||||
iCubeIndex |= destBit2;
|
||||
if (v110 == 0) iCubeIndex |= 8;
|
||||
iCubeIndex |= destBit4;
|
||||
if (v101 == 0) iCubeIndex |= 32;
|
||||
if (v111 == 0) iCubeIndex |= 64;
|
||||
iCubeIndex |= destBit7;
|
||||
if (v101 == 0) iCubeIndex |= 32;
|
||||
iCubeIndex |= destBit6;
|
||||
if (v111 == 0) iCubeIndex |= 128;
|
||||
}
|
||||
else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY()))
|
||||
{
|
||||
@ -226,26 +226,27 @@ namespace PolyVox
|
||||
|
||||
//y
|
||||
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_t srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8_t destBit5 = srcBit6 >> 1;
|
||||
uint8_t destBit4 = srcBit6 >> 2;
|
||||
|
||||
uint8_t srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8_t destBit5 = srcBit7 >> 2;
|
||||
|
||||
uint8_t srcBit3 = iPreviousCubeIndexY & 8;
|
||||
uint8_t destBit0 = srcBit3 >> 3;
|
||||
|
||||
uint8_t srcBit2 = iPreviousCubeIndexY & 4;
|
||||
uint8_t destBit1 = srcBit2 >> 1;
|
||||
uint8_t destBit0 = srcBit2 >> 2;
|
||||
|
||||
uint8_t srcBit3 = iPreviousCubeIndexY & 8;
|
||||
uint8_t destBit1 = srcBit3 >> 2;
|
||||
|
||||
iCubeIndex |= destBit0;
|
||||
iCubeIndex |= destBit1;
|
||||
if (v110 == 0) iCubeIndex |= 4;
|
||||
if (v010 == 0) iCubeIndex |= 8;
|
||||
if (v010 == 0) iCubeIndex |= 4;
|
||||
if (v110 == 0) iCubeIndex |= 8;
|
||||
iCubeIndex |= destBit4;
|
||||
iCubeIndex |= destBit5;
|
||||
if (v111 == 0) iCubeIndex |= 64;
|
||||
if (v011 == 0) iCubeIndex |= 128;
|
||||
if (v011 == 0) iCubeIndex |= 64;
|
||||
if (v111 == 0) iCubeIndex |= 128;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -257,34 +258,34 @@ namespace PolyVox
|
||||
|
||||
//y
|
||||
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_t srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8_t destBit5 = srcBit6 >> 1;
|
||||
|
||||
uint8_t srcBit3 = iPreviousCubeIndexY & 8;
|
||||
uint8_t destBit0 = srcBit3 >> 3;
|
||||
uint8_t destBit4 = srcBit6 >> 2;
|
||||
|
||||
uint8_t srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8_t destBit5 = srcBit7 >> 2;
|
||||
|
||||
uint8_t srcBit2 = iPreviousCubeIndexY & 4;
|
||||
uint8_t destBit1 = srcBit2 >> 1;
|
||||
uint8_t destBit0 = srcBit2 >> 2;
|
||||
|
||||
uint8_t srcBit3 = iPreviousCubeIndexY & 8;
|
||||
uint8_t destBit1 = srcBit3 >> 2;
|
||||
|
||||
//x
|
||||
uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
srcBit6 = iPreviousCubeIndexX & 64;
|
||||
uint8_t destBit7 = srcBit6 << 1;
|
||||
srcBit7 = iPreviousCubeIndexX & 128;
|
||||
uint8_t destBit6 = srcBit7 >> 1;
|
||||
|
||||
srcBit2 = iPreviousCubeIndexX & 4;
|
||||
uint8_t destBit3 = srcBit2 << 1;
|
||||
srcBit3 = iPreviousCubeIndexX & 8;
|
||||
uint8_t destBit2 = srcBit3 >> 1;
|
||||
|
||||
iCubeIndex |= destBit0;
|
||||
iCubeIndex |= destBit1;
|
||||
if (v110 == 0) iCubeIndex |= 4;
|
||||
iCubeIndex |= destBit3;
|
||||
iCubeIndex |= destBit1;
|
||||
iCubeIndex |= destBit2;
|
||||
if (v110 == 0) iCubeIndex |= 8;
|
||||
iCubeIndex |= destBit4;
|
||||
iCubeIndex |= destBit5;
|
||||
if (v111 == 0) iCubeIndex |= 64;
|
||||
iCubeIndex |= destBit7;
|
||||
iCubeIndex |= destBit5;
|
||||
iCubeIndex |= destBit6;
|
||||
if (v111 == 0) iCubeIndex |= 128;
|
||||
}
|
||||
|
||||
//Save the bitmask
|
||||
@ -334,8 +335,8 @@ namespace PolyVox
|
||||
|
||||
if (v001 == 0) iCubeIndex |= 16;
|
||||
if (v101 == 0) iCubeIndex |= 32;
|
||||
if (v111 == 0) iCubeIndex |= 64;
|
||||
if (v011 == 0) iCubeIndex |= 128;
|
||||
if (v011 == 0) iCubeIndex |= 64;
|
||||
if (v111 == 0) iCubeIndex |= 128;
|
||||
}
|
||||
else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY())
|
||||
{
|
||||
@ -350,16 +351,16 @@ namespace PolyVox
|
||||
|
||||
//x
|
||||
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_t srcBit7 = iPreviousCubeIndexX & 128;
|
||||
uint8_t destBit6 = srcBit7 >> 1;
|
||||
|
||||
uint8_t srcBit5 = iPreviousCubeIndexX & 32;
|
||||
uint8_t destBit4 = srcBit5 >> 1;
|
||||
|
||||
iCubeIndex |= destBit4;
|
||||
if (v101 == 0) iCubeIndex |= 32;
|
||||
if (v111 == 0) iCubeIndex |= 64;
|
||||
iCubeIndex |= destBit7;
|
||||
if (v101 == 0) iCubeIndex |= 32;
|
||||
iCubeIndex |= destBit6;
|
||||
if (v111 == 0) iCubeIndex |= 128;
|
||||
}
|
||||
else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY()))
|
||||
{
|
||||
@ -374,16 +375,16 @@ namespace PolyVox
|
||||
|
||||
//y
|
||||
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_t srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8_t destBit5 = srcBit6 >> 1;
|
||||
uint8_t destBit4 = srcBit6 >> 2;
|
||||
|
||||
uint8_t srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8_t destBit5 = srcBit7 >> 2;
|
||||
|
||||
iCubeIndex |= destBit4;
|
||||
iCubeIndex |= destBit5;
|
||||
if (v111 == 0) iCubeIndex |= 64;
|
||||
if (v011 == 0) iCubeIndex |= 128;
|
||||
if (v011 == 0) iCubeIndex |= 64;
|
||||
if (v111 == 0) iCubeIndex |= 128;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -396,21 +397,21 @@ namespace PolyVox
|
||||
|
||||
//y
|
||||
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_t srcBit6 = iPreviousCubeIndexY & 64;
|
||||
uint8_t destBit5 = srcBit6 >> 1;
|
||||
uint8_t destBit4 = srcBit6 >> 2;
|
||||
|
||||
uint8_t srcBit7 = iPreviousCubeIndexY & 128;
|
||||
uint8_t destBit5 = srcBit7 >> 2;
|
||||
|
||||
//x
|
||||
uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY(), regSlice.width()+1)];
|
||||
srcBit6 = iPreviousCubeIndexX & 64;
|
||||
uint8_t destBit7 = srcBit6 << 1;
|
||||
srcBit7 = iPreviousCubeIndexX & 128;
|
||||
uint8_t destBit6 = srcBit7 >> 1;
|
||||
|
||||
iCubeIndex |= destBit4;
|
||||
iCubeIndex |= destBit5;
|
||||
if (v111 == 0) iCubeIndex |= 64;
|
||||
iCubeIndex |= destBit7;
|
||||
iCubeIndex |= destBit5;
|
||||
iCubeIndex |= destBit6;
|
||||
if (v111 == 0) iCubeIndex |= 128;
|
||||
}
|
||||
|
||||
//Save the bitmask
|
||||
|
Reference in New Issue
Block a user