Started reintegrating Region class.
This commit is contained in:
parent
05f709482a
commit
f15491ec02
@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
void generateRoughMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, boost::uint16_t regionX, boost::uint16_t regionY, boost::uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch);
|
void generateRoughMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch);
|
||||||
Vector3DFloat computeNormal(BlockVolume<boost::uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
Vector3DFloat computeNormal(BlockVolume<boost::uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
||||||
|
|
||||||
void generateSmoothMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, boost::uint16_t regionX, boost::uint16_t regionY, boost::uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch);
|
void generateSmoothMeshDataForRegion(BlockVolume<boost::uint8_t>* volumeData, boost::uint16_t regionX, boost::uint16_t regionY, boost::uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch);
|
||||||
|
@ -4,21 +4,27 @@
|
|||||||
#include "GradientEstimators.h"
|
#include "GradientEstimators.h"
|
||||||
#include "IndexedSurfacePatch.h"
|
#include "IndexedSurfacePatch.h"
|
||||||
#include "MarchingCubesTables.h"
|
#include "MarchingCubesTables.h"
|
||||||
|
#include "Region.h"
|
||||||
#include "VolumeIterator.h"
|
#include "VolumeIterator.h"
|
||||||
|
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
void generateRoughMeshDataForRegion(BlockVolume<uint8_t>* volumeData, uint16_t regionX, uint16_t regionY, uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch)
|
void generateRoughMeshDataForRegion(BlockVolume<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch)
|
||||||
{
|
{
|
||||||
//First and last voxels in the region
|
//When generating the mesh for a region we actually look one voxel outside it in the
|
||||||
const uint16_t firstX = regionX * POLYVOX_REGION_SIDE_LENGTH;
|
// back, bottom, right direction. Protect against access violations by cropping region here
|
||||||
const uint16_t firstY = regionY * POLYVOX_REGION_SIDE_LENGTH;
|
Region regVolume = volumeData->getEnclosingRegion();
|
||||||
const uint16_t firstZ = regionZ * POLYVOX_REGION_SIDE_LENGTH;
|
regVolume.setUpperCorner(regVolume.getUpperCorner() - Vector3DInt32(1,1,1));
|
||||||
const uint16_t lastX = (std::min)(firstX + POLYVOX_REGION_SIDE_LENGTH-1,volumeData->getSideLength()-2);
|
region.cropTo(regVolume);
|
||||||
const uint16_t lastY = (std::min)(firstY + POLYVOX_REGION_SIDE_LENGTH-1,volumeData->getSideLength()-2);
|
|
||||||
const uint16_t lastZ = (std::min)(firstZ + POLYVOX_REGION_SIDE_LENGTH-1,volumeData->getSideLength()-2);
|
const uint16_t firstX = region.getLowerCorner().x();
|
||||||
|
const uint16_t firstY = region.getLowerCorner().y();
|
||||||
|
const uint16_t firstZ = region.getLowerCorner().z();
|
||||||
|
const uint16_t lastX = region.getUpperCorner().x();
|
||||||
|
const uint16_t lastY = region.getUpperCorner().y();
|
||||||
|
const uint16_t lastZ = region.getUpperCorner().z();
|
||||||
|
|
||||||
//Offset from lower block corner
|
//Offset from lower block corner
|
||||||
const Vector3DFloat offset(firstX,firstY,firstZ);
|
const Vector3DFloat offset(firstX,firstY,firstZ);
|
||||||
|
@ -83,7 +83,14 @@ namespace PolyVox
|
|||||||
regionGeometry.m_patchMultiMaterial = new IndexedSurfacePatch(true);
|
regionGeometry.m_patchMultiMaterial = new IndexedSurfacePatch(true);
|
||||||
regionGeometry.m_v3dRegionPosition = Vector3DInt32(regionX, regionY, regionZ);
|
regionGeometry.m_v3dRegionPosition = Vector3DInt32(regionX, regionY, regionZ);
|
||||||
|
|
||||||
generateRoughMeshDataForRegion(volumeData, regionX,regionY,regionZ, regionGeometry.m_patchSingleMaterial, regionGeometry.m_patchMultiMaterial);
|
const uint16_t firstX = regionX * POLYVOX_REGION_SIDE_LENGTH;
|
||||||
|
const uint16_t firstY = regionY * POLYVOX_REGION_SIDE_LENGTH;
|
||||||
|
const uint16_t firstZ = regionZ * POLYVOX_REGION_SIDE_LENGTH;
|
||||||
|
const uint16_t lastX = firstX + POLYVOX_REGION_SIDE_LENGTH-1;
|
||||||
|
const uint16_t lastY = firstY + POLYVOX_REGION_SIDE_LENGTH-1;
|
||||||
|
const uint16_t lastZ = firstZ + POLYVOX_REGION_SIDE_LENGTH-1;
|
||||||
|
|
||||||
|
generateRoughMeshDataForRegion(volumeData, Region(Vector3DInt32(firstX, firstY, firstZ), Vector3DInt32(lastX, lastY, lastZ)), regionGeometry.m_patchSingleMaterial, regionGeometry.m_patchMultiMaterial);
|
||||||
|
|
||||||
regionGeometry.m_bContainsSingleMaterialPatch = regionGeometry.m_patchSingleMaterial->getVertices().size() > 0;
|
regionGeometry.m_bContainsSingleMaterialPatch = regionGeometry.m_patchSingleMaterial->getVertices().size() > 0;
|
||||||
regionGeometry.m_bContainsMultiMaterialPatch = regionGeometry.m_patchMultiMaterial->getVertices().size() > 0;
|
regionGeometry.m_bContainsMultiMaterialPatch = regionGeometry.m_patchMultiMaterial->getVertices().size() > 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user