Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
| Show All 32 Lines | |||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_deform.h" | #include "BKE_deform.h" | ||||
| #include "BKE_gpencil_geom.h" | #include "BKE_gpencil_geom.h" | ||||
| #include "BKE_gpencil_modifier.h" | #include "BKE_gpencil_modifier.h" | ||||
| #include "BKE_lib_query.h" | |||||
| #include "BKE_modifier.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "MOD_gpencil_modifiertypes.h" | #include "MOD_gpencil_modifiertypes.h" | ||||
| #include "MOD_gpencil_util.h" | #include "MOD_gpencil_util.h" | ||||
| static void initData(GpencilModifierData *md) | static void initData(GpencilModifierData *md) | ||||
| { | { | ||||
| OffsetGpencilModifierData *gpmd = (OffsetGpencilModifierData *)md; | OffsetGpencilModifierData *gpmd = (OffsetGpencilModifierData *)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->vgname[0] = '\0'; | gpmd->vgname[0] = '\0'; | ||||
| ARRAY_SET_ITEMS(gpmd->loc, 0.0f, 0.0f, 0.0f); | ARRAY_SET_ITEMS(gpmd->loc, 0.0f, 0.0f, 0.0f); | ||||
| ARRAY_SET_ITEMS(gpmd->rot, 0.0f, 0.0f, 0.0f); | ARRAY_SET_ITEMS(gpmd->rot, 0.0f, 0.0f, 0.0f); | ||||
| ARRAY_SET_ITEMS(gpmd->scale, 0.0f, 0.0f, 0.0f); | ARRAY_SET_ITEMS(gpmd->scale, 0.0f, 0.0f, 0.0f); | ||||
| } | } | ||||
| static void copyData(const GpencilModifierData *md, GpencilModifierData *target) | static void copyData(const GpencilModifierData *md, GpencilModifierData *target) | ||||
| { | { | ||||
| Show All 11 Lines | static void deformStroke(GpencilModifierData *md, | ||||
| OffsetGpencilModifierData *mmd = (OffsetGpencilModifierData *)md; | OffsetGpencilModifierData *mmd = (OffsetGpencilModifierData *)md; | ||||
| const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname); | const int def_nr = BKE_object_defgroup_name_index(ob, mmd->vgname); | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| float loc[3], rot[3], scale[3]; | float loc[3], rot[3], scale[3]; | ||||
| 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_OFFSET_INVERT_LAYER, | mmd->flag & GP_OFFSET_INVERT_LAYER, | ||||
| mmd->flag & GP_OFFSET_INVERT_PASS, | mmd->flag & GP_OFFSET_INVERT_PASS, | ||||
| mmd->flag & GP_OFFSET_INVERT_LAYERPASS, | mmd->flag & GP_OFFSET_INVERT_LAYERPASS, | ||||
| Show All 35 Lines | LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | ||||
| LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { | LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { | ||||
| LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { | LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { | ||||
| deformStroke(md, depsgraph, ob, gpl, gpf, gps); | deformStroke(md, depsgraph, ob, gpl, gpf, gps); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData) | |||||
| { | |||||
| OffsetGpencilModifierData *mmd = (OffsetGpencilModifierData *)md; | |||||
| walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_NOP); | |||||
| } | |||||
| GpencilModifierTypeInfo modifierType_Gpencil_Offset = { | GpencilModifierTypeInfo modifierType_Gpencil_Offset = { | ||||
| /* name */ "Offset", | /* name */ "Offset", | ||||
| /* structName */ "OffsetGpencilModifierData", | /* structName */ "OffsetGpencilModifierData", | ||||
| /* structSize */ sizeof(OffsetGpencilModifierData), | /* structSize */ sizeof(OffsetGpencilModifierData), | ||||
| /* type */ eGpencilModifierTypeType_Gpencil, | /* type */ eGpencilModifierTypeType_Gpencil, | ||||
| /* flags */ eGpencilModifierTypeFlag_SupportsEditmode, | /* flags */ eGpencilModifierTypeFlag_SupportsEditmode, | ||||
| /* copyData */ copyData, | /* copyData */ copyData, | ||||
| /* deformStroke */ deformStroke, | /* deformStroke */ deformStroke, | ||||
| /* generateStrokes */ NULL, | /* generateStrokes */ NULL, | ||||
| /* bakeModifier */ bakeModifier, | /* bakeModifier */ bakeModifier, | ||||
| /* remapTime */ NULL, | /* remapTime */ NULL, | ||||
| /* initData */ initData, | /* initData */ initData, | ||||
| /* freeData */ NULL, | /* freeData */ NULL, | ||||
| /* isDisabled */ NULL, | /* isDisabled */ NULL, | ||||
| /* updateDepsgraph */ NULL, | /* updateDepsgraph */ NULL, | ||||
| /* dependsOnTime */ NULL, | /* dependsOnTime */ NULL, | ||||
| /* foreachObjectLink */ NULL, | /* foreachObjectLink */ NULL, | ||||
| /* foreachIDLink */ NULL, | /* foreachIDLink */ foreachIDLink, | ||||
| /* foreachTexLink */ NULL, | /* foreachTexLink */ NULL, | ||||
| }; | }; | ||||