Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_paint.c
| Show First 20 Lines • Show All 931 Lines • ▼ Show 20 Lines | static void gpencil_stroke_newfrombuffer(tGPsdata *p) | ||||
| MDeformVert *dvert = NULL; | MDeformVert *dvert = NULL; | ||||
| Brush *brush = p->brush; | Brush *brush = p->brush; | ||||
| ToolSettings *ts = p->scene->toolsettings; | ToolSettings *ts = p->scene->toolsettings; | ||||
| Depsgraph *depsgraph = p->depsgraph; | Depsgraph *depsgraph = p->depsgraph; | ||||
| Object *obact = (Object *)p->ownerPtr.data; | Object *obact = (Object *)p->ownerPtr.data; | ||||
| RegionView3D *rv3d = p->region->regiondata; | RegionView3D *rv3d = p->region->regiondata; | ||||
| const int def_nr = obact->actdef - 1; | const int def_nr = obact->actdef - 1; | ||||
| const bool have_weight = (bool)BLI_findlink(&obact->defbase, def_nr); | const bool have_weight = (bool)BLI_findlink(&obact->defbase, def_nr); | ||||
| const char *align_flag = &ts->gpencil_v3d_align; | const char align_flag = ts->gpencil_v3d_align; | ||||
| const bool is_depth = (bool)(*align_flag & (GP_PROJECT_DEPTH_VIEW | GP_PROJECT_DEPTH_STROKE)); | const bool is_depth = (bool)(align_flag & (GP_PROJECT_DEPTH_VIEW | GP_PROJECT_DEPTH_STROKE)); | ||||
| const bool is_camera = (bool)(ts->gp_sculpt.lock_axis == 0) && (rv3d->persp == RV3D_CAMOB) && | const bool is_lock_axis_view = (bool)(ts->gp_sculpt.lock_axis == 0); | ||||
| (!is_depth); | const bool is_camera = is_lock_axis_view && (rv3d->persp == RV3D_CAMOB) && (!is_depth); | ||||
| int totelem; | int totelem; | ||||
| /* For very low pressure at the end, truncate stroke. */ | /* For very low pressure at the end, truncate stroke. */ | ||||
| if (p->paintmode == GP_PAINTMODE_DRAW) { | if (p->paintmode == GP_PAINTMODE_DRAW) { | ||||
| int last_i = gpd->runtime.sbuffer_used - 1; | int last_i = gpd->runtime.sbuffer_used - 1; | ||||
| while (last_i > 0) { | while (last_i > 0) { | ||||
| ptc = (tGPspoint *)gpd->runtime.sbuffer + last_i; | ptc = (tGPspoint *)gpd->runtime.sbuffer + last_i; | ||||
| if (ptc->pressure > 0.001f) { | if (ptc->pressure > 0.001f) { | ||||
| ▲ Show 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { | ||||
| gpencil_reproject_toplane(p, gps); | gpencil_reproject_toplane(p, gps); | ||||
| pt = gps->points; | pt = gps->points; | ||||
| for (int i = 0; i < gps->totpoints; i++, pt++) { | for (int i = 0; i < gps->totpoints; i++, pt++) { | ||||
| /* if parented change position relative to parent object */ | /* if parented change position relative to parent object */ | ||||
| gpencil_apply_parent_point(depsgraph, obact, gpl, pt); | gpencil_apply_parent_point(depsgraph, obact, gpl, pt); | ||||
| } | } | ||||
| /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ | /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ | ||||
| if ((*p->align_flag & GP_PROJECT_VIEWSPACE) || is_camera) { | if (((align_flag & GP_PROJECT_VIEWSPACE) && is_lock_axis_view) || is_camera) { | ||||
| ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); | ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| float *depth_arr = NULL; | float *depth_arr = NULL; | ||||
| /* get an array of depths, far depths are blended */ | /* get an array of depths, far depths are blended */ | ||||
| if (gpencil_project_check(p)) { | if (gpencil_project_check(p)) { | ||||
| ▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | if ((brush->gpencil_settings->flag & GP_BRUSH_GROUP_SETTINGS) && | ||||
| BKE_gpencil_stroke_simplify_adaptive(gpd, gps, brush->gpencil_settings->simplify_f); | BKE_gpencil_stroke_simplify_adaptive(gpd, gps, brush->gpencil_settings->simplify_f); | ||||
| } | } | ||||
| /* reproject to plane (only in 3d space) */ | /* reproject to plane (only in 3d space) */ | ||||
| gpencil_reproject_toplane(p, gps); | gpencil_reproject_toplane(p, gps); | ||||
| /* change position relative to parent object */ | /* change position relative to parent object */ | ||||
| gpencil_apply_parent(depsgraph, obact, gpl, gps); | gpencil_apply_parent(depsgraph, obact, gpl, gps); | ||||
| /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ | /* If camera view or view projection, reproject flat to view to avoid perspective effect. */ | ||||
| if ((*p->align_flag & GP_PROJECT_VIEWSPACE) || is_camera) { | if (((align_flag & GP_PROJECT_VIEWSPACE) && is_lock_axis_view) || is_camera) { | ||||
| ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); | ED_gpencil_project_stroke_to_view(p->C, p->gpl, gps); | ||||
| } | } | ||||
| if (depth_arr) { | if (depth_arr) { | ||||
| MEM_freeN(depth_arr); | MEM_freeN(depth_arr); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,741 Lines • Show Last 20 Lines | |||||