Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpencil_modifiers/intern/MOD_gpenciltexture.c
| Show All 32 Lines | |||||
| #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.h" | #include "BKE_gpencil.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) | ||||
| { | { | ||||
| TextureGpencilModifierData *gpmd = (TextureGpencilModifierData *)md; | TextureGpencilModifierData *gpmd = (TextureGpencilModifierData *)md; | ||||
| gpmd->fit_method = GP_TEX_CONSTANT_LENGTH; | gpmd->fit_method = GP_TEX_CONSTANT_LENGTH; | ||||
| gpmd->fill_rotation = 0.0f; | gpmd->fill_rotation = 0.0f; | ||||
| gpmd->fill_scale = 1.0f; | gpmd->fill_scale = 1.0f; | ||||
| gpmd->fill_offset[0] = 0.0f; | gpmd->fill_offset[0] = 0.0f; | ||||
| gpmd->fill_offset[1] = 0.0f; | gpmd->fill_offset[1] = 0.0f; | ||||
| gpmd->uv_offset = 0.0f; | gpmd->uv_offset = 0.0f; | ||||
| gpmd->uv_scale = 1.0f; | gpmd->uv_scale = 1.0f; | ||||
| 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'; | ||||
| } | } | ||||
| 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); | ||||
| } | } | ||||
| /* change stroke uv texture values */ | /* change stroke uv texture values */ | ||||
| static void deformStroke(GpencilModifierData *md, | static void deformStroke(GpencilModifierData *md, | ||||
| Depsgraph *UNUSED(depsgraph), | Depsgraph *UNUSED(depsgraph), | ||||
| Object *ob, | Object *ob, | ||||
| bGPDlayer *gpl, | bGPDlayer *gpl, | ||||
| bGPDframe *UNUSED(gpf), | bGPDframe *UNUSED(gpf), | ||||
| bGPDstroke *gps) | bGPDstroke *gps) | ||||
| { | { | ||||
| TextureGpencilModifierData *mmd = (TextureGpencilModifierData *)md; | TextureGpencilModifierData *mmd = (TextureGpencilModifierData *)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); | ||||
| 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_TEX_INVERT_LAYER, | mmd->flag & GP_TEX_INVERT_LAYER, | ||||
| mmd->flag & GP_TEX_INVERT_PASS, | mmd->flag & GP_TEX_INVERT_PASS, | ||||
| mmd->flag & GP_TEX_INVERT_LAYERPASS, | mmd->flag & GP_TEX_INVERT_LAYERPASS, | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 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) | |||||
| { | |||||
| TextureGpencilModifierData *mmd = (TextureGpencilModifierData *)md; | |||||
| walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_NOP); | |||||
| } | |||||
| GpencilModifierTypeInfo modifierType_Gpencil_Texture = { | GpencilModifierTypeInfo modifierType_Gpencil_Texture = { | ||||
| /* name */ "Texture Mapping", | /* name */ "Texture Mapping", | ||||
| /* structName */ "TextureGpencilModifierData", | /* structName */ "TextureGpencilModifierData", | ||||
| /* structSize */ sizeof(TextureGpencilModifierData), | /* structSize */ sizeof(TextureGpencilModifierData), | ||||
| /* 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, | ||||
| }; | }; | ||||