From 81ce31432cd45d370ab7ea1d59a5fcfc0ed2ea58 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Sat, 11 Jan 2014 22:23:14 +0000 Subject: [PATCH] Rearrange some things to keep definitions in sensible places --- .../DualContouringSurfaceExtractor.inl | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.inl index e193319e..545ab542 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.inl @@ -160,6 +160,8 @@ namespace PolyVox { static_assert(std::is_signed::value, "Voxel type must be signed"); + const float threshold = 0.0f; + //Timer timer; Timer totalTimer; @@ -167,10 +169,6 @@ namespace PolyVox const auto regionYDimension = region.getDimensionsInVoxels().getY(); const auto regionZDimension = region.getDimensionsInVoxels().getZ(); - const auto cellRegionXDimension = regionXDimension+2; - const auto cellRegionYDimension = regionYDimension+2; - const auto cellRegionZDimension = regionZDimension+2; - const auto gradientRegionXDimension = regionXDimension+2; const auto gradientRegionYDimension = regionYDimension+2; const auto gradientRegionZDimension = regionZDimension+2; @@ -178,19 +176,10 @@ namespace PolyVox std::vector> gradients; gradients.reserve(gradientRegionXDimension * gradientRegionYDimension * gradientRegionZDimension); - std::vector> cells; - cells.reserve(cellRegionXDimension * cellRegionYDimension * cellRegionZDimension); - typename VolumeType::Sampler volSampler{volData}; volSampler.setPosition(region.getLowerCorner() - Vector3DInt32{1,1,1}); volSampler.setWrapMode(WrapMode::Border, -100.0); // -100.0 is well below the threshold - const float threshold = 0.0f; - - SurfaceMesh mesh; - - EdgeData* edges[12]; //Create this now but it will be overwritten for each cell - const auto lowerCornerX = region.getLowerCorner().getX(); const auto lowerCornerY = region.getLowerCorner().getZ(); const auto lowerCornerZ = region.getLowerCorner().getX(); @@ -216,11 +205,8 @@ namespace PolyVox const auto& voxel1nx = volSampler.peekVoxel1nx0py0pz(); const auto& voxel1ny = volSampler.peekVoxel0px1ny0pz(); const auto& voxel1nz = volSampler.peekVoxel0px0py1nz(); - const Vector3DFloat g(voxel1nx - voxel1px, voxel1ny - voxel1py, voxel1nz - voxel1pz); - std::pair data(voxel, g); - - gradients.push_back(data); + gradients.emplace_back(voxel, Vector3DFloat(voxel1nx - voxel1px, voxel1ny - voxel1py, voxel1nz - voxel1pz)); } } } @@ -228,6 +214,13 @@ namespace PolyVox //logTrace() << "Gradients took " << timer.elapsedTimeInMilliSeconds(); //timer.start(); + const auto cellRegionXDimension = regionXDimension+2; + const auto cellRegionYDimension = regionYDimension+2; + const auto cellRegionZDimension = regionZDimension+2; + + std::vector> cells; + cells.reserve(cellRegionXDimension * cellRegionYDimension * cellRegionZDimension); + for(int32_t cellZ = 0; cellZ < cellRegionZDimension; cellZ++) { for(int32_t cellY = 0; cellY < cellRegionYDimension; cellY++) @@ -271,6 +264,10 @@ namespace PolyVox //logTrace() << "Edges took " << timer.elapsedTimeInMilliSeconds(); //timer.start(); + EdgeData* edges[12]; //Create this now but it will be overwritten for each cell + + SurfaceMesh mesh; + for(int32_t cellZ = 0; cellZ < cellRegionZDimension; cellZ++) { for(int32_t cellY = 0; cellY < cellRegionYDimension; cellY++)