GP: Refactor Instance modifier and rename to Array
authorAntonioya <blendergit@gmail.com>
Sun, 28 Oct 2018 17:08:24 +0000 (18:08 +0100)
committerAntonioya <blendergit@gmail.com>
Sun, 28 Oct 2018 17:20:50 +0000 (18:20 +0100)
The old name Instance was logic when the modifier created new object instances, but now works equal to mesh Array modifier, so the old name was not logic and must be Array.

Also added a Object to use as offset similar to mesh Array modifier.

12 files changed:
release/scripts/startup/bl_ui/properties_data_modifier.py
source/blender/blenkernel/BKE_gpencil.h
source/blender/blenkernel/BKE_gpencil_modifier.h
source/blender/blenkernel/intern/gpencil_modifier.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/gpencil_modifiers/CMakeLists.txt
source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c [moved from source/blender/gpencil_modifiers/intern/MOD_gpencilinstance.c with 52% similarity]
source/blender/makesdna/DNA_gpencil_modifier_types.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/intern/rna_gpencil_modifier.c

index b72eb832d2a70f296b9fbca58271b011d2c23721..761805800fef884dee17c62012100ab89f5b3614 100644 (file)
@@ -1919,7 +1919,7 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         row.prop(md, "layer_pass", text="Pass")
         row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
 
-    def GP_INSTANCE(self, layout, ob, md):
+    def GP_ARRAY(self, layout, ob, md):
         gpd = ob.data
 
         col = layout.column()
@@ -1929,12 +1929,11 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         col = split.column()
         col.label(text="Offset:")
         col.prop(md, "offset", text="")
+        col.prop(md, "offset_object", text="Object")
 
         col = split.column()
         col.label(text="Shift:")
         col.prop(md, "shift", text="")
-        row = col.row(align=True)
-        row.prop(md, "lock_axis", expand=True)
 
         split = layout.split()
         col = split.column()
index 8ab088eff0297ce7be07f1997322147a99480e99..1debfecc895c8afb71089363ea485073b0e47db6 100644 (file)
@@ -50,7 +50,7 @@ struct Brush;
 struct Object;
 struct bDeformGroup;
 struct SimplifyGpencilModifierData;
-struct InstanceGpencilModifierData;
+struct ArrayGpencilModifierData;
 struct LatticeGpencilModifierData;
 
 struct MDeformVert;
index 5efc390015ce523da050aeeab5c91e1323740c2e..91f368613cb045deaff9d71cfdd24faef0e15f42 100644 (file)
@@ -234,8 +234,6 @@ typedef struct GpencilModifierTypeInfo {
                               GreasePencilTexWalkFunc walk, void *userData);
 } GpencilModifierTypeInfo;
 
-void BKE_gpencil_instance_modifier_instance_tfm(struct InstanceGpencilModifierData *mmd, const int elem_idx[3], float r_mat[4][4]);
-
 /* Initialize modifier's global data (type info and some common global storages). */
 void BKE_gpencil_modifier_init(void);
 
index abf6268a9a394a4e8f69eb37269e3b959e27a375..68691cd3d05c671da70a922f3d1d131896456809 100644 (file)
@@ -720,47 +720,6 @@ GpencilModifierData *BKE_gpencil_modifiers_findByName(Object *ob, const char *na
        return BLI_findstring(&(ob->greasepencil_modifiers), name, offsetof(GpencilModifierData, name));
 }
 
