26 template <
typename VoxelType>
27 uint32_t VolumeChangeTracker<VoxelType>::m_uCurrentTime = 0;
32 template <
typename VoxelType>
36 ,m_uRegionSideLength(regionSideLength)
47 template <
typename VoxelType>
52 template <
typename VoxelType>
55 incrementCurrentTime();
56 for(uint16_t blockZ = 0; blockZ < m_uVolumeDepthInRegions; ++blockZ)
58 for(uint16_t blockY = 0; blockY < m_uVolumeHeightInRegions; ++blockY)
60 for(uint16_t blockX = 0; blockX < m_uVolumeWidthInRegions; ++blockX)
62 volRegionLastModified->setVoxelAt(blockX, blockY, blockZ, m_uCurrentTime);
68 template <
typename VoxelType>
71 return m_uCurrentTime;
74 template <
typename VoxelType>
77 return volRegionLastModified->getVoxelAt(uX, uY, uZ);
80 template <
typename VoxelType>
86 template <
typename VoxelType>
92 incrementCurrentTime();
94 volumeData->setVoxelAt(x,y,z,value);
97 if((x % m_uRegionSideLength != 0) &&
98 (x % m_uRegionSideLength != m_uRegionSideLength-1) &&
99 (y % m_uRegionSideLength != 0) &&
100 (y % m_uRegionSideLength != m_uRegionSideLength-1) &&
101 (z % m_uRegionSideLength != 0) &&
102 (z % m_uRegionSideLength != m_uRegionSideLength-1))
104 volRegionLastModified->setVoxelAt(x >> m_uRegionSideLengthPower, y >> m_uRegionSideLengthPower, z >> m_uRegionSideLengthPower, m_uCurrentTime);
108 const uint16_t regionX = x >> m_uRegionSideLengthPower;
109 const uint16_t regionY = y >> m_uRegionSideLengthPower;
110 const uint16_t regionZ = z >> m_uRegionSideLengthPower;
112 const uint16_t minRegionX = (std::max)(uint16_t(0),uint16_t(regionX-1));
113 const uint16_t minRegionY = (std::max)(uint16_t(0),uint16_t(regionY-1));
114 const uint16_t minRegionZ = (std::max)(uint16_t(0),uint16_t(regionZ-1));
116 const uint16_t maxRegionX = (std::min)(uint16_t(m_uVolumeWidthInRegions-1),uint16_t(regionX+1));
117 const uint16_t maxRegionY = (std::min)(uint16_t(m_uVolumeHeightInRegions-1),uint16_t(regionY+1));
118 const uint16_t maxRegionZ = (std::min)(uint16_t(m_uVolumeDepthInRegions-1),uint16_t(regionZ+1));
120 for(uint16_t zCt = minRegionZ; zCt <= maxRegionZ; zCt++)
122 for(uint16_t yCt = minRegionY; yCt <= maxRegionY; yCt++)
124 for(uint16_t xCt = minRegionX; xCt <= maxRegionX; xCt++)
126 volRegionLastModified->setVoxelAt(xCt,yCt,zCt,m_uCurrentTime);
133 incrementCurrentTime();
136 template <
typename VoxelType>
145 volumeData->setVoxelAt(x,y,z,value);
148 template <
typename VoxelType>
153 throw std::logic_error(
"A region is already locked. Please unlock it before locking another.");
156 m_regLastLocked = regToLock;
160 template <
typename VoxelType>
165 throw std::logic_error(
"No region is locked. You must lock a region before you can unlock it.");
171 incrementCurrentTime();
173 const uint16_t firstRegionX = m_regLastLocked.getLowerCorner().getX() >> m_uRegionSideLengthPower;
174 const uint16_t firstRegionY = m_regLastLocked.getLowerCorner().getY() >> m_uRegionSideLengthPower;
175 const uint16_t firstRegionZ = m_regLastLocked.getLowerCorner().getZ() >> m_uRegionSideLengthPower;
177 const uint16_t lastRegionX = m_regLastLocked.getUpperCorner().getX() >> m_uRegionSideLengthPower;
178 const uint16_t lastRegionY = m_regLastLocked.getUpperCorner().getY() >> m_uRegionSideLengthPower;
179 const uint16_t lastRegionZ = m_regLastLocked.getUpperCorner().getZ() >> m_uRegionSideLengthPower;
181 for(uint16_t zCt = firstRegionZ; zCt <= lastRegionZ; zCt++)
183 for(uint16_t yCt = firstRegionY; yCt <= lastRegionY; yCt++)
185 for(uint16_t xCt = firstRegionX; xCt <= lastRegionX; xCt++)
187 volRegionLastModified->setVoxelAt(xCt,yCt,zCt,m_uCurrentTime);
195 incrementCurrentTime();
198 template <
typename VoxelType>
202 uint32_t time = m_uCurrentTime++;
206 assert(time < m_uCurrentTime);
207 if(time >= m_uCurrentTime)
209 throw std::overflow_error(
"The VolumeChangeTracker time has overflowed.");