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).
This commit is contained in:
@@ -185,6 +185,7 @@ class RENDER_PT_layers(RenderButtonsPanel):
|
|||||||
col.prop(freestyle, "sphere_radius", text="Sphere Radius")
|
col.prop(freestyle, "sphere_radius", text="Sphere Radius")
|
||||||
col.prop(freestyle, "ridges_and_valleys", text="Ridges and Valleys")
|
col.prop(freestyle, "ridges_and_valleys", text="Ridges and Valleys")
|
||||||
col.prop(freestyle, "suggestive_contours", text="Suggestive Contours")
|
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.prop(freestyle, "dkr_epsilon", text="Dkr Epsilon")
|
||||||
|
|
||||||
col.operator("scene.freestyle_module_add", text="Add Style Module")
|
col.operator("scene.freestyle_module_add", text="Add Style Module")
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ Controller::Controller()
|
|||||||
_ComputeRidges = true;
|
_ComputeRidges = true;
|
||||||
_ComputeSteerableViewMap = false;
|
_ComputeSteerableViewMap = false;
|
||||||
_ComputeSuggestive = true;
|
_ComputeSuggestive = true;
|
||||||
|
_ComputeMaterialBoundaries = true;
|
||||||
_sphereRadius = 1.0;
|
_sphereRadius = 1.0;
|
||||||
|
|
||||||
init_options();
|
init_options();
|
||||||
@@ -466,6 +467,7 @@ void Controller::ComputeViewMap()
|
|||||||
edgeDetector.enableOrthographicProjection(proj[3][3] != 0.0);
|
edgeDetector.enableOrthographicProjection(proj[3][3] != 0.0);
|
||||||
edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges);
|
edgeDetector.enableRidgesAndValleysFlag(_ComputeRidges);
|
||||||
edgeDetector.enableSuggestiveContours(_ComputeSuggestive);
|
edgeDetector.enableSuggestiveContours(_ComputeSuggestive);
|
||||||
|
edgeDetector.enableMaterialBoundaries(_ComputeMaterialBoundaries);
|
||||||
edgeDetector.setSphereRadius(_sphereRadius);
|
edgeDetector.setSphereRadius(_sphereRadius);
|
||||||
edgeDetector.setSuggestiveContourKrDerivativeEpsilon(_suggestiveContourKrDerivativeEpsilon);
|
edgeDetector.setSuggestiveContourKrDerivativeEpsilon(_suggestiveContourKrDerivativeEpsilon);
|
||||||
edgeDetector.processShapes(*_winged_edge);
|
edgeDetector.processShapes(*_winged_edge);
|
||||||
@@ -647,6 +649,7 @@ void Controller::setComputeRidgesAndValleysFlag(bool iBool){
|
|||||||
bool Controller::getComputeRidgesAndValleysFlag() const {
|
bool Controller::getComputeRidgesAndValleysFlag() const {
|
||||||
return _ComputeRidges;
|
return _ComputeRidges;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setComputeSuggestiveContoursFlag(bool b){
|
void Controller::setComputeSuggestiveContoursFlag(bool b){
|
||||||
_ComputeSuggestive = b;
|
_ComputeSuggestive = b;
|
||||||
}
|
}
|
||||||
@@ -654,6 +657,15 @@ void Controller::setComputeSuggestiveContoursFlag(bool b){
|
|||||||
bool Controller::getComputeSuggestiveContoursFlag() const {
|
bool Controller::getComputeSuggestiveContoursFlag() const {
|
||||||
return _ComputeSuggestive;
|
return _ComputeSuggestive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::setComputeMaterialBoundariesFlag(bool b){
|
||||||
|
_ComputeMaterialBoundaries = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Controller::getComputeMaterialBoundariesFlag() const {
|
||||||
|
return _ComputeMaterialBoundaries;
|
||||||
|
}
|
||||||
|
|
||||||
void Controller::setComputeSteerableViewMapFlag(bool iBool){
|
void Controller::setComputeSteerableViewMapFlag(bool iBool){
|
||||||
_ComputeSteerableViewMap = iBool;
|
_ComputeSteerableViewMap = iBool;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,8 @@ public:
|
|||||||
bool getComputeRidgesAndValleysFlag() const ;
|
bool getComputeRidgesAndValleysFlag() const ;
|
||||||
void setComputeSuggestiveContoursFlag(bool b);
|
void setComputeSuggestiveContoursFlag(bool b);
|
||||||
bool getComputeSuggestiveContoursFlag() const ;
|
bool getComputeSuggestiveContoursFlag() const ;
|
||||||
|
void setComputeMaterialBoundariesFlag(bool b);
|
||||||
|
bool getComputeMaterialBoundariesFlag() const ;
|
||||||
|
|
||||||
void setComputeSteerableViewMapFlag(bool iBool);
|
void setComputeSteerableViewMapFlag(bool iBool);
|
||||||
bool getComputeSteerableViewMapFlag() const;
|
bool getComputeSteerableViewMapFlag() const;
|
||||||
@@ -222,6 +224,7 @@ private:
|
|||||||
bool _EnableQI;
|
bool _EnableQI;
|
||||||
bool _ComputeRidges;
|
bool _ComputeRidges;
|
||||||
bool _ComputeSuggestive;
|
bool _ComputeSuggestive;
|
||||||
|
bool _ComputeMaterialBoundaries;
|
||||||
real _sphereRadius;
|
real _sphereRadius;
|
||||||
real _suggestiveContourKrDerivativeEpsilon;
|
real _suggestiveContourKrDerivativeEpsilon;
|
||||||
|
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ extern "C" {
|
|||||||
controller->setSphereRadius( config->sphere_radius );
|
controller->setSphereRadius( config->sphere_radius );
|
||||||
controller->setComputeRidgesAndValleysFlag( (config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
|
controller->setComputeRidgesAndValleysFlag( (config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
|
||||||
controller->setComputeSuggestiveContoursFlag( (config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_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 ) ;
|
controller->setSuggestiveContourKrDerivativeEpsilon( config->dkr_epsilon ) ;
|
||||||
|
|
||||||
cout << "Sphere radius : " << controller->getSphereRadius() << endl;
|
cout << "Sphere radius : " << controller->getSphereRadius() << endl;
|
||||||
|
|||||||
@@ -174,6 +174,10 @@ static PyLongObject _Nature_SUGGESTIVE_CONTOUR = {
|
|||||||
PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
PyVarObject_HEAD_INIT(&Nature_Type, 1)
|
||||||
{ Nature::SUGGESTIVE_CONTOUR }
|
{ 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_POINT ((PyObject *)&_Nature_POINT)
|
||||||
#define BPy_Nature_S_VERTEX ((PyObject *)&_Nature_S_VERTEX)
|
#define BPy_Nature_S_VERTEX ((PyObject *)&_Nature_S_VERTEX)
|
||||||
@@ -188,6 +192,7 @@ static PyLongObject _Nature_SUGGESTIVE_CONTOUR = {
|
|||||||
#define BPy_Nature_RIDGE ((PyObject *)&_Nature_RIDGE)
|
#define BPy_Nature_RIDGE ((PyObject *)&_Nature_RIDGE)
|
||||||
#define BPy_Nature_VALLEY ((PyObject *)&_Nature_VALLEY)
|
#define BPy_Nature_VALLEY ((PyObject *)&_Nature_VALLEY)
|
||||||
#define BPy_Nature_SUGGESTIVE_CONTOUR ((PyObject *)&_Nature_SUGGESTIVE_CONTOUR)
|
#define BPy_Nature_SUGGESTIVE_CONTOUR ((PyObject *)&_Nature_SUGGESTIVE_CONTOUR)
|
||||||
|
#define BPy_Nature_MATERIAL_BOUNDARY ((PyObject *)&_Nature_MATERIAL_BOUNDARY)
|
||||||
|
|
||||||
//-------------------MODULE INITIALIZATION--------------------------------
|
//-------------------MODULE INITIALIZATION--------------------------------
|
||||||
int Nature_Init( PyObject *module )
|
int Nature_Init( PyObject *module )
|
||||||
@@ -216,6 +221,7 @@ int Nature_Init( PyObject *module )
|
|||||||
PyDict_SetItemString( Nature_Type.tp_dict, "RIDGE", BPy_Nature_RIDGE );
|
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, "VALLEY", BPy_Nature_VALLEY );
|
||||||
PyDict_SetItemString( Nature_Type.tp_dict, "SUGGESTIVE_CONTOUR", BPy_Nature_SUGGESTIVE_CONTOUR );
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ void FEdgeXDetector::processShapes(WingedEdge& we) {
|
|||||||
if (progressBarDisplay)
|
if (progressBarDisplay)
|
||||||
_pProgressBar->setProgress(_pProgressBar->getProgress() + 1);
|
_pProgressBar->setProgress(_pProgressBar->getProgress() + 1);
|
||||||
processBorderShape(wxs);
|
processBorderShape(wxs);
|
||||||
|
if(_computeMaterialBoundaries)
|
||||||
|
processMaterialBoundaryShape(wxs);
|
||||||
processCreaseShape(wxs);
|
processCreaseShape(wxs);
|
||||||
if(_computeRidgesAndValleys)
|
if(_computeRidgesAndValleys)
|
||||||
processRidgesAndValleysShape(wxs);
|
processRidgesAndValleysShape(wxs);
|
||||||
@@ -679,6 +681,29 @@ void FEdgeXDetector::postProcessSuggestiveContourFace(WXFace *iFace) {
|
|||||||
sc_layer->removeSmoothEdge();
|
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
|
// Build Smooth edges
|
||||||
/////////////////////
|
/////////////////////
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public:
|
|||||||
_meanEdgeSize = 0;
|
_meanEdgeSize = 0;
|
||||||
_computeRidgesAndValleys = true;
|
_computeRidgesAndValleys = true;
|
||||||
_computeSuggestiveContours = true;
|
_computeSuggestiveContours = true;
|
||||||
|
_computeMaterialBoundaries = true;
|
||||||
_sphereRadius = 1.0;
|
_sphereRadius = 1.0;
|
||||||
_orthographicProjection = false;
|
_orthographicProjection = false;
|
||||||
_changes = false;
|
_changes = false;
|
||||||
@@ -103,6 +104,10 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MATERIAL BOUNDARY
|
||||||
|
virtual void FEdgeXDetector::processMaterialBoundaryShape(WXShape* iWShape);
|
||||||
|
virtual void FEdgeXDetector::ProcessMaterialBoundaryEdge(WXEdge *iEdge);
|
||||||
|
|
||||||
// EVERYBODY
|
// EVERYBODY
|
||||||
virtual void buildSmoothEdges(WXShape* iShape);
|
virtual void buildSmoothEdges(WXShape* iShape);
|
||||||
|
|
||||||
@@ -111,6 +116,7 @@ public:
|
|||||||
inline void enableOrthographicProjection(bool b) {_orthographicProjection = b;}
|
inline void enableOrthographicProjection(bool b) {_orthographicProjection = b;}
|
||||||
inline void enableRidgesAndValleysFlag(bool b) {_computeRidgesAndValleys = b;}
|
inline void enableRidgesAndValleysFlag(bool b) {_computeRidgesAndValleys = b;}
|
||||||
inline void enableSuggestiveContours(bool b) {_computeSuggestiveContours = 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)
|
/*! Sets the radius of the geodesic sphere around each vertex (for the curvature computation)
|
||||||
* \param r
|
* \param r
|
||||||
* The radius of the sphere expressed as a ratio of the mean edge size
|
* The radius of the sphere expressed as a ratio of the mean edge size
|
||||||
@@ -142,6 +148,7 @@ protected:
|
|||||||
|
|
||||||
bool _computeRidgesAndValleys;
|
bool _computeRidgesAndValleys;
|
||||||
bool _computeSuggestiveContours;
|
bool _computeSuggestiveContours;
|
||||||
|
bool _computeMaterialBoundaries;
|
||||||
real _sphereRadius; // expressed as a ratio of the mean edge size
|
real _sphereRadius; // expressed as a ratio of the mean edge size
|
||||||
bool _changes;
|
bool _changes;
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ namespace Nature {
|
|||||||
static const EdgeNature VALLEY = (1 << 4); // 16
|
static const EdgeNature VALLEY = (1 << 4); // 16
|
||||||
/*! true for suggestive contours */
|
/*! true for suggestive contours */
|
||||||
static const EdgeNature SUGGESTIVE_CONTOUR = (1 << 5); // 32
|
static const EdgeNature SUGGESTIVE_CONTOUR = (1 << 5); // 32
|
||||||
|
/*! true for material boundaries */
|
||||||
|
static const EdgeNature MATERIAL_BOUNDARY = (1 << 6); // 64
|
||||||
|
|
||||||
} // end of namespace Nature
|
} // end of namespace Nature
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#define FREESTYLE_SUGGESTIVE_CONTOURS_FLAG 1
|
#define FREESTYLE_SUGGESTIVE_CONTOURS_FLAG 1
|
||||||
#define FREESTYLE_RIDGES_AND_VALLEYS_FLAG 2
|
#define FREESTYLE_RIDGES_AND_VALLEYS_FLAG 2
|
||||||
|
#define FREESTYLE_MATERIAL_BOUNDARIES_FLAG 4
|
||||||
|
|
||||||
typedef struct FreestyleModuleConfig {
|
typedef struct FreestyleModuleConfig {
|
||||||
struct FreestyleModuleConfig *next, *prev;
|
struct FreestyleModuleConfig *next, *prev;
|
||||||
|
|||||||
@@ -1511,6 +1511,11 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
|
|||||||
RNA_def_property_ui_text(prop, "Ridges and Valleys", "Enable ridges and valleys.");
|
RNA_def_property_ui_text(prop, "Ridges and Valleys", "Enable ridges and valleys.");
|
||||||
RNA_def_property_update(prop, NC_SCENE, NULL);
|
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||||
|
|
||||||
|
prop= RNA_def_property(srna, "material_boundaries", PROP_BOOLEAN, PROP_NONE);
|
||||||
|
RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_MATERIAL_BOUNDARIES_FLAG);
|
||||||
|
RNA_def_property_ui_text(prop, "Material boundaries", "Enable material boundaries.");
|
||||||
|
RNA_def_property_update(prop, NC_SCENE, NULL);
|
||||||
|
|
||||||
prop= RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE);
|
prop= RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE);
|
||||||
RNA_def_property_float_sdna(prop, NULL, "sphere_radius");
|
RNA_def_property_float_sdna(prop, NULL, "sphere_radius");
|
||||||
RNA_def_property_range(prop, 0.0, 1000.0);
|
RNA_def_property_range(prop, 0.0, 1000.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user