[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28920] branches/soc-2008-mxcurioni: New option to specify the angular threshold for detecting crease edges.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sun May 23 01:56:42 CEST 2010


Revision: 28920
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28920
Author:   kjym3
Date:     2010-05-23 01:56:42 +0200 (Sun, 23 May 2010)

Log Message:
-----------
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.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.h
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h
    branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c

Modified: branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py	2010-05-22 22:21:15 UTC (rev 28919)
+++ branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py	2010-05-22 23:56:42 UTC (rev 28920)
@@ -182,6 +182,7 @@
             col = split.column()
             col.label(text="Freestyle:")
             freestyle = rl.freestyle_settings
+            col.prop(freestyle, "crease_angle", text="Crease Angle")
             col.prop(freestyle, "sphere_radius", text="Sphere Radius")
             col.prop(freestyle, "ridges_and_valleys", text="Ridges and Valleys")
             col.prop(freestyle, "suggestive_contours", text="Suggestive Contours")

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.cpp	2010-05-22 22:21:15 UTC (rev 28919)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.cpp	2010-05-22 23:56:42 UTC (rev 28920)
@@ -116,6 +116,7 @@
   _ComputeSuggestive = true;
   _ComputeMaterialBoundaries = true;
   _sphereRadius = 1.0;
+  _creaseAngle = 134.43;
 
 	init_options();
 }
@@ -468,6 +469,7 @@
   edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges);
   edgeDetector.enableSuggestiveContours(_ComputeSuggestive);
   edgeDetector.enableMaterialBoundaries(_ComputeMaterialBoundaries);
+  edgeDetector.setCreaseAngle(_creaseAngle);
   edgeDetector.setSphereRadius(_sphereRadius);
   edgeDetector.setSuggestiveContourKrDerivativeEpsilon(_suggestiveContourKrDerivativeEpsilon);
   edgeDetector.processShapes(*_winged_edge);

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.h	2010-05-22 22:21:15 UTC (rev 28919)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.h	2010-05-22 23:56:42 UTC (rev 28920)
@@ -124,6 +124,8 @@
 
   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 @@
   bool _ComputeRidges;
   bool _ComputeSuggestive;
   bool _ComputeMaterialBoundaries;
+  real _creaseAngle;
   real _sphereRadius;
   real _suggestiveContourKrDerivativeEpsilon;
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2010-05-22 22:21:15 UTC (rev 28919)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2010-05-22 23:56:42 UTC (rev 28920)
@@ -159,12 +159,14 @@
 		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 @@
 		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 )

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp	2010-05-22 22:21:15 UTC (rev 28919)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp	2010-05-22 23:56:42 UTC (rev 28920)
@@ -370,7 +370,7 @@
   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);
 }
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.h	2010-05-22 22:21:15 UTC (rev 28919)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.h	2010-05-22 23:56:42 UTC (rev 28920)
@@ -60,6 +60,7 @@
     _orthographicProjection = false;
     _changes = false;
     _kr_derivative_epsilon = 0.0;
+	_creaseAngle = 0.7; // angle of 134.43 degrees
   }
   virtual ~FEdgeXDetector() {}
 
@@ -79,6 +80,23 @@
   // 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 @@
   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;

Modified: branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h	2010-05-22 22:21:15 UTC (rev 28919)
+++ branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h	2010-05-22 23:56:42 UTC (rev 28920)
@@ -22,7 +22,7 @@
 	int flags;
 	float sphere_radius;
 	float dkr_epsilon;
-	int pad;
+	float crease_angle;
 	
 } FreestyleConfig;
 

Modified: branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c	2010-05-22 22:21:15 UTC (rev 28919)
+++ branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c	2010-05-22 23:56:42 UTC (rev 28920)
@@ -1527,6 +1527,12 @@
 	RNA_def_property_range(prop, 0.0, 1000.0);
 	RNA_def_property_ui_text(prop, "Dkr Epsilon", "*TBD*");
 	RNA_def_property_update(prop, NC_SCENE, NULL);
+
+	prop= RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "crease_angle");
+	RNA_def_property_range(prop, 0.0, 180.0);
+	RNA_def_property_ui_text(prop, "Crease Angle", "Angular threshold in degrees (between 0 and 180) for detecting crease edges.");
+	RNA_def_property_update(prop, NC_SCENE, NULL);
 }
 
 static void rna_def_scene_game_data(BlenderRNA *brna)





More information about the Bf-blender-cvs mailing list