Moved some stuff from VolumeChangeTracker to SurfaceExtractors.
This commit is contained in:
parent
29d1cd8ad1
commit
22fd38b255
@ -45,7 +45,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
BlockVolume& operator=(const BlockVolume& rhs);
|
BlockVolume& operator=(const BlockVolume& rhs);
|
||||||
|
|
||||||
Region getEnclosingRegion(void);
|
Region getEnclosingRegion(void) const;
|
||||||
boost::uint16_t getSideLength(void) const;
|
boost::uint16_t getSideLength(void) const;
|
||||||
VoxelType getVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos) const;
|
VoxelType getVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos) const;
|
||||||
VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const;
|
VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const;
|
||||||
|
@ -121,7 +121,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
#pragma region Getters
|
#pragma region Getters
|
||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
Region BlockVolume<VoxelType>::getEnclosingRegion(void)
|
Region BlockVolume<VoxelType>::getEnclosingRegion(void) const
|
||||||
{
|
{
|
||||||
return Region(Vector3DInt32(0,0,0), Vector3DInt32(m_uSideLength-1,m_uSideLength-1,m_uSideLength-1));
|
return Region(Vector3DInt32(0,0,0), Vector3DInt32(m_uSideLength-1,m_uSideLength-1,m_uSideLength-1));
|
||||||
}
|
}
|
||||||
|
@ -24,17 +24,22 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
|
|
||||||
#pragma region Headers
|
#pragma region Headers
|
||||||
#include "PolyVoxForwardDeclarations.h"
|
#include "PolyVoxForwardDeclarations.h"
|
||||||
|
#include "TypeDef.h"
|
||||||
|
|
||||||
#include "boost/cstdint.hpp"
|
#include "boost/cstdint.hpp"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
void generateRoughMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch);
|
POLYVOX_API std::list<RegionGeometry> getChangedRegionGeometry(VolumeChangeTracker& volume);
|
||||||
Vector3DFloat computeNormal(BlockVolume<boost::uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
|
||||||
|
|
||||||
void generateSmoothMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch);
|
POLYVOX_API void generateRoughMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch);
|
||||||
Vector3DFloat computeSmoothNormal(BlockVolume<boost::uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
POLYVOX_API Vector3DFloat computeNormal(BlockVolume<boost::uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
||||||
|
|
||||||
|
POLYVOX_API void generateSmoothMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch);
|
||||||
|
POLYVOX_API Vector3DFloat computeSmoothNormal(BlockVolume<boost::uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -42,11 +42,10 @@ namespace PolyVox
|
|||||||
~VolumeChangeTracker();
|
~VolumeChangeTracker();
|
||||||
|
|
||||||
//Getters
|
//Getters
|
||||||
std::list<RegionGeometry> getChangedRegionGeometry(void);
|
void getChangedRegions(std::list<Region>& listToFill) const;
|
||||||
void getChangedRegions(std::list<Region>& listToFill);
|
Region getEnclosingRegion(void) const;
|
||||||
Region getEnclosingRegion(void);
|
|
||||||
boost::uint16_t getSideLength(void);
|
boost::uint16_t getSideLength(void);
|
||||||
const BlockVolume<boost::uint8_t>* getVolumeData(void) const;
|
BlockVolume<boost::uint8_t>* getVolumeData(void) const;
|
||||||
boost::uint8_t getVoxelAt(const Vector3DUint16& pos);
|
boost::uint8_t getVoxelAt(const Vector3DUint16& pos);
|
||||||
boost::uint8_t getVoxelAt(boost::uint16_t uX, boost::uint16_t uY, boost::uint16_t uZ);
|
boost::uint8_t getVoxelAt(boost::uint16_t uX, boost::uint16_t uY, boost::uint16_t uZ);
|
||||||
|
|
||||||
|
@ -5,12 +5,40 @@
|
|||||||
#include "IndexedSurfacePatch.h"
|
#include "IndexedSurfacePatch.h"
|
||||||
#include "MarchingCubesTables.h"
|
#include "MarchingCubesTables.h"
|
||||||
#include "Region.h"
|
#include "Region.h"
|
||||||
|
#include "RegionGeometry.h"
|
||||||
|
#include "VolumeChangeTracker.h"
|
||||||
#include "VolumeIterator.h"
|
#include "VolumeIterator.h"
|
||||||
|
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
|
std::list<RegionGeometry> getChangedRegionGeometry(VolumeChangeTracker& volume)
|
||||||
|
{
|
||||||
|
std::list<Region> listChangedRegions;
|
||||||
|
volume.getChangedRegions(listChangedRegions);
|
||||||
|
|
||||||
|
std::list<RegionGeometry> listChangedRegionGeometry;
|
||||||
|
for(std::list<Region>::const_iterator iterChangedRegions = listChangedRegions.begin(); iterChangedRegions != listChangedRegions.end(); ++iterChangedRegions)
|
||||||
|
{
|
||||||
|
//Generate the surface
|
||||||
|
RegionGeometry regionGeometry;
|
||||||
|
regionGeometry.m_patchSingleMaterial = new IndexedSurfacePatch(false);
|
||||||
|
regionGeometry.m_patchMultiMaterial = new IndexedSurfacePatch(true);
|
||||||
|
regionGeometry.m_v3dRegionPosition = iterChangedRegions->getLowerCorner();
|
||||||
|
|
||||||
|
generateRoughMeshDataForRegion(volume.getVolumeData(), *iterChangedRegions, regionGeometry.m_patchSingleMaterial, regionGeometry.m_patchMultiMaterial);
|
||||||
|
|
||||||
|
regionGeometry.m_bContainsSingleMaterialPatch = regionGeometry.m_patchSingleMaterial->getVertices().size() > 0;
|
||||||
|
regionGeometry.m_bContainsMultiMaterialPatch = regionGeometry.m_patchMultiMaterial->getVertices().size() > 0;
|
||||||
|
regionGeometry.m_bIsEmpty = ((regionGeometry.m_patchSingleMaterial->getVertices().size() == 0) && (regionGeometry.m_patchMultiMaterial->getIndices().size() == 0));
|
||||||
|
|
||||||
|
listChangedRegionGeometry.push_back(regionGeometry);
|
||||||
|
}
|
||||||
|
|
||||||
|
return listChangedRegionGeometry;
|
||||||
|
}
|
||||||
|
|
||||||
void generateRoughMeshDataForRegion(BlockVolume<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch)
|
void generateRoughMeshDataForRegion(BlockVolume<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch)
|
||||||
{
|
{
|
||||||
//When generating the mesh for a region we actually look one voxel outside it in the
|
//When generating the mesh for a region we actually look one voxel outside it in the
|
||||||
|
@ -56,33 +56,9 @@ namespace PolyVox
|
|||||||
volRegionUpToDate = new LinearVolume<bool>(PolyVox::logBase2(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS));
|
volRegionUpToDate = new LinearVolume<bool>(PolyVox::logBase2(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<RegionGeometry> VolumeChangeTracker::getChangedRegionGeometry(void)
|
|
||||||
{
|
|
||||||
std::list<Region> listChangedRegions;
|
|
||||||
getChangedRegions(listChangedRegions);
|
|
||||||
|
|
||||||
std::list<RegionGeometry> listChangedRegionGeometry;
|
void VolumeChangeTracker::getChangedRegions(std::list<Region>& listToFill) const
|
||||||
for(std::list<Region>::const_iterator iterChangedRegions = listChangedRegions.begin(); iterChangedRegions != listChangedRegions.end(); ++iterChangedRegions)
|
|
||||||
{
|
|
||||||
//Generate the surface
|
|
||||||
RegionGeometry regionGeometry;
|
|
||||||
regionGeometry.m_patchSingleMaterial = new IndexedSurfacePatch(false);
|
|
||||||
regionGeometry.m_patchMultiMaterial = new IndexedSurfacePatch(true);
|
|
||||||
regionGeometry.m_v3dRegionPosition = iterChangedRegions->getLowerCorner();
|
|
||||||
|
|
||||||
generateRoughMeshDataForRegion(volumeData, *iterChangedRegions, regionGeometry.m_patchSingleMaterial, regionGeometry.m_patchMultiMaterial);
|
|
||||||
|
|
||||||
regionGeometry.m_bContainsSingleMaterialPatch = regionGeometry.m_patchSingleMaterial->getVertices().size() > 0;
|
|
||||||
regionGeometry.m_bContainsMultiMaterialPatch = regionGeometry.m_patchMultiMaterial->getVertices().size() > 0;
|
|
||||||
regionGeometry.m_bIsEmpty = ((regionGeometry.m_patchSingleMaterial->getVertices().size() == 0) && (regionGeometry.m_patchMultiMaterial->getIndices().size() == 0));
|
|
||||||
|
|
||||||
listChangedRegionGeometry.push_back(regionGeometry);
|
|
||||||
}
|
|
||||||
|
|
||||||
return listChangedRegionGeometry;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VolumeChangeTracker::getChangedRegions(std::list<Region>& listToFill)
|
|
||||||
{
|
{
|
||||||
//Clear the list
|
//Clear the list
|
||||||
listToFill.clear();
|
listToFill.clear();
|
||||||
@ -127,35 +103,12 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void VolumeChangeTracker::markRegionChanged(uint16_t firstX, uint16_t firstY, uint16_t firstZ, uint16_t lastX, uint16_t lastY, uint16_t lastZ)
|
|
||||||
{
|
|
||||||
const uint16_t firstRegionX = firstX >> POLYVOX_REGION_SIDE_LENGTH_POWER;
|
|
||||||
const uint16_t firstRegionY = firstY >> POLYVOX_REGION_SIDE_LENGTH_POWER;
|
|
||||||
const uint16_t firstRegionZ = firstZ >> POLYVOX_REGION_SIDE_LENGTH_POWER;
|
|
||||||
|
|
||||||
const uint16_t lastRegionX = lastX >> POLYVOX_REGION_SIDE_LENGTH_POWER;
|
|
||||||
const uint16_t lastRegionY = lastY >> POLYVOX_REGION_SIDE_LENGTH_POWER;
|
|
||||||
const uint16_t lastRegionZ = lastZ >> POLYVOX_REGION_SIDE_LENGTH_POWER;
|
|
||||||
|
|
||||||
for(uint16_t zCt = firstRegionZ; zCt <= lastRegionZ; zCt++)
|
|
||||||
{
|
|
||||||
for(uint16_t yCt = firstRegionY; yCt <= lastRegionY; yCt++)
|
|
||||||
{
|
|
||||||
for(uint16_t xCt = firstRegionX; xCt <= lastRegionX; xCt++)
|
|
||||||
{
|
|
||||||
//surfaceUpToDate[xCt][yCt][zCt] = false;
|
|
||||||
volRegionUpToDate->setVoxelAt(xCt,yCt,zCt,false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
uint16_t VolumeChangeTracker::getSideLength(void)
|
uint16_t VolumeChangeTracker::getSideLength(void)
|
||||||
{
|
{
|
||||||
return volumeData->getSideLength();
|
return volumeData->getSideLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
Region VolumeChangeTracker::getEnclosingRegion(void)
|
Region VolumeChangeTracker::getEnclosingRegion(void) const
|
||||||
{
|
{
|
||||||
return volumeData->getEnclosingRegion();
|
return volumeData->getEnclosingRegion();
|
||||||
}
|
}
|
||||||
@ -176,7 +129,7 @@ namespace PolyVox
|
|||||||
return volIter.getVoxel();
|
return volIter.getVoxel();
|
||||||
}
|
}
|
||||||
|
|
||||||
const BlockVolume<boost::uint8_t>* VolumeChangeTracker::getVolumeData(void) const
|
BlockVolume<boost::uint8_t>* VolumeChangeTracker::getVolumeData(void) const
|
||||||
{
|
{
|
||||||
return volumeData;
|
return volumeData;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user