diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-04-13 02:17:15 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-04-13 02:17:15 +0400 |
commit | 4ee5dcf7ab6fcc044be478e34538a4564e0e9456 (patch) | |
tree | 1201a3f25484032476c71a76d13d808fd665698b /source/blender/freestyle/intern/view_map | |
parent | 3df52d4e19790df7a7a9c80e37c5724613427b86 (diff) |
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.)
Diffstat (limited to 'source/blender/freestyle/intern/view_map')
-rwxr-xr-x | source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
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<WVertex*>& wvertices = iWShape->getVertexList(); for(vector<WVertex*>::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<WFace*>& wfaces = iShape->GetFaceList(); @@ -722,7 +724,21 @@ void FEdgeXDetector::buildSmoothEdges(WXShape* iShape){ for(vector<WXFaceLayer*>::iterator wxfl = faceLayers.begin(), wxflend=faceLayers.end(); wxfl!=wxflend; ++wxfl){ - (*wxfl)->BuildSmoothEdge(); + if ((*wxfl)->BuildSmoothEdge()) + hasSmoothEdges = true; + } + } + + if (hasSmoothEdges && !_computeRidgesAndValleys && !_computeSuggestiveContours) { + vector<WVertex*>& wvertices = iShape->getVertexList(); + for(vector<WVertex*>::iterator wv=wvertices.begin(), wvend=wvertices.end(); + wv!=wvend; + ++wv){ + // Compute curvatures + WXVertex * wxv = dynamic_cast<WXVertex*>(*wv); + computeCurvatures(wxv); } + _meanK1 /= (real)(_nPoints); + _meanKr /= (real)(_nPoints); } } |