Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/gpencil/gpencil_convert.c
| Context not available. | |||||
| * - assumes that the active space is the 3D-View | * - assumes that the active space is the 3D-View | ||||
| */ | */ | ||||
| static void gp_strokepoint_convertcoords( | static void gp_strokepoint_convertcoords( | ||||
| bContext *C, bGPDlayer *gpl, bGPDstroke *gps, bGPDspoint *source_pt, | bContext *C, bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps, bGPDspoint *source_pt, | ||||
| float p3d[3], const rctf *subrect) | float p3d[3], const rctf *subrect) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| View3D *v3d = CTX_wm_view3d(C); | View3D *v3d = CTX_wm_view3d(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| Object *obact = CTX_data_active_object(C); | |||||
| bGPDspoint mypt, *pt; | bGPDspoint mypt, *pt; | ||||
| float diff_mat[4][4]; | float diff_mat[4][4]; | ||||
| pt = &mypt; | pt = &mypt; | ||||
| /* calculate difference matrix if parent object */ | /* apply parent transform */ | ||||
| if (gpl->parent == NULL) { | float fpt[3]; | ||||
| copy_v3_v3(&pt->x, &source_pt->x); | ED_gpencil_parent_location(obact, gpd, gpl, diff_mat); | ||||
| } | mul_v3_m4v3(fpt, diff_mat, &source_pt->x); | ||||
| else { | copy_v3_v3(&pt->x, fpt); | ||||
| /* apply parent transform */ | |||||
| float fpt[3]; | |||||
| ED_gpencil_parent_location(gpl, diff_mat); | |||||
| mul_v3_m4v3(fpt, diff_mat, &source_pt->x); | |||||
| copy_v3_v3(&pt->x, fpt); | |||||
| } | |||||
| if (gps->flag & GP_STROKE_3DSPACE) { | if (gps->flag & GP_STROKE_3DSPACE) { | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect, Nurb **curnu, | static void gp_stroke_to_path(bContext *C, bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect, Nurb **curnu, | ||||
| float minmax_weights[2], const float rad_fac, bool stitch, const bool add_start_point, | float minmax_weights[2], const float rad_fac, bool stitch, const bool add_start_point, | ||||
| const bool add_end_point, tGpTimingData *gtd) | const bool add_end_point, tGpTimingData *gtd) | ||||
| { | { | ||||
| Context not available. | |||||
| bp = &nu->bp[old_nbp - 1]; | bp = &nu->bp[old_nbp - 1]; | ||||
| /* First point */ | /* First point */ | ||||
| gp_strokepoint_convertcoords(C, gpl, gps, gps->points, p, subrect); | gp_strokepoint_convertcoords(C, gpd, gpl, gps, gps->points, p, subrect); | ||||
| if (prev_bp) { | if (prev_bp) { | ||||
| interp_v3_v3v3(p1, bp->vec, prev_bp->vec, -GAP_DFAC); | interp_v3_v3v3(p1, bp->vec, prev_bp->vec, -GAP_DFAC); | ||||
| if (do_gtd) { | if (do_gtd) { | ||||
| Context not available. | |||||
| /* Second point */ | /* Second point */ | ||||
| /* Note dt2 is always negative, which marks the gap. */ | /* Note dt2 is always negative, which marks the gap. */ | ||||
| if (gps->totpoints > 1) { | if (gps->totpoints > 1) { | ||||
| gp_strokepoint_convertcoords(C, gpl, gps, gps->points + 1, next_p, subrect); | gp_strokepoint_convertcoords(C, gpd, gpl, gps, gps->points + 1, next_p, subrect); | ||||
| interp_v3_v3v3(p2, p, next_p, -GAP_DFAC); | interp_v3_v3v3(p2, p, next_p, -GAP_DFAC); | ||||
| if (do_gtd) { | if (do_gtd) { | ||||
| dt2 = interpf(gps->points[1].time, gps->points[0].time, -GAP_DFAC); | dt2 = interpf(gps->points[1].time, gps->points[0].time, -GAP_DFAC); | ||||
| Context not available. | |||||
| float p[3], next_p[3]; | float p[3], next_p[3]; | ||||
| float dt = 0.0f; | float dt = 0.0f; | ||||
| gp_strokepoint_convertcoords(C, gpl, gps, gps->points, p, subrect); | gp_strokepoint_convertcoords(C, gpd, gpl, gps, gps->points, p, subrect); | ||||
| if (gps->totpoints > 1) { | if (gps->totpoints > 1) { | ||||
| gp_strokepoint_convertcoords(C, gpl, gps, gps->points + 1, next_p, subrect); | gp_strokepoint_convertcoords(C, gpd, gpl, gps, gps->points + 1, next_p, subrect); | ||||
| interp_v3_v3v3(p, p, next_p, -GAP_DFAC); | interp_v3_v3v3(p, p, next_p, -GAP_DFAC); | ||||
| if (do_gtd) { | if (do_gtd) { | ||||
| dt = interpf(gps->points[1].time, gps->points[0].time, -GAP_DFAC); | dt = interpf(gps->points[1].time, gps->points[0].time, -GAP_DFAC); | ||||
| Context not available. | |||||
| float width = pt->pressure * (gps->thickness + gpl->thickness) * WIDTH_CORR_FAC; | float width = pt->pressure * (gps->thickness + gpl->thickness) * WIDTH_CORR_FAC; | ||||
| /* get coordinates to add at */ | /* get coordinates to add at */ | ||||
| gp_strokepoint_convertcoords(C, gpl, gps, pt, p, subrect); | gp_strokepoint_convertcoords(C, gpd, gpl, gps, pt, p, subrect); | ||||
| gp_stroke_to_path_add_point(gtd, bp, p, (prev_bp) ? prev_bp->vec : p, do_gtd, gps->inittime, pt->time, | gp_stroke_to_path_add_point(gtd, bp, p, (prev_bp) ? prev_bp->vec : p, do_gtd, gps->inittime, pt->time, | ||||
| width, rad_fac, minmax_weights); | width, rad_fac, minmax_weights); | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect, Nurb **curnu, | static void gp_stroke_to_bezier(bContext *C, bGPdata *gpd, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect, Nurb **curnu, | ||||
| float minmax_weights[2], const float rad_fac, bool stitch, const bool add_start_point, | float minmax_weights[2], const float rad_fac, bool stitch, const bool add_start_point, | ||||
| const bool add_end_point, tGpTimingData *gtd) | const bool add_end_point, tGpTimingData *gtd) | ||||
| { | { | ||||
| Context not available. | |||||
| /* get initial coordinates */ | /* get initial coordinates */ | ||||
| pt = gps->points; | pt = gps->points; | ||||
| if (tot) { | if (tot) { | ||||
| gp_strokepoint_convertcoords(C, gpl, gps, pt, (stitch) ? p3d_prev : p3d_cur, subrect); | gp_strokepoint_convertcoords(C, gpd, gpl, gps, pt, (stitch) ? p3d_prev : p3d_cur, subrect); | ||||
| if (tot > 1) { | if (tot > 1) { | ||||
| gp_strokepoint_convertcoords(C, gpl, gps, pt + 1, (stitch) ? p3d_cur : p3d_next, subrect); | gp_strokepoint_convertcoords(C, gpd, gpl, gps, pt + 1, (stitch) ? p3d_cur : p3d_next, subrect); | ||||
| } | } | ||||
| if (stitch && tot > 2) { | if (stitch && tot > 2) { | ||||
| gp_strokepoint_convertcoords(C, gpl, gps, pt + 2, p3d_next, subrect); | gp_strokepoint_convertcoords(C, gpd, gpl, gps, pt + 2, p3d_next, subrect); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| copy_v3_v3(p3d_cur, p3d_next); | copy_v3_v3(p3d_cur, p3d_next); | ||||
| if (i + 2 < tot) { | if (i + 2 < tot) { | ||||
| gp_strokepoint_convertcoords(C, gpl, gps, pt + 2, p3d_next, subrect); | gp_strokepoint_convertcoords(C, gpd, gpl, gps, pt + 2, p3d_next, subrect); | ||||
| } | } | ||||
| prev_bezt = bezt; | prev_bezt = bezt; | ||||
| Context not available. | |||||
| switch (mode) { | switch (mode) { | ||||
| case GP_STROKECONVERT_PATH: | case GP_STROKECONVERT_PATH: | ||||
| gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch, | gp_stroke_to_path(C, gpd, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch, | ||||
| add_start_point, add_end_point, gtd); | add_start_point, add_end_point, gtd); | ||||
| break; | break; | ||||
| case GP_STROKECONVERT_CURVE: | case GP_STROKECONVERT_CURVE: | ||||
| case GP_STROKECONVERT_POLY: /* convert after */ | case GP_STROKECONVERT_POLY: /* convert after */ | ||||
| gp_stroke_to_bezier(C, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch, | gp_stroke_to_bezier(C, gpd, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch, | ||||
| add_start_point, add_end_point, gtd); | add_start_point, add_end_point, gtd); | ||||
| break; | break; | ||||
| default: | default: | ||||
| Context not available. | |||||