Work on generating surface patches on demand.
This commit is contained in:
parent
8b98d69d4e
commit
f32616d5a9
@ -53,6 +53,8 @@ namespace PolyVox
|
||||
const bool isEmpty(void) const;
|
||||
|
||||
Vector3DInt32 m_v3dRegionPosition; //FIXME - remove this?
|
||||
|
||||
int32 m_iTimeStamp;
|
||||
|
||||
private:
|
||||
std::vector<uint32> m_vecTriangleIndices;
|
||||
|
@ -45,6 +45,8 @@ namespace PolyVox
|
||||
bool containsPoint(const Vector3DInt32& pos, uint8 boundary) const;
|
||||
void cropTo(const Region& other);
|
||||
void shift(const Vector3DInt32& amount);
|
||||
void shiftLowerCorner(const Vector3DInt32& amount);
|
||||
void shiftUpperCorner(const Vector3DInt32& amount);
|
||||
|
||||
private:
|
||||
Vector3DInt32 m_v3dLowerCorner;
|
||||
|
@ -41,13 +41,16 @@ namespace PolyVox
|
||||
|
||||
//Getters
|
||||
void getChangedRegions(std::list<Region>& listToFill) const;
|
||||
int32 getCurrentTime(void) const;
|
||||
Region getEnclosingRegion(void) const;
|
||||
int32 getLastModifiedTimeForRegion(uint16 uX, uint16 uY, uint16 uZ);
|
||||
uint16 getSideLength(void);
|
||||
BlockVolume<uint8>* getVolumeData(void) const;
|
||||
uint8 getVoxelAt(const Vector3DUint16& pos);
|
||||
uint8 getVoxelAt(uint16 uX, uint16 uY, uint16 uZ);
|
||||
|
||||
//Setters
|
||||
void setAllRegionsModified(void);
|
||||
void setAllRegionsUpToDate(bool newUpToDateValue);
|
||||
void setLockedVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value);
|
||||
void setVolumeData(BlockVolume<uint8>* volumeDataToSet);
|
||||
@ -63,6 +66,9 @@ namespace PolyVox
|
||||
Region m_regLastLocked;
|
||||
BlockVolume<uint8>* volumeData;
|
||||
LinearVolume<bool>* volRegionUpToDate;
|
||||
LinearVolume<int32>* volRegionLastModified;
|
||||
|
||||
static int32 m_iCurrentTime;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ namespace PolyVox
|
||||
{
|
||||
IndexedSurfacePatch::IndexedSurfacePatch()
|
||||
{
|
||||
m_iTimeStamp = -1;
|
||||
}
|
||||
|
||||
IndexedSurfacePatch::~IndexedSurfacePatch()
|
||||
|
@ -69,4 +69,14 @@ namespace PolyVox
|
||||
m_v3dLowerCorner += amount;
|
||||
m_v3dUpperCorner += amount;
|
||||
}
|
||||
|
||||
void Region::shiftLowerCorner(const Vector3DInt32& amount)
|
||||
{
|
||||
m_v3dLowerCorner += amount;
|
||||
}
|
||||
|
||||
void Region::shiftUpperCorner(const Vector3DInt32& amount)
|
||||
{
|
||||
m_v3dUpperCorner += amount;
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
int32 VolumeChangeTracker::m_iCurrentTime = 0;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// VolumeChangeTracker
|
||||
@ -54,6 +55,7 @@ namespace PolyVox
|
||||
{
|
||||
volumeData = volumeDataToSet;
|
||||
volRegionUpToDate = new LinearVolume<bool>(PolyVox::logBase2(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS));
|
||||
volRegionLastModified = new LinearVolume<int32>(PolyVox::logBase2(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS));
|
||||
}
|
||||
|
||||
|
||||
@ -106,6 +108,26 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
void VolumeChangeTracker::setAllRegionsModified(void)
|
||||
{
|
||||
for(uint16 blockZ = 0; blockZ < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockZ)
|
||||
{
|
||||
for(uint16 blockY = 0; blockY < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockY)
|
||||
{
|
||||
for(uint16 blockX = 0; blockX < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockX)
|
||||
{
|
||||
volRegionLastModified->setVoxelAt(blockX, blockY, blockZ, m_iCurrentTime);
|
||||
++m_iCurrentTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32 VolumeChangeTracker::getCurrentTime(void) const
|
||||
{
|
||||
return m_iCurrentTime;
|
||||
}
|
||||
|
||||
uint16 VolumeChangeTracker::getSideLength(void)
|
||||
{
|
||||
return volumeData->getSideLength();
|
||||
@ -116,6 +138,11 @@ namespace PolyVox
|
||||
return volumeData->getEnclosingRegion();
|
||||
}
|
||||
|
||||
int32 VolumeChangeTracker::getLastModifiedTimeForRegion(uint16 uX, uint16 uY, uint16 uZ)
|
||||
{
|
||||
return volRegionLastModified->getVoxelAt(uX, uY, uZ);
|
||||
}
|
||||
|
||||
uint8 VolumeChangeTracker::getVoxelAt(const Vector3DUint16& pos)
|
||||
{
|
||||
return getVoxelAt(pos.getX(), pos.getY(), pos.getZ());
|
||||
@ -153,6 +180,7 @@ namespace PolyVox
|
||||
(z % POLYVOX_REGION_SIDE_LENGTH != POLYVOX_REGION_SIDE_LENGTH-1))
|
||||
{
|
||||
volRegionUpToDate->setVoxelAt(x >> POLYVOX_REGION_SIDE_LENGTH_POWER, y >> POLYVOX_REGION_SIDE_LENGTH_POWER, z >> POLYVOX_REGION_SIDE_LENGTH_POWER, false);
|
||||
volRegionLastModified->setVoxelAt(x >> POLYVOX_REGION_SIDE_LENGTH_POWER, y >> POLYVOX_REGION_SIDE_LENGTH_POWER, z >> POLYVOX_REGION_SIDE_LENGTH_POWER, m_iCurrentTime);
|
||||
}
|
||||
else //Mark surrounding regions as well
|
||||
{
|
||||
@ -175,10 +203,12 @@ namespace PolyVox
|
||||
for(uint16 xCt = minRegionX; xCt <= maxRegionX; xCt++)
|
||||
{
|
||||
volRegionUpToDate->setVoxelAt(xCt,yCt,zCt,false);
|
||||
volRegionLastModified->setVoxelAt(xCt,yCt,zCt,m_iCurrentTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++m_iCurrentTime;
|
||||
}
|
||||
|
||||
void VolumeChangeTracker::setLockedVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value)
|
||||
@ -224,10 +254,12 @@ namespace PolyVox
|
||||
for(uint16 xCt = firstRegionX; xCt <= lastRegionX; xCt++)
|
||||
{
|
||||
volRegionUpToDate->setVoxelAt(xCt,yCt,zCt,false);
|
||||
volRegionLastModified->setVoxelAt(xCt,yCt,zCt,m_iCurrentTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++m_iCurrentTime;
|
||||
m_bIsLocked = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user