[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28919] branches/soc-2008-mxcurioni: New option for detecting feature edges at material boundaries.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Sun May 23 00:21:15 CEST 2010


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

Log Message:
-----------
New option for detecting feature edges at material boundaries.
A checkbox "Material Boundaries" has been added to the Freestyle
options in the Layers tab of the Render buttons.  By enabling the
option, any edge between two faces with different materials is
detected as a feature edge.  In style modules, edges at material
boundaries can be tested with pyNatureUP1D(Nature.MATERIAL_BOUNDARY).

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/python/BPy_Nature.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/freestyle/intern/winged_edge/Nature.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 11:58:21 UTC (rev 28918)
+++ branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py	2010-05-22 22:21:15 UTC (rev 28919)
@@ -185,6 +185,7 @@
             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")
+            col.prop(freestyle, "material_boundaries", text="Material Boundaries")
             col.prop(freestyle, "dkr_epsilon", text="Dkr Epsilon")
 
             col.operator("scene.freestyle_module_add", text="Add Style Module")

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 11:58:21 UTC (rev 28918)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.cpp	2010-05-22 22:21:15 UTC (rev 28919)
@@ -114,6 +114,7 @@
   _ComputeRidges = true;
   _ComputeSteerableViewMap = false;
   _ComputeSuggestive = true;
+  _ComputeMaterialBoundaries = true;
   _sphereRadius = 1.0;
 
 	init_options();
@@ -466,6 +467,7 @@
   edgeDetector.enableOrthographicProjection(proj[3][3] != 0.0);
   edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges);
   edgeDetector.enableSuggestiveContours(_ComputeSuggestive);
+  edgeDetector.enableMaterialBoundaries(_ComputeMaterialBoundaries);
   edgeDetector.setSphereRadius(_sphereRadius);
   edgeDetector.setSuggestiveContourKrDerivativeEpsilon(_suggestiveContourKrDerivativeEpsilon);
   edgeDetector.processShapes(*_winged_edge);
@@ -647,6 +649,7 @@
 bool Controller::getComputeRidgesAndValleysFlag() const {
   return _ComputeRidges;
 }
+
 void Controller::setComputeSuggestiveContoursFlag(bool b){
   _ComputeSuggestive = b;
 }
@@ -654,6 +657,15 @@
 bool Controller::getComputeSuggestiveContoursFlag() const {
   return _ComputeSuggestive;
 }
+
+void Controller::setComputeMaterialBoundariesFlag(bool b){
+  _ComputeMaterialBoundaries = b;
+}
+  
+bool Controller::getComputeMaterialBoundariesFlag() const {
+  return _ComputeMaterialBoundaries;
+}
+
 void Controller::setComputeSteerableViewMapFlag(bool iBool){
   _ComputeSteerableViewMap = iBool;
 }

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 11:58:21 UTC (rev 28918)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/application/Controller.h	2010-05-22 22:21:15 UTC (rev 28919)
@@ -119,6 +119,8 @@
   bool getComputeRidgesAndValleysFlag() const ;
   void setComputeSuggestiveContoursFlag(bool b);
   bool getComputeSuggestiveContoursFlag() const ;
+  void setComputeMaterialBoundariesFlag(bool b);
+  bool getComputeMaterialBoundariesFlag() const ;
 
   void setComputeSteerableViewMapFlag(bool iBool);
   bool getComputeSteerableViewMapFlag() const;
@@ -222,6 +224,7 @@
   bool _EnableQI;
   bool _ComputeRidges;
   bool _ComputeSuggestive;
+  bool _ComputeMaterialBoundaries;
   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 11:58:21 UTC (rev 28918)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp	2010-05-22 22:21:15 UTC (rev 28919)
@@ -162,6 +162,7 @@
 		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 << "Sphere radius : " << controller->getSphereRadius() << endl;

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Nature.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Nature.cpp	2010-05-22 11:58:21 UTC (rev 28918)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_Nature.cpp	2010-05-22 22:21:15 UTC (rev 28919)
@@ -174,6 +174,10 @@
 	PyVarObject_HEAD_INIT(&Nature_Type, 1)
 	{ Nature::SUGGESTIVE_CONTOUR }
 };
+static PyLongObject _Nature_MATERIAL_BOUNDARY = {
+	PyVarObject_HEAD_INIT(&Nature_Type, 1)
+	{ Nature::MATERIAL_BOUNDARY }
+};
 
 #define BPy_Nature_POINT               ((PyObject *)&_Nature_POINT)
 #define BPy_Nature_S_VERTEX            ((PyObject *)&_Nature_S_VERTEX)
@@ -188,6 +192,7 @@
 #define BPy_Nature_RIDGE               ((PyObject *)&_Nature_RIDGE)
 #define BPy_Nature_VALLEY              ((PyObject *)&_Nature_VALLEY)
 #define BPy_Nature_SUGGESTIVE_CONTOUR  ((PyObject *)&_Nature_SUGGESTIVE_CONTOUR)
