Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
| #include "DEG_depsgraph_build.h" | #include "DEG_depsgraph_build.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| static void initData(GpencilModifierData *md) | static void initData(GpencilModifierData *md) | ||||
| { | { | ||||
| MirrorGpencilModifierData *gpmd = (MirrorGpencilModifierData *)md; | MirrorGpencilModifierData *gpmd = (MirrorGpencilModifierData *)md; | ||||
| gpmd->pass_index = 0; | gpmd->pass_index = 0; | ||||
| gpmd->layername[0] = '\0'; | gpmd->layername[0] = '\0'; | ||||
| gpmd->materialname[0] = '\0'; | gpmd->material = NULL; | ||||
| gpmd->object = NULL; | gpmd->object = NULL; | ||||
| gpmd->flag |= GP_MIRROR_AXIS_X; | gpmd->flag |= GP_MIRROR_AXIS_X; | ||||
| } | } | ||||
| static void copyData(const GpencilModifierData *md, GpencilModifierData *target) | static void copyData(const GpencilModifierData *md, GpencilModifierData *target) | ||||
| { | { | ||||
| BKE_gpencil_modifier_copydata_generic(md, target); | BKE_gpencil_modifier_copydata_generic(md, target); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | for (int xi = 0; xi < 3; xi++) { | ||||
| if (mmd->flag & (GP_MIRROR_AXIS_X << xi)) { | if (mmd->flag & (GP_MIRROR_AXIS_X << xi)) { | ||||
| /* count strokes to avoid infinite loop after adding new strokes to tail of listbase */ | /* count strokes to avoid infinite loop after adding new strokes to tail of listbase */ | ||||
| tot_strokes = BLI_listbase_count(&gpf->strokes); | tot_strokes = BLI_listbase_count(&gpf->strokes); | ||||
| for (i = 0, gps = gpf->strokes.first; i < tot_strokes; i++, gps = gps->next) { | for (i = 0, gps = gpf->strokes.first; i < tot_strokes; i++, gps = gps->next) { | ||||
| if (is_stroke_affected_by_modifier(ob, | if (is_stroke_affected_by_modifier(ob, | ||||
| mmd->layername, | mmd->layername, | ||||
| mmd->materialname, | mmd->material, | ||||
| mmd->pass_index, | mmd->pass_index, | ||||
| mmd->layer_pass, | mmd->layer_pass, | ||||
| 1, | 1, | ||||
| gpl, | gpl, | ||||
| gps, | gps, | ||||
| mmd->flag & GP_MIRROR_INVERT_LAYER, | mmd->flag & GP_MIRROR_INVERT_LAYER, | ||||
| mmd->flag & GP_MIRROR_INVERT_PASS, | mmd->flag & GP_MIRROR_INVERT_PASS, | ||||
| mmd->flag & GP_MIRROR_INVERT_LAYERPASS, | mmd->flag & GP_MIRROR_INVERT_LAYERPASS, | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | static void foreachObjectLink(GpencilModifierData *md, | ||||
| ObjectWalkFunc walk, | ObjectWalkFunc walk, | ||||
| void *userData) | void *userData) | ||||
| { | { | ||||
| MirrorGpencilModifierData *mmd = (MirrorGpencilModifierData *)md; | MirrorGpencilModifierData *mmd = (MirrorGpencilModifierData *)md; | ||||
| walk(userData, ob, &mmd->object, IDWALK_CB_NOP); | walk(userData, ob, &mmd->object, IDWALK_CB_NOP); | ||||
| } | } | ||||
| static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) | |||||
| { | |||||
| MirrorGpencilModifierData *mmd = (MirrorGpencilModifierData *)md; | |||||
| walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_NOP); | |||||
| foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData); | |||||
| } | |||||
| GpencilModifierTypeInfo modifierType_Gpencil_Mirror = { | GpencilModifierTypeInfo modifierType_Gpencil_Mirror = { | ||||
| /* name */ "Mirror", | /* name */ "Mirror", | ||||
| /* structName */ "MirrorGpencilModifierData", | /* structName */ "MirrorGpencilModifierData", | ||||
| /* structSize */ sizeof(MirrorGpencilModifierData), | /* structSize */ sizeof(MirrorGpencilModifierData), | ||||
| /* type */ eGpencilModifierTypeType_Gpencil, | /* type */ eGpencilModifierTypeType_Gpencil, | ||||
| /* flags */ eGpencilModifierTypeFlag_SupportsEditmode, | /* flags */ eGpencilModifierTypeFlag_SupportsEditmode, | ||||
| /* copyData */ copyData, | /* copyData */ copyData, | ||||
| /* deformStroke */ NULL, | /* deformStroke */ NULL, | ||||
| /* generateStrokes */ generateStrokes, | /* generateStrokes */ generateStrokes, | ||||
| /* bakeModifier */ bakeModifier, | /* bakeModifier */ bakeModifier, | ||||
| /* remapTime */ NULL, | /* remapTime */ NULL, | ||||
| /* initData */ initData, | /* initData */ initData, | ||||
| /* freeData */ NULL, | /* freeData */ NULL, | ||||
| /* isDisabled */ isDisabled, | /* isDisabled */ isDisabled, | ||||
| /* updateDepsgraph */ updateDepsgraph, | /* updateDepsgraph */ updateDepsgraph, | ||||
| /* dependsOnTime */ NULL, | /* dependsOnTime */ NULL, | ||||
| /* foreachObjectLink */ foreachObjectLink, | /* foreachObjectLink */ foreachObjectLink, | ||||
| /* foreachIDLink */ NULL, | /* foreachIDLink */ foreachIDLink, | ||||
| /* foreachTexLink */ NULL, | /* foreachTexLink */ NULL, | ||||
| }; | }; | ||||