Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_interpolate.c
| Show First 20 Lines • Show All 272 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* Load a Hash with the relationship between strokes. */ | /* Load a Hash with the relationship between strokes. */ | ||||
| static void gpencil_stroke_pair_table(bContext *C, | static void gpencil_stroke_pair_table(bContext *C, | ||||
| tGPDinterpolate *tgpi, | tGPDinterpolate *tgpi, | ||||
| tGPDinterpolate_layer *tgpil) | tGPDinterpolate_layer *tgpil) | ||||
| { | { | ||||
| bGPdata *gpd = tgpi->gpd; | bGPdata *gpd = tgpi->gpd; | ||||
| const bool only_selected = ((GPENCIL_EDIT_MODE(gpd)) && | const bool only_selected = (GPENCIL_EDIT_MODE(gpd) && | ||||
| ((tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) != 0)); | ((tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) != 0)); | ||||
| const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); | const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); | ||||
| /* Create hash tablets with relationship between strokes. */ | /* Create hash tablets with relationship between strokes. */ | ||||
| BLI_listbase_clear(&tgpil->selected_strokes); | BLI_listbase_clear(&tgpil->selected_strokes); | ||||
| tgpil->used_strokes = BLI_ghash_ptr_new(__func__); | tgpil->used_strokes = BLI_ghash_ptr_new(__func__); | ||||
| tgpil->pair_strokes = BLI_ghash_ptr_new(__func__); | tgpil->pair_strokes = BLI_ghash_ptr_new(__func__); | ||||
| /* Create a table with source and target pair of strokes. */ | /* Create a table with source and target pair of strokes. */ | ||||
| LISTBASE_FOREACH (bGPDstroke *, gps_from, &tgpil->prevFrame->strokes) { | LISTBASE_FOREACH (bGPDstroke *, gps_from, &tgpil->prevFrame->strokes) { | ||||
| bGPDstroke *gps_to = NULL; | bGPDstroke *gps_to = NULL; | ||||
| /* only selected */ | /* only selected */ | ||||
| if ((GPENCIL_EDIT_MODE(gpd)) && (only_selected) && | if (GPENCIL_EDIT_MODE(gpd) && (only_selected) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) { | ||||
| ((gps_from->flag & GP_STROKE_SELECT) == 0)) { | |||||
| continue; | continue; | ||||
| } | } | ||||
| /* skip strokes that are invalid for current view */ | /* skip strokes that are invalid for current view */ | ||||
| if (ED_gpencil_stroke_can_use(C, gps_from) == false) { | if (ED_gpencil_stroke_can_use(C, gps_from) == false) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Check if the material is editable. */ | /* Check if the material is editable. */ | ||||
| if (ED_gpencil_stroke_material_editable(tgpi->ob, tgpil->gpl, gps_from) == false) { | if (ED_gpencil_stroke_material_editable(tgpi->ob, tgpil->gpl, gps_from) == false) { | ||||
| ▲ Show 20 Lines • Show All 403 Lines • ▼ Show 20 Lines | static bool gpencil_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinterpolate *tgpi) | ||||
| /* set GP datablock */ | /* set GP datablock */ | ||||
| tgpi->gpd = tgpi->ob->data; | tgpi->gpd = tgpi->ob->data; | ||||
| /* set interpolation weight */ | /* set interpolation weight */ | ||||
| tgpi->shift = RNA_float_get(op->ptr, "shift"); | tgpi->shift = RNA_float_get(op->ptr, "shift"); | ||||
| SET_FLAG_FROM_TEST( | SET_FLAG_FROM_TEST( | ||||
| tgpi->flag, (RNA_enum_get(op->ptr, "layers") == 1), GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS); | tgpi->flag, (RNA_enum_get(op->ptr, "layers") == 1), GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS); | ||||
| SET_FLAG_FROM_TEST( | SET_FLAG_FROM_TEST( | ||||
| tgpi->flag, | tgpi->flag, | ||||
| ((GPENCIL_EDIT_MODE(tgpi->gpd)) && (RNA_boolean_get(op->ptr, "interpolate_selected_only"))), | (GPENCIL_EDIT_MODE(tgpi->gpd) && (RNA_boolean_get(op->ptr, "interpolate_selected_only"))), | ||||
| GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED); | GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED); | ||||
| tgpi->flipmode = RNA_enum_get(op->ptr, "flip"); | tgpi->flipmode = RNA_enum_get(op->ptr, "flip"); | ||||
| tgpi->smooth_factor = RNA_float_get(op->ptr, "smooth_factor"); | tgpi->smooth_factor = RNA_float_get(op->ptr, "smooth_factor"); | ||||
| tgpi->smooth_steps = RNA_int_get(op->ptr, "smooth_steps"); | tgpi->smooth_steps = RNA_int_get(op->ptr, "smooth_steps"); | ||||
| /* Untag strokes to be sure nothing is pending due any canceled process. */ | /* Untag strokes to be sure nothing is pending due any canceled process. */ | ||||
| ▲ Show 20 Lines • Show All 520 Lines • ▼ Show 20 Lines | static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) | ||||
| gpencil_point_conversion_init(C, &gsc); | gpencil_point_conversion_init(C, &gsc); | ||||
| int cfra = CFRA; | int cfra = CFRA; | ||||
| GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate; | GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate; | ||||
| const int step = RNA_int_get(op->ptr, "step"); | const int step = RNA_int_get(op->ptr, "step"); | ||||
| const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); | const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); | ||||
| const bool all_layers = (bool)(RNA_enum_get(op->ptr, "layers") == 1); | const bool all_layers = (bool)(RNA_enum_get(op->ptr, "layers") == 1); | ||||
| const bool only_selected = ((GPENCIL_EDIT_MODE(gpd)) && | const bool only_selected = (GPENCIL_EDIT_MODE(gpd) && | ||||
| (RNA_boolean_get(op->ptr, "interpolate_selected_only") != 0)); | (RNA_boolean_get(op->ptr, "interpolate_selected_only") != 0)); | ||||
| eGP_InterpolateFlipMode flipmode = RNA_enum_get(op->ptr, "flip"); | eGP_InterpolateFlipMode flipmode = RNA_enum_get(op->ptr, "flip"); | ||||
| const float smooth_factor = RNA_float_get(op->ptr, "smooth_factor"); | const float smooth_factor = RNA_float_get(op->ptr, "smooth_factor"); | ||||
| const int smooth_steps = RNA_int_get(op->ptr, "smooth_steps"); | const int smooth_steps = RNA_int_get(op->ptr, "smooth_steps"); | ||||
| const eGP_Interpolate_Type type = RNA_enum_get(op->ptr, "type"); | const eGP_Interpolate_Type type = RNA_enum_get(op->ptr, "type"); | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | ||||
| /* Create a table with source and target pair of strokes. */ | /* Create a table with source and target pair of strokes. */ | ||||
| ListBase selected_strokes = {NULL}; | ListBase selected_strokes = {NULL}; | ||||
| GHash *used_strokes = BLI_ghash_ptr_new(__func__); | GHash *used_strokes = BLI_ghash_ptr_new(__func__); | ||||
| GHash *pair_strokes = BLI_ghash_ptr_new(__func__); | GHash *pair_strokes = BLI_ghash_ptr_new(__func__); | ||||
| LISTBASE_FOREACH (bGPDstroke *, gps_from, &prevFrame->strokes) { | LISTBASE_FOREACH (bGPDstroke *, gps_from, &prevFrame->strokes) { | ||||
| bGPDstroke *gps_to = NULL; | bGPDstroke *gps_to = NULL; | ||||
| /* Only selected. */ | /* Only selected. */ | ||||
| if ((GPENCIL_EDIT_MODE(gpd)) && (only_selected) && | if (GPENCIL_EDIT_MODE(gpd) && (only_selected) && | ||||
| ((gps_from->flag & GP_STROKE_SELECT) == 0)) { | ((gps_from->flag & GP_STROKE_SELECT) == 0)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Skip strokes that are invalid for current view. */ | /* Skip strokes that are invalid for current view. */ | ||||
| if (ED_gpencil_stroke_can_use(C, gps_from) == false) { | if (ED_gpencil_stroke_can_use(C, gps_from) == false) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Check if the material is editable. */ | /* Check if the material is editable. */ | ||||
| ▲ Show 20 Lines • Show All 502 Lines • Show Last 20 Lines | |||||