Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
| Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
| #include "MOD_gpencil_modifiertypes.h" | #include "MOD_gpencil_modifiertypes.h" | ||||
| static void initData(GpencilModifierData *md) | static void initData(GpencilModifierData *md) | ||||
| { | { | ||||
| OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md; | OpacityGpencilModifierData *gpmd = (OpacityGpencilModifierData *)md; | ||||
| gpmd->pass_index = 0; | gpmd->pass_index = 0; | ||||
| gpmd->factor = 1.0f; | gpmd->factor = 1.0f; | ||||
| gpmd->layername[0] = '\0'; | gpmd->layername[0] = '\0'; | ||||
| gpmd->materialname[0] = '\0'; | |||||
| gpmd->vgname[0] = '\0'; | gpmd->vgname[0] = '\0'; | ||||
| gpmd->flag |= GP_OPACITY_CREATE_COLORS; | gpmd->flag |= GP_OPACITY_CREATE_COLORS; | ||||
| gpmd->modify_color = GP_MODIFY_COLOR_BOTH; | gpmd->modify_color = GP_MODIFY_COLOR_BOTH; | ||||
| } | } | ||||
| 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); | ||||
| } | } | ||||
| /* opacity strokes */ | /* opacity strokes */ | ||||
| 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) | ||||
| { | { | ||||
| OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md; | OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md; | ||||
| const int def_nr = defgroup_name_index(ob, mmd->vgname); | const int def_nr = 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->pass_index, | mmd->pass_index, | ||||
| mmd->layer_pass, | mmd->layer_pass, | ||||
| 1, | 1, | ||||
| gpl, | gpl, | ||||
| gps, | gps, | ||||
| mmd->flag & GP_OPACITY_INVERT_LAYER, | mmd->flag & GP_OPACITY_INVERT_LAYER, | ||||
| mmd->flag & GP_OPACITY_INVERT_PASS, | mmd->flag & GP_OPACITY_INVERT_PASS, | ||||
| mmd->flag & GP_OPACITY_INVERT_LAYERPASS)) { | mmd->flag & GP_OPACITY_INVERT_LAYERPASS, | ||||
| mmd->flag & GP_OPACITY_INVERT_MATERIAL)) { | |||||
| return; | return; | ||||
| } | } | ||||
| if (mmd->modify_color != GP_MODIFY_COLOR_FILL) { | if (mmd->modify_color != GP_MODIFY_COLOR_FILL) { | ||||
| gps->runtime.tmp_stroke_rgba[3] *= mmd->factor; | gps->runtime.tmp_stroke_rgba[3] *= mmd->factor; | ||||
| /* if factor is > 1, then force opacity */ | /* if factor is > 1, then force opacity */ | ||||
| if (mmd->factor > 1.0f) { | if (mmd->factor > 1.0f) { | ||||
| gps->runtime.tmp_stroke_rgba[3] += mmd->factor - 1.0f; | gps->runtime.tmp_stroke_rgba[3] += mmd->factor - 1.0f; | ||||
| ▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines | |||||