Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_edit.c
| Show First 20 Lines • Show All 3,639 Lines • ▼ Show 20 Lines | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Stroke Re-project Operator | /** \name Stroke Re-project Operator | ||||
| * \{ */ | * \{ */ | ||||
| static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op) | static int gpencil_strokes_reproject_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| bGPdata *gpd = ED_gpencil_data_get_active(C); | bGPdata *gpd = ED_gpencil_data_get_active(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Main *bmain = CTX_data_main(C); | |||||
| Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| int oldframe = (int)DEG_get_ctime(depsgraph); | int oldframe = (int)DEG_get_ctime(depsgraph); | ||||
| const eGP_ReprojectModes mode = RNA_enum_get(op->ptr, "type"); | const eGP_ReprojectModes mode = RNA_enum_get(op->ptr, "type"); | ||||
| const bool keep_original = RNA_boolean_get(op->ptr, "keep_original"); | const bool keep_original = RNA_boolean_get(op->ptr, "keep_original"); | ||||
| /* Init space conversion stuff. */ | /* Init space conversion stuff. */ | ||||
| GP_SpaceConversion gsc = {NULL}; | GP_SpaceConversion gsc = {NULL}; | ||||
| SnapObjectContext *sctx = NULL; | SnapObjectContext *sctx = NULL; | ||||
| gpencil_point_conversion_init(C, &gsc); | gpencil_point_conversion_init(C, &gsc); | ||||
| /* Init snap context for geometry projection. */ | /* Init snap context for geometry projection. */ | ||||
| sctx = ED_transform_snap_object_context_create_view3d(scene, 0, region, CTX_wm_view3d(C)); | sctx = ED_transform_snap_object_context_create_view3d(scene, 0, region, CTX_wm_view3d(C)); | ||||
| int cfra_prv = INT_MIN; | int cfra_prv = INT_MIN; | ||||
| /* Go through each editable + selected stroke, adjusting each of its points one by one... */ | /* Go through each editable + selected stroke, adjusting each of its points one by one... */ | ||||
| GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { | GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { | ||||
| if (gps->flag & GP_STROKE_SELECT) { | if (gps->flag & GP_STROKE_SELECT) { | ||||
| /* update frame to get the new location of objects */ | /* update frame to get the new location of objects */ | ||||
| if ((mode == GP_REPROJECT_SURFACE) && (cfra_prv != gpf_->framenum)) { | if ((mode == GP_REPROJECT_SURFACE) && (cfra_prv != gpf_->framenum)) { | ||||
| cfra_prv = gpf_->framenum; | cfra_prv = gpf_->framenum; | ||||
| CFRA = gpf_->framenum; | CFRA = gpf_->framenum; | ||||
| BKE_scene_graph_update_for_newframe(depsgraph, bmain); | BKE_scene_graph_update_for_newframe(depsgraph); | ||||
| } | } | ||||
| ED_gpencil_stroke_reproject(depsgraph, &gsc, sctx, gpl, gpf_, gps, mode, keep_original); | ED_gpencil_stroke_reproject(depsgraph, &gsc, sctx, gpl, gpf_, gps, mode, keep_original); | ||||
| } | } | ||||
| } | } | ||||
| GP_EDITABLE_STROKES_END(gpstroke_iter); | GP_EDITABLE_STROKES_END(gpstroke_iter); | ||||
| /* return frame state and DB to original state */ | /* return frame state and DB to original state */ | ||||
| CFRA = oldframe; | CFRA = oldframe; | ||||
| BKE_scene_graph_update_for_newframe(depsgraph, bmain); | BKE_scene_graph_update_for_newframe(depsgraph); | ||||
| if (sctx != NULL) { | if (sctx != NULL) { | ||||
| ED_transform_snap_object_context_destroy(sctx); | ED_transform_snap_object_context_destroy(sctx); | ||||
| } | } | ||||
| /* update changed data */ | /* update changed data */ | ||||
| DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); | DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | 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); | ||||
| ▲ Show 20 Lines • Show All 1,273 Lines • Show Last 20 Lines | |||||