Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_sculpt_paint.c
| Show First 20 Lines • Show All 1,346 Lines • ▼ Show 20 Lines | LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | ||||
| if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { | if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { | ||||
| bGPDframe *gpf = gpl->actframe; | bGPDframe *gpf = gpl->actframe; | ||||
| /* Make a new frame to work on if the layer's frame | /* Make a new frame to work on if the layer's frame | ||||
| * and the current scene frame don't match up: | * and the current scene frame don't match up: | ||||
| * - This is useful when animating as it saves that "uh-oh" moment when you realize you've | * - This is useful when animating as it saves that "uh-oh" moment when you realize you've | ||||
| * spent too much time editing the wrong frame. | * spent too much time editing the wrong frame. | ||||
| */ | */ | ||||
| if ((IS_AUTOKEY_ON(scene)) && (gpf->framenum != cfra)) { | if (IS_AUTOKEY_ON(scene) && (gpf->framenum != cfra)) { | ||||
| BKE_gpencil_frame_addcopy(gpl, cfra); | BKE_gpencil_frame_addcopy(gpl, cfra); | ||||
| /* Need tag to recalculate evaluated data to avoid crashes. */ | /* Need tag to recalculate evaluated data to avoid crashes. */ | ||||
| DEG_id_tag_update(&gso->gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); | DEG_id_tag_update(&gso->gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); | ||||
| WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* save off new current frame, so that next update works fine */ | /* save off new current frame, so that next update works fine */ | ||||
| gso->cfra = cfra; | gso->cfra = cfra; | ||||
| } | } | ||||
| /* Apply ----------------------------------------------- */ | /* Apply ----------------------------------------------- */ | ||||
| /* Get angle of the segment relative to the original segment before any transformation | /* Get angle of the segment relative to the original segment before any transformation | ||||
| * For strokes with one point only this is impossible to calculate because there isn't a | * For strokes with one point only this is impossible to calculate because there isn't a | ||||
| * valid reference point. | * valid reference point. | ||||
| */ | */ | ||||
| static float gpencil_sculpt_rotation_eval_get(tGP_BrushEditData *gso, | static float gpencil_sculpt_rotation_eval_get(tGP_BrushEditData *gso, | ||||
| bGPDstroke *gps_eval, | bGPDstroke *gps_eval, | ||||
| bGPDspoint *pt_eval, | bGPDspoint *pt_eval, | ||||
| int idx_eval) | int idx_eval) | ||||
| { | { | ||||
| /* If multiframe or no modifiers, return 0. */ | /* If multiframe or no modifiers, return 0. */ | ||||
| if ((GPENCIL_MULTIEDIT_SESSIONS_ON(gso->gpd)) || (!gso->is_transformed)) { | if (GPENCIL_MULTIEDIT_SESSIONS_ON(gso->gpd) || (!gso->is_transformed)) { | ||||
| return 0.0f; | return 0.0f; | ||||
| } | } | ||||
| const GP_SpaceConversion *gsc = &gso->gsc; | const GP_SpaceConversion *gsc = &gso->gsc; | ||||
| bGPDstroke *gps_orig = (gps_eval->runtime.gps_orig) ? gps_eval->runtime.gps_orig : gps_eval; | bGPDstroke *gps_orig = (gps_eval->runtime.gps_orig) ? gps_eval->runtime.gps_orig : gps_eval; | ||||
| bGPDspoint *pt_orig = &gps_orig->points[pt_eval->runtime.idx_orig]; | bGPDspoint *pt_orig = &gps_orig->points[pt_eval->runtime.idx_orig]; | ||||
| bGPDspoint *pt_prev_eval = NULL; | bGPDspoint *pt_prev_eval = NULL; | ||||
| bGPDspoint *pt_orig_prev = NULL; | bGPDspoint *pt_orig_prev = NULL; | ||||
| ▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | for (i = 0; (i + 1) < gps->totpoints; i++) { | ||||
| /* To each point individually... */ | /* To each point individually... */ | ||||
| pt = &gps->points[i]; | pt = &gps->points[i]; | ||||
| if ((pt->runtime.pt_orig == NULL) && (tool != GPSCULPT_TOOL_GRAB)) { | if ((pt->runtime.pt_orig == NULL) && (tool != GPSCULPT_TOOL_GRAB)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt; | pt_active = (pt->runtime.pt_orig) ? pt->runtime.pt_orig : pt; | ||||
| /* If masked and the point is not selected, skip it. */ | /* If masked and the point is not selected, skip it. */ | ||||
| if ((GPENCIL_ANY_SCULPT_MASK(gso->mask)) && | if (GPENCIL_ANY_SCULPT_MASK(gso->mask) && ((pt_active->flag & GP_SPOINT_SELECT) == 0)) { | ||||
| ((pt_active->flag & GP_SPOINT_SELECT) == 0)) { | |||||
| continue; | continue; | ||||
| } | } | ||||
| index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i; | index = (pt->runtime.pt_orig) ? pt->runtime.idx_orig : i; | ||||
| if ((pt_active != NULL) && (index < gps_active->totpoints)) { | if ((pt_active != NULL) && (index < gps_active->totpoints)) { | ||||
| rot_eval = gpencil_sculpt_rotation_eval_get(gso, gps, pt, i); | rot_eval = gpencil_sculpt_rotation_eval_get(gso, gps, pt, i); | ||||
| ok = apply(gso, gps_active, rot_eval, index, radius, pc1); | ok = apply(gso, gps_active, rot_eval, index, radius, pc1); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 646 Lines • Show Last 20 Lines | |||||