Optimised order in which slice elements are processed.

This commit is contained in:
David Williams 2009-06-03 21:02:15 +00:00
parent cd0f8529ca
commit 57eed6e901

View File

@ -131,58 +131,40 @@ namespace PolyVox
uZVolSpace = regSlice1.getLowerCorner().getZ(); uZVolSpace = regSlice1.getLowerCorner().getZ();
uZRegSpace = uZVolSpace - m_v3dRegionOffset.getZ(); uZRegSpace = uZVolSpace - m_v3dRegionOffset.getZ();
//Iterate over each cell in the region //Process the lower left corner
/*for(*/uYVolSpace = regSlice1.getLowerCorner().getY();/* uYVolSpace <= uMaxYVolSpace; uYVolSpace += m_uStepSize)*/ uYVolSpace = regSlice1.getLowerCorner().getY();
{ uXVolSpace = regSlice1.getLowerCorner().getX();
/*for(*/uXVolSpace = regSlice1.getLowerCorner().getX();/* uXVolSpace <= uMaxXVolSpace; uXVolSpace += m_uStepSize)*/
{
uXRegSpace = uXVolSpace - m_v3dRegionOffset.getX();
uYRegSpace = uYVolSpace - m_v3dRegionOffset.getY();
//Current position uXRegSpace = uXVolSpace - m_v3dRegionOffset.getX();
m_sampVolume.setPosition(uXVolSpace,uYVolSpace,uZVolSpace); uYRegSpace = uYVolSpace - m_v3dRegionOffset.getY();
//Determine the index into the edge table which tells us which vertices are inside of the surface m_sampVolume.setPosition(uXVolSpace,uYVolSpace,uZVolSpace);
computeBitmaskForCell(false, false, !bIsFirstSlice, m_uLodLevel); computeBitmaskForCell(false, false, !bIsFirstSlice, m_uLodLevel);
}//For each cell
}
//Iterate over each cell in the region //Process the edge where x is minimal.
uXVolSpace = regSlice1.getLowerCorner().getX();
for(uYVolSpace = regSlice1.getLowerCorner().getY() + m_uStepSize; uYVolSpace <= uMaxYVolSpace; uYVolSpace += m_uStepSize) for(uYVolSpace = regSlice1.getLowerCorner().getY() + m_uStepSize; uYVolSpace <= uMaxYVolSpace; uYVolSpace += m_uStepSize)
{ {
/*for(*/uXVolSpace = regSlice1.getLowerCorner().getX();/* uXVolSpace <= uMaxXVolSpace; uXVolSpace += m_uStepSize)*/ uXRegSpace = uXVolSpace - m_v3dRegionOffset.getX();
{ uYRegSpace = uYVolSpace - m_v3dRegionOffset.getY();
uXRegSpace = uXVolSpace - m_v3dRegionOffset.getX();
uYRegSpace = uYVolSpace - m_v3dRegionOffset.getY();
//Current position m_sampVolume.setPosition(uXVolSpace,uYVolSpace,uZVolSpace);
m_sampVolume.setPosition(uXVolSpace,uYVolSpace,uZVolSpace); computeBitmaskForCell(false, true, !bIsFirstSlice, m_uLodLevel);
//Determine the index into the edge table which tells us which vertices are inside of the surface
computeBitmaskForCell(false, true, !bIsFirstSlice, m_uLodLevel);
}//For each cell
} }
//Iterate over each cell in the region //Process the edge where y is minimal.
/*for(*/uYVolSpace = regSlice1.getLowerCorner().getY();/* uYVolSpace <= uMaxYVolSpace; uYVolSpace += m_uStepSize)*/ uYVolSpace = regSlice1.getLowerCorner().getY();
{ for(uXVolSpace = regSlice1.getLowerCorner().getX() + m_uStepSize; uXVolSpace <= uMaxXVolSpace; uXVolSpace += m_uStepSize)
for(uXVolSpace = regSlice1.getLowerCorner().getX() + m_uStepSize; uXVolSpace <= uMaxXVolSpace; uXVolSpace += m_uStepSize) {
{ uXRegSpace = uXVolSpace - m_v3dRegionOffset.getX();
uXRegSpace = uXVolSpace - m_v3dRegionOffset.getX(); uYRegSpace = uYVolSpace - m_v3dRegionOffset.getY();
uYRegSpace = uYVolSpace - m_v3dRegionOffset.getY();
//Current position m_sampVolume.setPosition(uXVolSpace,uYVolSpace,uZVolSpace);
m_sampVolume.setPosition(uXVolSpace,uYVolSpace,uZVolSpace); computeBitmaskForCell(true, false, !bIsFirstSlice, m_uLodLevel);
//Determine the index into the edge table which tells us which vertices are inside of the surface
computeBitmaskForCell(true, false, !bIsFirstSlice, m_uLodLevel);
}//For each cell
} }
//Iterate over each cell in the region //Process all remaining elemnents of the slice. In this case, previous x and y values are always available
for(uYVolSpace = regSlice1.getLowerCorner().getY() + m_uStepSize; uYVolSpace <= uMaxYVolSpace; uYVolSpace += m_uStepSize) for(uYVolSpace = regSlice1.getLowerCorner().getY() + m_uStepSize; uYVolSpace <= uMaxYVolSpace; uYVolSpace += m_uStepSize)
{ {
for(uXVolSpace = regSlice1.getLowerCorner().getX() + m_uStepSize; uXVolSpace <= uMaxXVolSpace; uXVolSpace += m_uStepSize) for(uXVolSpace = regSlice1.getLowerCorner().getX() + m_uStepSize; uXVolSpace <= uMaxXVolSpace; uXVolSpace += m_uStepSize)
@ -190,13 +172,9 @@ namespace PolyVox
uXRegSpace = uXVolSpace - m_v3dRegionOffset.getX(); uXRegSpace = uXVolSpace - m_v3dRegionOffset.getX();
uYRegSpace = uYVolSpace - m_v3dRegionOffset.getY(); uYRegSpace = uYVolSpace - m_v3dRegionOffset.getY();
//Current position
m_sampVolume.setPosition(uXVolSpace,uYVolSpace,uZVolSpace); m_sampVolume.setPosition(uXVolSpace,uYVolSpace,uZVolSpace);
//Determine the index into the edge table which tells us which vertices are inside of the surface
computeBitmaskForCell(true, true, !bIsFirstSlice, m_uLodLevel); computeBitmaskForCell(true, true, !bIsFirstSlice, m_uLodLevel);
}
}//For each cell
} }
return m_uNoOfOccupiedCells; return m_uNoOfOccupiedCells;