Merge branch 'master' of git://gitorious.org/polyvox/polyvox
This commit is contained in:
commit
b63d74b3ca
@ -24,8 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __OpenGLExample_Shapes_H__
|
||||
#define __OpenGLExample_Shapes_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
||||
|
||||
void createSphereInVolume(PolyVox::LargeVolume<PolyVox::MaterialDensityPair44>& volData, float fRadius, uint8_t uValue);
|
||||
void createCubeInVolume(PolyVox::LargeVolume<PolyVox::MaterialDensityPair44>& volData, PolyVox::Vector3DInt32 lowerCorner, PolyVox::Vector3DInt32 upperCorner, uint8_t uValue);
|
||||
|
@ -21,10 +21,11 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Filters.h"
|
||||
#include "PolyVoxCore/Log.h"
|
||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
#include "PolyVoxCore/LowPassFilter.h"
|
||||
#include "PolyVoxCore/RawVolume.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxImpl/Utility.h"
|
||||
|
||||
@ -101,8 +102,11 @@ int main(int argc, char *argv[])
|
||||
createCubeInVolume(volData, Vector3DInt32(midPos-10, midPos-10 ,1), Vector3DInt32(midPos+10, midPos+10, maxPos-1), MaterialDensityPair44::getMaxDensity());
|
||||
|
||||
//Smooth part of the volume
|
||||
smoothRegion<LargeVolume, MaterialDensityPair44>(volData, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(127, 127, 127)));
|
||||
smoothRegion<LargeVolume, MaterialDensityPair44>(volData, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(127, 127, 127)));
|
||||
RawVolume<MaterialDensityPair44> tempVolume(PolyVox::Region(0,0,0,128, 128, 128));
|
||||
LowPassFilter<LargeVolume, RawVolume, MaterialDensityPair44> pass1(&volData, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(126, 126, 126)), &tempVolume, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(126, 126, 126)), 3);
|
||||
pass1.executeSAT();
|
||||
LowPassFilter<RawVolume, LargeVolume, MaterialDensityPair44> pass2(&tempVolume, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(126, 126, 126)), &volData, PolyVox::Region(Vector3DInt32(62, 62, 62), Vector3DInt32(126, 126, 126)), 3);
|
||||
pass2.executeSAT();
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
|
@ -29,7 +29,6 @@ freely, subject to the following restrictions:
|
||||
#include "PolyVoxCore/SurfaceExtractor.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
#include "PolyVoxCore/Filters.h"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
|
@ -24,7 +24,6 @@ freely, subject to the following restrictions:
|
||||
#include "OpenGLWidget.h"
|
||||
|
||||
#include "PolyVoxCore/Density.h"
|
||||
#include "PolyVoxCore/Filters.h"
|
||||
#include "PolyVoxCore/SurfaceExtractor.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/RawVolume.h"
|
||||
@ -86,10 +85,10 @@ int main(int argc, char *argv[])
|
||||
SimpleVolume<Density8> volData(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(63, 63, 63)));
|
||||
createSphereInVolume(volData, 28);
|
||||
|
||||
//Smooth the data
|
||||
smoothRegion<SimpleVolume, Density8>(volData, volData.getEnclosingRegion());
|
||||
smoothRegion<SimpleVolume, Density8>(volData, volData.getEnclosingRegion());
|
||||
smoothRegion<SimpleVolume, Density8>(volData, volData.getEnclosingRegion());
|
||||
//Smooth the data - should reimplement this using LowPassFilter
|
||||
//smoothRegion<SimpleVolume, Density8>(volData, volData.getEnclosingRegion());
|
||||
//smoothRegion<SimpleVolume, Density8>(volData, volData.getEnclosingRegion());
|
||||
//smoothRegion<SimpleVolume, Density8>(volData, volData.getEnclosingRegion());
|
||||
|
||||
RawVolume<Density8> volDataLowLOD(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(15, 31, 31)));
|
||||
|
||||
|
@ -29,14 +29,16 @@ SET(CORE_INC_FILES
|
||||
include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h
|
||||
include/PolyVoxCore/CubicSurfaceExtractorWithNormals.inl
|
||||
include/PolyVoxCore/Density.h
|
||||
include/PolyVoxCore/Filters.h
|
||||
include/PolyVoxCore/Filters.inl
|
||||
include/PolyVoxCore/GradientEstimators.h
|
||||
include/PolyVoxCore/GradientEstimators.inl
|
||||
include/PolyVoxCore/IteratorController.h
|
||||
include/PolyVoxCore/IteratorController.inl
|
||||
include/PolyVoxCore/LargeVolume.h
|
||||
include/PolyVoxCore/LargeVolume.inl
|
||||
include/PolyVoxCore/LargeVolumeSampler.inl
|
||||
include/PolyVoxCore/Log.h
|
||||
include/PolyVoxCore/LowPassFilter.h
|
||||
include/PolyVoxCore/LowPassFilter.inl
|
||||
include/PolyVoxCore/Material.h
|
||||
include/PolyVoxCore/MaterialDensityPair.h
|
||||
include/PolyVoxCore/MeshDecimator.h
|
||||
|
@ -24,13 +24,14 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_AStarPathfinder_H__
|
||||
#define __PolyVox_AStarPathfinder_H__
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxImpl/AStarPathfinderImpl.h"
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
|
||||
#include <list>
|
||||
#include <stdexcept> //For runtime_error
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
const float sqrt_1 = 1.0f;
|
||||
|
@ -21,8 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Material.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -24,8 +24,14 @@ freely, subject to the following restrictions:
|
||||
#ifndef __AmbientOcclusionCalculator_H__
|
||||
#define __AmbientOcclusionCalculator_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
#include "PolyVoxImpl/RandomUnitVectors.h"
|
||||
#include "PolyVoxImpl/RandomVectors.h"
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/Raycast.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
|
@ -21,15 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/Raycast.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
|
||||
#include "PolyVoxImpl/RandomUnitVectors.h"
|
||||
#include "PolyVoxImpl/RandomVectors.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
|
@ -24,10 +24,10 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Array_H__
|
||||
#define __PolyVox_Array_H__
|
||||
|
||||
#include "PolyVoxCore/ArraySizes.h" //Not strictly required, but convienient
|
||||
|
||||
#include "PolyVoxImpl/SubArray.h"
|
||||
|
||||
#include "PolyVoxCore/ArraySizes.h" //Not strictly required, but convienient
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
///Provides an efficient implementation of a multidimensional array.
|
||||
|
@ -24,8 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_ConstVolumeProxy_H__
|
||||
#define __PolyVox_ConstVolumeProxy_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
|
@ -24,12 +24,11 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_CubicSurfaceExtractor_H__
|
||||
#define __PolyVox_CubicSurfaceExtractor_H__
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
|
@ -21,12 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxImpl/MarchingCubesTables.h"
|
||||
#include "PolyVoxCore/VertexTypes.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
|
@ -24,10 +24,10 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_CubicSurfaceExtractorWithNormals_H__
|
||||
#define __PolyVox_CubicSurfaceExtractorWithNormals_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
#include "PolyVoxImpl/MarchingCubesTables.h"
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
|
@ -21,12 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxImpl/MarchingCubesTables.h"
|
||||
#include "PolyVoxCore/VertexTypes.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
|
@ -24,9 +24,10 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Density_H__
|
||||
#define __PolyVox_Density_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
///This class represents a voxel storing only a density.
|
||||
@ -62,7 +63,7 @@ namespace PolyVox
|
||||
Type getMaterial() const throw() { return 1; }
|
||||
|
||||
void setDensity(Type uDensity) { m_uDensity = uDensity; }
|
||||
void setMaterial(Type uMaterial) { assert("Cannot set material on voxel of type 'Density'"); }
|
||||
void setMaterial(Type uMaterial) { assert(false); } //Cannot set material on voxel of type Density
|
||||
|
||||
static Type getMaxDensity() throw() { return (0x01 << (sizeof(Type) * 8)) - 1; }
|
||||
static Type getMinDensity() throw() { return 0; }
|
||||
|
@ -1,73 +0,0 @@
|
||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
void smoothRegion(VolumeType<VoxelType>& volData, const Region& regionToSmooth)
|
||||
{
|
||||
Region croppedRegion = regionToSmooth;
|
||||
|
||||
uint32_t uArrayWidth = croppedRegion.getUpperCorner().getX() - croppedRegion.getLowerCorner().getX() + 1;
|
||||
uint32_t uArrayHeight = croppedRegion.getUpperCorner().getY() - croppedRegion.getLowerCorner().getY() + 1;
|
||||
uint32_t uArrayDepth = croppedRegion.getUpperCorner().getZ() - croppedRegion.getLowerCorner().getZ() + 1;
|
||||
Array<3, uint16_t> temp(ArraySizes(uArrayWidth)(uArrayHeight)(uArrayDepth));
|
||||
|
||||
for (int32_t z = croppedRegion.getLowerCorner().getZ(); z <= croppedRegion.getUpperCorner().getZ(); z++)
|
||||
{
|
||||
for (int32_t y = croppedRegion.getLowerCorner().getY(); y <= croppedRegion.getUpperCorner().getY(); y++)
|
||||
{
|
||||
for (int32_t x = croppedRegion.getLowerCorner().getX(); x <= croppedRegion.getUpperCorner().getX(); x++)
|
||||
{
|
||||
uint16_t& uDensity = temp[x-croppedRegion.getLowerCorner().getX()][y-croppedRegion.getLowerCorner().getY()][z-croppedRegion.getLowerCorner().getZ()];
|
||||
|
||||
uDensity=0;
|
||||
uDensity += volData.getVoxelAt(x-1,y-1,z-1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-1,y-1,z-0).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-1,y-1,z+1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-1,y-0,z-1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-1,y-0,z-0).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-1,y-0,z+1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-1,y+1,z-1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-1,y+1,z-0).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-1,y+1,z+1).getDensity();
|
||||
|
||||
uDensity += volData.getVoxelAt(x-0,y-1,z-1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-0,y-1,z-0).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-0,y-1,z+1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-0,y-0,z-1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-0,y-0,z-0).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-0,y-0,z+1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-0,y+1,z-1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-0,y+1,z-0).getDensity();
|
||||
uDensity += volData.getVoxelAt(x-0,y+1,z+1).getDensity();
|
||||
|
||||
uDensity += volData.getVoxelAt(x+1,y-1,z-1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x+1,y-1,z-0).getDensity();
|
||||
uDensity += volData.getVoxelAt(x+1,y-1,z+1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x+1,y-0,z-1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x+1,y-0,z-0).getDensity();
|
||||
uDensity += volData.getVoxelAt(x+1,y-0,z+1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x+1,y+1,z-1).getDensity();
|
||||
uDensity += volData.getVoxelAt(x+1,y+1,z-0).getDensity();
|
||||
uDensity += volData.getVoxelAt(x+1,y+1,z+1).getDensity();
|
||||
uDensity /= 27;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t z = croppedRegion.getLowerCorner().getZ(); z < croppedRegion.getUpperCorner().getZ(); z++)
|
||||
{
|
||||
for (int32_t y = croppedRegion.getLowerCorner().getY(); y < croppedRegion.getUpperCorner().getY(); y++)
|
||||
{
|
||||
for (int32_t x = croppedRegion.getLowerCorner().getX(); x < croppedRegion.getUpperCorner().getX(); x++)
|
||||
{
|
||||
uint16_t& uDensity = temp[x-croppedRegion.getLowerCorner().getX()][y-croppedRegion.getLowerCorner().getY()][z-croppedRegion.getLowerCorner().getZ()];
|
||||
|
||||
VoxelType val = volData.getVoxelAt(x,y,z);
|
||||
val.setDensity(uDensity);
|
||||
volData.setVoxelAt(x,y,z,val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,9 +24,10 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_GradientEstimators_H__
|
||||
#define __PolyVox_GradientEstimators_H__
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/VoxelFilters.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
|
@ -21,10 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/VoxelFilters.h"
|
||||
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
|
@ -21,18 +21,26 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef __PolyVox_Filters_H__
|
||||
#define __PolyVox_Filters_H__
|
||||
#ifndef __PolyVox_IteratorController_H__
|
||||
#define __PolyVox_IteratorController_H__
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
void smoothRegion(VolumeType<VoxelType>& volData, const Region& regionToSmooth);
|
||||
}//namespace PolyVox
|
||||
template <typename IteratorType>
|
||||
class IteratorController
|
||||
{
|
||||
public:
|
||||
void reset(void);
|
||||
bool moveForward(void);
|
||||
|
||||
#include "PolyVoxCore/Filters.inl"
|
||||
public:
|
||||
Region m_regValid;
|
||||
IteratorType* m_Iter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
#include "PolyVoxCore/IteratorController.inl"
|
||||
|
||||
#endif //__PolyVox_IteratorController_H__
|
@ -0,0 +1,63 @@
|
||||
/*******************************************************************************
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename IteratorType>
|
||||
void IteratorController<IteratorType>::reset(void)
|
||||
{
|
||||
m_Iter->setPosition(m_regValid.getLowerCorner());
|
||||
}
|
||||
|
||||
template <typename IteratorType>
|
||||
bool IteratorController<IteratorType>::moveForward(void)
|
||||
{
|
||||
Vector3DInt32 v3dInitialPosition(m_Iter->getPosX(), m_Iter->getPosY(), m_Iter->getPosZ());
|
||||
|
||||
if(v3dInitialPosition.getX() < m_regValid.getUpperCorner().getX())
|
||||
{
|
||||
m_Iter->movePositiveX();
|
||||
return true;
|
||||
}
|
||||
|
||||
v3dInitialPosition.setX(m_regValid.getLowerCorner().getX());
|
||||
|
||||
if(v3dInitialPosition.getY() < m_regValid.getUpperCorner().getY())
|
||||
{
|
||||
v3dInitialPosition.setY(v3dInitialPosition.getY() + 1);
|
||||
m_Iter->setPosition(v3dInitialPosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
v3dInitialPosition.setY(m_regValid.getLowerCorner().getY());
|
||||
|
||||
if(v3dInitialPosition.getZ() < m_regValid.getUpperCorner().getZ())
|
||||
{
|
||||
v3dInitialPosition.setZ(v3dInitialPosition.getZ() + 1);
|
||||
m_Iter->setPosition(v3dInitialPosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -25,14 +25,19 @@ freely, subject to the following restrictions:
|
||||
#define __PolyVox_LargeVolume_H__
|
||||
|
||||
#include "PolyVoxImpl/Block.h"
|
||||
#include "PolyVoxCore/Log.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/Volume.h"
|
||||
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
#include <cstdlib> //For abort()
|
||||
#include <cstring> //For memcpy
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
#include <stdexcept> //For invalid_argument
|
||||
#include <vector>
|
||||
|
||||
namespace PolyVox
|
||||
@ -141,12 +146,25 @@ namespace PolyVox
|
||||
/// This is true even if you are only reading data from the volume, as concurrently reading from different threads can invalidate the contents
|
||||
/// of the block cache (amoung other problems).
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename VoxelType> class ConstVolumeProxy;
|
||||
|
||||
template <typename VoxelType>
|
||||
class LargeVolume : public Volume<VoxelType>
|
||||
{
|
||||
public:
|
||||
typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn
|
||||
class Sampler : public VolumeOfVoxelType::template Sampler< LargeVolume<VoxelType> >
|
||||
//There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared.
|
||||
//There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but
|
||||
//which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler
|
||||
//option. For now it seems best to 'fix' it with the preprocessor insstead, but maybe the workaround can be reinstated
|
||||
//in the future
|
||||
//typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences.
|
||||
//class Sampler : public VolumeOfVoxelType::template Sampler< LargeVolume<VoxelType> >
|
||||
#if defined(_MSC_VER)
|
||||
class Sampler : public Volume<VoxelType>::Sampler< LargeVolume<VoxelType> > //This line works on VS2010
|
||||
#else
|
||||
class Sampler : public Volume<VoxelType>::template Sampler< LargeVolume<VoxelType> > //This line works on GCC
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
Sampler(LargeVolume<VoxelType>* volume);
|
||||
@ -162,6 +180,7 @@ namespace PolyVox
|
||||
|
||||
void setPosition(const Vector3DInt32& v3dNewPos);
|
||||
void setPosition(int32_t xPos, int32_t yPos, int32_t zPos);
|
||||
inline bool setVoxel(VoxelType tValue);
|
||||
|
||||
void movePositiveX(void);
|
||||
void movePositiveY(void);
|
||||
|
@ -21,18 +21,8 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
//Included here rather than in the .h because it refers to LargeVolume (avoids forward declaration)
|
||||
#include "PolyVoxCore/ConstVolumeProxy.h"
|
||||
#include "PolyVoxImpl/Block.h"
|
||||
#include "PolyVoxCore/Log.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
#include <cstdlib> //For abort()
|
||||
#include <cstring> //For memcpy
|
||||
#include <list>
|
||||
#include <stdexcept> //For invalid_argument
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
@ -113,6 +103,7 @@ namespace PolyVox
|
||||
LargeVolume<VoxelType>::~LargeVolume()
|
||||
{
|
||||
flushAll();
|
||||
delete[] m_pUncompressedBorderData;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -21,17 +21,11 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxImpl/Block.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
|
||||
#define BORDER_LOW(x) ((( x >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != x)
|
||||
#define BORDER_HIGH(x) ((( (x+1) >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != (x+1))
|
||||
//#define BORDER_LOW(x) (( x % mVolume->m_uBlockSideLength) != 0)
|
||||
//#define BORDER_HIGH(x) (( x % mVolume->m_uBlockSideLength) != mVolume->m_uBlockSideLength - 1)
|
||||
|
||||
#include <limits>
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
@ -159,6 +153,15 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
bool LargeVolume<VoxelType>::Sampler::setVoxel(VoxelType tValue)
|
||||
{
|
||||
//*mCurrentVoxel = tValue;
|
||||
//Need to think what effect this has on any existing iterators.
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void LargeVolume<VoxelType>::Sampler::movePositiveX(void)
|
||||
{
|
||||
@ -525,3 +528,6 @@ namespace PolyVox
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1);
|
||||
}
|
||||
}
|
||||
|
||||
#undef BORDER_LOW
|
||||
#undef BORDER_HIGH
|
60
library/PolyVoxCore/include/PolyVoxCore/LowPassFilter.h
Normal file
60
library/PolyVoxCore/include/PolyVoxCore/LowPassFilter.h
Normal file
@ -0,0 +1,60 @@
|
||||
/*******************************************************************************
|
||||
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_LowPassFilter_H__
|
||||
#define __PolyVox_LowPassFilter_H__
|
||||
|
||||
#include "PolyVoxCore/IteratorController.h"
|
||||
#include "PolyVoxCore/RawVolume.h" //Is this desirable?
|
||||
#include "PolyVoxCore/Region.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class SrcVolumeType, template<typename> class DestVolumeType, typename VoxelType>
|
||||
class LowPassFilter
|
||||
{
|
||||
public:
|
||||
LowPassFilter(SrcVolumeType<VoxelType>* pVolSrc, Region regSrc, DestVolumeType<VoxelType>* pVolDst, Region regDst, uint32_t uKernelSize);
|
||||
|
||||
void execute();
|
||||
void executeSAT();
|
||||
|
||||
private:
|
||||
//Source data
|
||||
SrcVolumeType<VoxelType>* m_pVolSrc;
|
||||
Region m_regSrc;
|
||||
|
||||
//Destination data
|
||||
DestVolumeType<VoxelType>* m_pVolDst;
|
||||
Region m_regDst;
|
||||
|
||||
//Kernel size
|
||||
uint32_t m_uKernelSize;
|
||||
};
|
||||
|
||||
}//namespace PolyVox
|
||||
|
||||
#include "PolyVoxCore/LowPassFilter.inl"
|
||||
|
||||
#endif //__PolyVox_LowPassFilter_H__
|
||||
|
265
library/PolyVoxCore/include/PolyVoxCore/LowPassFilter.inl
Normal file
265
library/PolyVoxCore/include/PolyVoxCore/LowPassFilter.inl
Normal file
@ -0,0 +1,265 @@
|
||||
/*******************************************************************************
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class SrcVolumeType, template<typename> class DestVolumeType, typename VoxelType>
|
||||
LowPassFilter<SrcVolumeType, DestVolumeType, VoxelType>::LowPassFilter(SrcVolumeType<VoxelType>* pVolSrc, Region regSrc, DestVolumeType<VoxelType>* pVolDst, Region regDst, uint32_t uKernelSize)
|
||||
:m_pVolSrc(pVolSrc)
|
||||
,m_regSrc(regSrc)
|
||||
,m_pVolDst(pVolDst)
|
||||
,m_regDst(regDst)
|
||||
,m_uKernelSize(uKernelSize)
|
||||
{
|
||||
//Kernel size must be at least three
|
||||
assert(m_uKernelSize >= 3);
|
||||
m_uKernelSize = std::max(m_uKernelSize, static_cast<uint32_t>(3)); //For release builds
|
||||
|
||||
//Kernel size must be odd
|
||||
assert(m_uKernelSize % 2 == 1);
|
||||
if(m_uKernelSize % 2 == 0) //For release builds
|
||||
{
|
||||
m_uKernelSize++;
|
||||
}
|
||||
}
|
||||
|
||||
template< template<typename> class SrcVolumeType, template<typename> class DestVolumeType, typename VoxelType>
|
||||
void LowPassFilter<SrcVolumeType, DestVolumeType, VoxelType>::execute()
|
||||
{
|
||||
int32_t iSrcMinX = m_regSrc.getLowerCorner().getX();
|
||||
int32_t iSrcMinY = m_regSrc.getLowerCorner().getY();
|
||||
int32_t iSrcMinZ = m_regSrc.getLowerCorner().getZ();
|
||||
|
||||
int32_t iSrcMaxX = m_regSrc.getUpperCorner().getX();
|
||||
int32_t iSrcMaxY = m_regSrc.getUpperCorner().getY();
|
||||
int32_t iSrcMaxZ = m_regSrc.getUpperCorner().getZ();
|
||||
|
||||
int32_t iDstMinX = m_regDst.getLowerCorner().getX();
|
||||
int32_t iDstMinY = m_regDst.getLowerCorner().getY();
|
||||
int32_t iDstMinZ = m_regDst.getLowerCorner().getZ();
|
||||
|
||||
//int32_t iDstMaxX = m_regDst.getUpperCorner().getX();
|
||||
//int32_t iDstMaxY = m_regDst.getUpperCorner().getY();
|
||||
//int32_t iDstMaxZ = m_regDst.getUpperCorner().getZ();
|
||||
|
||||
typename SrcVolumeType<VoxelType>::Sampler srcSampler(m_pVolSrc);
|
||||
|
||||
for(int32_t iSrcZ = iSrcMinZ, iDstZ = iDstMinZ; iSrcZ <= iSrcMaxZ; iSrcZ++, iDstZ++)
|
||||
{
|
||||
for(int32_t iSrcY = iSrcMinY, iDstY = iDstMinY; iSrcY <= iSrcMaxY; iSrcY++, iDstY++)
|
||||
{
|
||||
for(int32_t iSrcX = iSrcMinX, iDstX = iDstMinX; iSrcX <= iSrcMaxX; iSrcX++, iDstX++)
|
||||
{
|
||||
//VoxelType tSrcVoxel = m_pVolSrc->getVoxelAt(iSrcX, iSrcY, iSrcZ);
|
||||
srcSampler.setPosition(iSrcX, iSrcY, iSrcZ);
|
||||
|
||||
VoxelType tSrcVoxel = srcSampler.getVoxel();
|
||||
|
||||
uint32_t uDensity = 0;
|
||||
uDensity += srcSampler.peekVoxel1nx1ny1nz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1nx1ny0pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1nx1ny1pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1nx0py1nz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1nx0py0pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1nx0py1pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1nx1py1nz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1nx1py0pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1nx1py1pz().getDensity();
|
||||
|
||||
uDensity += srcSampler.peekVoxel0px1ny1nz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel0px1ny0pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel0px1ny1pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel0px0py1nz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel0px0py0pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel0px0py1pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel0px1py1nz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel0px1py0pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel0px1py1pz().getDensity();
|
||||
|
||||
uDensity += srcSampler.peekVoxel1px1ny1nz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1px1ny0pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1px1ny1pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1px0py1nz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1px0py0pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1px0py1pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1px1py1nz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1px1py0pz().getDensity();
|
||||
uDensity += srcSampler.peekVoxel1px1py1pz().getDensity();
|
||||
|
||||
uDensity /= 27;
|
||||
|
||||
tSrcVoxel.setDensity(uDensity);
|
||||
m_pVolDst->setVoxelAt(iSrcX, iSrcY, iSrcZ, tSrcVoxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template< template<typename> class SrcVolumeType, template<typename> class DestVolumeType, typename VoxelType>
|
||||
void LowPassFilter<SrcVolumeType, DestVolumeType, VoxelType>::executeSAT()
|
||||
{
|
||||
const int border = m_uKernelSize - 1;
|
||||
|
||||
Vector3DInt32 satLowerCorner = m_regSrc.getLowerCorner() - Vector3DInt32(border+1, border+1, border+1);
|
||||
Vector3DInt32 satUpperCorner = m_regSrc.getUpperCorner() + Vector3DInt32(border, border, border);
|
||||
|
||||
RawVolume<uint32_t> satVolume(Region(satLowerCorner, satUpperCorner));
|
||||
|
||||
//Clear to zeros (necessary?)
|
||||
for(int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++)
|
||||
{
|
||||
for(int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++)
|
||||
{
|
||||
for(int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++)
|
||||
{
|
||||
satVolume.setVoxelAt(x,y,z,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RawVolume<uint32_t>::Sampler satVolumeIter(&satVolume);
|
||||
|
||||
IteratorController<RawVolume<uint32_t>::Sampler> satIterCont;
|
||||
satIterCont.m_regValid = Region(satLowerCorner, satUpperCorner);
|
||||
satIterCont.m_Iter = &satVolumeIter;
|
||||
satIterCont.reset();
|
||||
|
||||
typename SrcVolumeType<VoxelType>::Sampler srcVolumeIter(m_pVolSrc);
|
||||
|
||||
IteratorController<typename SrcVolumeType<VoxelType>::Sampler> srcIterCont;
|
||||
srcIterCont.m_regValid = Region(satLowerCorner, satUpperCorner);
|
||||
srcIterCont.m_Iter = &srcVolumeIter;
|
||||
srcIterCont.reset();
|
||||
|
||||
do
|
||||
{
|
||||
uint32_t previousSum = satVolumeIter.peekVoxel1nx0py0pz();
|
||||
|
||||
uint32_t currentVal = srcVolumeIter.getVoxel().getDensity();
|
||||
|
||||
satVolumeIter.setVoxel(previousSum + currentVal);
|
||||
|
||||
srcIterCont.moveForward();
|
||||
|
||||
}while(satIterCont.moveForward());
|
||||
|
||||
//Build SAT in three passes
|
||||
/*for(int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++)
|
||||
{
|
||||
for(int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++)
|
||||
{
|
||||
for(int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++)
|
||||
{
|
||||
uint32_t previousSum = satVolume.getVoxelAt(x-1,y,z);
|
||||
uint32_t currentVal = m_pVolSrc->getVoxelAt(x,y,z).getDensity();
|
||||
|
||||
satVolume.setVoxelAt(x,y,z,previousSum + currentVal);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
for(int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++)
|
||||
{
|
||||
for(int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++)
|
||||
{
|
||||
for(int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++)
|
||||
{
|
||||
uint32_t previousSum = satVolume.getVoxelAt(x,y-1,z);
|
||||
uint32_t currentSum = satVolume.getVoxelAt(x,y,z);
|
||||
|
||||
satVolume.setVoxelAt(x,y,z,previousSum + currentSum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int32_t z = satLowerCorner.getZ(); z <= satUpperCorner.getZ(); z++)
|
||||
{
|
||||
for(int32_t y = satLowerCorner.getY(); y <= satUpperCorner.getY(); y++)
|
||||
{
|
||||
for(int32_t x = satLowerCorner.getX(); x <= satUpperCorner.getX(); x++)
|
||||
{
|
||||
uint32_t previousSum = satVolume.getVoxelAt(x,y,z-1);
|
||||
uint32_t currentSum = satVolume.getVoxelAt(x,y,z);
|
||||
|
||||
satVolume.setVoxelAt(x,y,z,previousSum + currentSum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now compute the average
|
||||
const Vector3DInt32& v3dDestLowerCorner = m_regDst.getLowerCorner();
|
||||
const Vector3DInt32& v3dDestUpperCorner = m_regDst.getUpperCorner();
|
||||
|
||||
const Vector3DInt32& v3dSrcLowerCorner = m_regSrc.getLowerCorner();
|
||||
const Vector3DInt32& v3dSrcUpperCorner = m_regSrc.getUpperCorner();
|
||||
|
||||
for(int32_t iDstZ = v3dDestLowerCorner.getZ(), iSrcZ = v3dSrcLowerCorner.getZ(); iDstZ <= v3dDestUpperCorner.getZ(); iDstZ++, iSrcZ++)
|
||||
{
|
||||
for(int32_t iDstY = v3dDestLowerCorner.getY(), iSrcY = v3dSrcLowerCorner.getY(); iDstY <= v3dDestUpperCorner.getY(); iDstY++, iSrcY++)
|
||||
{
|
||||
for(int32_t iDstX = v3dDestLowerCorner.getX(), iSrcX = v3dSrcLowerCorner.getX(); iDstX <= v3dDestUpperCorner.getX(); iDstX++, iSrcX++)
|
||||
{
|
||||
int32_t satLowerX = iSrcX - border - 1;
|
||||
int32_t satLowerY = iSrcY - border - 1;
|
||||
int32_t satLowerZ = iSrcZ - border - 1;
|
||||
|
||||
int32_t satUpperX = iSrcX + border;
|
||||
int32_t satUpperY = iSrcY + border;
|
||||
int32_t satUpperZ = iSrcZ + border;
|
||||
|
||||
int32_t a = satVolume.getVoxelAt(satLowerX,satLowerY,satLowerZ);
|
||||
int32_t b = satVolume.getVoxelAt(satUpperX,satLowerY,satLowerZ);
|
||||
int32_t c = satVolume.getVoxelAt(satLowerX,satUpperY,satLowerZ);
|
||||
int32_t d = satVolume.getVoxelAt(satUpperX,satUpperY,satLowerZ);
|
||||
int32_t e = satVolume.getVoxelAt(satLowerX,satLowerY,satUpperZ);
|
||||
int32_t f = satVolume.getVoxelAt(satUpperX,satLowerY,satUpperZ);
|
||||
int32_t g = satVolume.getVoxelAt(satLowerX,satUpperY,satUpperZ);
|
||||
int32_t h = satVolume.getVoxelAt(satUpperX,satUpperY,satUpperZ);
|
||||
|
||||
int32_t sum = h+c-d-g-f-a+b+e;
|
||||
|
||||
int32_t sideLength = border * 2 + 1;
|
||||
|
||||
int32_t average = sum / (sideLength*sideLength*sideLength);
|
||||
|
||||
VoxelType voxel = m_pVolSrc->getVoxelAt(iDstX, iDstY, iDstZ);
|
||||
|
||||
voxel.setDensity(average);
|
||||
|
||||
m_pVolDst->setVoxelAt(iDstX, iDstY, iDstZ, voxel);
|
||||
|
||||
|
||||
//float maxSolid = border * 2/* + 1*/;
|
||||
/*maxSolid = maxSolid * maxSolid * maxSolid;
|
||||
|
||||
float percentSolid = noSolid / maxSolid;
|
||||
float percentEmpty = 1.0f - percentSolid;
|
||||
|
||||
(*mAmbientOcclusionVolume)[ambVolZ][ambVolY][ambVolX] = 255 * percentEmpty;*/
|
||||
|
||||
//(*mAmbientOcclusionVolume)[ambVolZ][ambVolY][ambVolX] = 255 - ((h+c-d-g-f-a+b+e) * 19); //FIXME - should not be 9
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,7 +24,6 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Material_H__
|
||||
#define __PolyVox_Material_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include <cassert>
|
||||
@ -76,7 +75,7 @@ namespace PolyVox
|
||||
|
||||
Type getMaterial() const throw() { return m_uMaterial; }
|
||||
|
||||
void setDensity(Type /*uDensity*/) { assert("Cannot set density on voxel of type 'Material'"); }
|
||||
void setDensity(Type /*uDensity*/) { assert(false); } //Cannot set density on voxel of type Material
|
||||
void setMaterial(Type uMaterial) { m_uMaterial = uMaterial; }
|
||||
|
||||
static Type getMaxDensity() throw() { return 2; }
|
||||
|
@ -24,7 +24,6 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_MaterialDensityPair_H__
|
||||
#define __PolyVox_MaterialDensityPair_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
namespace PolyVox
|
||||
|
@ -24,7 +24,9 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_MeshDecimator_H__
|
||||
#define __PolyVox_MeshDecimator_H__
|
||||
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/VertexTypes.h"
|
||||
|
||||
#include <bitset>
|
||||
#include <vector>
|
||||
|
@ -21,8 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -261,9 +259,9 @@ namespace PolyVox
|
||||
bool MeshDecimator<VertexType>::collapseChangesFaceNormals(uint32_t uSrc, uint32_t uDst, float fThreshold)
|
||||
{
|
||||
bool faceFlipped = false;
|
||||
vector<uint32_t>& triangles = trianglesUsingVertex[uSrc];
|
||||
std::vector<uint32_t>& triangles = trianglesUsingVertex[uSrc];
|
||||
|
||||
for(vector<uint32_t>::iterator triIter = triangles.begin(); triIter != triangles.end(); triIter++)
|
||||
for(std::vector<uint32_t>::iterator triIter = triangles.begin(); triIter != triangles.end(); triIter++)
|
||||
{
|
||||
uint32_t tri = *triIter;
|
||||
|
||||
|
@ -60,18 +60,10 @@ namespace PolyVox
|
||||
|
||||
template <typename VoxelType> class Block;
|
||||
|
||||
template <typename VoxelType> class ConstVolumeProxy;
|
||||
|
||||
//---------- LargeVolume ----------
|
||||
template <typename VoxelType> class LargeVolume;
|
||||
//---------------------------------
|
||||
|
||||
//---------- Mesh ----------
|
||||
class Mesh;
|
||||
class MeshEdge;
|
||||
class MeshFace;
|
||||
class MeshVertex;
|
||||
//---------------------------------
|
||||
|
||||
template <typename Type> class Density;
|
||||
typedef Density<uint8_t> Density8;
|
||||
|
@ -24,12 +24,16 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_RawVolume_H__
|
||||
#define __PolyVox_RawVolume_H__
|
||||
|
||||
#include "PolyVoxCore/Log.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/Volume.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib> //For abort()
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <stdexcept> //For invalid_argument
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
@ -38,8 +42,18 @@ namespace PolyVox
|
||||
{
|
||||
public:
|
||||
#ifndef SWIG
|
||||
typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn
|
||||
class Sampler : public VolumeOfVoxelType::template Sampler< RawVolume<VoxelType> >
|
||||
//There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared.
|
||||
//There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but
|
||||
//which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler
|
||||
//option. For now it seems best to 'fix' it with the preprocessor insstead, but maybe the workaround can be reinstated
|
||||
//in the future
|
||||
//typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences.
|
||||
//class Sampler : public VolumeOfVoxelType::template Sampler< RawVolume<VoxelType> >
|
||||
#if defined(_MSC_VER)
|
||||
class Sampler : public Volume<VoxelType>::Sampler< RawVolume<VoxelType> > //This line works on VS2010
|
||||
#else
|
||||
class Sampler : public Volume<VoxelType>::template Sampler< RawVolume<VoxelType> > //This line works on GCC
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
Sampler(RawVolume<VoxelType>* volume);
|
||||
@ -52,6 +66,7 @@ namespace PolyVox
|
||||
|
||||
void setPosition(const Vector3DInt32& v3dNewPos);
|
||||
void setPosition(int32_t xPos, int32_t yPos, int32_t zPos);
|
||||
inline bool setVoxel(VoxelType tValue);
|
||||
|
||||
void movePositiveX(void);
|
||||
void movePositiveY(void);
|
||||
@ -96,7 +111,10 @@ namespace PolyVox
|
||||
VoxelType* mCurrentVoxel;
|
||||
|
||||
//Whether the current position is inside the volume
|
||||
bool m_bIsCurrentPositionValid;
|
||||
//FIXME - Replace these with flags
|
||||
bool m_bIsCurrentPositionValidInX;
|
||||
bool m_bIsCurrentPositionValidInY;
|
||||
bool m_bIsCurrentPositionValidInZ;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -21,17 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/ConstVolumeProxy.h"
|
||||
#include "PolyVoxImpl/Block.h"
|
||||
#include "PolyVoxCore/Log.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
#include <cstdlib> //For abort()
|
||||
#include <stdexcept> //For invalid_argument
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -49,6 +38,8 @@ namespace PolyVox
|
||||
)
|
||||
:Volume<VoxelType>(regValid)
|
||||
{
|
||||
setBorderValue(VoxelType());
|
||||
|
||||
//Create a volume of the right size.
|
||||
resize(regValid);
|
||||
}
|
||||
@ -85,11 +76,16 @@ namespace PolyVox
|
||||
{
|
||||
if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)))
|
||||
{
|
||||
const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner();
|
||||
int32_t iLocalXPos = uXPos - v3dLowerCorner.getX();
|
||||
int32_t iLocalYPos = uYPos - v3dLowerCorner.getY();
|
||||
int32_t iLocalZPos = uZPos - v3dLowerCorner.getZ();
|
||||
|
||||
return m_pData
|
||||
[
|
||||
uXPos +
|
||||
uYPos * this->getWidth() +
|
||||
uZPos * this->getWidth() * this->getHeight()
|
||||
iLocalXPos +
|
||||
iLocalYPos * this->getWidth() +
|
||||
iLocalZPos * this->getWidth() * this->getHeight()
|
||||
];
|
||||
}
|
||||
else
|
||||
@ -127,17 +123,27 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
bool RawVolume<VoxelType>::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue)
|
||||
{
|
||||
assert(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)));
|
||||
if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)))
|
||||
{
|
||||
const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner();
|
||||
int32_t iLocalXPos = uXPos - v3dLowerCorner.getX();
|
||||
int32_t iLocalYPos = uYPos - v3dLowerCorner.getY();
|
||||
int32_t iLocalZPos = uZPos - v3dLowerCorner.getZ();
|
||||
|
||||
m_pData
|
||||
[
|
||||
uXPos +
|
||||
uYPos * this->getWidth() +
|
||||
uZPos * this->getWidth() * this->getHeight()
|
||||
] = tValue;
|
||||
m_pData
|
||||
[
|
||||
iLocalXPos +
|
||||
iLocalYPos * this->getWidth() +
|
||||
iLocalZPos * this->getWidth() * this->getHeight()
|
||||
] = tValue;
|
||||
|
||||
//Return true to indicate that we modified a voxel.
|
||||
return true;
|
||||
//Return true to indicate that we modified a voxel.
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -21,19 +21,22 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxImpl/Block.h"
|
||||
#include "PolyVoxCore/RawVolume.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#define BORDER_LOWX(val) (val > this->mVolume->getEnclosingRegion().getLowerCorner().getX())
|
||||
#define BORDER_HIGHX(val) (val < this->mVolume->getEnclosingRegion().getUpperCorner().getX())
|
||||
#define BORDER_LOWY(val) (val > this->mVolume->getEnclosingRegion().getLowerCorner().getY())
|
||||
#define BORDER_HIGHY(val) (val < this->mVolume->getEnclosingRegion().getUpperCorner().getY())
|
||||
#define BORDER_LOWZ(val) (val > this->mVolume->getEnclosingRegion().getLowerCorner().getZ())
|
||||
#define BORDER_HIGHZ(val) (val < this->mVolume->getEnclosingRegion().getUpperCorner().getZ())
|
||||
|
||||
#include <limits>
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
RawVolume<VoxelType>::Sampler::Sampler(RawVolume<VoxelType>* volume)
|
||||
:Volume<VoxelType>::template Sampler< RawVolume<VoxelType> >(volume)
|
||||
,mCurrentVoxel(0)
|
||||
,m_bIsCurrentPositionValid(false)
|
||||
,m_bIsCurrentPositionValidInX(false)
|
||||
,m_bIsCurrentPositionValidInY(false)
|
||||
,m_bIsCurrentPositionValidInZ(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -63,7 +66,7 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::getVoxel(void) const
|
||||
{
|
||||
return m_bIsCurrentPositionValid ? *mCurrentVoxel : this->mVolume->getBorderValue();
|
||||
return (m_bIsCurrentPositionValidInX && m_bIsCurrentPositionValidInY && m_bIsCurrentPositionValidInZ) ? *mCurrentVoxel : this->mVolume->getBorderValue();
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -79,13 +82,35 @@ namespace PolyVox
|
||||
this->mYPosInVolume = yPos;
|
||||
this->mZPosInVolume = zPos;
|
||||
|
||||
const uint32_t uVoxelIndex = xPos +
|
||||
yPos * this->mVolume->getWidth() +
|
||||
zPos * this->mVolume->getWidth() * this->mVolume->getHeight();
|
||||
const Vector3DInt32& v3dLowerCorner = this->mVolume->m_regValidRegion.getLowerCorner();
|
||||
int32_t iLocalXPos = xPos - v3dLowerCorner.getX();
|
||||
int32_t iLocalYPos = yPos - v3dLowerCorner.getY();
|
||||
int32_t iLocalZPos = zPos - v3dLowerCorner.getZ();
|
||||
|
||||
const int32_t uVoxelIndex = iLocalXPos +
|
||||
iLocalYPos * this->mVolume->getWidth() +
|
||||
iLocalZPos * this->mVolume->getWidth() * this->mVolume->getHeight();
|
||||
|
||||
mCurrentVoxel = this->mVolume->m_pData + uVoxelIndex;
|
||||
|
||||
m_bIsCurrentPositionValid = this->mVolume->getEnclosingRegion().containsPoint(Vector3DInt32(xPos, yPos, zPos));
|
||||
m_bIsCurrentPositionValidInX = this->mVolume->getEnclosingRegion().containsPointInX(xPos);
|
||||
m_bIsCurrentPositionValidInY = this->mVolume->getEnclosingRegion().containsPointInY(yPos);
|
||||
m_bIsCurrentPositionValidInZ = this->mVolume->getEnclosingRegion().containsPointInZ(zPos);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
bool RawVolume<VoxelType>::Sampler::setVoxel(VoxelType tValue)
|
||||
{
|
||||
//return m_bIsCurrentPositionValid ? *mCurrentVoxel : this->mVolume->getBorderValue();
|
||||
if(m_bIsCurrentPositionValidInX && m_bIsCurrentPositionValidInY && m_bIsCurrentPositionValidInZ)
|
||||
{
|
||||
*mCurrentVoxel = tValue;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -93,7 +118,7 @@ namespace PolyVox
|
||||
{
|
||||
this->mXPosInVolume++;
|
||||
++mCurrentVoxel;
|
||||
m_bIsCurrentPositionValid = this->mXPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getX();
|
||||
m_bIsCurrentPositionValidInX = this->mVolume->getEnclosingRegion().containsPointInX(this->mXPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -101,7 +126,7 @@ namespace PolyVox
|
||||
{
|
||||
this->mYPosInVolume++;
|
||||
mCurrentVoxel += this->mVolume->getWidth();
|
||||
m_bIsCurrentPositionValid = this->mYPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getY();
|
||||
m_bIsCurrentPositionValidInY = this->mVolume->getEnclosingRegion().containsPointInY(this->mYPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -109,7 +134,7 @@ namespace PolyVox
|
||||
{
|
||||
this->mZPosInVolume++;
|
||||
mCurrentVoxel += this->mVolume->getWidth() * this->mVolume->getHeight();
|
||||
m_bIsCurrentPositionValid = this->mZPosInVolume <= this->mVolume->getEnclosingRegion().getUpperCorner().getZ();
|
||||
m_bIsCurrentPositionValidInZ = this->mVolume->getEnclosingRegion().containsPointInZ(this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -117,7 +142,7 @@ namespace PolyVox
|
||||
{
|
||||
this->mXPosInVolume--;
|
||||
--mCurrentVoxel;
|
||||
m_bIsCurrentPositionValid = this->mXPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getX();
|
||||
m_bIsCurrentPositionValidInX = this->mVolume->getEnclosingRegion().containsPointInX(this->mXPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -125,7 +150,7 @@ namespace PolyVox
|
||||
{
|
||||
this->mYPosInVolume--;
|
||||
mCurrentVoxel -= this->mVolume->getWidth();
|
||||
m_bIsCurrentPositionValid = this->mYPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getY();
|
||||
m_bIsCurrentPositionValidInY = this->mVolume->getEnclosingRegion().containsPointInY(this->mYPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -133,60 +158,96 @@ namespace PolyVox
|
||||
{
|
||||
this->mZPosInVolume--;
|
||||
mCurrentVoxel -= this->mVolume->getWidth() * this->mVolume->getHeight();
|
||||
m_bIsCurrentPositionValid =this->mZPosInVolume >= this->mVolume->getEnclosingRegion().getLowerCorner().getZ();
|
||||
m_bIsCurrentPositionValidInZ = this->mVolume->getEnclosingRegion().containsPointInZ(this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mXPosInVolume) && BORDER_LOWY(this->mYPosInVolume) && BORDER_LOWZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - 1 - this->mVolume->getWidth() - this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mXPosInVolume) && BORDER_LOWY(this->mYPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - 1 - this->mVolume->getWidth());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mXPosInVolume) && BORDER_LOWY(this->mYPosInVolume) && BORDER_HIGHZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - 1 - this->mVolume->getWidth() + this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume-1,this->mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mXPosInVolume) && BORDER_LOWZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - 1 - this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mXPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - 1);
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mXPosInVolume) && BORDER_HIGHZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - 1 + this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume,this->mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mXPosInVolume) && BORDER_HIGHY(this->mYPosInVolume) && BORDER_LOWZ(this->mYPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - 1 + this->mVolume->getWidth() - this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mXPosInVolume) && BORDER_HIGHY(this->mYPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - 1 + this->mVolume->getWidth());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mXPosInVolume) && BORDER_HIGHY(this->mYPosInVolume) && BORDER_HIGHZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - 1 + this->mVolume->getWidth() + this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume-1,this->mYPosInVolume+1,this->mZPosInVolume+1);
|
||||
}
|
||||
|
||||
@ -195,24 +256,40 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
|
||||
{
|
||||
if( BORDER_LOWX(this->mYPosInVolume) && BORDER_LOWZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - this->mVolume->getWidth() - this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
|
||||
{
|
||||
if( BORDER_LOWY(this->mYPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - this->mVolume->getWidth());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
|
||||
{
|
||||
if( BORDER_LOWY(this->mYPosInVolume) && BORDER_HIGHZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - this->mVolume->getWidth() + this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume-1,this->mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
|
||||
{
|
||||
if( BORDER_LOWZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel - this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume-1);
|
||||
}
|
||||
|
||||
@ -225,24 +302,40 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
|
||||
{
|
||||
if( BORDER_HIGHZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume,this->mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
|
||||
{
|
||||
if( BORDER_HIGHY(this->mYPosInVolume) && BORDER_LOWZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + this->mVolume->getWidth() - this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
|
||||
{
|
||||
if( BORDER_HIGHY(this->mYPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + this->mVolume->getWidth());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
|
||||
{
|
||||
if( BORDER_HIGHY(this->mYPosInVolume) && BORDER_HIGHZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + this->mVolume->getWidth() + this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume,this->mYPosInVolume+1,this->mZPosInVolume+1);
|
||||
}
|
||||
|
||||
@ -251,54 +344,97 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
|
||||
{
|
||||
if( BORDER_HIGHX(this->mXPosInVolume) && BORDER_LOWY(this->mYPosInVolume) && BORDER_LOWZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + 1 - this->mVolume->getWidth() - this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
|
||||
{
|
||||
if( BORDER_HIGHX(this->mXPosInVolume) && BORDER_LOWY(this->mYPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + 1 - this->mVolume->getWidth());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
|
||||
{
|
||||
if( BORDER_HIGHX(this->mXPosInVolume) && BORDER_LOWY(this->mYPosInVolume) && BORDER_HIGHZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + 1 - this->mVolume->getWidth() + this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume-1,this->mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
|
||||
{
|
||||
if( BORDER_HIGHX(this->mXPosInVolume) && BORDER_LOWZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + 1 - this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
|
||||
{
|
||||
if( BORDER_HIGHX(this->mXPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + 1);
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
|
||||
{
|
||||
if( BORDER_HIGHX(this->mXPosInVolume) && BORDER_HIGHZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + 1 + this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume,this->mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
|
||||
{
|
||||
if( BORDER_HIGHX(this->mXPosInVolume) && BORDER_HIGHY(this->mYPosInVolume) && BORDER_LOWZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + 1 + this->mVolume->getWidth() - this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
|
||||
{
|
||||
if( BORDER_HIGHX(this->mXPosInVolume) && BORDER_HIGHY(this->mYPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + 1 + this->mVolume->getWidth());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
|
||||
{
|
||||
if( BORDER_HIGHX(this->mXPosInVolume) && BORDER_HIGHY(this->mYPosInVolume) && BORDER_HIGHZ(this->mZPosInVolume) )
|
||||
{
|
||||
return *(mCurrentVoxel + 1 + this->mVolume->getWidth() + this->mVolume->getHeight() * this->mVolume->getHeight());
|
||||
}
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1);
|
||||
}
|
||||
}
|
||||
|
||||
#undef BORDER_LOWX
|
||||
#undef BORDER_HIGHX
|
||||
#undef BORDER_LOWY
|
||||
#undef BORDER_HIGHY
|
||||
#undef BORDER_LOWZ
|
||||
#undef BORDER_HIGHZ
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Raycast_H__
|
||||
#define __PolyVox_Raycast_H__
|
||||
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
/// Stores the result of a raycast operation.
|
||||
@ -39,6 +41,7 @@ namespace PolyVox
|
||||
bool foundIntersection;
|
||||
///If an intersection was found then this field holds the intersecting voxel, otherwise it is undefined.
|
||||
Vector3DInt32 intersectionVoxel;
|
||||
Vector3DInt32 previousVoxel;
|
||||
};
|
||||
|
||||
/// The Raycast class can be used to find the fist filled voxel along a given path.
|
||||
|
@ -20,6 +20,7 @@ freely, subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -142,6 +143,7 @@ namespace PolyVox
|
||||
m_result.intersectionVoxel = Vector3DInt32(i,j,k);
|
||||
return;
|
||||
}
|
||||
m_result.previousVoxel = Vector3DInt32(i,j,k);
|
||||
|
||||
if(tx <= ty && tx <= tz)
|
||||
{
|
||||
@ -173,5 +175,6 @@ namespace PolyVox
|
||||
//Didn't hit anything
|
||||
m_result.foundIntersection = false;
|
||||
m_result.intersectionVoxel = Vector3DInt32(0,0,0);
|
||||
m_result.previousVoxel = Vector3DInt32(0,0,0);
|
||||
}
|
||||
}
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_RaycastWithCallback_H__
|
||||
#define __PolyVox_RaycastWithCallback_H__
|
||||
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
|
@ -20,6 +20,7 @@ freely, subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
|
@ -25,6 +25,7 @@ freely, subject to the following restrictions:
|
||||
#define __PolyVox_Region_H__
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
namespace PolyVox
|
||||
@ -51,6 +52,13 @@ namespace PolyVox
|
||||
|
||||
bool containsPoint(const Vector3DFloat& pos, float boundary = 0.0f) const;
|
||||
bool containsPoint(const Vector3DInt32& pos, uint8_t boundary = 0) const;
|
||||
//FIXME - Don't like these. Make containsPoint take flags indicating which axes to check?
|
||||
bool containsPointInX(float pos, float boundary = 0.0f) const;
|
||||
bool containsPointInX(int32_t pos, uint8_t boundary = 0) const;
|
||||
bool containsPointInY(float pos, float boundary = 0.0f) const;
|
||||
bool containsPointInY(int32_t pos, uint8_t boundary = 0) const;
|
||||
bool containsPointInZ(float pos, float boundary = 0.0f) const;
|
||||
bool containsPointInZ(int32_t pos, uint8_t boundary = 0) const;
|
||||
void cropTo(const Region& other);
|
||||
/// Deprecated and misleading
|
||||
int32_t depth(void) const;
|
||||
|
@ -24,12 +24,19 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_SimpleVolume_H__
|
||||
#define __PolyVox_SimpleVolume_H__
|
||||
|
||||
#include "PolyVoxImpl/Utility.h"
|
||||
|
||||
#include "PolyVoxCore/Log.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/Volume.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdlib> //For abort()
|
||||
#include <cstring> //For memcpy
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <stdexcept> //For invalid_argument
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
@ -42,6 +49,7 @@ namespace PolyVox
|
||||
{
|
||||
public:
|
||||
Block(uint16_t uSideLength = 0);
|
||||
~Block();
|
||||
|
||||
uint16_t getSideLength(void) const;
|
||||
VoxelType getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const;
|
||||
@ -60,8 +68,18 @@ namespace PolyVox
|
||||
uint8_t m_uSideLengthPower;
|
||||
};
|
||||
|
||||
typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences. See http://goo.gl/qu1wn
|
||||
class Sampler : public VolumeOfVoxelType::template Sampler< SimpleVolume<VoxelType> >
|
||||
//There seems to be some descrepency between Visual Studio and GCC about how the following class should be declared.
|
||||
//There is a work around (see also See http://goo.gl/qu1wn) given below which appears to work on VS2010 and GCC, but
|
||||
//which seems to cause internal compiler errors on VS2008 when building with the /Gm 'Enable Minimal Rebuild' compiler
|
||||
//option. For now it seems best to 'fix' it with the preprocessor insstead, but maybe the workaround can be reinstated
|
||||
//in the future
|
||||
//typedef Volume<VoxelType> VolumeOfVoxelType; //Workaround for GCC/VS2010 differences.
|
||||
//class Sampler : public VolumeOfVoxelType::template Sampler< SimpleVolume<VoxelType> >
|
||||
#if defined(_MSC_VER)
|
||||
class Sampler : public Volume<VoxelType>::Sampler< SimpleVolume<VoxelType> > //This line works on VS2010
|
||||
#else
|
||||
class Sampler : public Volume<VoxelType>::template Sampler< SimpleVolume<VoxelType> > //This line works on GCC
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
Sampler(SimpleVolume<VoxelType>* volume);
|
||||
@ -77,6 +95,7 @@ namespace PolyVox
|
||||
|
||||
void setPosition(const Vector3DInt32& v3dNewPos);
|
||||
void setPosition(int32_t xPos, int32_t yPos, int32_t zPos);
|
||||
inline bool setVoxel(VoxelType tValue);
|
||||
|
||||
void movePositiveX(void);
|
||||
void movePositiveY(void);
|
||||
@ -179,6 +198,7 @@ private:
|
||||
uint16_t m_uDepthInBlocks;
|
||||
|
||||
//The size of the blocks
|
||||
uint32_t m_uNoOfVoxelsPerBlock;
|
||||
uint16_t m_uBlockSideLength;
|
||||
uint8_t m_uBlockSideLengthPower;
|
||||
};
|
||||
|
@ -21,17 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/ConstVolumeProxy.h"
|
||||
#include "PolyVoxImpl/Block.h"
|
||||
#include "PolyVoxCore/Log.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include <limits>
|
||||
#include <cassert>
|
||||
#include <cstdlib> //For abort()
|
||||
#include <stdexcept> //For invalid_argument
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -82,7 +71,7 @@ namespace PolyVox
|
||||
SimpleVolume<VoxelType>::~SimpleVolume()
|
||||
{
|
||||
delete[] m_pBlocks;
|
||||
m_pBlocks = 0;
|
||||
delete[] m_pUncompressedBorderData;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -143,7 +132,7 @@ namespace PolyVox
|
||||
{
|
||||
/*Block<VoxelType>* pUncompressedBorderBlock = getUncompressedBlock(&m_pBorderBlock);
|
||||
return pUncompressedBorderBlock->fill(tBorder);*/
|
||||
std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, tBorder);
|
||||
std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uNoOfVoxelsPerBlock, tBorder);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -205,6 +194,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
m_uBlockSideLength = uBlockSideLength;
|
||||
m_uNoOfVoxelsPerBlock = m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength;
|
||||
m_pUncompressedBorderData = 0;
|
||||
|
||||
this->m_regValidRegion = regValidRegion;
|
||||
@ -230,8 +220,8 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
//Create the border block
|
||||
m_pUncompressedBorderData = new VoxelType[m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength];
|
||||
std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, VoxelType());
|
||||
m_pUncompressedBorderData = new VoxelType[m_uNoOfVoxelsPerBlock];
|
||||
std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uNoOfVoxelsPerBlock, VoxelType());
|
||||
|
||||
//Other properties we might find useful later
|
||||
this->m_uLongestSideLength = (std::max)((std::max)(this->getWidth(),this->getHeight()),this->getDepth());
|
||||
@ -266,7 +256,7 @@ namespace PolyVox
|
||||
{
|
||||
uint32_t uSizeInBytes = sizeof(SimpleVolume);
|
||||
|
||||
uint32_t uSizeOfBlockInBytes = m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength * sizeof(VoxelType);
|
||||
uint32_t uSizeOfBlockInBytes = m_uNoOfVoxelsPerBlock * sizeof(VoxelType);
|
||||
|
||||
//Memory used by the blocks ( + 1 is for border)
|
||||
uSizeInBytes += uSizeOfBlockInBytes * (m_uNoOfBlocksInVolume + 1);
|
||||
|
@ -21,14 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxImpl/Utility.h"
|
||||
#include "Vector.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> //For memcpy
|
||||
#include <limits>
|
||||
#include <stdexcept> //for std::invalid_argument
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
@ -43,6 +35,12 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
SimpleVolume<VoxelType>::Block::~Block()
|
||||
{
|
||||
delete[] m_tUncompressedData;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
uint16_t SimpleVolume<VoxelType>::Block::getSideLength(void) const
|
||||
{
|
||||
|
@ -21,17 +21,11 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxImpl/Block.h"
|
||||
#include "PolyVoxCore/SimpleVolume.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
|
||||
#define BORDER_LOW(x) ((( x >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != x)
|
||||
#define BORDER_HIGH(x) ((( (x+1) >> this->mVolume->m_uBlockSideLengthPower) << this->mVolume->m_uBlockSideLengthPower) != (x+1))
|
||||
//#define BORDER_LOW(x) (( x % this->mVolume->m_uBlockSideLength) != 0)
|
||||
//#define BORDER_HIGH(x) (( x % this->mVolume->m_uBlockSideLength) != this->mVolume->m_uBlockSideLength - 1)
|
||||
|
||||
#include <limits>
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
@ -159,6 +153,23 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
bool SimpleVolume<VoxelType>::Sampler::setVoxel(VoxelType tValue)
|
||||
{
|
||||
VoxelType* pBorderDataEndPlusOne = this->mVolume->m_pUncompressedBorderData + this->mVolume->m_uNoOfVoxelsPerBlock;
|
||||
|
||||
//Make sure we're not trying to write to the border data
|
||||
if((mCurrentVoxel < this->mVolume->m_pUncompressedBorderData) || (mCurrentVoxel >= pBorderDataEndPlusOne))
|
||||
{
|
||||
*mCurrentVoxel = tValue;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void SimpleVolume<VoxelType>::Sampler::movePositiveX(void)
|
||||
{
|
||||
@ -525,3 +536,6 @@ namespace PolyVox
|
||||
return this->mVolume->getVoxelAt(this->mXPosInVolume+1,this->mYPosInVolume+1,this->mZPosInVolume+1);
|
||||
}
|
||||
}
|
||||
|
||||
#undef BORDER_LOW
|
||||
#undef BORDER_HIGH
|
||||
|
@ -24,11 +24,12 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_SurfaceExtractor_H__
|
||||
#define __PolyVox_SurfaceExtractor_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
|
||||
#include "PolyVoxImpl/MarchingCubesTables.h"
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
|
@ -21,12 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Array.h"
|
||||
#include "PolyVoxCore/MaterialDensityPair.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxImpl/MarchingCubesTables.h"
|
||||
#include "PolyVoxCore/VertexTypes.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType, typename VoxelType>
|
||||
|
@ -24,15 +24,18 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_SurfaceMesh_H__
|
||||
#define __PolyVox_SurfaceMesh_H__
|
||||
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include <memory>
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/VertexTypes.h"
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/VertexTypes.h" //Should probably do away with this on in the future...
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
class LodRecord
|
||||
|
@ -21,12 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <cstdlib>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VertexType>
|
||||
@ -366,7 +360,7 @@ namespace PolyVox
|
||||
template <typename VertexType>
|
||||
void SurfaceMesh<VertexType>::removeUnusedVertices(void)
|
||||
{
|
||||
vector<bool> isVertexUsed(m_vecVertices.size());
|
||||
std::vector<bool> isVertexUsed(m_vecVertices.size());
|
||||
fill(isVertexUsed.begin(), isVertexUsed.end(), false);
|
||||
|
||||
for(uint32_t triCt = 0; triCt < m_vecTriangleIndices.size(); triCt++)
|
||||
@ -376,7 +370,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
int noOfUsedVertices = 0;
|
||||
vector<uint32_t> newPos(m_vecVertices.size());
|
||||
std::vector<uint32_t> newPos(m_vecVertices.size());
|
||||
for(uint32_t vertCt = 0; vertCt < m_vecVertices.size(); vertCt++)
|
||||
{
|
||||
if(isVertexUsed[vertCt])
|
||||
|
@ -24,8 +24,11 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Vector_H__
|
||||
#define __PolyVox_Vector_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
|
||||
namespace PolyVox
|
||||
|
@ -21,11 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
//-------------------------- Constructors, etc ---------------------------------
|
||||
|
@ -25,6 +25,7 @@ freely, subject to the following restrictions:
|
||||
#define __PolyVox_SurfaceVertex_H__
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include <bitset>
|
||||
|
@ -24,11 +24,12 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Volume_H__
|
||||
#define __PolyVox_Volume_H__
|
||||
|
||||
#include "PolyVoxCore/Log.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
@ -47,10 +48,11 @@ namespace PolyVox
|
||||
int32_t getPosX(void) const;
|
||||
int32_t getPosY(void) const;
|
||||
int32_t getPosZ(void) const;
|
||||
inline VoxelType getVoxel(void) const;
|
||||
inline VoxelType getVoxel(void) const;
|
||||
|
||||
void setPosition(const Vector3DInt32& v3dNewPos);
|
||||
void setPosition(int32_t xPos, int32_t yPos, int32_t zPos);
|
||||
inline bool setVoxel(VoxelType tValue);
|
||||
|
||||
void movePositiveX(void);
|
||||
void movePositiveY(void);
|
||||
@ -140,7 +142,7 @@ namespace PolyVox
|
||||
/// Calculates approximatly how many bytes of memory the volume is currently using.
|
||||
uint32_t calculateSizeInBytes(void);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
//The size of the volume
|
||||
Region m_regValidRegion;
|
||||
|
||||
|
@ -21,12 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/Log.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
@ -197,7 +191,6 @@ namespace PolyVox
|
||||
uint32_t Volume<VoxelType>::calculateSizeInBytes(void)
|
||||
{
|
||||
return getWidth() * getHeight() * getDepth() * sizeof(VoxelType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_VolumeResampler_H__
|
||||
#define __PolyVox_VolumeResampler_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include <cmath>
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
@ -38,7 +38,6 @@ namespace PolyVox
|
||||
|
||||
private:
|
||||
void resampleSameSize();
|
||||
void resampleHalfSize();
|
||||
void resampleArbitrary();
|
||||
|
||||
//Source data
|
||||
|
@ -119,7 +119,8 @@ namespace PolyVox
|
||||
uint8_t voxel110Den = voxel110.getDensity();
|
||||
uint8_t voxel111Den = voxel111.getDensity();
|
||||
|
||||
float dummy;
|
||||
//FIXME - should accept all float parameters, but GCC complains?
|
||||
double dummy;
|
||||
sx = modf(sx, &dummy);
|
||||
sy = modf(sy, &dummy);
|
||||
sz = modf(sz, &dummy);
|
||||
|
@ -21,12 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxImpl/Block.h"
|
||||
#include "PolyVoxCore/Volume.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
|
||||
#include <limits>
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
@ -91,6 +85,13 @@ namespace PolyVox
|
||||
mZPosInVolume = zPos;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
template <typename DerivedVolumeType>
|
||||
bool Volume<VoxelType>::Sampler<DerivedVolumeType>::setVoxel(VoxelType tValue)
|
||||
{
|
||||
return mVolume->setVoxelAt(mXPosInVolume, mYPosInVolume, mZPosInVolume, tValue);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
template <typename DerivedVolumeType>
|
||||
void Volume<VoxelType>::Sampler<DerivedVolumeType>::movePositiveX(void)
|
||||
|
@ -24,11 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_VoxelFilters_H__
|
||||
#define __PolyVox_VoxelFilters_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template< template<typename> class VolumeType>
|
||||
|
@ -26,6 +26,7 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits> //For numeric_limits
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
@ -24,7 +24,9 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Block_H__
|
||||
#define __PolyVox_Block_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
@ -44,8 +46,6 @@ namespace PolyVox
|
||||
static uint32_t maxRunlength(void) {return (std::numeric_limits<LengthType>::max)();}
|
||||
};
|
||||
|
||||
//Make Sampler a friend
|
||||
friend class LargeVolume<VoxelType>::Sampler;
|
||||
public:
|
||||
Block(uint16_t uSideLength = 0);
|
||||
|
||||
|
@ -23,7 +23,6 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "PolyVoxImpl/Utility.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> //For memcpy
|
||||
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_RandomUnitVectors_H__
|
||||
#define __PolyVox_RandomUnitVectors_H__
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
namespace PolyVox
|
||||
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_RandomVectors_H__
|
||||
#define __PolyVox_RandomVectors_H__
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
namespace PolyVox
|
||||
|
@ -24,6 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_SubArray_H__
|
||||
#define __PolyVox_SubArray_H__
|
||||
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template <uint32_t noOfDims, typename ElementType> class Array;
|
||||
|
@ -23,8 +23,6 @@ freely, subject to the following restrictions:
|
||||
|
||||
#include "PolyVoxCore/AStarPathfinder.h"
|
||||
|
||||
#include "PolyVoxCore/Material.h"
|
||||
|
||||
using namespace PolyVox;
|
||||
|
||||
namespace PolyVox
|
||||
|
@ -21,12 +21,9 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/GradientEstimators.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/VertexTypes.h"
|
||||
#include "PolyVoxImpl/TypeDef.h"
|
||||
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
#include "PolyVoxCore/GradientEstimators.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -1,7 +1,31 @@
|
||||
#include "PolyVoxCore/MeshDecimator.h"
|
||||
/*******************************************************************************
|
||||
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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/MeshDecimator.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template<>
|
||||
|
@ -100,6 +100,42 @@ namespace PolyVox
|
||||
&& (pos.getZ() >= m_v3dLowerCorner.getZ() + boundary);
|
||||
}
|
||||
|
||||
bool Region::containsPointInX(float pos, float boundary) const
|
||||
{
|
||||
return (pos <= m_v3dUpperCorner.getX() - boundary)
|
||||
&& (pos >= m_v3dLowerCorner.getX() + boundary);
|
||||
}
|
||||
|
||||
bool Region::containsPointInX(int32_t pos, uint8_t boundary) const
|
||||
{
|
||||
return (pos <= m_v3dUpperCorner.getX() - boundary)
|
||||
&& (pos >= m_v3dLowerCorner.getX() + boundary);
|
||||
}
|
||||
|
||||
bool Region::containsPointInY(float pos, float boundary) const
|
||||
{
|
||||
return (pos <= m_v3dUpperCorner.getY() - boundary)
|
||||
&& (pos >= m_v3dLowerCorner.getY() + boundary);
|
||||
}
|
||||
|
||||
bool Region::containsPointInY(int32_t pos, uint8_t boundary) const
|
||||
{
|
||||
return (pos <= m_v3dUpperCorner.getY() - boundary)
|
||||
&& (pos >= m_v3dLowerCorner.getY() + boundary);
|
||||
}
|
||||
|
||||
bool Region::containsPointInZ(float pos, float boundary) const
|
||||
{
|
||||
return (pos <= m_v3dUpperCorner.getZ() - boundary)
|
||||
&& (pos >= m_v3dLowerCorner.getZ() + boundary);
|
||||
}
|
||||
|
||||
bool Region::containsPointInZ(int32_t pos, uint8_t boundary) const
|
||||
{
|
||||
return (pos <= m_v3dUpperCorner.getZ() - boundary)
|
||||
&& (pos >= m_v3dLowerCorner.getZ() + boundary);
|
||||
}
|
||||
|
||||
void Region::cropTo(const Region& other)
|
||||
{
|
||||
m_v3dLowerCorner.setX((std::max)(m_v3dLowerCorner.getX(), other.m_v3dLowerCorner.getX()));
|
||||
|
@ -21,8 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "PolyVoxCore/VertexTypes.h"
|
||||
|
||||
namespace PolyVox
|
||||
|
@ -24,7 +24,8 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_Serialization_H__
|
||||
#define __PolyVox_Serialization_H__
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxImpl/Utility.h"
|
||||
|
||||
#include "PolyVoxCore/Region.h"
|
||||
|
||||
#include <iostream>
|
||||
|
@ -21,8 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxImpl/Utility.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
//Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller.
|
||||
|
@ -24,10 +24,11 @@ freely, subject to the following restrictions:
|
||||
#ifndef __PolyVox_VolumeChangeTracker_H__
|
||||
#define __PolyVox_VolumeChangeTracker_H__
|
||||
|
||||
#include <list>
|
||||
#include "PolyVoxImpl/Utility.h"
|
||||
|
||||
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||
#include "PolyVoxCore/Region.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
|
@ -21,14 +21,6 @@ freely, subject to the following restrictions:
|
||||
distribution.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "PolyVoxCore/GradientEstimators.h"
|
||||
#include "PolyVoxCore/SurfaceMesh.h"
|
||||
#include "PolyVoxImpl/MarchingCubesTables.h"
|
||||
#include "PolyVoxCore/VertexTypes.h"
|
||||
#include "PolyVoxImpl/Utility.h"
|
||||
#include "PolyVoxCore/Vector.h"
|
||||
#include "PolyVoxCore/LargeVolume.h"
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
|
@ -47,6 +47,10 @@ ADD_TEST(ArrayReadWriteTest ${LATEST_TEST} testReadWrite)
|
||||
CREATE_TEST(TestAStarPathfinder.h TestAStarPathfinder.cpp TestAStarPathfinder)
|
||||
ADD_TEST(AStarPathfinderExecuteTest ${LATEST_TEST} testExecute)
|
||||
|
||||
# Low pass filter tests
|
||||
CREATE_TEST(TestLowPassFilter.h TestLowPassFilter.cpp TestLowPassFilter)
|
||||
ADD_TEST(LowPassFilterExecuteTest ${LATEST_TEST} testExecute)
|
||||
|
||||
# LargeVolume tests
|
||||
CREATE_TEST(testvolume.h testvolume.cpp testvolume)
|
||||
ADD_TEST(VolumeSizeTest ${LATEST_TEST} testSize)
|
||||
|
@ -24,6 +24,7 @@ freely, subject to the following restrictions:
|
||||
#include "TestAStarPathfinder.h"
|
||||
|
||||
#include "PolyVoxCore/AStarPathfinder.h"
|
||||
#include "PolyVoxCore/Material.h"
|
||||
#include "PolyVoxCore/RawVolume.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
70
tests/TestLowPassFilter.cpp
Normal file
70
tests/TestLowPassFilter.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2010 Matt 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.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "TestLowPassFilter.h"
|
||||
|
||||
#include "PolyVoxCore/Density.h"
|
||||
#include "PolyVoxCore/LowPassFilter.h"
|
||||
#include "PolyVoxCore/RawVolume.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
using namespace PolyVox;
|
||||
|
||||
void TestLowPassFilter::testExecute()
|
||||
{
|
||||
const int32_t g_uVolumeSideLength = 16;
|
||||
|
||||
Region reg(Vector3DInt32(0,0,0), Vector3DInt32(g_uVolumeSideLength-1, g_uVolumeSideLength-1, g_uVolumeSideLength-1));
|
||||
|
||||
//Create empty volume
|
||||
RawVolume<Density8> volData(reg);
|
||||
|
||||
//Create two solid walls at opposite sides of the volume
|
||||
for (int32_t z = 0; z < g_uVolumeSideLength; z++)
|
||||
{
|
||||
for (int32_t y = 0; y < g_uVolumeSideLength; y++)
|
||||
{
|
||||
for (int32_t x = 0; x < g_uVolumeSideLength; x++)
|
||||
{
|
||||
if(x % 2 == 0)
|
||||
{
|
||||
Density8 voxel(32);
|
||||
volData.setVoxelAt(x, y, z, voxel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RawVolume<Density8> resultVolume(reg);
|
||||
|
||||
LowPassFilter<RawVolume, RawVolume, Density8> pass1(&volData, reg, &resultVolume, reg, 5);
|
||||
|
||||
pass1.executeSAT();
|
||||
|
||||
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(1,2,3).getDensity()) << std::endl; // 7
|
||||
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(10,6,7).getDensity()) << std::endl; // 17
|
||||
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(15,2,12).getDensity()) << std::endl; // 4
|
||||
}
|
||||
|
||||
QTEST_MAIN(TestLowPassFilter)
|
37
tests/TestLowPassFilter.h
Normal file
37
tests/TestLowPassFilter.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*******************************************************************************
|
||||
Copyright (c) 2010 Matt 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_TestLowPassFilter_H__
|
||||
#define __PolyVox_TestLowPassFilter_H__
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class TestLowPassFilter: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testExecute();
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user