Using a bit less memory.
This commit is contained in:
parent
efb9844fe2
commit
c8124097e3
@ -68,10 +68,12 @@ namespace PolyVox
|
|||||||
memset(pIndicesY.getRawData(), 0xff, pIndicesY.getNoOfElements() * 4);
|
memset(pIndicesY.getRawData(), 0xff, pIndicesY.getNoOfElements() * 4);
|
||||||
memset(pIndicesZ.getRawData(), 0xff, pIndicesZ.getNoOfElements() * 4);
|
memset(pIndicesZ.getRawData(), 0xff, pIndicesZ.getNoOfElements() * 4);
|
||||||
|
|
||||||
Array2DUint8 pCurrentBitmask(uArrayWidth, uArrayHeight);
|
Array2DUint8 pPreviousSliceBitmask(uArrayWidth, uArrayHeight);
|
||||||
Array2DUint8 pPreviousBitmask(uArrayWidth, uArrayHeight);
|
Array1DUint8 pPreviousRowBitmask(uArrayWidth);
|
||||||
memset(pCurrentBitmask.getRawData(), 0x00, pCurrentBitmask.getNoOfElements());
|
memset(pPreviousSliceBitmask.getRawData(), 0x00, pPreviousSliceBitmask.getNoOfElements());
|
||||||
memset(pPreviousBitmask.getRawData(), 0x00, pPreviousBitmask.getNoOfElements());
|
memset(pPreviousRowBitmask.getRawData(), 0x00, pPreviousRowBitmask.getNoOfElements());
|
||||||
|
|
||||||
|
uint8_t uPreviousCell = 0;
|
||||||
|
|
||||||
for (int32_t iZVolSpace = m_regSizeInVoxels.getLowerZ(); iZVolSpace <= m_regSizeInVoxels.getUpperZ(); iZVolSpace++)
|
for (int32_t iZVolSpace = m_regSizeInVoxels.getLowerZ(); iZVolSpace <= m_regSizeInVoxels.getUpperZ(); iZVolSpace++)
|
||||||
{
|
{
|
||||||
@ -90,7 +92,7 @@ namespace PolyVox
|
|||||||
uint8_t iPreviousCubeIndexX = 0;
|
uint8_t iPreviousCubeIndexX = 0;
|
||||||
if (uXRegSpace != 0) // Previous X is available
|
if (uXRegSpace != 0) // Previous X is available
|
||||||
{
|
{
|
||||||
iPreviousCubeIndexX = pCurrentBitmask(uXRegSpace - 1, uYRegSpace);
|
iPreviousCubeIndexX = uPreviousCell;
|
||||||
iPreviousCubeIndexX &= 170; //170 = 128+32+8+2
|
iPreviousCubeIndexX &= 170; //170 = 128+32+8+2
|
||||||
iPreviousCubeIndexX >>= 1;
|
iPreviousCubeIndexX >>= 1;
|
||||||
}
|
}
|
||||||
@ -98,7 +100,7 @@ namespace PolyVox
|
|||||||
uint8_t iPreviousCubeIndexY = 0;
|
uint8_t iPreviousCubeIndexY = 0;
|
||||||
if (uYRegSpace != 0) // Previous Y is available
|
if (uYRegSpace != 0) // Previous Y is available
|
||||||
{
|
{
|
||||||
iPreviousCubeIndexY = pCurrentBitmask(uXRegSpace, uYRegSpace - 1);
|
iPreviousCubeIndexY = pPreviousRowBitmask(uXRegSpace);
|
||||||
iPreviousCubeIndexY &= 204; //204 = 128+64+8+4
|
iPreviousCubeIndexY &= 204; //204 = 128+64+8+4
|
||||||
iPreviousCubeIndexY >>= 2;
|
iPreviousCubeIndexY >>= 2;
|
||||||
}
|
}
|
||||||
@ -106,7 +108,7 @@ namespace PolyVox
|
|||||||
uint8_t iPreviousCubeIndexZ = 0;
|
uint8_t iPreviousCubeIndexZ = 0;
|
||||||
if (uZRegSpace != 0) // Previous Z is available
|
if (uZRegSpace != 0) // Previous Z is available
|
||||||
{
|
{
|
||||||
iPreviousCubeIndexZ = pPreviousBitmask(uXRegSpace, uYRegSpace);
|
iPreviousCubeIndexZ = pPreviousSliceBitmask(uXRegSpace, uYRegSpace);
|
||||||
iPreviousCubeIndexZ >>= 4;
|
iPreviousCubeIndexZ >>= 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,11 +117,9 @@ namespace PolyVox
|
|||||||
typename VolumeType::VoxelType v111 = m_sampVolume.peekVoxel0px0py0pz();
|
typename VolumeType::VoxelType v111 = m_sampVolume.peekVoxel0px0py0pz();
|
||||||
if (m_controller.convertToDensity(v111) < m_tThreshold) iCubeIndex |= 128;
|
if (m_controller.convertToDensity(v111) < m_tThreshold) iCubeIndex |= 128;
|
||||||
|
|
||||||
if (iCubeIndex != 0)
|
uPreviousCell = iCubeIndex;
|
||||||
{
|
pPreviousRowBitmask(uXRegSpace) = iCubeIndex;
|
||||||
//Save the bitmask
|
pPreviousSliceBitmask(uXRegSpace, uYRegSpace) = iCubeIndex;
|
||||||
pCurrentBitmask(uXRegSpace, uYRegSpace) = iCubeIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Cube is entirely in/out of the surface */
|
/* Cube is entirely in/out of the surface */
|
||||||
if (edgeTable[iCubeIndex] != 0)
|
if (edgeTable[iCubeIndex] != 0)
|
||||||
@ -313,8 +313,8 @@ namespace PolyVox
|
|||||||
} // For X
|
} // For X
|
||||||
} // For Y
|
} // For Y
|
||||||
|
|
||||||
pPreviousBitmask.swap(pCurrentBitmask);
|
//pPreviousBitmask.swap(pCurrentBitmask);
|
||||||
memset(pCurrentBitmask.getRawData(), 0x00, pCurrentBitmask.getNoOfElements());
|
//memset(pCurrentBitmask.getRawData(), 0x00, pCurrentBitmask.getNoOfElements());
|
||||||
} // For Z
|
} // For Z
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user