Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_gpencil.c
| Show First 20 Lines • Show All 205 Lines • ▼ Show 20 Lines | if (format.attr_len == 0) { | ||||
| GPU_vertformat_attr_add(&format, "weight", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); | GPU_vertformat_attr_add(&format, "weight", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); | ||||
| } | } | ||||
| return &format; | return &format; | ||||
| } | } | ||||
| /* MUST match the format below. */ | /* MUST match the format below. */ | ||||
| typedef struct gpEditCurveVert { | typedef struct gpEditCurveVert { | ||||
| float pos[3]; | float pos[3]; | ||||
| int data; | uint32_t data; | ||||
| } gpEditCurveVert; | } gpEditCurveVert; | ||||
| static GPUVertFormat *gpencil_edit_curve_format(void) | static GPUVertFormat *gpencil_edit_curve_format(void) | ||||
| { | { | ||||
| static GPUVertFormat format = {0}; | static GPUVertFormat format = {0}; | ||||
| if (format.attr_len == 0) { | if (format.attr_len == 0) { | ||||
| /* initialize vertex formats */ | /* initialize vertex formats */ | ||||
| GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); | GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); | ||||
| GPU_vertformat_attr_add(&format, "data", GPU_COMP_U8, 1, GPU_FETCH_INT); | GPU_vertformat_attr_add(&format, "data", GPU_COMP_U32, 1, GPU_FETCH_INT); | ||||
| } | } | ||||
| return &format; | return &format; | ||||
| } | } | ||||
| /* MUST match the format below. */ | /* MUST match the format below. */ | ||||
| typedef struct gpColorVert { | typedef struct gpColorVert { | ||||
| float vcol[4]; /* Vertex color */ | float vcol[4]; /* Vertex color */ | ||||
| float fcol[4]; /* Fill color */ | float fcol[4]; /* Fill color */ | ||||
| ▲ Show 20 Lines • Show All 517 Lines • ▼ Show 20 Lines | if (gps->editcurve == NULL) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* Store first index offset */ | /* Store first index offset */ | ||||
| gps->runtime.curve_start = iter->curve_len; | gps->runtime.curve_start = iter->curve_len; | ||||
| iter->curve_len += gps->editcurve->tot_curve_points * 4; | iter->curve_len += gps->editcurve->tot_curve_points * 4; | ||||
| } | } | ||||
| static char gpencil_beztriple_vflag_get(char flag, | static uint32_t gpencil_beztriple_vflag_get(char flag, | ||||
| char col_id, | char col_id, | ||||
| bool handle_point, | bool handle_point, | ||||
| const bool handle_selected) | const bool handle_selected) | ||||
| { | { | ||||
| char vflag = 0; | uint32_t vflag = 0; | ||||
| SET_FLAG_FROM_TEST(vflag, (flag & SELECT), VFLAG_VERT_SELECTED); | SET_FLAG_FROM_TEST(vflag, (flag & SELECT), VFLAG_VERT_SELECTED); | ||||
| SET_FLAG_FROM_TEST(vflag, handle_point, BEZIER_HANDLE); | SET_FLAG_FROM_TEST(vflag, handle_point, BEZIER_HANDLE); | ||||
| SET_FLAG_FROM_TEST(vflag, handle_selected, VFLAG_VERT_SELECTED_BEZT_HANDLE); | SET_FLAG_FROM_TEST(vflag, handle_selected, VFLAG_VERT_SELECTED_BEZT_HANDLE); | ||||
| /* Reuse flag of Freestyle to indicate is GPencil data. */ | vflag |= VFLAG_VERT_GPENCIL_BEZT_HANDLE; | ||||
fclem: This comment can be removed. | |||||
| vflag |= VFLAG_EDGE_FREESTYLE; | |||||
| /* Handle color id. */ | /* Handle color id. */ | ||||
| vflag |= col_id << COLOR_SHIFT; | vflag |= col_id << COLOR_SHIFT; | ||||
| return vflag; | return vflag; | ||||
| } | } | ||||
| static void gpencil_edit_curve_stroke_iter_cb(bGPDlayer *gpl, | static void gpencil_edit_curve_stroke_iter_cb(bGPDlayer *gpl, | ||||
| bGPDframe *UNUSED(gpf), | bGPDframe *UNUSED(gpf), | ||||
| Show All 13 Lines | static void gpencil_edit_curve_stroke_iter_cb(bGPDlayer *gpl, | ||||
| gpEditCurveVert *vert_ptr = iter->verts + v; | gpEditCurveVert *vert_ptr = iter->verts + v; | ||||
| /* Hide points when the curve is unselected. Passing the control point | /* Hide points when the curve is unselected. Passing the control point | ||||
| * as handle produces the point shader skip it if you are not in ALL mode. */ | * as handle produces the point shader skip it if you are not in ALL mode. */ | ||||
| const bool hide = !(editcurve->flag & GP_CURVE_SELECT); | const bool hide = !(editcurve->flag & GP_CURVE_SELECT); | ||||
| for (int i = 0; i < editcurve->tot_curve_points; i++) { | for (int i = 0; i < editcurve->tot_curve_points; i++) { | ||||
| BezTriple *bezt = &editcurve->curve_points[i].bezt; | BezTriple *bezt = &editcurve->curve_points[i].bezt; | ||||
| const bool handle_selected = BEZT_ISSEL_ANY(bezt); | const bool handle_selected = BEZT_ISSEL_ANY(bezt); | ||||
| const char vflag[3] = { | const uint32_t vflag[3] = { | ||||
| gpencil_beztriple_vflag_get(bezt->f1, bezt->h1, true, handle_selected), | gpencil_beztriple_vflag_get(bezt->f1, bezt->h1, true, handle_selected), | ||||
| gpencil_beztriple_vflag_get(bezt->f2, bezt->h1, hide, handle_selected), | gpencil_beztriple_vflag_get(bezt->f2, bezt->h1, hide, handle_selected), | ||||
| gpencil_beztriple_vflag_get(bezt->f3, bezt->h2, true, handle_selected), | gpencil_beztriple_vflag_get(bezt->f3, bezt->h2, true, handle_selected), | ||||
| }; | }; | ||||
| /* First segment. */ | /* First segment. */ | ||||
| copy_v3_v3(vert_ptr->pos, bezt->vec[0]); | copy_v3_v3(vert_ptr->pos, bezt->vec[0]); | ||||
| vert_ptr->data = vflag[0]; | vert_ptr->data = vflag[0]; | ||||
| ▲ Show 20 Lines • Show All 139 Lines • Show Last 20 Lines | |||||
This comment can be removed.