Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_mode_maskshrinkfatten.c
| Show All 30 Lines | |||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "transform.h" | #include "transform.h" | ||||
| #include "transform_data.h" | |||||
| #include "transform_mode.h" | #include "transform_mode.h" | ||||
| #include "transform_snap.h" | #include "transform_snap.h" | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /* Transform (Mask Shrink/Fatten) */ | /* Transform (Mask Shrink/Fatten) */ | ||||
| /** \name Transform Mask Shrink/Fatten | /** \name Transform Mask Shrink/Fatten | ||||
| * \{ */ | * \{ */ | ||||
| static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| { | { | ||||
| float ratio; | float ratio; | ||||
| int i; | |||||
| bool initial_feather = false; | bool initial_feather = false; | ||||
| char str[UI_MAX_DRAW_STR]; | char str[UI_MAX_DRAW_STR]; | ||||
| ratio = t->values[0]; | ratio = t->values[0]; | ||||
| snapGridIncrement(t, &ratio); | snapGridIncrement(t, &ratio); | ||||
| applyNumInput(&t->num, &ratio); | applyNumInput(&t->num, &ratio); | ||||
| Show All 12 Lines | static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) | ||||
| } | } | ||||
| /* detect if no points have feather yet */ | /* detect if no points have feather yet */ | ||||
| if (ratio > 1.0f) { | if (ratio > 1.0f) { | ||||
| initial_feather = true; | initial_feather = true; | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | for (int tdi = 0; tdi < tc->data_len; tdi++) { | ||||
| if (td->flag & TD_SKIP) { | if (td->basic[tdi].flag & TD_SKIP) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (td->ival >= 0.001f) { | if (td->special[tdi].ival >= 0.001f) { | ||||
| initial_feather = false; | initial_feather = false; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* apply shrink/fatten */ | /* apply shrink/fatten */ | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | TransData *td = tc->data; | ||||
| for (td = tc->data, i = 0; i < tc->data_len; i++, td++) { | for (int tdi = 0; tdi < tc->data_len; tdi++) { | ||||
| if (td->flag & TD_SKIP) { | if (td->basic[tdi].flag & TD_SKIP) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (td->val) { | if (td->special[tdi].val) { | ||||
| if (initial_feather) { | if (initial_feather) { | ||||
| *td->val = td->ival + (ratio - 1.0f) * 0.01f; | *td->special[tdi].val = td->special[tdi].ival + (ratio - 1.0f) * 0.01f; | ||||
| } | } | ||||
| else { | else { | ||||
| *td->val = td->ival * ratio; | *td->special[tdi].val = td->special[tdi].ival * ratio; | ||||
| } | } | ||||
| /* apply PET */ | /* apply PET */ | ||||
| *td->val = (*td->val * td->factor) + ((1.0f - td->factor) * td->ival); | *td->special[tdi].val = (*td->special[tdi].val * td->prop[tdi].factor) + | ||||
| if (*td->val <= 0.0f) { | ((1.0f - td->prop[tdi].factor) * td->special[tdi].ival); | ||||
| *td->val = 0.001f; | if (*td->special[tdi].val <= 0.0f) { | ||||
| *td->special[tdi].val = 0.001f; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| recalcData(t); | recalcData(t); | ||||
| ED_area_status_text(t->area, str); | ED_area_status_text(t->area, str); | ||||
| Show All 27 Lines | |||||