Stripped out unused code.

This commit is contained in:
David Williams 2013-06-26 22:14:01 +02:00
parent acb43d54d9
commit 1064ea1c47
7 changed files with 0 additions and 218 deletions

View File

@ -263,64 +263,8 @@ public:
{
std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl;
}
virtual void dataRequiredHandler(const ConstVolumeProxy<MaterialDensityPair44>& volumeProxy, const Region& region)
{
POLYVOX_ASSERT(false, "NOT IMPLEMENTED");
}
virtual void dataOverflowHandler(const ConstVolumeProxy<MaterialDensityPair44>& /*volumeProxy*/, const Region& region)
{
std::cout << "warning unloading region: " << region.getLowerCorner() << " -> " << region.getUpperCorner() << std::endl;
}
};
void load(const ConstVolumeProxy<MaterialDensityPair44>& volume, const PolyVox::Region& reg)
{
Perlin perlin(2,2,1,234);
for(int x = reg.getLowerX(); x <= reg.getUpperX(); x++)
{
for(int y = reg.getLowerY(); y <= reg.getUpperY(); y++)
{
float perlinVal = perlin.Get(x / static_cast<float>(255-1), y / static_cast<float>(255-1));
perlinVal += 1.0f;
perlinVal *= 0.5f;
perlinVal *= 255;
for(int z = reg.getLowerZ(); z <= reg.getUpperZ(); z++)
{
MaterialDensityPair44 voxel;
if(z < perlinVal)
{
const int xpos = 50;
const int zpos = 100;
if((x-xpos)*(x-xpos) + (z-zpos)*(z-zpos) < 200) {
// tunnel
voxel.setMaterial(0);
voxel.setDensity(MaterialDensityPair44::getMinDensity());
} else {
// solid
voxel.setMaterial(245);
voxel.setDensity(MaterialDensityPair44::getMaxDensity());
}
}
else
{
voxel.setMaterial(0);
voxel.setDensity(MaterialDensityPair44::getMinDensity());
}
volume.setVoxelAt(x, y, z, voxel);
}
}
}
}
void unload(const ConstVolumeProxy<MaterialDensityPair44>& /*vol*/, const PolyVox::Region& reg)
{
std::cout << "warning unloading region: " << reg.getLowerCorner() << " -> " << reg.getUpperCorner() << std::endl;
}
int main(int argc, char *argv[])
{
//Create and show the Qt OpenGL window
@ -330,19 +274,10 @@ int main(int argc, char *argv[])
RLECompressor<MaterialDensityPair44, uint16_t>* compressor = new RLECompressor<MaterialDensityPair44, uint16_t>();
PerlinNoisePager* pager = new PerlinNoisePager();
//If these lines don't compile, please try commenting them out and using the two lines after
//(you will need Boost for this). If you have to do this then please let us know in the forums as
//we rely on community feedback to keep the Boost version running.
LargeVolume<MaterialDensityPair44> volData(Region::MaxRegion, compressor, pager, 256);
//LargeVolume<MaterialDensityPair44> volData(polyvox_bind(&load, polyvox_placeholder_1, polyvox_placeholder_2),
// polyvox_bind(&unload, polyvox_placeholder_1, polyvox_placeholder_2), 256);
volData.setMaxNumberOfBlocksInMemory(4096);
volData.setMaxNumberOfUncompressedBlocks(64);
//volData.dataRequiredHandler = &load;
//volData.dataOverflowHandler = &unload;
//volData.setMaxNumberOfUncompressedBlocks(4096);
//createSphereInVolume(volData, 30);
//createPerlinTerrain(volData);

View File

@ -49,7 +49,6 @@ SET(CORE_INC_FILES
include/PolyVoxCore/BaseVolume.inl
include/PolyVoxCore/BaseVolumeSampler.inl
include/PolyVoxCore/Compressor.h
include/PolyVoxCore/ConstVolumeProxy.h
include/PolyVoxCore/CubicSurfaceExtractor.h
include/PolyVoxCore/CubicSurfaceExtractor.inl
include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h

View File

@ -1,83 +0,0 @@
/*******************************************************************************
Copyright (c) 2005-2009 David Williams
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*******************************************************************************/
#ifndef __PolyVox_ConstVolumeProxy_H__
#define __PolyVox_ConstVolumeProxy_H__
#include "PolyVoxCore/Region.h"
#include "PolyVoxCore/Vector.h"
namespace PolyVox
{
template <typename VoxelType>
class ConstVolumeProxy
{
//LargeVolume is a friend so it can call the constructor.
friend class LargeVolume<VoxelType>;
public:
VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const
{
// PolyVox does not throw an exception when a voxel is out of range. Please see 'Error Handling' in the User Manual.
POLYVOX_ASSERT(m_regValid.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region");
return m_pVolume.getVoxel<WrapModes::AssumeValid>(uXPos, uYPos, uZPos);
}
VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const
{
// PolyVox does not throw an exception when a voxel is out of range. Please see 'Error Handling' in the User Manual.
POLYVOX_ASSERT(m_regValid.containsPoint(v3dPos), "Position is outside valid region");
return getVoxelAt<WrapModes::AssumeValid>(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
}
void setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const
{
// PolyVox does not throw an exception when a voxel is out of range. Please see 'Error Handling' in the User Manual.
POLYVOX_ASSERT(m_regValid.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)), "Position is outside valid region");
m_pVolume.setVoxelAtConst(uXPos, uYPos, uZPos, tValue);
}
void setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue) const
{
// PolyVox does not throw an exception when a voxel is out of range. Please see 'Error Handling' in the User Manual.
POLYVOX_ASSERT(m_regValid.containsPoint(v3dPos), "Position is outside valid region");
setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue);
}
private:
//Private constructor, so client code can't abuse this class.
ConstVolumeProxy(const LargeVolume<VoxelType>& pVolume, const Region& regValid)
:m_pVolume(pVolume)
,m_regValid(regValid)
{
}
//Private assignment operator, so client code can't abuse this class.
ConstVolumeProxy& operator=(const ConstVolumeProxy& rhs)
{
}
const LargeVolume<VoxelType>& m_pVolume;
const Region& m_regValid;
};
}
#endif //__PolyVox_ConstVolumeProxy_H__

