Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_brush.c
| Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | |||||
| /* ************************************************ */ | /* ************************************************ */ | ||||
| /* General Brush Editing Context */ | /* General Brush Editing Context */ | ||||
| /* Context for brush operators */ | /* Context for brush operators */ | ||||
| typedef struct tGP_BrushEditData { | typedef struct tGP_BrushEditData { | ||||
| /* Current editor/region/etc. */ | /* Current editor/region/etc. */ | ||||
| /* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */ | /* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */ | ||||
| Depsgraph *depsgraph; | |||||
| struct Main *bmain; | struct Main *bmain; | ||||
| Scene *scene; | Scene *scene; | ||||
| Object *object; | Object *object; | ||||
| ScrArea *sa; | ScrArea *sa; | ||||
| ARegion *ar; | ARegion *ar; | ||||
| /* Current GPencil datablock */ | /* Current GPencil datablock */ | ||||
| ▲ Show 20 Lines • Show All 948 Lines • ▼ Show 20 Lines | |||||
| /* Create new copies of the strokes on the clipboard */ | /* Create new copies of the strokes on the clipboard */ | ||||
| static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) | static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) | ||||
| { | { | ||||
| tGPSB_CloneBrushData *data = gso->customdata; | tGPSB_CloneBrushData *data = gso->customdata; | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); | bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Scene *scene = CTX_data_scene(C); | ||||
| int cfra_eval = (int)DEG_get_ctime(depsgraph); | int cfra_eval = CFRA; | ||||
| bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_ADD_NEW); | bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, cfra_eval, GP_GETFRAME_ADD_NEW); | ||||
| bGPDstroke *gps; | bGPDstroke *gps; | ||||
| float delta[3]; | float delta[3]; | ||||
| size_t strokes_added = 0; | size_t strokes_added = 0; | ||||
| /* Compute amount to offset the points by */ | /* Compute amount to offset the points by */ | ||||
| ▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | #if 0 | ||||
| eGP_Sculpt_Types mode = is_weight_mode ? gset->weighttype : gset->brushtype; | eGP_Sculpt_Types mode = is_weight_mode ? gset->weighttype : gset->brushtype; | ||||
| #endif | #endif | ||||
| tGP_BrushEditData *gso; | tGP_BrushEditData *gso; | ||||
| /* setup operator data */ | /* setup operator data */ | ||||
| gso = MEM_callocN(sizeof(tGP_BrushEditData), "tGP_BrushEditData"); | gso = MEM_callocN(sizeof(tGP_BrushEditData), "tGP_BrushEditData"); | ||||
| op->customdata = gso; | op->customdata = gso; | ||||
| gso->depsgraph = CTX_data_depsgraph(C); | |||||
| gso->bmain = CTX_data_main(C); | gso->bmain = CTX_data_main(C); | ||||
| /* store state */ | /* store state */ | ||||
| gso->settings = gpsculpt_get_settings(scene); | gso->settings = gpsculpt_get_settings(scene); | ||||
| gso->gp_brush = gpsculpt_get_brush(scene, is_weight_mode); | gso->gp_brush = gpsculpt_get_brush(scene, is_weight_mode); | ||||
| gso->is_weight_mode = is_weight_mode; | gso->is_weight_mode = is_weight_mode; | ||||
| if (is_weight_mode) { | if (is_weight_mode) { | ||||
| gso->brush_type = gso->settings->weighttype; | gso->brush_type = gso->settings->weighttype; | ||||
| ▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | |||||
| /* Init Sculpt Stroke ---------------------------------- */ | /* Init Sculpt Stroke ---------------------------------- */ | ||||
| static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso) | static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso) | ||||
| { | { | ||||
| bGPdata *gpd = gso->gpd; | bGPdata *gpd = gso->gpd; | ||||
| bGPDlayer *gpl; | bGPDlayer *gpl; | ||||
| int cfra_eval = (int)DEG_get_ctime(gso->depsgraph); | Scene *scene = gso->scene; | ||||
| int cfra_eval = CFRA; | |||||
| /* only try to add a new frame if this is the first stroke, or the frame has changed */ | /* only try to add a new frame if this is the first stroke, or the frame has changed */ | ||||
| if ((gpd == NULL) || (cfra_eval == gso->cfra)) { | if ((gpd == NULL) || (cfra_eval == gso->cfra)) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* go through each layer, and ensure that we've got a valid frame to use */ | /* go through each layer, and ensure that we've got a valid frame to use */ | ||||
| for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| ▲ Show 20 Lines • Show All 763 Lines • Show Last 20 Lines | |||||