00001 /******************************************************************************* 00002 Copyright (c) 2005-2009 David Williams 00003 00004 This software is provided 'as-is', without any express or implied 00005 warranty. In no event will the authors be held liable for any damages 00006 arising from the use of this software. 00007 00008 Permission is granted to anyone to use this software for any purpose, 00009 including commercial applications, and to alter it and redistribute it 00010 freely, subject to the following restrictions: 00011 00012 1. The origin of this software must not be misrepresented; you must not 00013 claim that you wrote the original software. If you use this software 00014 in a product, an acknowledgment in the product documentation would be 00015 appreciated but is not required. 00016 00017 2. Altered source versions must be plainly marked as such, and must not be 00018 misrepresented as being the original software. 00019 00020 3. This notice may not be removed or altered from any source 00021 distribution. 00022 *******************************************************************************/ 00023 00024 #ifndef __PolyVox_VolumeChangeTracker_H__ 00025 #define __PolyVox_VolumeChangeTracker_H__ 00026 00027 #include "PolyVoxImpl/Utility.h" 00028 00029 #include "PolyVoxCore/Region.h" 00030 #include "PolyVoxCore/SurfaceMesh.h" 00031 #include "PolyVoxCore/Vector.h" 00032 00033 namespace PolyVox 00034 { 00036 template <typename VoxelType> 00037 class VolumeChangeTracker 00038 { 00039 public: 00040 //Constructors, etc 00041 VolumeChangeTracker(LargeVolume<VoxelType>* volumeDataToSet, uint16_t regionSideLength); 00042 ~VolumeChangeTracker(); 00043 00044 //Getters 00045 int32_t getCurrentTime(void) const; 00046 int32_t getLastModifiedTimeForRegion(uint16_t uX, uint16_t uY, uint16_t uZ); 00047 LargeVolume<VoxelType>* getWrappedVolume(void) const; 00048 00049 //Setters 00050 void setAllRegionsModified(void); 00051 void setLockedVoxelAt(uint16_t x, uint16_t y, uint16_t z, VoxelType value); 00052 void setVoxelAt(uint16_t x, uint16_t y, uint16_t z, VoxelType value); 00053 00054 //Others 00055 void lockRegion(const Region& regToLock); 00056 void unlockRegion(void); 00057 //void markRegionChanged(uint16_t firstX, uint16_t firstY, uint16_t firstZ, uint16_t lastX, uint16_t lastY, uint16_t lastZ); 00058 00059 public: 00060 void incrementCurrentTime(void); 00061 bool m_bIsLocked; 00062 Region m_regLastLocked; 00063 LargeVolume<VoxelType>* volumeData; 00064 00065 uint16_t m_uRegionSideLength; 00066 uint8_t m_uRegionSideLengthPower; 00067 uint16_t m_uVolumeWidthInRegions; 00068 uint16_t m_uVolumeHeightInRegions; 00069 uint16_t m_uVolumeDepthInRegions; 00070 00071 00072 //It's not what the block class was designed for, but it 00073 //provides a handy way of storing a 3D grid of values. 00074 LargeVolume<int32_t>* volRegionLastModified; 00075 00076 static uint32_t m_uCurrentTime; 00077 }; 00078 } 00079 00080 #include "PolyVoxUtil/VolumeChangeTracker.inl" 00081 00082 #endif