-/* helper function for per-instance positioning */
-void BKE_gpencil_instance_modifier_instance_tfm(InstanceGpencilModifierData *mmd, const int elem_idx[3], float r_mat[4][4])
-{
-       float offset[3], rot[3], scale[3];
-       int ri = mmd->rnd[0];
-       float factor;
-
-       offset[0] = mmd->offset[0] * elem_idx[0];
-       offset[1] = mmd->offset[1] * elem_idx[1];
-       offset[2] = mmd->offset[2] * elem_idx[2];
-
-       /* rotation */
-       if (mmd->flag & GP_INSTANCE_RANDOM_ROT) {
-               factor = mmd->rnd_rot * mmd->rnd[ri];
-               mul_v3_v3fl(rot, mmd->rot, factor);
-               add_v3_v3(rot, mmd->rot);
-       }
-       else {
-               copy_v3_v3(rot, mmd->rot);
-       }
-
-       /* scale */
-       if (mmd->flag & GP_INSTANCE_RANDOM_SIZE) {
-               factor = mmd->rnd_size * mmd->rnd[ri];
-               mul_v3_v3fl(scale, mmd->scale, factor);
-               add_v3_v3(scale, mmd->scale);
-       }
-       else {
-               copy_v3_v3(scale, mmd->scale);
-       }
-
-       /* advance random index */
-       mmd->rnd[0]++;
-       if (mmd->rnd[0] > 19) {
-               mmd->rnd[0] = 1;
-       }
-
-       /* calculate matrix */
-       loc_eul_size_to_mat4(r_mat, offset, rot, scale);
-}
-
 void BKE_gpencil_subdivide(bGPDstroke *gps, int level, int flag)
 {
        bGPDspoint *temp_points;
index 1c45dc24108fd666b1aa8dc566adcc8ec9652a46..41ec458c0231b7470b275416ca9e34a481d96e18 100644 (file)
@@ -1064,7 +1064,7 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
                                                case eGpencilModifierType_Tint:
                                                        data.icon = ICON_COLOR;
                                                        break;
-                                               case eGpencilModifierType_Instance:
+                                               case eGpencilModifierType_Array:
                                                        data.icon = ICON_MOD_ARRAY;
                                                        break;
                                                case eGpencilModifierType_Build:
index 00a387c58e8fb82b4690bf7aaf33a151256d949e..b28a83372b884905b5f69953ee5b03b058ca14a1 100644 (file)
@@ -50,7 +50,7 @@ set(SRC
        intern/MOD_gpencilthick.c
        intern/MOD_gpenciltint.c
        intern/MOD_gpencilcolor.c
-       intern/MOD_gpencilinstance.c
+       intern/MOD_gpencilarray.c
        intern/MOD_gpencilbuild.c
        intern/MOD_gpencilopacity.c
        intern/MOD_gpencillattice.c
index d820bbcc7c82de0bdbc8c07ab9268d0b393599fe..07db9f152883f2fe9b6ce32528d9b62ec81dfcfe 100644 (file)
@@ -36,7 +36,7 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Simplify;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Thick;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Tint;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Color;
-extern GpencilModifierTypeInfo modifierType_Gpencil_Instance;
+extern GpencilModifierTypeInfo modifierType_Gpencil_Array;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Build;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Opacity;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Lattice;
index 1a61133f3f7d4f478134cd04c0ab748be08e54aa..2551d9a216d2e818215f1787e8d8b161010c7993 100644 (file)
@@ -69,7 +69,7 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[])
        INIT_GP_TYPE(Thick);
        INIT_GP_TYPE(Tint);
        INIT_GP_TYPE(Color);
-       INIT_GP_TYPE(Instance);
+       INIT_GP_TYPE(Array);
        INIT_GP_TYPE(Build);
        INIT_GP_TYPE(Opacity);
        INIT_GP_TYPE(Lattice);
similarity index 52%
rename from source/blender/gpencil_modifiers/intern/MOD_gpencilinstance.c
rename to source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
index 9c56a06af996c3603ce0aedaf25b358c2edfec3e..b188dd0de0b3d8b40dbfb31c2d79abf0f1495c1c 100644 (file)
 
 #include "BKE_gpencil.h"
 #include "BKE_gpencil_modifier.h"
+#include "BKE_modifier.h"
 #include "BKE_context.h"
 #include "BKE_global.h"
 #include "BKE_object.h"
 #include "BKE_main.h"
 #include "BKE_scene.h"
 #include "BKE_layer.h"
+#include "BKE_library_query.h"
 #include "BKE_collection.h"
 
 #include "DEG_depsgraph.h"
 #include "MOD_gpencil_util.h"
 #include "MOD_gpencil_modifiertypes.h"
 
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
+
 static void initData(GpencilModifierData *md)
 {
-       InstanceGpencilModifierData *gpmd = (InstanceGpencilModifierData *)md;
-       gpmd->count[0] = 1;
-       gpmd->count[1] = 1;
-       gpmd->count[2] = 1;
+       ArrayGpencilModifierData *gpmd = (ArrayGpencilModifierData *)md;
+       gpmd->count = 2;
        gpmd->offset[0] = 1.0f;
-       gpmd->offset[1] = 1.0f;
-       gpmd->offset[2] = 1.0f;
+       gpmd->offset[1] = 0.0f;
+       gpmd->offset[2] = 0.0f;
        gpmd->shift[0] = 0.0f;
        gpmd->shift[1] = 0.0f;
        gpmd->shift[2] = 0.0f;
@@ -76,7 +80,7 @@ static void initData(GpencilModifierData *md)
        gpmd->scale[2] = 1.0f;
        gpmd->rnd_rot = 0.5f;
        gpmd->rnd_size = 0.5f;
-       gpmd->lock_axis |= GP_LOCKAXIS_X;
+       gpmd->object = NULL;
 
        /* fill random values */
        BLI_array_frand(gpmd->rnd, 20, 1);
@@ -89,14 +93,74 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
 }
 
 /* -------------------------------- */
+/* helper function for per-instance positioning */
+static void BKE_gpencil_instance_modifier_instance_tfm(
+       Object *ob, ArrayGpencilModifierData *mmd, const int elem_idx,
+       float r_mat[4][4], float r_offset[4][4])
+{
+       float offset[3], rot[3], scale[3];
+       int ri = mmd->rnd[0];
+       float factor;
+
+       offset[0] = mmd->offset[0] * elem_idx;
+       offset[1] = mmd->offset[1] * elem_idx;
+       offset[2] = mmd->offset[2] * elem_idx;
+
+       /* rotation */
+       if (mmd->flag & GP_ARRAY_RANDOM_ROT) {
+               factor = mmd->rnd_rot * mmd->rnd[ri];
+               mul_v3_v3fl(rot, mmd->rot, factor);
+               add_v3_v3(rot, mmd->rot);
+       }
+       else {
+               copy_v3_v3(rot, mmd->rot);
+       }
+
+       /* scale */
+       if (mmd->flag & GP_ARRAY_RANDOM_SIZE) {
+               factor = mmd->rnd_size * mmd->rnd[ri];
+               mul_v3_v3fl(scale, mmd->scale, factor);
+               add_v3_v3(scale, mmd->scale);
+       }
+       else {
+               copy_v3_v3(scale, mmd->scale);
+       }
+
+       /* advance random index */
+       mmd->rnd[0]++;
+       if (mmd->rnd[0] > 19) {
+               mmd->rnd[0] = 1;
+       }
+
+       /* calculate matrix */
+       loc_eul_size_to_mat4(r_mat, offset, rot, scale);
+
+       copy_m4_m4(r_offset, r_mat);
+
+       /* offset object */
+       if (mmd->object) {
+               float mat_offset[4][4];
+               float obinv[4][4];
+
+               unit_m4(mat_offset);
+               add_v3_v3(mat_offset[3], mmd->offset);
+               invert_m4_m4(obinv, ob->obmat);
+
+               mul_m4_series(r_offset, mat_offset,
+                       obinv, mmd->object->obmat);
+               copy_m4_m4(mat_offset, r_offset);
+
+               /* clear r_mat locations to avoid double transform */
+               zero_v3(r_mat[3]);
+       }
+}
 
 /* array modifier - generate geometry callback (for viewport/rendering) */
-/* TODO: How to skip this for the simplify options?   -->  !GP_SIMPLIFY_MODIF(ts, playing) */
 static void generate_geometry(
         GpencilModifierData *md, Depsgraph *UNUSED(depsgraph),
         Object *ob, bGPDlayer *gpl, bGPDframe *gpf)
 {
-       InstanceGpencilModifierData *mmd = (InstanceGpencilModifierData *)md;
+       ArrayGpencilModifierData *mmd = (ArrayGpencilModifierData *)md;
        ListBase stroke_cache = {NULL, NULL};
        bGPDstroke *gps;
        int idx;
@@ -115,8 +179,8 @@ static void generate_geometry(
                 */
                if (is_stroke_affected_by_modifier(ob,
                        mmd->layername, mmd->pass_index, mmd->layer_pass, 1, gpl, gps,
-                       mmd->flag & GP_INSTANCE_INVERT_LAYER, mmd->flag & GP_INSTANCE_INVERT_PASS,
-                               mmd->flag & GP_INSTANCE_INVERT_LAYERPASS))
+                       mmd->flag & GP_ARRAY_INVERT_LAYER, mmd->flag & GP_ARRAY_INVERT_PASS,
+                               mmd->flag & GP_ARRAY_INVERT_LAYERPASS))
                {
                        valid_strokes[idx] = true;
                        num_valid++;
@@ -138,66 +202,69 @@ static void generate_geometry(
         * keeping each instance together so they maintain
         * the correct ordering relative to each other
         */
-       for (int x = 0; x < mmd->count[0]; x++) {
-               for (int y = 0; y < mmd->count[1]; y++) {
-                       for (int z = 0; z < mmd->count[2]; z++) {
-                               /* original strokes are at index = 0,0,0 */
-                               if ((x == 0) && (y == 0) && (z == 0)) {
-                                       continue;
-                               }
+       float current_offset[4][4];
+       unit_m4(current_offset);
 
-                               /* Compute transforms for this instance */
-                               const int elem_idx[3] = {x, y, z};
-                               float mat[4][4];
+       for (int x = 0; x < mmd->count; x++) {
+               /* original strokes are at index = 0 */
+               if (x == 0) {
+                       continue;
+               }
 
-                               BKE_gpencil_instance_modifier_instance_tfm(mmd, elem_idx, mat);
+               /* Compute transforms for this instance */
+               float mat[4][4];
+               float mat_offset[4][4];
+               BKE_gpencil_instance_modifier_instance_tfm(ob, mmd, x, mat, mat_offset);
 
-                               /* apply shift */
-                               int sh = x;
-                               if (mmd->lock_axis == GP_LOCKAXIS_Y) {
-                                       sh = y;
-                               }
-                               if (mmd->lock_axis == GP_LOCKAXIS_Z) {
-                                       sh = z;
+               if (mmd->object) {
+                       /* recalculate cumulative offset here */
+                       mul_m4_m4m4(current_offset, current_offset, mat_offset);
+               }
+               else {
+                       copy_m4_m4(current_offset, mat);
+               }
+               /* apply shift */
+               madd_v3_v3fl(current_offset[3], mmd->shift, x);
+
+               /* Duplicate original strokes to create this instance */
+               for (gps = gpf->strokes.first, idx = 0; gps; gps = gps->next, idx++) {
+                       /* check if stroke can be duplicated */
+                       if (valid_strokes[idx]) {
+                               /* Duplicate stroke */
+                               bGPDstroke *gps_dst = MEM_dupallocN(gps);
+                               gps_dst->points = MEM_dupallocN(gps->points);
+                               if (gps->dvert) {
+                                       gps_dst->dvert = MEM_dupallocN(gps->dvert);
+                                       BKE_gpencil_stroke_weights_duplicate(gps, gps_dst);
                                }
-                               madd_v3_v3fl(mat[3], mmd->shift, sh);
-
-                               /* Duplicate original strokes to create this instance */
-                               for (gps = gpf->strokes.first, idx = 0; gps; gps = gps->next, idx++) {
-                                       /* check if stroke can be duplicated */
-                                       if (valid_strokes[idx]) {
-                                               /* Duplicate stroke */
-                                               bGPDstroke *gps_dst = MEM_dupallocN(gps);
-                                               gps_dst->points = MEM_dupallocN(gps->points);
-                                               if (gps->dvert) {
-                                                       gps_dst->dvert = MEM_dupallocN(gps->dvert);
-                                                       BKE_gpencil_stroke_weights_duplicate(gps, gps_dst);
-                                               }
-                                               gps_dst->triangles = MEM_dupallocN(gps->triangles);
-
-                                               /* Move points */
-                                               for (int i = 0; i < gps->totpoints; i++) {
-                                                       bGPDspoint *pt = &gps_dst->points[i];
-                                                       mul_m4_v3(mat, &pt->x);
-                                               }
-
-                                               /* if replace material, use new one */
-                                               if ((mmd->mat_rpl > 0) && (mmd->mat_rpl <= ob->totcol)) {
-                                                       gps_dst->mat_nr = mmd->mat_rpl - 1;
-                                               }
-
-                                               /* Add new stroke to cache, to be added to the frame once
-                                                * all duplicates have been made
-                                                */
-                                               BLI_addtail(&stroke_cache, gps_dst);
+                               gps_dst->triangles = MEM_dupallocN(gps->triangles);
+
+                               /* Move points */
+                               for (int i = 0; i < gps->totpoints; i++) {
+                                       bGPDspoint *pt = &gps_dst->points[i];
+                                       if (mmd->object) {
+                                               /* apply local changes (rot/scale) */
+                                               mul_m4_v3(mat, &pt->x);
                                        }
+                                       /* global changes */
+                                       mul_m4_v3(current_offset, &pt->x);
                                }
+
+                               /* if replace material, use new one */
+                               if ((mmd->mat_rpl > 0) && (mmd->mat_rpl <= ob->totcol)) {
+                                       gps_dst->mat_nr = mmd->mat_rpl - 1;
+                               }
+
+                               /* Add new stroke to cache, to be added to the frame once
+                                * all duplicates have been made
+                                */
+                               BLI_addtail(&stroke_cache, gps_dst);
                        }
                }
        }
 
        /* merge newly created stroke instances back into the main stroke list */
-       if (mmd->flag & GP_INSTANCE_KEEP_ONTOP) {
+       if (mmd->flag & GP_ARRAY_KEEP_ONTOP) {
                BLI_movelisttolist_reverse(&gpf->strokes, &stroke_cache);
        }
        else {
@@ -232,10 +299,30 @@ static void generateStrokes(
        generate_geometry(md, depsgraph, ob, gpl, gpf);
 }
 
-GpencilModifierTypeInfo modifierType_Gpencil_Instance = {
-       /* name */              "Instance",
-       /* structName */        "InstanceGpencilModifierData",
-       /* structSize */        sizeof(InstanceGpencilModifierData),
+static void updateDepsgraph(GpencilModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
+{
+       ArrayGpencilModifierData *lmd = (ArrayGpencilModifierData *)md;
+       if (lmd->object != NULL) {
+               DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_GEOMETRY, "Array Modifier");
+               DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_TRANSFORM, "Array Modifier");
+       }
+       DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Array Modifier");
+}
+
+static void foreachObjectLink(
+       GpencilModifierData *md, Object *ob,
+       ObjectWalkFunc walk, void *userData)
+{
+       ArrayGpencilModifierData *mmd = (ArrayGpencilModifierData *)md;
+
+       walk(userData, ob, &mmd->object, IDWALK_CB_NOP);
+}
+
+
+GpencilModifierTypeInfo modifierType_Gpencil_Array = {
+       /* name */              "Array",
+       /* structName */        "ArrayGpencilModifierData",
+       /* structSize */        sizeof(ArrayGpencilModifierData),
        /* type */              eGpencilModifierTypeType_Gpencil,
        /* flags */             0,
 
@@ -249,9 +336,9 @@ GpencilModifierTypeInfo modifierType_Gpencil_Instance = {
        /* initData */          initData,
        /* freeData */          NULL,
        /* isDisabled */        NULL,
-       /* updateDepsgraph */   NULL,
+       /* updateDepsgraph */   updateDepsgraph,
        /* dependsOnTime */     NULL,
-       /* foreachObjectLink */ NULL,
+       /* foreachObjectLink */ foreachObjectLink,
        /* foreachIDLink */     NULL,
        /* foreachTexLink */    NULL,
 };
index 65c75c151cd8266d069ffab1c6b9d20fd4e20d04..191588a9d3648b36eb4a0fe803e9f08c373ab4d5 100644 (file)
@@ -40,7 +40,7 @@ typedef enum GpencilModifierType {
        eGpencilModifierType_Subdiv    = 2,
        eGpencilModifierType_Thick     = 3,
        eGpencilModifierType_Tint      = 4,
-       eGpencilModifierType_Instance  = 5,
+       eGpencilModifierType_Array     = 5,
        eGpencilModifierType_Build     = 6,
        eGpencilModifierType_Opacity   = 7,
        eGpencilModifierType_Color     = 8,
@@ -235,9 +235,10 @@ typedef enum eOpacityGpencil_Flag {
        GP_OPACITY_INVERT_LAYERPASS = (1 << 4),
 } eOpacityGpencil_Flag;
 
-typedef struct InstanceGpencilModifierData {
+typedef struct ArrayGpencilModifierData {
        GpencilModifierData modifier;
-       int count[3];                /* number of elements in array */
+       struct Object *object;
+       int count;                   /* number of elements in array */
        int flag;                    /* several flags */
        float offset[3];             /* Location increments */
        float shift[3];              /* shift increment */
@@ -246,22 +247,22 @@ typedef struct InstanceGpencilModifierData {
        float rot[3];                /* Rotation changes */
        float scale[3];              /* Scale changes */
        float rnd[20];               /* (first element is the index) random values */
-       int  lock_axis;              /* lock shift to one axis */
+       char pad_[4];
 
        int pass_index;              /* custom index for passes */
        char layername[64];          /* layer name */
        int mat_rpl;                 /* material replace (0 keep default) */
        int layer_pass;              /* custom index for passes */
-} InstanceGpencilModifierData;
-
-typedef enum eInstanceGpencil_Flag {
-       GP_INSTANCE_RANDOM_SIZE   = (1 << 0),
-       GP_INSTANCE_RANDOM_ROT    = (1 << 1),
-       GP_INSTANCE_INVERT_LAYER  = (1 << 2),
-       GP_INSTANCE_INVERT_PASS   = (1 << 3),
-       GP_INSTANCE_KEEP_ONTOP    = (1 << 4),
-       GP_INSTANCE_INVERT_LAYERPASS = (1 << 5),
-} eInstanceGpencil_Flag;
+} ArrayGpencilModifierData;
+
+typedef enum eArrayGpencil_Flag {
+       GP_ARRAY_RANDOM_SIZE   = (1 << 0),
+       GP_ARRAY_RANDOM_ROT    = (1 << 1),
+       GP_ARRAY_INVERT_LAYER  = (1 << 2),
+       GP_ARRAY_INVERT_PASS   = (1 << 3),
+       GP_ARRAY_KEEP_ONTOP    = (1 << 4),
+       GP_ARRAY_INVERT_LAYERPASS = (1 << 5),
+} eArrayGpencil_Flag;
 
 typedef struct BuildGpencilModifierData {
        GpencilModifierData modifier;
index 0125b7c7b375160d32a1a4deb0a16dfd47dc0198..c11520587395eea79ce92f0a62803ce323c86975 100644 (file)
@@ -607,7 +607,7 @@ extern StructRNA RNA_ThickGpencilModifier;
 extern StructRNA RNA_TintGpencilModifier;
 extern StructRNA RNA_TimeGpencilModifier;
 extern StructRNA RNA_ColorGpencilModifier;
-extern StructRNA RNA_InstanceGpencilModifier;
+extern StructRNA RNA_ArrayGpencilModifier;
 extern StructRNA RNA_DupliGpencilModifier;
 extern StructRNA RNA_OpacityGpencilModifier;
 extern StructRNA RNA_LatticeGpencilModifier;
index 37bcd83e8b70e365f649b02bf36ef7ef6b782aeb..0be38cbc5582029db9e8d5560f6692cb9f82991d 100644 (file)
@@ -61,7 +61,7 @@
 
 const EnumPropertyItem rna_enum_object_greasepencil_modifier_type_items[] = {
        {0, "", 0, N_("Generate"), "" },
-       {eGpencilModifierType_Instance, "GP_INSTANCE", ICON_MOD_ARRAY, "Instance", "Create grid of duplicate instances"},
+       {eGpencilModifierType_Array, "GP_ARRAY", ICON_MOD_ARRAY, "Array", "Create array of duplicate instances"},
        {eGpencilModifierType_Build, "GP_BUILD", ICON_MOD_BUILD, "Build", "Create duplication of strokes"},
        {eGpencilModifierType_Mirror, "GP_MIRROR", ICON_MOD_MIRROR, "Mirror", "Duplicate strokes like a mirror"},
        {eGpencilModifierType_Simplify, "GP_SIMPLIFY", ICON_MOD_DECIM, "Simplify", "Simplify stroke reducing number of points"},
@@ -103,13 +103,6 @@ static const EnumPropertyItem modifier_gphook_falloff_items[] = {
        { 0, NULL, 0, NULL, NULL }
 };
 
-static const EnumPropertyItem rna_enum_gpencil_lockshift_items[] = {
-       { GP_LOCKAXIS_X, "GP_LOCKAXIS_X", 0, "X", "Use X axis" },
-       { GP_LOCKAXIS_Y, "GP_LOCKAXIS_Y", 0, "Y", "Use Y axis" },
-       { GP_LOCKAXIS_Z, "GP_LOCKAXIS_Z", 0, "Z", "Use Z axis" },
-       { 0, NULL, 0, NULL, NULL }
-};
-
 static const EnumPropertyItem rna_enum_time_mode_items[] = {
        { GP_TIME_MODE_NORMAL, "NORMAL", 0, "Normal", "Apply offset in normal animation direction" },
        { GP_TIME_MODE_REVERSE, "REVERSE", 0, "Reverse", "Apply offset in reverse animation direction" },
@@ -154,8 +147,8 @@ static StructRNA *rna_GpencilModifier_refine(struct PointerRNA *ptr)
                        return &RNA_TimeGpencilModifier;
                case eGpencilModifierType_Color:
                        return &RNA_ColorGpencilModifier;
-               case eGpencilModifierType_Instance:
-                       return &RNA_InstanceGpencilModifier;
+               case eGpencilModifierType_Array:
+                       return &RNA_ArrayGpencilModifier;
                case eGpencilModifierType_Build:
                        return &RNA_BuildGpencilModifier;
                case eGpencilModifierType_Opacity:
@@ -1012,9 +1005,9 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna)
        StructRNA *srna;
        PropertyRNA *prop;
 
-       srna = RNA_def_struct(brna, "InstanceGpencilModifier", "GpencilModifier");
+       srna = RNA_def_struct(brna, "ArrayGpencilModifier", "GpencilModifier");
        RNA_def_struct_ui_text(srna, "Instance Modifier", "Create grid of duplicate instances");
-       RNA_def_struct_sdna(srna, "InstanceGpencilModifierData");
+       RNA_def_struct_sdna(srna, "ArrayGpencilModifierData");
        RNA_def_struct_ui_icon(srna, ICON_MOD_ARRAY);
 
        prop = RNA_def_property(srna, "layer", PROP_STRING, PROP_NONE);
@@ -1028,13 +1021,21 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Pass", "Pass index");
        RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
-       prop = RNA_def_property(srna, "count", PROP_INT, PROP_XYZ);
+       prop = RNA_def_property(srna, "count", PROP_INT, PROP_NONE);
        RNA_def_property_range(prop, 1, INT_MAX);
-       RNA_def_property_ui_range(prop, 1, 20, 1, -1);
+       RNA_def_property_ui_range(prop, 1, 50, 1, -1);
        RNA_def_property_ui_text(prop, "Count", "Number of items");
        RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
        /* Offset parameters */
+       prop = RNA_def_property(srna, "offset_object", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "object");
+       RNA_def_property_ui_text(prop, "Object Offset",
+               "Use the location and rotation of another object to determine the distance and "
+               "rotational change between arrayed items");
+       RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
+       RNA_def_property_update(prop, 0, "rna_GpencilModifier_dependency_update");
+
        prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_TRANSLATION);
        RNA_def_property_float_sdna(prop, NULL, "offset");
        RNA_def_property_ui_text(prop, "Offset", "Value for the distance between items");
@@ -1047,13 +1048,6 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna)
        RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
        RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
-       prop = RNA_def_property(srna, "lock_axis", PROP_ENUM, PROP_NONE);
-       RNA_def_property_enum_sdna(prop, NULL, "lock_axis");
-       RNA_def_property_enum_items(prop, rna_enum_gpencil_lockshift_items);
-       //RNA_def_property_flag(prop, PROP_ENUM_FLAG);
-       RNA_def_property_ui_text(prop, "Axis", "");
-       RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
-
        prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_EULER);
        RNA_def_property_float_sdna(prop, NULL, "rot");
        RNA_def_property_ui_text(prop, "Rotation", "Value for changes in rotation");
@@ -1067,7 +1061,7 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna)
        RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
        prop = RNA_def_property(srna, "random_rot", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_INSTANCE_RANDOM_ROT);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_RANDOM_ROT);
        RNA_def_property_ui_text(prop, "Random Rotation", "Use random factors for rotation");
        RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
@@ -1078,7 +1072,7 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna)
        RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
        prop = RNA_def_property(srna, "random_scale", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_INSTANCE_RANDOM_SIZE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_RANDOM_SIZE);
        RNA_def_property_ui_text(prop, "Random Scale", "Use random factors for scale");
        RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
@@ -1095,12 +1089,12 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna)
        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_INSTANCE_INVERT_LAYER);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_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_material_pass", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_INSTANCE_INVERT_PASS);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_INVERT_PASS);
        RNA_def_property_ui_text(prop, "Inverse Pass", "Inverse filter");
        RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");
 
@@ -1111,12 +1105,12 @@ static void rna_def_modifier_gpencilinstance(BlenderRNA *brna)
        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_INSTANCE_INVERT_LAYERPASS);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_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, "keep_on_top", PROP_BOOLEAN, PROP_NONE);
-       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_INSTANCE_KEEP_ONTOP);
+       RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_ARRAY_KEEP_ONTOP);
        RNA_def_property_ui_text(prop, "Keep On Top",
                "Keep the original stroke in front of new instances (only affect by layer)");
        RNA_def_property_update(prop, 0, "rna_GpencilModifier_update");