From 4ee5dcf7ab6fcc044be478e34538a4564e0e9456 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Tue, 12 Apr 2011 22:17:15 +0000 Subject: Fix for a crash in silhouette edge detection. The problem was reported by macouno. Thanks! The crash was caused by a lack of curvature information required for smooth edges. Now the curvature information is computed if and only if there are smooth edges. This leads to a minor performance improvement, because in the past the curvature information was always computed when the Face Smoothness was enabled. (To be precise, the above description is true when both the Ridges and Valleys and Suggestive Contours options are disabled. If they are enabled, the curvature information is always computed because it is necessary for the determination of these edge natures.) --- .../freestyle/intern/view_map/FEdgeXDetector.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp') diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp index 65fe146aec5..93e3354cb6a 100755 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp @@ -114,7 +114,7 @@ void FEdgeXDetector::preProcessShape(WXShape* iWShape) { preProcessFace((WXFace*)(*f)); } - if(_faceSmoothness || _computeRidgesAndValleys || _computeSuggestiveContours ) { + if(_computeRidgesAndValleys || _computeSuggestiveContours ) { vector& wvertices = iWShape->getVertexList(); for(vector::iterator wv=wvertices.begin(), wvend=wvertices.end(); wv!=wvend; @@ -711,6 +711,8 @@ void FEdgeXDetector::ProcessMaterialBoundaryEdge(WXEdge *iEdge) // Build Smooth edges ///////////////////// void FEdgeXDetector::buildSmoothEdges(WXShape* iShape){ + bool hasSmoothEdges = false; + // Make a last pass to build smooth edges from the previous stored values: //-------------------------------------------------------------------------- vector& wfaces = iShape->GetFaceList(); @@ -722,7 +724,21 @@ void FEdgeXDetector::buildSmoothEdges(WXShape* iShape){ for(vector::iterator wxfl = faceLayers.begin(), wxflend=faceLayers.end(); wxfl!=wxflend; ++wxfl){ - (*wxfl)->BuildSmoothEdge(); + if ((*wxfl)->BuildSmoothEdge()) + hasSmoothEdges = true; + } + } + + if (hasSmoothEdges && !_computeRidgesAndValleys && !_computeSuggestiveContours) { + vector& wvertices = iShape->getVertexList(); + for(vector::iterator wv=wvertices.begin(), wvend=wvertices.end(); + wv!=wvend; + ++wv){ + // Compute curvatures + WXVertex * wxv = dynamic_cast(*wv); + computeCurvatures(wxv); } + _meanK1 /= (real)(_nPoints); + _meanKr /= (real)(_nPoints); } } -- cgit v1.2.3