From 09d5624cc8141b02c40498cbe3a521674f80b844 Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Thu, 16 Jan 2014 17:36:13 +0000 Subject: [PATCH] Pass things as const reference to the extractor --- .../include/PolyVoxCore/DualContouringSurfaceExtractor.h | 4 ++-- .../include/PolyVoxCore/DualContouringSurfaceExtractor.inl | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.h index 9ba479dc..f8c9c0c4 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.h @@ -32,8 +32,8 @@ freely, subject to the following restrictions: namespace PolyVox { - template< typename VolumeType> - SurfaceMesh dualContouringSurfaceExtractor(VolumeType* volData, Region region); + template< typename VolumeType, typename ControllerType> + SurfaceMesh dualContouringSurfaceExtractor(VolumeType* volData, const Region& region, const ControllerType& controller); } #include "PolyVoxCore/DualContouringSurfaceExtractor.inl" diff --git a/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.inl index f0ebc50e..02426fc0 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/DualContouringSurfaceExtractor.inl @@ -129,8 +129,7 @@ namespace PolyVox matrix[rows][1] = normal.getY(); matrix[rows][2] = normal.getZ(); - const Vector3DFloat p = vertices[i] - massPoint; - const Vector3DFloat product = normal * p; + const Vector3DFloat product = normal * (vertices[i] - massPoint); vector[rows] = product.getX() + product.getY() + product.getZ(); @@ -141,6 +140,8 @@ namespace PolyVox const auto& vertexPosition = evaluateQEF(matrix, vector, rows) + massPoint; + POLYVOX_ASSERT(vertexPosition.getX() >= -0.01 && vertexPosition.getY() >= -0.01 && vertexPosition.getZ() >= -0.01 && vertexPosition.getX() <= 1.01 && vertexPosition.getY() <= 1.01 && vertexPosition.getZ() <= 1.01, "Vertex is outside unit cell"); //0.01 to give a little leniency + if(cellVertexNormal.lengthSquared() != 0.0f) { cellVertexNormal.normalise(); @@ -156,7 +157,7 @@ namespace PolyVox } template - SurfaceMesh dualContouringSurfaceExtractor(VolumeType* volData, Region region, ControllerType controller) + SurfaceMesh dualContouringSurfaceExtractor(VolumeType* volData, const Region& region, const ControllerType& controller) { static_assert(std::is_signed::value, "Voxel type must be signed");