View File

@ -124,14 +124,6 @@ namespace PolyVox
fclose(pFile);
}
virtual void dataRequiredHandler(const ConstVolumeProxy<VoxelType>& volumeProxy, const Region& region)
{
}
virtual void dataOverflowHandler(const ConstVolumeProxy<VoxelType>& volumeProxy, const Region& region)
{
}
protected:
std::string m_strFolderName;
};

View File

@ -42,8 +42,6 @@ freely, subject to the following restrictions:
namespace PolyVox
{
template <typename VoxelType> class ConstVolumeProxy;
/// The LargeVolume class provides a memory efficient method of storing voxel data while also allowing fast access and modification.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// A LargeVolume is essentially a 3D array in which each element (or <i>voxel</i>) is identified by a three dimensional (x,y,z) coordinate.
@ -228,9 +226,6 @@ namespace PolyVox
VoxelType* mCurrentVoxel;
};
// Make the ConstVolumeProxy a friend
friend class ConstVolumeProxy<VoxelType>;
#endif
public:
@ -327,21 +322,9 @@ namespace PolyVox
VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType<WrapModes::Clamp>, VoxelType tBorder) const;
VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType<WrapModes::Border>, VoxelType tBorder) const;
VoxelType getVoxelImpl(int32_t uXPos, int32_t uYPos, int32_t uZPos, WrapModeType<WrapModes::AssumeValid>, VoxelType tBorder) const;
/// gets called when a new region is allocated and needs to be filled
/// NOTE: accessing ANY voxels outside this region during the process of this function
/// is absolutely unsafe
//polyvox_function<void(const ConstVolumeProxy<VoxelType>&, const Region&)> m_funcDataRequiredHandler;
/// gets called when a Region needs to be stored by the user, because LargeVolume will erase it right after
/// this function returns
/// NOTE: accessing ANY voxels outside this region during the process of this function
/// is absolutely unsafe
//polyvox_function<void(const ConstVolumeProxy<VoxelType>&, const Region&)> m_funcDataOverflowHandler;
Block<VoxelType>* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const;
void eraseBlock(typename std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare>::iterator itBlock) const;
/// this function can be called by m_funcDataRequiredHandler without causing any weird effects
bool setVoxelAtConst(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const;
// The block data
mutable std::map<Vector3DInt32, Block<VoxelType>, BlockPositionCompare> m_pBlocks;

View File

@ -25,9 +25,6 @@ freely, subject to the following restrictions:
#include "PolyVoxCore/MinizCompressor.h"
//Included here rather than in the .h because it refers to LargeVolume (avoids forward declaration)
#include "PolyVoxCore/ConstVolumeProxy.h"
namespace PolyVox
{
////////////////////////////////////////////////////////////////////////////////
@ -558,9 +555,6 @@ namespace PolyVox
Vector3DInt32 v3dUpper = v3dLower + Vector3DInt32(m_uBlockSideLength-1, m_uBlockSideLength-1, m_uBlockSideLength-1);
Region reg(v3dLower, v3dUpper);
/*ConstVolumeProxy<VoxelType> ConstVolumeProxy(*this, reg);
m_pPager->dataOverflowHandler(ConstVolumeProxy, reg);*/
m_pPager->pageOut(reg, &(itBlock->second));
}
@ -581,30 +575,6 @@ namespace PolyVox
m_pBlocks.erase(itBlock);
}
template <typename VoxelType>
bool LargeVolume<VoxelType>::setVoxelAtConst(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const
{
//We don't have any range checks in this function because it
//is a private function only called by the ConstVolumeProxy. The
//ConstVolumeProxy takes care of ensuring the range is appropriate.
const int32_t blockX = uXPos >> m_uBlockSideLengthPower;
const int32_t blockY = uYPos >> m_uBlockSideLengthPower;
const int32_t blockZ = uZPos >> m_uBlockSideLengthPower;
const uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower);
const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower);
const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower);
Block<VoxelType>* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ);
pUncompressedBlock->setVoxelAt(xOffset,yOffset,zOffset, tValue);
//Return true to indicate that we modified a voxel.
return true;
}
template <typename VoxelType>
Block<VoxelType>* LargeVolume<VoxelType>::getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const
{
@ -665,8 +635,6 @@ namespace PolyVox
Vector3DInt32 v3dLower(v3dBlockPos.getX() << m_uBlockSideLengthPower, v3dBlockPos.getY() << m_uBlockSideLengthPower, v3dBlockPos.getZ() << m_uBlockSideLengthPower);
Vector3DInt32 v3dUpper = v3dLower + Vector3DInt32(m_uBlockSideLength-1, m_uBlockSideLength-1, m_uBlockSideLength-1);
Region reg(v3dLower, v3dUpper);
/*ConstVolumeProxy<VoxelType> ConstVolumeProxy(*this, reg);
m_pPager->dataRequiredHandler(ConstVolumeProxy, reg);*/
m_pPager->pageIn(reg, &(itBlock->second));
}

View File

@ -27,8 +27,6 @@ freely, subject to the following restrictions:
#include "PolyVoxCore/Impl/Block.h"
#include "PolyVoxCore/Impl/TypeDef.h"
#include "PolyVoxCore/ConstVolumeProxy.h"
namespace PolyVox
{
/**
@ -45,16 +43,6 @@ namespace PolyVox
virtual void pageIn(const Region& region, Block<VoxelType>* pBlockData) = 0;
virtual void pageOut(const Region& region, Block<VoxelType>* pBlockData) = 0;
virtual void dataRequiredHandler(const ConstVolumeProxy<VoxelType>& volumeProxy, const Region& region)
{
POLYVOX_ASSERT(false, "NOT IMPLEMENTED");
}
virtual void dataOverflowHandler(const ConstVolumeProxy<VoxelType>& volumeProxy, const Region& region)
{
POLYVOX_ASSERT(false, "NOT IMPLEMENTED");
}
};
}