diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-05-23 03:56:42 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2010-05-23 03:56:42 +0400 |
commit | 7d377478c394931f1226fbbacf96e095daf18c5d (patch) | |
tree | d5fae412ade82e42bee7415d33279afc3d0b0c7e /source/blender/freestyle | |
parent | b85985535dd420e50cc906bd6e7dd352cc2b8b97 (diff) |
New option to specify the angular threshold for detecting crease edges.
An entry "Crease Angle" has been added to the Layers tab of the Render
buttons, to allow users to specify an angle (between 0 and 180) used for
crease edge detection. An edge is considered a crease edge if the angle
between two faces sharing the edge is smaller than the threshold. The
default value is 134.43 degrees (for backward compatibility). Be aware
that a larger threshold leads to a larger number of feature edges and
thus a larger memory consumption.
Diffstat (limited to 'source/blender/freestyle')
5 files changed, 28 insertions, 1 deletions
diff --git a/source/blender/freestyle/intern/application/Controller.cpp b/source/blender/freestyle/intern/application/Controller.cpp index 707f4e7118c..5cf1b40a344 100755 --- a/source/blender/freestyle/intern/application/Controller.cpp +++ b/source/blender/freestyle/intern/application/Controller.cpp @@ -116,6 +116,7 @@ Controller::Controller() _ComputeSuggestive = true; _ComputeMaterialBoundaries = true; _sphereRadius = 1.0; + _creaseAngle = 134.43; init_options(); } @@ -468,6 +469,7 @@ void Controller::ComputeViewMap() edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges); edgeDetector.enableSuggestiveContours(_ComputeSuggestive); edgeDetector.enableMaterialBoundaries(_ComputeMaterialBoundaries); + edgeDetector.setCreaseAngle(_creaseAngle); edgeDetector.setSphereRadius(_sphereRadius); edgeDetector.setSuggestiveContourKrDerivativeEpsilon(_suggestiveContourKrDerivativeEpsilon); edgeDetector.processShapes(*_winged_edge); diff --git a/source/blender/freestyle/intern/application/Controller.h b/source/blender/freestyle/intern/application/Controller.h index 739e49c16ca..367b57bf6c3 100755 --- a/source/blender/freestyle/intern/application/Controller.h +++ b/source/blender/freestyle/intern/application/Controller.h @@ -124,6 +124,8 @@ public: void setComputeSteerableViewMapFlag(bool iBool); bool getComputeSteerableViewMapFlag() const; + void setCreaseAngle(real angle){_creaseAngle=angle;} + real getCreaseAngle() const {return _creaseAngle;} void setSphereRadius(real s){_sphereRadius=s;} real getSphereRadius() const {return _sphereRadius;} void setSuggestiveContourKrDerivativeEpsilon(real dkr){_suggestiveContourKrDerivativeEpsilon=dkr;} @@ -225,6 +227,7 @@ private: bool _ComputeRidges; bool _ComputeSuggestive; bool _ComputeMaterialBoundaries; + real _creaseAngle; real _sphereRadius; real _suggestiveContourKrDerivativeEpsilon; diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 3aadbbb8deb..5af350e3ad0 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -159,12 +159,14 @@ extern "C" { cout << endl; // set parameters + controller->setCreaseAngle( config->crease_angle ); controller->setSphereRadius( config->sphere_radius ); controller->setComputeRidgesAndValleysFlag( (config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false); controller->setComputeSuggestiveContoursFlag( (config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false); controller->setComputeMaterialBoundariesFlag( (config->flags & FREESTYLE_MATERIAL_BOUNDARIES_FLAG) ? true : false); controller->setSuggestiveContourKrDerivativeEpsilon( config->dkr_epsilon ) ; + cout << "Crease angle : " << controller->getCreaseAngle() << endl; cout << "Sphere radius : " << controller->getSphereRadius() << endl; cout << "Redges and valleys : " << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled") << endl; cout << "Suggestive contours : " << (controller->getComputeSuggestiveContoursFlag() ? "enabled" : "disabled") << endl; @@ -312,6 +314,7 @@ extern "C" { config->flags = 0; config->sphere_radius = 1.0; config->dkr_epsilon = 0.001; + config->crease_angle = 134.43; } void FRS_free_freestyle_config( SceneRenderLayer* srl ) diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp index ecab4fc413c..aca7334d045 100755 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp @@ -370,7 +370,7 @@ void FEdgeXDetector::ProcessCreaseEdge(WXEdge *iEdge) WXFace * fB = (WXFace *)iEdge->GetaOEdge()->GetbFace(); WVertex * aVertex = iEdge->GetaVertex(); - if((fA->GetVertexNormal(aVertex) * fB->GetVertexNormal(aVertex)) <= 0.7) // angle of 140 degrees + if((fA->GetVertexNormal(aVertex) * fB->GetVertexNormal(aVertex)) <= _creaseAngle) iEdge->AddNature(Nature::CREASE); } diff --git a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h index e0d76b5b0f9..14a835d9cd3 100755 --- a/source/blender/freestyle/intern/view_map/FEdgeXDetector.h +++ b/source/blender/freestyle/intern/view_map/FEdgeXDetector.h @@ -60,6 +60,7 @@ public: _orthographicProjection = false; _changes = false; _kr_derivative_epsilon = 0.0; + _creaseAngle = 0.7; // angle of 134.43 degrees } virtual ~FEdgeXDetector() {} @@ -79,6 +80,23 @@ public: // CREASE virtual void processCreaseShape(WXShape* iShape); virtual void ProcessCreaseEdge(WXEdge *iEdge); + /*! Sets the minimum angle for detecting crease edges + * \param angle + * The angular threshold in degrees (between 0 and 180) for detecting crease + * edges. An edge is considered a crease edge if the angle between two faces + * sharing the edge is smaller than the given threshold. + */ + inline void setCreaseAngle(real angle) { + if (angle < 0.0) + angle = 0.0; + else if (angle > 180.0) + angle = 180.0; + angle = cos(M_PI * (180.0 - angle) / 180.0); + if (angle != _creaseAngle){ + _creaseAngle = angle; + _changes = true; + } + } // BORDER virtual void processBorderShape(WXShape* iShape); @@ -150,6 +168,7 @@ protected: bool _computeSuggestiveContours; bool _computeMaterialBoundaries; real _sphereRadius; // expressed as a ratio of the mean edge size + real _creaseAngle; // [-1, 1] compared with the inner product of face normals bool _changes; real _kr_derivative_epsilon; |