Added typedefs to simplify code.
This commit is contained in:
		| @@ -314,6 +314,9 @@ namespace PolyVox | |||||||
| 			} | 			} | ||||||
| 		};	 | 		};	 | ||||||
|  |  | ||||||
|  | 		typedef std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare> CompressedBlockMap; | ||||||
|  | 		typedef std::map<Vector3DInt32, UncompressedBlock<VoxelType>*, BlockPositionCompare> UncompressedBlockMap; | ||||||
|  |  | ||||||
| 		uint32_t calculateBlockMemoryUsage(void) const; | 		uint32_t calculateBlockMemoryUsage(void) const; | ||||||
|  |  | ||||||
| 		void flushOldestExcessiveBlocks(void) const; | 		void flushOldestExcessiveBlocks(void) const; | ||||||
| @@ -331,11 +334,11 @@ namespace PolyVox | |||||||
| 	 | 	 | ||||||
| 		CompressedBlock<VoxelType>* getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const; | 		CompressedBlock<VoxelType>* getCompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const; | ||||||
| 		UncompressedBlock<VoxelType>* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const; | 		UncompressedBlock<VoxelType>* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const; | ||||||
| 		void eraseBlock(typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator itBlock) const; | 		void eraseBlock(typename CompressedBlockMap::iterator itBlock) const; | ||||||
|  |  | ||||||
| 		// The block data | 		// The block data | ||||||
| 		mutable std::map<Vector3DInt32, UncompressedBlock<VoxelType>*, BlockPositionCompare> m_pUncompressedBlockCache; | 		mutable CompressedBlockMap m_pBlocks; | ||||||
| 		mutable std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare> m_pBlocks; | 		mutable UncompressedBlockMap m_pUncompressedBlockCache; | ||||||
|  |  | ||||||
| 		mutable uint32_t m_uTimestamper; | 		mutable uint32_t m_uTimestamper; | ||||||
| 		mutable Vector3DInt32 m_v3dLastAccessedBlockPos; | 		mutable Vector3DInt32 m_v3dLastAccessedBlockPos; | ||||||
|   | |||||||
| @@ -405,7 +405,7 @@ namespace PolyVox | |||||||
| 				for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++) | 				for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++) | ||||||
| 				{ | 				{ | ||||||
| 					Vector3DInt32 pos(x,y,z); | 					Vector3DInt32 pos(x,y,z); | ||||||
| 					typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos); | 					typename CompressedBlockMap::iterator itBlock = m_pBlocks.find(pos); | ||||||
| 					 | 					 | ||||||
| 					if(itBlock != m_pBlocks.end()) | 					if(itBlock != m_pBlocks.end()) | ||||||
| 					{ | 					{ | ||||||
| @@ -436,7 +436,7 @@ namespace PolyVox | |||||||
| 	template <typename VoxelType> | 	template <typename VoxelType> | ||||||
| 	void LargeVolume<VoxelType>::flushAll() | 	void LargeVolume<VoxelType>::flushAll() | ||||||
| 	{ | 	{ | ||||||
| 		typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator i; | 		typename CompressedBlockMap::iterator i; | ||||||
| 		//Replaced the for loop here as the call to | 		//Replaced the for loop here as the call to | ||||||
| 		//eraseBlock was invalidating the iterator. | 		//eraseBlock was invalidating the iterator. | ||||||
| 		while(m_pBlocks.size() > 0) | 		while(m_pBlocks.size() > 0) | ||||||
| @@ -470,7 +470,7 @@ namespace PolyVox | |||||||
| 				for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++) | 				for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++) | ||||||
| 				{ | 				{ | ||||||
| 					Vector3DInt32 pos(x,y,z); | 					Vector3DInt32 pos(x,y,z); | ||||||
| 					typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos); | 					typename CompressedBlockMap::iterator itBlock = m_pBlocks.find(pos); | ||||||
| 					if(itBlock == m_pBlocks.end()) | 					if(itBlock == m_pBlocks.end()) | ||||||
| 					{ | 					{ | ||||||
| 						// not loaded, not unloading | 						// not loaded, not unloading | ||||||
| @@ -548,7 +548,7 @@ namespace PolyVox | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	template <typename VoxelType> | 	template <typename VoxelType> | ||||||
| 	void LargeVolume<VoxelType>::eraseBlock(typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator itBlock) const | 	void LargeVolume<VoxelType>::eraseBlock(typename CompressedBlockMap::iterator itBlock) const | ||||||
| 	{ | 	{ | ||||||
| 		POLYVOX_ASSERT(false, "This function has not been implemented properly"); | 		POLYVOX_ASSERT(false, "This function has not been implemented properly"); | ||||||
|  |  | ||||||
| @@ -591,7 +591,7 @@ namespace PolyVox | |||||||
| 	{ | 	{ | ||||||
| 		Vector3DInt32 v3dBlockPos(uBlockX, uBlockY, uBlockZ); | 		Vector3DInt32 v3dBlockPos(uBlockX, uBlockY, uBlockZ); | ||||||
|  |  | ||||||
| 		typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(v3dBlockPos); | 		typename CompressedBlockMap::iterator itBlock = m_pBlocks.find(v3dBlockPos); | ||||||
| 		// check whether the block is already loaded | 		// check whether the block is already loaded | ||||||
| 		if(itBlock == m_pBlocks.end()) | 		if(itBlock == m_pBlocks.end()) | ||||||
| 		{ | 		{ | ||||||
| @@ -635,7 +635,7 @@ namespace PolyVox | |||||||
| 		CompressedBlock<VoxelType>* block = getCompressedBlock(uBlockX, uBlockY, uBlockZ); | 		CompressedBlock<VoxelType>* block = getCompressedBlock(uBlockX, uBlockY, uBlockZ); | ||||||
|  |  | ||||||
|  |  | ||||||
| 		typename std::map<Vector3DInt32, UncompressedBlock<VoxelType>*, BlockPositionCompare>::iterator itUncompressedBlock = m_pUncompressedBlockCache.find(v3dBlockPos); | 		typename UncompressedBlockMap::iterator itUncompressedBlock = m_pUncompressedBlockCache.find(v3dBlockPos); | ||||||
| 		// check whether the block is already loaded | 		// check whether the block is already loaded | ||||||
| 		if(itUncompressedBlock == m_pUncompressedBlockCache.end()) | 		if(itUncompressedBlock == m_pUncompressedBlockCache.end()) | ||||||
| 		{ | 		{ | ||||||
| @@ -681,7 +681,7 @@ namespace PolyVox | |||||||
| 		uint32_t uSizeInBytes = sizeof(LargeVolume); | 		uint32_t uSizeInBytes = sizeof(LargeVolume); | ||||||
|  |  | ||||||
| 		//Memory used by the blocks | 		//Memory used by the blocks | ||||||
| 		typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator i; | 		typename CompressedBlockMap::iterator i; | ||||||
| 		for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) | 		for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) | ||||||
| 		{ | 		{ | ||||||
| 			//Inaccurate - account for rest of loaded block. | 			//Inaccurate - account for rest of loaded block. | ||||||
| @@ -700,7 +700,7 @@ namespace PolyVox | |||||||
| 	{ | 	{ | ||||||
| 		uint32_t uMemoryUsage = 0; | 		uint32_t uMemoryUsage = 0; | ||||||
|  |  | ||||||
| 		typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator i; | 		typename CompressedBlockMap::iterator i; | ||||||
| 		for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) | 		for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) | ||||||
| 		{ | 		{ | ||||||
| 			//Inaccurate - account for rest of loaded block. | 			//Inaccurate - account for rest of loaded block. | ||||||
| @@ -720,8 +720,8 @@ namespace PolyVox | |||||||
| 		while(calculateBlockMemoryUsage() > m_uCompressedBlockMemoryLimitInBytes) //FIXME - This calculation of size is slow and should be outside the loop. | 		while(calculateBlockMemoryUsage() > m_uCompressedBlockMemoryLimitInBytes) //FIXME - This calculation of size is slow and should be outside the loop. | ||||||
| 		{ | 		{ | ||||||
| 			// find the least recently used block | 			// find the least recently used block | ||||||
| 			typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator i; | 			typename CompressedBlockMap::iterator i; | ||||||
| 			typename std::map<Vector3DInt32, CompressedBlock<VoxelType>*, BlockPositionCompare>::iterator itUnloadBlock = m_pBlocks.begin(); | 			typename CompressedBlockMap::iterator itUnloadBlock = m_pBlocks.begin(); | ||||||
| 			for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) | 			for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++) | ||||||
| 			{ | 			{ | ||||||
| 				if(i->second->m_uBlockLastAccessed < itUnloadBlock->second->m_uBlockLastAccessed) | 				if(i->second->m_uBlockLastAccessed < itUnloadBlock->second->m_uBlockLastAccessed) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user