Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_sculpt_paint.c
| Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_brush.h" | #include "BKE_brush.h" | ||||
| #include "BKE_colortools.h" | #include "BKE_colortools.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.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_gpencil_update_cache.h" | |||||
| #include "BKE_main.h" | #include "BKE_main.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "BKE_object_deform.h" | #include "BKE_object_deform.h" | ||||
| #include "BKE_report.h" | #include "BKE_report.h" | ||||
| #include "UI_interface.h" | #include "UI_interface.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| ▲ Show 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | |||||
| /* Recalc any stroke tagged. */ | /* Recalc any stroke tagged. */ | ||||
| static void gpencil_update_geometry(bGPdata *gpd) | static void gpencil_update_geometry(bGPdata *gpd) | ||||
| { | { | ||||
| if (gpd == NULL) { | if (gpd == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| bool changed = false; | |||||
| LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { | ||||
| LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { | LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { | ||||
| if ((gpl->actframe != gpf) && ((gpf->flag & GP_FRAME_SELECT) == 0)) { | if ((gpl->actframe != gpf) && ((gpf->flag & GP_FRAME_SELECT) == 0)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { | LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { | ||||
| if (gps->flag & GP_STROKE_TAG) { | if (gps->flag & GP_STROKE_TAG) { | ||||
| BKE_gpencil_stroke_geometry_update(gpd, gps); | BKE_gpencil_stroke_geometry_update(gpd, gps); | ||||
| BKE_gpencil_tag_full_update(gpd, gpl, gpf, gps); | |||||
| gps->flag &= ~GP_STROKE_TAG; | gps->flag &= ~GP_STROKE_TAG; | ||||
| changed = true; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE); | if (changed) { | ||||
| DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY); | |||||
| WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL); | ||||
| } | } | ||||
| } | |||||
| /* ************************************************ */ | /* ************************************************ */ | ||||
| /* Brush Callbacks */ | /* Brush Callbacks */ | ||||
| /* This section defines the callbacks used by each brush to perform their magic. | /* This section defines the callbacks used by each brush to perform their magic. | ||||
| * These are called on each point within the brush's radius. | * These are called on each point within the brush's radius. | ||||
| */ | */ | ||||
| /* ----------------------------------------------- */ | /* ----------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 1,021 Lines • ▼ Show 20 Lines | if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { | ||||
| /* 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); | ||||
| BKE_gpencil_tag_full_update(gpd, gpl, NULL, NULL); | |||||
| /* 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); | ||||
| 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; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 327 Lines • ▼ Show 20 Lines | if (redo_geom) { | ||||
| else { | else { | ||||
| gpencil_recalc_geometry_tag(gps_active); | gpencil_recalc_geometry_tag(gps_active); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Delay a full recalculation for other frames. */ | /* Delay a full recalculation for other frames. */ | ||||
| gpencil_recalc_geometry_tag(gps_active); | gpencil_recalc_geometry_tag(gps_active); | ||||
| } | } | ||||
| bGPDlayer *gpl_active = (gpl->runtime.gpl_orig) ? gpl->runtime.gpl_orig : gpl; | |||||
| bGPDframe *gpf_active = (gpf->runtime.gpf_orig) ? gpf->runtime.gpf_orig : gpf; | |||||
| BKE_gpencil_tag_full_update(gpd, gpl_active, gpf_active, gps_active); | |||||
| } | } | ||||
| } | } | ||||
| return changed; | return changed; | ||||
| } | } | ||||
| /* Perform two-pass brushes which modify the existing strokes */ | /* Perform two-pass brushes which modify the existing strokes */ | ||||
| static bool gpencil_sculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) | static bool gpencil_sculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) | ||||
| ▲ Show 20 Lines • Show All 460 Lines • Show Last 20 Lines | |||||