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:
Diffstat (limited to 'source/blender/makesrna/intern/rna_gpencil_modifier.c')
-rw-r--r--source/blender/makesrna/intern/rna_gpencil_modifier.c312
1 files changed, 287 insertions, 25 deletions
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index 0647bc62081..320ef169ae5 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -9,11 +9,8 @@
#include <stdlib.h>
#include "DNA_armature_types.h"
-#include "DNA_brush_types.h"
-#include "DNA_cachefile_types.h"
#include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h"
-#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
@@ -21,20 +18,13 @@
#include "MEM_guardedalloc.h"
-#include "BLI_math.h"
-#include "BLI_rand.h"
+#include "BLI_math_base.h"
+#include "BLI_math_rotation.h"
#include "BLI_string_utils.h"
#include "BLT_translation.h"
#include "BKE_animsys.h"
-#include "BKE_data_transfer.h"
-#include "BKE_dynamicpaint.h"
-#include "BKE_effect.h"
-#include "BKE_fluid.h" /* For BKE_fluid_modifier_free & BKE_fluid_modifier_create_type_data */
-#include "BKE_mesh_mapping.h"
-#include "BKE_mesh_remap.h"
-#include "BKE_multires.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -82,7 +72,7 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = {
"Generate dot-dash styled strokes"},
{eGpencilModifierType_Envelope,
"GP_ENVELOPE",
- ICON_MOD_SKIN,
+ ICON_MOD_ENVELOPE,
"Envelope",
"Create an envelope shape"},
{eGpencilModifierType_Length,
@@ -105,6 +95,11 @@ const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = {
ICON_GP_MULTIFRAME_EDITING,
"Multiple Strokes",
"Produce multiple strokes along one stroke"},
+ {eGpencilModifierType_Outline,
+ "GP_OUTLINE",
+ ICON_MOD_OUTLINE,
+ "Outline",
+ "Convert stroke to perimeter"},
{eGpencilModifierType_Simplify,
"GP_SIMPLIFY",
ICON_MOD_SIMPLIFY,
@@ -196,7 +191,19 @@ static const EnumPropertyItem rna_enum_time_mode_items[] = {
{GP_TIME_MODE_NORMAL, "NORMAL", 0, "Regular", "Apply offset in usual animation direction"},
{GP_TIME_MODE_REVERSE, "REVERSE", 0, "Reverse", "Apply offset in reverse animation direction"},
{GP_TIME_MODE_FIX, "FIX", 0, "Fixed Frame", "Keep frame and do not change with time"},
- {GP_TIME_MODE_PINGPONG, "PINGPONG", 0, "Ping Pong", "Loop back and forth"},
+ {GP_TIME_MODE_PINGPONG, "PINGPONG", 0, "Ping Pong", "Loop back and forth starting in reverse"},
+ {GP_TIME_MODE_CHAIN, "CHAIN", 0, "Chain", "List of chained animation segments"},
+ {0, NULL, 0, NULL, NULL},
+};
+
+static const EnumPropertyItem rna_enum_time_seg_mode_items[] = {
+ {GP_TIME_SEG_MODE_NORMAL, "NORMAL", 0, "Regular", "Apply offset in usual animation direction"},
+ {GP_TIME_SEG_MODE_REVERSE,
+ "REVERSE",
+ 0,
+ "Reverse",
+ "Apply offset in reverse animation direction"},
+ {GP_TIME_SEG_MODE_PINGPONG, "PINGPONG", 0, "Ping Pong", "Loop back and forth"},
{0, NULL, 0, NULL, NULL},
};
@@ -286,6 +293,8 @@ static StructRNA *rna_GpencilModifier_refine(struct PointerRNA *ptr)
return &RNA_BuildGpencilModifier;
case eGpencilModifierType_Opacity:
return &RNA_OpacityGpencilModifier;
+ case eGpencilModifierType_Outline:
+ return &RNA_OutlineGpencilModifier;
case eGpencilModifierType_Lattice:
return &RNA_LatticeGpencilModifier;
case eGpencilModifierType_Length:
@@ -668,6 +677,37 @@ static void rna_OpacityGpencilModifier_material_set(PointerRNA *ptr,
rna_GpencilModifier_material_set(ptr, value, ma_target, reports);
}
+static void rna_OutlineGpencilModifier_object_set(PointerRNA *ptr,
+ PointerRNA value,
+ struct ReportList *UNUSED(reports))
+{
+ OutlineGpencilModifierData *omd = ptr->data;
+ Object *ob = (Object *)value.data;
+
+ omd->object = ob;
+ id_lib_extern((ID *)ob);
+}
+
+static void rna_OutlineGpencilModifier_material_set(PointerRNA *ptr,
+ PointerRNA value,
+ struct ReportList *reports)
+{
+ OutlineGpencilModifierData *omd = (OutlineGpencilModifierData *)ptr->data;
+ Material **ma_target = &omd->material;
+
+ rna_GpencilModifier_material_set(ptr, value, ma_target, reports);
+}
+
+static void rna_OutlineStrokeGpencilModifier_material_set(PointerRNA *ptr,
+ PointerRNA value,
+ struct ReportList *reports)
+{
+ OutlineGpencilModifierData *omd = (OutlineGpencilModifierData *)ptr->data;
+ Material **ma_target = &omd->outline_material;
+
+ rna_GpencilModifier_material_set(ptr, value, ma_target, reports);
+}
+
static void rna_LatticeGpencilModifier_material_set(PointerRNA *ptr,
PointerRNA value,
struct ReportList *reports)
@@ -753,7 +793,32 @@ static void rna_GpencilDash_segments_begin(CollectionPropertyIterator *iter, Poi
iter, dmd->segments, sizeof(DashGpencilModifierSegment), dmd->segments_len, false, NULL);
}
+static void rna_GpencilTime_segments_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
+{
+ TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)ptr->data;
+ rna_iterator_array_begin(
+ iter, gpmd->segments, sizeof(TimeGpencilModifierSegment), gpmd->segments_len, false, NULL);
+}
+
+static char *rna_TimeGpencilModifierSegment_path(const PointerRNA *ptr)
+{
+ TimeGpencilModifierSegment *ds = (TimeGpencilModifierSegment *)ptr->data;
+
+ TimeGpencilModifierData *gpmd = (TimeGpencilModifierData *)ds->gpmd;
+
+ BLI_assert(gpmd != NULL);
+
+ char name_esc[sizeof(gpmd->modifier.name) * 2];
+ BLI_str_escape(name_esc, gpmd->modifier.name, sizeof(name_esc));
+
+ char ds_name_esc[sizeof(ds->name) * 2];
+ BLI_str_escape(ds_name_esc, ds->name, sizeof(ds_name_esc));
+
+ return BLI_sprintfN("grease_pencil_modifiers[\"%s\"].segments[\"%s\"]", name_esc, ds_name_esc);
+}
+
static char *rna_DashGpencilModifierSegment_path(const PointerRNA *ptr)
+
{
const DashGpencilModifierSegment *ds = (DashGpencilModifierSegment *)ptr->data;
@@ -781,6 +846,17 @@ static bool dash_segment_name_exists_fn(void *arg, const char *name)
return false;
}
+static bool time_segment_name_exists_fn(void *arg, const char *name)
+{
+ const TimeGpencilModifierData *gpmd = (const TimeGpencilModifierData *)arg;
+ for (int i = 0; i < gpmd->segments_len; i++) {
+ if (STREQ(gpmd->segments[i].name, name) && gpmd->segments[i].name != name) {
+ return true;
+ }
+ }
+ return false;
+}
+
static void rna_DashGpencilModifierSegment_name_set(PointerRNA *ptr, const char *value)
{
DashGpencilModifierSegment *ds = ptr->data;
@@ -804,6 +880,29 @@ static void rna_DashGpencilModifierSegment_name_set(PointerRNA *ptr, const char
BKE_animdata_fix_paths_rename_all(NULL, prefix, oldname, ds->name);
}
+static void rna_TimeGpencilModifierSegment_name_set(PointerRNA *ptr, const char *value)
+{
+ TimeGpencilModifierSegment *ds = ptr->data;
+
+ char oldname[sizeof(ds->name)];
+ BLI_strncpy(oldname, ds->name, sizeof(ds->name));
+
+ BLI_strncpy_utf8(ds->name, value, sizeof(ds->name));
+
+ BLI_assert(ds->gpmd != NULL);
+ BLI_uniquename_cb(
+ time_segment_name_exists_fn, ds->gpmd, "Segment", '.', ds->name, sizeof(ds->name));
+
+ char name_esc[sizeof(ds->gpmd->modifier.name) * 2];
+ BLI_str_escape(name_esc, ds->gpmd->modifier.name, sizeof(name_esc));
+
+ char prefix[36 + sizeof(name_esc) + 1];
+ SNPRINTF(prefix, "grease_pencil_modifiers[\"%s\"].segments", name_esc);
+
+ /* Fix all the animation data which may link to this. */
+ BKE_animdata_fix_paths_rename_all(NULL, prefix, oldname, ds->name);
+}
+
static int rna_ShrinkwrapGpencilModifier_face_cull_get(PointerRNA *ptr)
{
ShrinkwrapGpencilModifierData *swm = (ShrinkwrapGpencilModifierData *)ptr->data;
@@ -1680,6 +1779,38 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
+ srna = RNA_def_struct(brna, "TimeGpencilModifierSegment", NULL);
+ RNA_def_struct_ui_text(srna, "Time Modifier Segment", "Configuration for a single dash segment");
+ RNA_def_struct_sdna(srna, "TimeGpencilModifierSegment");
+ RNA_def_struct_path_func(srna, "rna_TimeGpencilModifierSegment_path");
+
+ prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Name", "Name of the dash segment");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+ RNA_def_property_string_funcs(prop, NULL, NULL, "rna_TimeGpencilModifierSegment_name_set");
+ RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER | NA_RENAME, NULL);
+ RNA_def_struct_name_property(srna, prop);
+
+ prop = RNA_def_property(srna, "seg_start", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 0, INT16_MAX);
+ RNA_def_property_ui_text(prop, "Frame Start", "First frame of the segment");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "seg_end", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 0, INT16_MAX);
+ RNA_def_property_ui_text(prop, "End", "Last frame of the segment");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "seg_repeat", PROP_INT, PROP_NONE);
+ RNA_def_property_range(prop, 1, INT16_MAX);
+ RNA_def_property_ui_text(prop, "Repeat", "Number of cycle repeats");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "seg_mode", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "seg_mode");
+ RNA_def_property_enum_items(prop, rna_enum_time_seg_mode_items);
+ RNA_def_property_ui_text(prop, "Mode", "");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
srna = RNA_def_struct(brna, "TimeGpencilModifier", "GpencilModifier");
RNA_def_struct_ui_text(srna, "Time Offset Modifier", "Time offset modifier");
@@ -1688,6 +1819,24 @@ static void rna_def_modifier_gpenciltime(BlenderRNA *brna)
RNA_define_lib_overridable(true);
+ prop = RNA_def_property(srna, "segments", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "TimeGpencilModifierSegment");
+ RNA_def_property_collection_sdna(prop, NULL, "segments", NULL);
+ RNA_def_property_collection_funcs(prop,
+ "rna_GpencilTime_segments_begin",
+ "rna_iterator_array_next",
+ "rna_iterator_array_end",
+ "rna_iterator_array_get",
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ RNA_def_property_ui_text(prop, "Segments", "");
+
+ prop = RNA_def_property(srna, "segment_active_index", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Active Dash Segment Index", "Active index in the segment list");
+
prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "mode");
RNA_def_property_enum_items(prop, rna_enum_time_mode_items);
@@ -1972,6 +2121,107 @@ static void rna_def_modifier_gpencilopacity(BlenderRNA *brna)
RNA_define_lib_overridable(false);
}
+static void rna_def_modifier_gpenciloutline(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna = RNA_def_struct(brna, "OutlineGpencilModifier", "GpencilModifier");
+ RNA_def_struct_ui_text(srna, "Outline Modifier", "Outline of Strokes modifier from camera view");
+ RNA_def_struct_sdna(srna, "OutlineGpencilModifierData");
+ RNA_def_struct_ui_icon(srna, ICON_MOD_OUTLINE);
+
+ RNA_define_lib_overridable(true);
+
+ prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "layername");
+ RNA_def_property_ui_text(prop, "Layer", "Layer name");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "material", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_funcs(prop,
+ NULL,
+ "rna_OutlineGpencilModifier_material_set",
+ NULL,
+ "rna_GpencilModifier_material_poll");
+ RNA_def_property_ui_text(prop, "Material", "Material used for filtering effect");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "pass_index", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "pass_index");
+ RNA_def_property_range(prop, 0, 100);
+ RNA_def_property_ui_text(prop, "Pass", "Pass index");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "invert_layers", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OUTLINE_INVERT_LAYER);
+ RNA_def_property_ui_text(prop, "Inverse Layers", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "invert_materials", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OUTLINE_INVERT_MATERIAL);
+ RNA_def_property_ui_text(prop, "Inverse Materials", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "invert_material_pass", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OUTLINE_INVERT_PASS);
+ RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "layer_pass", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "layer_pass");
+ RNA_def_property_range(prop, 0, 100);
+ RNA_def_property_ui_text(prop, "Pass", "Layer pass index");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "invert_layer_pass", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OUTLINE_INVERT_LAYERPASS);
+ RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "thickness");
+ RNA_def_property_range(prop, 1, 1000);
+ RNA_def_property_ui_text(prop, "Thickness", "Thickness of the perimeter stroke");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "sample_length", PROP_FLOAT, PROP_NONE);
+ RNA_def_property_float_sdna(prop, NULL, "sample_length");
+ RNA_def_property_ui_range(prop, 0.0f, 100.0f, 0.1f, 2);
+ RNA_def_property_ui_text(prop, "Sample Length", "");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "subdivision", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "subdiv");
+ RNA_def_property_range(prop, 0, 10);
+ RNA_def_property_ui_text(prop, "Subdivisions", "Number of subdivisions");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "use_keep_shape", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_OUTLINE_KEEP_SHAPE);
+ RNA_def_property_ui_text(prop, "Keep Shape", "Try to keep global shape");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "outline_material", PROP_POINTER, PROP_NONE);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_pointer_funcs(prop,
+ NULL,
+ "rna_OutlineStrokeGpencilModifier_material_set",
+ NULL,
+ "rna_GpencilModifier_material_poll");
+ RNA_def_property_ui_text(prop, "Outline Material", "Material used for outline strokes");
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
+
+ prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
+ RNA_def_property_ui_text(prop, "Target Object", "Target object to define stroke start");
+ RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_OutlineGpencilModifier_object_set", NULL, NULL);
+ RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
+
+ RNA_define_lib_overridable(false);
+}
+
static void rna_def_modifier_gpencilarray(BlenderRNA *brna)
{
StructRNA *srna;
@@ -3197,9 +3447,27 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
};
static const EnumPropertyItem modifier_lineart_shadow_region_filtering[] = {
- {LRT_SHADOW_FILTER_NONE, "NONE", 0, "None", ""},
- {LRT_SHADOW_FILTER_LIT, "LIT", 0, "Lit", ""},
- {LRT_SHADOW_FILTER_SHADED, "SHADED", 0, "Shaded", ""},
+ {LRT_SHADOW_FILTER_NONE,
+ "NONE",
+ 0,
+ "None",
+ "Not filtering any lines based on illumination region"},
+ {LRT_SHADOW_FILTER_ILLUMINATED,
+ "ILLUMINATED",
+ 0,
+ "Illuminated",
+ "Only selecting lines from illuminated regions"},
+ {LRT_SHADOW_FILTER_SHADED,
+ "SHADED",
+ 0,
+ "Shaded",
+ "Only selecting lines from shaded regions"},
+ {LRT_SHADOW_FILTER_ILLUMINATED_ENCLOSED_SHAPES,
+ "ILLUMINATED_ENCLOSED",
+ 0,
+ "Illuminated (Enclosed Shapes)",
+ "Selecting lines from lit regions, and make the combination of contour, light contour and "
+ "shadow lines into enclosed shapes"},
{0, NULL, 0, NULL, NULL},
};
@@ -3464,13 +3732,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
"affect cast shadow and light contour since they are at the border");
RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
- prop = RNA_def_property(srna, "use_shadow_enclosed_shapes", PROP_BOOLEAN, PROP_NONE);
- RNA_def_property_boolean_sdna(prop, NULL, "calculation_flags", LRT_SHADOW_ENCLOSED_SHAPES);
- RNA_def_property_ui_text(prop,
- "Shadow Enclosed Shapes",
- "Reproject visible lines again to get enclosed shadow shapes");
- RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
prop = RNA_def_property(srna, "silhouette_filtering", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "silhouette_selection");
RNA_def_property_enum_items(prop, modifier_lineart_silhouette_filtering);
@@ -4159,7 +4420,7 @@ static void rna_def_modifier_gpencilenvelope(BlenderRNA *brna)
srna = RNA_def_struct(brna, "EnvelopeGpencilModifier", "GpencilModifier");
RNA_def_struct_ui_text(srna, "Envelope Modifier", "Envelope stroke effect modifier");
RNA_def_struct_sdna(srna, "EnvelopeGpencilModifierData");
- RNA_def_struct_ui_icon(srna, ICON_MOD_SKIN);
+ RNA_def_struct_ui_icon(srna, ICON_MOD_ENVELOPE);
RNA_define_lib_overridable(true);
@@ -4342,6 +4603,7 @@ void RNA_def_greasepencil_modifier(BlenderRNA *brna)
rna_def_modifier_gpencilarray(brna);
rna_def_modifier_gpencilbuild(brna);
rna_def_modifier_gpencilopacity(brna);
+ rna_def_modifier_gpenciloutline(brna);
rna_def_modifier_gpencillattice(brna);
rna_def_modifier_gpencilmirror(brna);
rna_def_modifier_gpencilhook(brna);