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/freestyle/modules/parameter_editor.py22
-rw-r--r--release/scripts/startup/bl_ui/properties_freestyle.py12
-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
8 files changed, 109 insertions, 4 deletions
diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py
index ce15028d0d7..73ae0f4712c 100644
--- a/release/scripts/freestyle/modules/parameter_editor.py
+++ b/release/scripts/freestyle/modules/parameter_editor.py
@@ -23,6 +23,7 @@
from freestyle.types import (
BinaryPredicate1D,
+ IntegrationType,
Interface0DIterator,
Nature,
Noise,
@@ -51,6 +52,8 @@ from freestyle.predicates import (
ExternalContourUP1D,
FalseBP1D,
FalseUP1D,
+ Length2DBP1D,
+ NotBP1D,
NotUP1D,
OrUP1D,
QuantitativeInvisibilityUP1D,
@@ -58,6 +61,7 @@ from freestyle.predicates import (
TrueUP1D,
WithinImageBoundaryUP1D,
pyNatureUP1D,
+ pyZBP1D,
)
from freestyle.shaders import (
BackboneStretcherShader,
@@ -1163,6 +1167,14 @@ class StrokeCleaner(StrokeShader):
stroke.update_length()
+integration_types = {
+ 'MEAN': IntegrationType.MEAN,
+ 'MIN': IntegrationType.MIN,
+ 'MAX': IntegrationType.MAX,
+ 'FIRST': IntegrationType.FIRST,
+ 'LAST': IntegrationType.LAST}
+
+
# main function for parameter processing
def process(layer_name, lineset_name):
@@ -1291,6 +1303,16 @@ def process(layer_name, lineset_name):
length_min = linestyle.length_min if linestyle.use_length_min else None
length_max = linestyle.length_max if linestyle.use_length_max else None
Operators.select(LengthThresholdUP1D(length_min, length_max))
+ # sort selected chains
+ if linestyle.use_sorting:
+ integration = integration_types.get(linestyle.integration_type, IntegrationType.MEAN)
+ if linestyle.sort_key == 'DISTANCE_FROM_CAMERA':
+ bpred = pyZBP1D(integration)
+ elif linestyle.sort_key == '2D_LENGTH':
+ bpred = Length2DBP1D()
+ if linestyle.sort_order == 'REVERSE':
+ bpred = NotBP1D(bpred)
+ Operators.sort(bpred)
# prepare a list of stroke shaders
shaders_list = []
###
diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py
index 197b0d2f970..bedee24d8ef 100644
--- a/release/scripts/startup/bl_ui/properties_freestyle.py
+++ b/release/scripts/startup/bl_ui/properties_freestyle.py
@@ -603,6 +603,18 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
sub.active = linestyle.use_length_max
sub.prop(linestyle, "length_max")
+ ## Sorting
+ layout.prop(linestyle, "use_sorting", text="Sorting:")
+ col = layout.column()
+ col.active = linestyle.use_sorting
+ row = col.row(align=True)
+ row.prop(linestyle, "sort_key", text="")
+ sub = row.row()
+ sub.active = linestyle.sort_key in {'DISTANCE_FROM_CAMERA'}
+ sub.prop(linestyle, "integration_type", text="")
+ row = col.row(align=True)
+ row.prop(linestyle, "sort_order", expand=True)
+
## Caps
layout.label(text="Caps:")
row = layout.row(align=True)
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");