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:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-12-10 03:19:46 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-12-10 03:19:46 +0400
commit5083e0737f6413c63ab49b82735333534181d9b4 (patch)
treeb21a7977e79ff5db7bc2c7f53471cc2f5ccf76bd
parent3c4987f98378d44eda133311c65aa19412e4cd38 (diff)
All angle properties were switched from degrees to radians (using PROP_ANGLE
RNA subtype), since Freestyle internally use angles in radians. A patch set by Bastien Montagne (many thanks!) NOTICE FOR BRANCH USERS: This commit may break line drawing settings of already saved Freestyle files. All angles are now treated as radians instead of degrees, so collections of angle values might be necessary in order to recover previous visual results. Affected properties are: - Crease Angle in the edge detection options - Min 2D Angle in the 'Splitting' section of a line style - Max 2D Angle in the 'Splitting' section of a line style - 'orientation' parameter of the Calligraphy thickness modifier - 'angle' parameter of the PerlinNoise1D geometry modifier - 'angle' parameter of the PerlinNoise2D geometry modifier - 'angle' parameter of the 2DTransform geometry modifier
-rw-r--r--release/datafiles/startup.blendbin425168 -> 425180 bytes
-rw-r--r--release/scripts/freestyle/style_modules/parameter_editor.py19
-rw-r--r--source/blender/blenkernel/intern/linestyle.c9
-rw-r--r--source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp2
-rw-r--r--source/blender/makesdna/DNA_freestyle_types.h2
-rw-r--r--source/blender/makesdna/DNA_linestyle_types.h12
-rw-r--r--source/blender/makesrna/intern/rna_linestyle.c18
-rw-r--r--source/blender/makesrna/intern/rna_scene.c6
8 files changed, 34 insertions, 34 deletions
diff --git a/release/datafiles/startup.blend b/release/datafiles/startup.blend
index 49212f6f9cb..c66002de805 100644
--- a/release/datafiles/startup.blend
+++ b/release/datafiles/startup.blend
Binary files differ
diff --git a/release/scripts/freestyle/style_modules/parameter_editor.py b/release/scripts/freestyle/style_modules/parameter_editor.py
index 71d55e9a541..b2086eb1782 100644
--- a/release/scripts/freestyle/style_modules/parameter_editor.py
+++ b/release/scripts/freestyle/style_modules/parameter_editor.py
@@ -480,8 +480,7 @@ class CalligraphicThicknessShader(ThicknessBlenderMixIn, ScalarBlendModifier):
blend, influence, orientation, min_thickness, max_thickness):
ThicknessBlenderMixIn.__init__(self, thickness_position, thickness_ratio)
ScalarBlendModifier.__init__(self, blend, influence)
- rad = orientation / 180.0 * math.pi
- self.__orientation = mathutils.Vector((math.cos(rad), math.sin(rad)))
+ self.__orientation = mathutils.Vector((math.cos(orientation), math.sin(orientation)))
self.__min_thickness = min_thickness
self.__max_thickness = max_thickness
def shade(self, stroke):
@@ -533,14 +532,13 @@ class SinusDisplacementShader(StrokeShader):
stroke.UpdateLength()
class PerlinNoise1DShader(StrokeShader):
- def __init__(self, freq = 10, amp = 10, oct = 4, angle = 45, seed = -1):
+ def __init__(self, freq = 10, amp = 10, oct = 4, angle = math.radians(45), seed = -1):
StrokeShader.__init__(self)
self.__noise = Noise(seed)
self.__freq = freq
self.__amp = amp
self.__oct = oct
- theta = pi * angle / 180.0
- self.__dir = Vector([cos(theta), sin(theta)])
+ self.__dir = Vector([cos(angle), sin(angle)])
def getName(self):
return "PerlinNoise1DShader"
def shade(self, stroke):
@@ -554,14 +552,13 @@ class PerlinNoise1DShader(StrokeShader):
stroke.UpdateLength()
class PerlinNoise2DShader(StrokeShader):
- def __init__(self, freq = 10, amp = 10, oct = 4, angle = 45, seed = -1):
+ def __init__(self, freq = 10, amp = 10, oct = 4, angle = math.radians(45), seed = -1):
StrokeShader.__init__(self)
self.__noise = Noise(seed)
self.__freq = freq
self.__amp = amp
self.__oct = oct
- theta = pi * angle / 180.0
- self.__dir = Vector([cos(theta), sin(theta)])
+ self.__dir = Vector([cos(angle), sin(angle)])
def getName(self):
return "PerlinNoise2DShader"
def shade(self, stroke):
@@ -647,8 +644,8 @@ class Transform2DShader(StrokeShader):
elif self.__pivot == "ABSOLUTE":
pivot = Vector([self.__pivot_x, self.__pivot_y])
# apply scaling and rotation operations
- cos_theta = math.cos(math.pi * self.__angle / 180.0)
- sin_theta = math.sin(math.pi * self.__angle / 180.0)
+ cos_theta = math.cos(self.__angle)
+ sin_theta = math.sin(self.__angle)
it = stroke.strokeVerticesBegin()
while not it.isEnd():
v = it.getObject()
@@ -883,7 +880,7 @@ class DashedLineShader(StrokeShader):
class AngleLargerThanBP1D(BinaryPredicate1D):
def __init__(self, angle):
BinaryPredicate1D.__init__(self)
- self._angle = math.pi * angle / 180.0
+ self._angle = angle
def getName(self):
return "AngleLargerThanBP1D"
def __call__(self, i1, i2):
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index 43a0daef80c..aa319ba67f2 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -47,6 +47,7 @@
#include "BKE_animsys.h"
#include "BLI_blenlib.h"
+#include "BLI_math.h"
static const char *modifier_name[LS_MODIFIER_NUM] = {
NULL,
@@ -506,7 +507,7 @@ LineStyleModifier *FRS_add_linestyle_thickness_modifier(FreestyleLineStyle *line
case LS_MODIFIER_CALLIGRAPHY:
((LineStyleThicknessModifier_Calligraphy *)m)->min_thickness = 1.0f;
((LineStyleThicknessModifier_Calligraphy *)m)->max_thickness = 10.0f;
- ((LineStyleThicknessModifier_Calligraphy *)m)->orientation = 60.0f;
+ ((LineStyleThicknessModifier_Calligraphy *)m)->orientation = DEG2RADF(60.0f);
break;
default:
return NULL; /* unknown modifier type */
@@ -683,13 +684,13 @@ LineStyleModifier *FRS_add_linestyle_geometry_modifier(FreestyleLineStyle *lines
((LineStyleGeometryModifier_PerlinNoise1D *)m)->frequency = 10.0;
((LineStyleGeometryModifier_PerlinNoise1D *)m)->amplitude = 10.0;
((LineStyleGeometryModifier_PerlinNoise1D *)m)->octaves = 4;
- ((LineStyleGeometryModifier_PerlinNoise1D *)m)->angle = 45.0;
+ ((LineStyleGeometryModifier_PerlinNoise1D *)m)->angle = DEG2RADF(45.0f);
break;
case LS_MODIFIER_PERLIN_NOISE_2D:
((LineStyleGeometryModifier_PerlinNoise2D *)m)->frequency = 10.0;
((LineStyleGeometryModifier_PerlinNoise2D *)m)->amplitude = 10.0;
((LineStyleGeometryModifier_PerlinNoise2D *)m)->octaves = 4;
- ((LineStyleGeometryModifier_PerlinNoise2D *)m)->angle = 45.0;
+ ((LineStyleGeometryModifier_PerlinNoise2D *)m)->angle = DEG2RADF(45.0f);
break;
case LS_MODIFIER_BACKBONE_STRETCHER:
((LineStyleGeometryModifier_BackboneStretcher *)m)->backbone_length = 10.0;
@@ -721,7 +722,7 @@ LineStyleModifier *FRS_add_linestyle_geometry_modifier(FreestyleLineStyle *lines
((LineStyleGeometryModifier_2DTransform *)m)->pivot = LS_MODIFIER_2D_TRANSFORM_PIVOT_CENTER;
((LineStyleGeometryModifier_2DTransform *)m)->scale_x = 1.f;
((LineStyleGeometryModifier_2DTransform *)m)->scale_y = 1.f;
- ((LineStyleGeometryModifier_2DTransform *)m)->angle = 0.f;
+ ((LineStyleGeometryModifier_2DTransform *)m)->angle = DEG2RADF(0.0f);
((LineStyleGeometryModifier_2DTransform *)m)->pivot_u = 0.5f;
((LineStyleGeometryModifier_2DTransform *)m)->pivot_x = 0.f;
((LineStyleGeometryModifier_2DTransform *)m)->pivot_y = 0.f;
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index b5e67597caa..e432815a30f 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -351,7 +351,7 @@ extern "C" {
controller->setSuggestiveContourKrDerivativeEpsilon( DEFAULT_DKR_EPSILON );
}
controller->setFaceSmoothness( (config->flags & FREESTYLE_FACE_SMOOTHNESS_FLAG) ? true : false);
- controller->setCreaseAngle( config->crease_angle );
+ controller->setCreaseAngle( RAD2DEGF(config->crease_angle) );
controller->setVisibilityAlgo( (config->flags & FREESTYLE_CULLING) ?
FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE : FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE );
diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h
index b78ea9a13bb..505fe474e8b 100644
--- a/source/blender/makesdna/DNA_freestyle_types.h
+++ b/source/blender/makesdna/DNA_freestyle_types.h
@@ -125,7 +125,7 @@ typedef struct FreestyleConfig {
int flags; /* suggestive contours, ridges/valleys, material boundaries */
float sphere_radius;
float dkr_epsilon;
- float crease_angle;
+ float crease_angle; /* in radians! */
ListBase linesets;
diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h
index 2507b072a2f..5ceb89e020a 100644
--- a/source/blender/makesdna/DNA_linestyle_types.h
+++ b/source/blender/makesdna/DNA_linestyle_types.h
@@ -267,7 +267,8 @@ typedef struct LineStyleGeometryModifier_SpatialNoise {
typedef struct LineStyleGeometryModifier_PerlinNoise1D {
struct LineStyleModifier modifier;
- float frequency, amplitude, angle;
+ float frequency, amplitude;
+ float angle; /* in radians! */
unsigned int octaves;
int seed;
int pad1;
@@ -277,7 +278,8 @@ typedef struct LineStyleGeometryModifier_PerlinNoise1D {
typedef struct LineStyleGeometryModifier_PerlinNoise2D {
struct LineStyleModifier modifier;
- float frequency, amplitude, angle;
+ float frequency, amplitude;
+ float angle; /* in radians! */
unsigned int octaves;
int seed;
int pad1;
@@ -353,7 +355,7 @@ typedef struct LineStyleGeometryModifier_2DTransform {
int pivot;
float scale_x, scale_y;
- float angle;
+ float angle; /* in radians! */
float pivot_u;
float pivot_x, pivot_y;
int pad;
@@ -366,7 +368,7 @@ typedef struct LineStyleThicknessModifier_Calligraphy {
struct LineStyleModifier modifier;
float min_thickness, max_thickness;
- float orientation;
+ float orientation; /* in radians! */
int pad;
} LineStyleThicknessModifier_Calligraphy;
@@ -419,7 +421,7 @@ typedef struct FreestyleLineStyle {
int chaining;
unsigned int rounds;
float split_length;
- float min_angle, max_angle; /* for splitting */
+ float min_angle, max_angle; /* in radians, for splitting */
float min_length, max_length;
unsigned short split_dash1, split_gap1;
unsigned short split_dash2, split_gap2;
diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c
index fbe8eae31b3..809603d5ddf 100644
--- a/source/blender/makesrna/intern/rna_linestyle.c
+++ b/source/blender/makesrna/intern/rna_linestyle.c
@@ -565,7 +565,7 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna)
RNA_def_struct_ui_text(srna, "Calligraphy", "Change line thickness so that stroke looks like made with a calligraphic pen");
rna_def_thickness_modifier(srna);
- prop= RNA_def_property(srna, "orientation", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "orientation", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "orientation");
RNA_def_property_ui_text(prop, "Orientation", "Angle of the main direction");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
@@ -675,9 +675,9 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Octaves", "Number of octaves (i.e., the amount of detail of the Perlin noise)");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
- prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "angle");
- RNA_def_property_ui_text(prop, "Angle", "Displacement direction in degrees");
+ RNA_def_property_ui_text(prop, "Angle", "Displacement direction");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
prop= RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
@@ -704,9 +704,9 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Octaves", "Number of octaves (i.e., the amount of detail of the Perlin noise)");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
- prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "angle");
- RNA_def_property_ui_text(prop, "Angle", "Displacement direction in degrees");
+ RNA_def_property_ui_text(prop, "Angle", "Displacement direction");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
prop= RNA_def_property(srna, "seed", PROP_INT, PROP_NONE);
@@ -830,9 +830,9 @@ static void rna_def_linestyle_modifiers(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Scale Y", "Scaling factor that is applied along the Y axis");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
- prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "angle");
- RNA_def_property_ui_text(prop, "Rotation Angle", "Rotation angle in degrees");
+ RNA_def_property_ui_text(prop, "Rotation Angle", "Rotation angle");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
prop= RNA_def_property(srna, "pivot_u", PROP_FLOAT, PROP_FACTOR);
@@ -982,7 +982,7 @@ static void rna_def_linestyle(BlenderRNA *brna)
prop= RNA_def_property(srna, "min_angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "min_angle");
- RNA_def_property_range(prop, 0.0f, (float)M_PI);
+ RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
RNA_def_property_ui_text(prop, "Min 2D Angle", "Minimum 2D angle for splitting chains");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
@@ -993,7 +993,7 @@ static void rna_def_linestyle(BlenderRNA *brna)
prop= RNA_def_property(srna, "max_angle", PROP_FLOAT, PROP_ANGLE);
RNA_def_property_float_sdna(prop, NULL, "max_angle");
- RNA_def_property_range(prop, 0.0f, (float)M_PI);
+ RNA_def_property_range(prop, 0.0f, DEG2RADF(180.0f));
RNA_def_property_ui_text(prop, "Max 2D Angle", "Maximum 2D angle for splitting chains");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 0e9b6a7d9a2..d472827aa96 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2688,10 +2688,10 @@ static void rna_def_freestyle_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Kr Derivative Epsilon", "Kr derivative epsilon for computing suggestive contours");
RNA_def_property_update(prop, NC_SCENE, NULL);
- prop= RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_NONE);
+ prop= RNA_def_property(srna, "crease_angle", PROP_FLOAT, PROP_ANGLE);
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_range(prop, 0.0, DEG2RAD(180.0));
+ RNA_def_property_ui_text(prop, "Crease Angle", "Angular threshold for detecting crease edges");
RNA_def_property_update(prop, NC_SCENE, NULL);
prop= RNA_def_property(srna, "linesets", PROP_COLLECTION, PROP_NONE);