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
path: root/source
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-04-18 09:59:02 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-04-18 10:02:45 +0400
commitf60a66f41784de388a01c4c882c969730d675375 (patch)
treea469d0acdfa48cefa2611837d268f2c636225372 /source
parent6a94e73a854286f711bffa81d351d640b4cf3675 (diff)
Freestyle: New options for sorting to arrange the stacking order of lines.
Line styles now have a set of new options for rearranging the stacking order of lines. This gives artists more control to determine which lines should be drawn on top of others. Two available sort keys are the distance from camera and curvilinear 2D length. Since the distance of a line from camera may vary over vertices, another option called integration type is used to compute the sort key for a line from the values computed at individual vertices. Available integration types are MEAN, MIN, MAX, FIRST and LAST (see the tool tips for more detail).
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/intern/linestyle.c4
-rw-r--r--source/blender/blenloader/intern/versioning_270.c11
-rw-r--r--source/blender/blenloader/intern/versioning_defaults.c7
-rw-r--r--source/blender/makesdna/DNA_linestyle_types.h14
-rw-r--r--source/blender/makesrna/intern/rna_linestyle.c41
6 files changed, 75 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 9a67284304c..e29aa142d76 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 270
-#define BLENDER_SUBVERSION 2
+#define BLENDER_SUBVERSION 3
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 262
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c
index f826e611a11..78d062ce1f7 100644
--- a/source/blender/blenkernel/intern/linestyle.c
+++ b/source/blender/blenkernel/intern/linestyle.c
@@ -81,7 +81,7 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle)
linestyle->thickness = 3.0f;
linestyle->thickness_position = LS_THICKNESS_CENTER;
linestyle->thickness_ratio = 0.5f;
- linestyle->flag = LS_SAME_OBJECT;
+ linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING;
linestyle->chaining = LS_CHAINING_PLAIN;
linestyle->rounds = 3;
linestyle->min_angle = DEG2RADF(0.0f);
@@ -89,6 +89,8 @@ static void default_linestyle_settings(FreestyleLineStyle *linestyle)
linestyle->min_length = 0.0f;
linestyle->max_length = 10000.0f;
linestyle->split_length = 100;
+ linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
+ linestyle->integration_type = LS_INTEGRATION_MEAN;
BLI_listbase_clear(&linestyle->color_modifiers);
BLI_listbase_clear(&linestyle->alpha_modifiers);
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 2dd227ef036..41b95064ac6 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -43,6 +43,7 @@
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_sdna_types.h"
+#include "DNA_linestyle_types.h"
#include "DNA_genfile.h"
@@ -171,4 +172,14 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
me->smoothresh = DEG2RADF(me->smoothresh);
}
}
+
+ if (!MAIN_VERSION_ATLEAST(main, 270, 3)) {
+ FreestyleLineStyle *linestyle;
+
+ for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
+ linestyle->flag |= LS_NO_SORTING;
+ linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
+ linestyle->integration_type = LS_INTEGRATION_MEAN;
+ }
+ }
}
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index d6caf16f7aa..b455ef016b2 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -59,8 +59,11 @@ void BLO_update_defaults_startup_blend(Main *main)
}
}
- for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next)
- linestyle->flag = LS_SAME_OBJECT;
+ for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
+ linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING;
+ linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
+ linestyle->integration_type = LS_INTEGRATION_MEAN;
+ }
{
bScreen *screen;
diff --git a/source/blender/makesdna/DNA_linestyle_types.h b/source/blender/makesdna/DNA_linestyle_types.h
index 19c4e057a96..8d5f81ede5a 100644
--- a/source/blender/makesdna/DNA_linestyle_types.h
+++ b/source/blender/makesdna/DNA_linestyle_types.h
@@ -368,6 +368,8 @@ typedef struct LineStyleThicknessModifier_Calligraphy {
#define LS_MAX_2D_ANGLE (1 << 8)
#define LS_SPLIT_LENGTH (1 << 9)
#define LS_SPLIT_PATTERN (1 << 10)
+#define LS_NO_SORTING (1 << 11)
+#define LS_REVERSE_ORDER (1 << 12) /* for sorting */
/* FreestyleLineStyle::chaining */
#define LS_CHAINING_PLAIN 1
@@ -384,6 +386,17 @@ typedef struct LineStyleThicknessModifier_Calligraphy {
#define LS_THICKNESS_OUTSIDE 3
#define LS_THICKNESS_RELATIVE 4 /* thickness_ratio is used */
+/* FreestyleLineStyle::sort_key */
+#define LS_SORT_KEY_DISTANCE_FROM_CAMERA 1
+#define LS_SORT_KEY_2D_LENGTH 2
+
+/* FreestyleLineStyle::integration_type */
+#define LS_INTEGRATION_MEAN 1
+#define LS_INTEGRATION_MIN 2
+#define LS_INTEGRATION_MAX 3
+#define LS_INTEGRATION_FIRST 4
+#define LS_INTEGRATION_LAST 5
+
typedef struct FreestyleLineStyle {
ID id;
struct AnimData *adt;
@@ -401,6 +414,7 @@ typedef struct FreestyleLineStyle {
unsigned short split_dash1, split_gap1;
unsigned short split_dash2, split_gap2;
unsigned short split_dash3, split_gap3;
+ int sort_key, integration_type;
int pad;
unsigned short dash1, gap1, dash2, gap2, dash3, gap3;
int panel; /* for UI */
diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c
index 0619bb0352a..e97f3c2b418 100644
--- a/source/blender/makesrna/intern/rna_linestyle.c
+++ b/source/blender/makesrna/intern/rna_linestyle.c
@@ -915,6 +915,24 @@ static void rna_def_linestyle(BlenderRNA *brna)
{LS_THICKNESS_RELATIVE, "RELATIVE", 0, "Relative", "Stroke thickness is split by a user-defined ratio"},
{0, NULL, 0, NULL, NULL}
};
+ static EnumPropertyItem sort_key_items[] = {
+ {LS_SORT_KEY_DISTANCE_FROM_CAMERA, "DISTANCE_FROM_CAMERA", 0, "Distance from Camera", "Sort by distance from camera (closer lines lie on top of further lines)"},
+ {LS_SORT_KEY_2D_LENGTH, "2D_LENGTH", 0, "2D Length", "Sort by curvilinear 2D length (longer lines lie on top of shorter lines)"},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static EnumPropertyItem sort_order_items[] = {
+ {0, "DEFAULT", 0, "Default", "Default order of the sort key"},
+ {LS_REVERSE_ORDER, "REVERSE", 0, "Reverse", "Reverse order"},
+ {0, NULL, 0, NULL, NULL}
+ };
+ static EnumPropertyItem integration_type_items[] = {
+ {LS_INTEGRATION_MEAN, "MEAN", 0, "Mean", "The value computed for the chain is the mean of the values obtained for chain vertices"},
+ {LS_INTEGRATION_MIN, "MIN", 0, "Min", "The value computed for the chain is the minimum of the values obtained for chain vertices"},
+ {LS_INTEGRATION_MAX, "MAX", 0, "Max", "The value computed for the chain is the maximum of the values obtained for chain vertices"},
+ {LS_INTEGRATION_FIRST, "FIRST", 0, "First", "The value computed for the chain is the value obtained for the first chain vertex"},
+ {LS_INTEGRATION_LAST, "LAST", 0, "Last", "The value computed for the chain is the value obtained for the last chain vertex"},
+ {0, NULL, 0, NULL, NULL}
+ };
srna = RNA_def_struct(brna, "FreestyleLineStyle", "ID");
RNA_def_struct_ui_text(srna, "Freestyle Line Style", "Freestyle line style, reusable by multiple line sets");
@@ -1104,6 +1122,29 @@ static void rna_def_linestyle(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Material Boundary", "If true, chains of feature edges are split at material boundaries");
RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+ prop = RNA_def_property(srna, "use_sorting", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", LS_NO_SORTING);
+ RNA_def_property_ui_text(prop, "Sorting", "Arrange the stacking order of strokes");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
+ prop = RNA_def_property(srna, "sort_key", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "sort_key");
+ RNA_def_property_enum_items(prop, sort_key_items);
+ RNA_def_property_ui_text(prop, "Sort Key", "Select the sort key to determine the stacking order of chains");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
+ prop = RNA_def_property(srna, "sort_order", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
+ RNA_def_property_enum_items(prop, sort_order_items);
+ RNA_def_property_ui_text(prop, "Sort Order", "Select the sort order");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
+ prop = RNA_def_property(srna, "integration_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "integration_type");
+ RNA_def_property_enum_items(prop, integration_type_items);
+ RNA_def_property_ui_text(prop, "Integration Type", "Select the way how the sort key is computed for each chain");
+ RNA_def_property_update(prop, NC_LINESTYLE, NULL);
+
prop = RNA_def_property(srna, "use_dashed_line", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", LS_DASHED_LINE);
RNA_def_property_ui_text(prop, "Dashed Line", "Enable or disable dashed line");