+#define BPy_Nature_MATERIAL_BOUNDARY   ((PyObject *)&_Nature_MATERIAL_BOUNDARY)
 
 //-------------------MODULE INITIALIZATION--------------------------------
 int Nature_Init( PyObject *module )
@@ -216,6 +221,7 @@
 	PyDict_SetItemString( Nature_Type.tp_dict, "RIDGE", BPy_Nature_RIDGE );
 	PyDict_SetItemString( Nature_Type.tp_dict, "VALLEY", BPy_Nature_VALLEY );
 	PyDict_SetItemString( Nature_Type.tp_dict, "SUGGESTIVE_CONTOUR", BPy_Nature_SUGGESTIVE_CONTOUR );
+	PyDict_SetItemString( Nature_Type.tp_dict, "MATERIAL_BOUNDARY", BPy_Nature_MATERIAL_BOUNDARY );
 
 	return 0;
 }

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 11:58:21 UTC (rev 28918)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.cpp	2010-05-22 22:21:15 UTC (rev 28919)
@@ -64,6 +64,8 @@
     if (progressBarDisplay)
       _pProgressBar->setProgress(_pProgressBar->getProgress() + 1);
     processBorderShape(wxs);
+    if(_computeMaterialBoundaries)
+      processMaterialBoundaryShape(wxs);
     processCreaseShape(wxs);
     if(_computeRidgesAndValleys)
       processRidgesAndValleysShape(wxs);
@@ -679,7 +681,30 @@
     sc_layer->removeSmoothEdge();
 }
 
+// MATERIAL_BOUNDARY
+////////////////////
+void FEdgeXDetector::processMaterialBoundaryShape(WXShape* iWShape) {
 
+  if(!_computeViewIndependant)
+    return;
+  // Make a pass on the edges to detect material boundaries
+  vector<WEdge*>::iterator we, weend;
+  vector<WEdge*> &wedges = iWShape->getEdgeList();
+  for(we=wedges.begin(), weend=wedges.end();
+  we!=weend;
+  ++we){
+    ProcessMaterialBoundaryEdge((WXEdge*)(*we));
+  }
+}
+
+void FEdgeXDetector::ProcessMaterialBoundaryEdge(WXEdge *iEdge)
+{
+  // check whether the edge is a material boundary?
+  if(iEdge->GetaFace()->frs_materialIndex() != iEdge->GetbFace()->frs_materialIndex()){
+    iEdge->AddNature(Nature::MATERIAL_BOUNDARY);
+  }
+}
+
 // Build Smooth edges
 /////////////////////
 void FEdgeXDetector::buildSmoothEdges(WXShape* iShape){

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 11:58:21 UTC (rev 28918)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/view_map/FEdgeXDetector.h	2010-05-22 22:21:15 UTC (rev 28919)
@@ -55,6 +55,7 @@
     _meanEdgeSize = 0;
     _computeRidgesAndValleys = true;
     _computeSuggestiveContours = true;
+	_computeMaterialBoundaries = true;
     _sphereRadius = 1.0;
     _orthographicProjection = false;
     _changes = false;
@@ -103,6 +104,10 @@
     }
   }
 
+  // MATERIAL BOUNDARY
+  virtual void FEdgeXDetector::processMaterialBoundaryShape(WXShape* iWShape);
+  virtual void FEdgeXDetector::ProcessMaterialBoundaryEdge(WXEdge *iEdge);
+
   // EVERYBODY
   virtual void buildSmoothEdges(WXShape* iShape);
 
@@ -111,6 +116,7 @@
   inline void enableOrthographicProjection(bool b) {_orthographicProjection = b;}
   inline void enableRidgesAndValleysFlag(bool b) {_computeRidgesAndValleys = b;}
   inline void enableSuggestiveContours(bool b) {_computeSuggestiveContours = b;}
+  inline void enableMaterialBoundaries(bool b) {_computeMaterialBoundaries = b;}
   /*! Sets the radius of the geodesic sphere around each vertex (for the curvature computation)
    *  \param r
    *    The radius of the sphere expressed as a ratio of the mean edge size
@@ -142,6 +148,7 @@
 
   bool _computeRidgesAndValleys;
   bool _computeSuggestiveContours;
+  bool _computeMaterialBoundaries;
   real _sphereRadius; // expressed as a ratio of the mean edge size
   bool _changes;
 

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/Nature.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/Nature.h	2010-05-22 11:58:21 UTC (rev 28918)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/winged_edge/Nature.h	2010-05-22 22:21:15 UTC (rev 28919)
@@ -69,6 +69,8 @@
   static const EdgeNature VALLEY		= (1 << 4);	// 16
   /*! true for suggestive contours */
   static const EdgeNature SUGGESTIVE_CONTOUR	= (1 << 5);	// 32
+  /*! true for material boundaries */
+  static const EdgeNature MATERIAL_BOUNDARY		= (1 << 6);	// 64
 
 } // end of namespace Nature
 

Modified: branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list