Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--release/scripts/ui/properties_render.py1
-rwxr-xr-xsource/blender/freestyle/intern/application/Controller.cpp2
-rwxr-xr-xsource/blender/freestyle/intern/application/Controller.h3
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp3
-rwxr-xr-xsource/blender/freestyle/intern/view_map/FEdgeXDetector.cpp2
-rwxr-xr-xsource/blender/freestyle/intern/view_map/FEdgeXDetector.h19
-rw-r--r--source/blender/makesdna/DNA_freestyle_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_scene.c6
8 files changed, 36 insertions, 2 deletions
diff --git a/release/scripts/ui/properties_render.py b/release/scripts/ui/properties_render.py
index f69cf309304..bcd79158f7f 100644
--- a/release/scripts/ui/properties_render.py
+++ b/release/scripts/ui/properties_render.py
@@ -182,6 +182,7 @@ class RENDER_PT_layers(RenderButtonsPanel):
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")
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;
diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h
index 459a6e8cf9f..c49a47fc22a 100644
--- a/source/blender/makesdna/DNA_freestyle_types.h
+++ b/source/blender/makesdna/DNA_freestyle_types.h
@@ -22,7 +22,7 @@ typedef struct FreestyleConfig {
int flags;
float sphere_radius;
float dkr_epsilon;
- int pad;
+ float crease_angle;
} FreestyleConfig;
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 8c98ec74961..d6825959083 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -1527,6 +1527,12 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
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)