diff --git a/library/PolyVoxCore/include/SurfaceMesh.h b/library/PolyVoxCore/include/SurfaceMesh.h index 578899b0..da51d008 100644 --- a/library/PolyVoxCore/include/SurfaceMesh.h +++ b/library/PolyVoxCore/include/SurfaceMesh.h @@ -63,7 +63,6 @@ namespace PolyVox void clear(void); const bool isEmpty(void) const; - void smoothPositions(float fAmount, bool bIncludeGeometryEdgeVertices = false); void sumNearbyNormals(bool bNormaliseResult = true); polyvox_shared_ptr< SurfaceMesh > extractSubset(std::set setMaterials); diff --git a/library/PolyVoxCore/include/SurfaceMesh.inl b/library/PolyVoxCore/include/SurfaceMesh.inl index e2433040..556e9128 100644 --- a/library/PolyVoxCore/include/SurfaceMesh.inl +++ b/library/PolyVoxCore/include/SurfaceMesh.inl @@ -146,86 +146,6 @@ namespace PolyVox return (getNoOfVertices() == 0) || (getNoOfIndices() == 0); } - //////////////////////////////////////////////////////////////////////////////// - /// The function works on a per triangle basis without any need for connectivity - /// information. It determines whether a triangle is lying on a flat or curved - /// section of the surface patch by examining the normals - therefore these - /// normals must hve been set to something sensible before this functions is called. - /// \param fAmount A factor controlling how much the vertices move by. Find a good - /// value by experimentation, starting with something small such as 0.1f. - /// \param bIncludeGeometryEdgeVertices Indicates whether vertices on the edge of an - /// SurfaceMesh should be smoothed. This can cause dicontinuities between - /// neighbouring patches. - //////////////////////////////////////////////////////////////////////////////// - template - void SurfaceMesh::smoothPositions(float fAmount, bool bIncludeGeometryEdgeVertices) - { - if(m_vecVertices.size() == 0) //FIXME - I don't think we should need this test, but I have seen crashes otherwise... - { - return; - } - - //This will hold the new positions, and is initialised with the current positions. - std::vector newPositions(m_vecVertices.size()); - for(uint32_t uIndex = 0; uIndex < newPositions.size(); uIndex++) - { - newPositions[uIndex] = m_vecVertices[uIndex].getPosition(); - } - - //Iterate over each triangle - for(vector::iterator iterIndex = m_vecTriangleIndices.begin(); iterIndex != m_vecTriangleIndices.end();) - { - //Get the vertex data for the triangle - PositionMaterialNormal& v0 = m_vecVertices[*iterIndex]; - Vector3DFloat& v0New = newPositions[*iterIndex]; - iterIndex++; - PositionMaterialNormal& v1 = m_vecVertices[*iterIndex]; - Vector3DFloat& v1New = newPositions[*iterIndex]; - iterIndex++; - PositionMaterialNormal& v2 = m_vecVertices[*iterIndex]; - Vector3DFloat& v2New = newPositions[*iterIndex]; - iterIndex++; - - //Find the midpoint - Vector3DFloat v3dMidpoint = (v0.position + v1.position + v2.position) / 3.0f; - - //Vectors from vertex to midpoint - Vector3DFloat v0ToMidpoint = v3dMidpoint - v0.position; - Vector3DFloat v1ToMidpoint = v3dMidpoint - v1.position; - Vector3DFloat v2ToMidpoint = v3dMidpoint - v2.position; - - //Get the vertex normals - Vector3DFloat n0 = v0.getNormal(); - Vector3DFloat n1 = v1.getNormal(); - Vector3DFloat n2 = v2.getNormal(); - - //I don't think these normalisation are necessary... and could be slow. - //Normals should be normalised anyway, and as long as all triangles are - //about the same size the distances to midpoint should be similar too. - //v0ToMidpoint.normalise(); - //v1ToMidpoint.normalise(); - //v2ToMidpoint.normalise(); - //n0.normalise(); - //n1.normalise(); - //n2.normalise(); - - //If the dot product is zero the the normals are perpendicular - //to the triangle, hence the positions do not move. - v0New += (n0 * (n0.dot(v0ToMidpoint)) * fAmount); - v1New += (n1 * (n1.dot(v1ToMidpoint)) * fAmount); - v2New += (n2 * (n2.dot(v2ToMidpoint)) * fAmount); - } - - //Update with the new positions - for(uint32_t uIndex = 0; uIndex < newPositions.size(); uIndex++) - { - if((bIncludeGeometryEdgeVertices) || (m_vecVertices[uIndex].isOnGeometryEdge() == false)) - { - m_vecVertices[uIndex].setPosition(newPositions[uIndex]); - } - } - } - //////////////////////////////////////////////////////////////////////////////// /// This function can help improve the visual appearance of a surface patch by /// smoothing normals with other nearby normals. It iterates over each triangle diff --git a/library/PolyVoxCore/include/VertexTypes.h b/library/PolyVoxCore/include/VertexTypes.h index 48f7cda0..5820e967 100644 --- a/library/PolyVoxCore/include/VertexTypes.h +++ b/library/PolyVoxCore/include/VertexTypes.h @@ -32,7 +32,11 @@ freely, subject to the following restrictions: namespace PolyVox { +#ifdef SWIG + class PositionMaterial +#else class POLYVOXCORE_API PositionMaterial +#endif { public: PositionMaterial(); @@ -49,7 +53,11 @@ namespace PolyVox float material; }; +#ifdef SWIG + class PositionMaterialNormal +#else class POLYVOXCORE_API PositionMaterialNormal +#endif { public: PositionMaterialNormal();