diff options
4 files changed, 28 insertions, 16 deletions
diff --git a/release/scripts/startup/bl_ui/properties_render.py b/release/scripts/startup/bl_ui/properties_render.py index 72b41cca62c..7f00689d254 100644 --- a/release/scripts/startup/bl_ui/properties_render.py +++ b/release/scripts/startup/bl_ui/properties_render.py @@ -207,12 +207,11 @@ class RENDER_PT_freestyle(RenderButtonsPanel, Panel): col.prop(freestyle, "raycasting_algorithm", text="Raycasting Algorithm") col.prop(freestyle, "mode", text="Control Mode") + col.label(text="Edge Detection Options:") + col.prop(freestyle, "use_smoothness") + col.prop(freestyle, "crease_angle") + if freestyle.mode == "EDITOR": - col.label(text="Edge Detection Options:") - col.prop(freestyle, "use_smoothness") - col.prop(freestyle, "crease_angle") - col.prop(freestyle, "sphere_radius") - col.prop(freestyle, "kr_derivative_epsilon") lineset = freestyle.linesets.active @@ -236,15 +235,14 @@ class RENDER_PT_freestyle(RenderButtonsPanel, Panel): else: # freestyle.mode == "SCRIPT" - col.prop(freestyle, "use_smoothness") - col.prop(freestyle, "crease_angle") - col.prop(freestyle, "sphere_radius") + col.prop(freestyle, "use_material_boundaries") col.prop(freestyle, "use_ridges_and_valleys") col.prop(freestyle, "use_suggestive_contours") - sub = col.row() - sub.prop(freestyle, "kr_derivative_epsilon") - sub.active = freestyle.use_suggestive_contours - col.prop(freestyle, "use_material_boundaries") + col.prop(freestyle, "use_advanced_options") + if freestyle.use_advanced_options: + col.prop(freestyle, "sphere_radius") + col.prop(freestyle, "kr_derivative_epsilon") + col.separator() col.operator("scene.freestyle_module_add") for i, module in enumerate(freestyle.modules): diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 2b054307365..d81e887be07 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -34,6 +34,9 @@ extern "C" { #include "../../FRS_freestyle.h" #include "../../FRS_freestyle_config.h" +#define DEFAULT_SPHERE_RADIUS 1.0f +#define DEFAULT_DKR_EPSILON 0.0f + // Freestyle configuration static short freestyle_is_initialized = 0; static Config::Path *pathconfig = NULL; @@ -330,10 +333,15 @@ extern "C" { } // set parameters + if (config->mode == FREESTYLE_CONTROL_SCRIPT_MODE && (config->flags & FREESTYLE_ADVANCED_OPTIONS_FLAG)) { + controller->setSphereRadius( config->sphere_radius ); + controller->setSuggestiveContourKrDerivativeEpsilon( config->dkr_epsilon ); + } else { + controller->setSphereRadius( DEFAULT_SPHERE_RADIUS ); + controller->setSuggestiveContourKrDerivativeEpsilon( DEFAULT_DKR_EPSILON ); + } controller->setFaceSmoothness( (config->flags & FREESTYLE_FACE_SMOOTHNESS_FLAG) ? true : false); controller->setCreaseAngle( config->crease_angle ); - controller->setSphereRadius( config->sphere_radius ); - controller->setSuggestiveContourKrDerivativeEpsilon( config->dkr_epsilon ) ; controller->setVisibilityAlgo( config->raycasting_algorithm ); cout << "Crease angle : " << controller->getCreaseAngle() << endl; @@ -500,8 +508,8 @@ extern "C" { config->modules.first = config->modules.last = NULL; config->flags = 0; - config->sphere_radius = 1.0f; - config->dkr_epsilon = 0.001f; + config->sphere_radius = DEFAULT_SPHERE_RADIUS; + config->dkr_epsilon = DEFAULT_DKR_EPSILON; config->crease_angle = 134.43f; config->linesets.first = config->linesets.last = NULL; diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h index 30888bff15f..9d56209f9f4 100644 --- a/source/blender/makesdna/DNA_freestyle_types.h +++ b/source/blender/makesdna/DNA_freestyle_types.h @@ -40,6 +40,7 @@ struct FreestyleLineStyle; #define FREESTYLE_RIDGES_AND_VALLEYS_FLAG 2 #define FREESTYLE_MATERIAL_BOUNDARIES_FLAG 4 #define FREESTYLE_FACE_SMOOTHNESS_FLAG 8 +#define FREESTYLE_ADVANCED_OPTIONS_FLAG 16 /* FreestyleConfig::mode */ #define FREESTYLE_CONTROL_SCRIPT_MODE 1 diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 3e9ab08c9d7..1cb8de6eed5 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2523,6 +2523,11 @@ static void rna_def_freestyle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Face Smoothness", "Take face smoothness into account in view map calculation"); RNA_def_property_update(prop, NC_SCENE, NULL); + prop= RNA_def_property(srna, "use_advanced_options", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_ADVANCED_OPTIONS_FLAG); + RNA_def_property_ui_text(prop, "Advanced Edge Detection Options", "Enable advanced edge detection options (sphere radius and Kr derivative epsilon)"); + RNA_def_property_update(prop, NC_SCENE, NULL); + prop= RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "sphere_radius"); RNA_def_property_range(prop, 0.0, 1000.0); |