diff options
author | Charlie Jolly <mistajolly@gmail.com> | 2018-12-04 18:21:09 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2018-12-05 18:59:23 +0300 |
commit | 94503efb126526a31d62be6363d8562651f43f0a (patch) | |
tree | beded5f1c71dd8b76490e1dd362602babedb2160 /source/blender/editors/gpencil/gpencil_primitive.c | |
parent | cdf626615d99f3a73ba453f0ebcada88d20ca8bb (diff) |
GP: Fix precision issue with Circle and Arc tools
Differential Revision: https://developer.blender.org/D4030
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_primitive.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index d22e9736172..9d36c1f3963 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -260,37 +260,37 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi /* ----------------------- */ /* create a rectangle */ -static void gp_primitive_rectangle(tGPDprimitive *tgpi, tGPspoint *points2D) +static void gp_primitive_rectangle(tGPDprimitive *tgpi, tPGPspoint *points2D) { BLI_assert(tgpi->tot_edges == 4); - points2D[0].x = tgpi->top[0]; - points2D[0].y = tgpi->top[1]; + points2D[0].x = (float)tgpi->top[0]; + points2D[0].y = (float)tgpi->top[1]; - points2D[1].x = tgpi->bottom[0]; - points2D[1].y = tgpi->top[1]; + points2D[1].x = (float)tgpi->bottom[0]; + points2D[1].y = (float)tgpi->top[1]; - points2D[2].x = tgpi->bottom[0]; - points2D[2].y = tgpi->bottom[1]; + points2D[2].x = (float)tgpi->bottom[0]; + points2D[2].y = (float)tgpi->bottom[1]; - points2D[3].x = tgpi->top[0]; - points2D[3].y = tgpi->bottom[1]; + points2D[3].x = (float)tgpi->top[0]; + points2D[3].y = (float)tgpi->bottom[1]; } /* create a line */ -static void gp_primitive_line(tGPDprimitive *tgpi, tGPspoint *points2D) +static void gp_primitive_line(tGPDprimitive *tgpi, tPGPspoint *points2D) { BLI_assert(tgpi->tot_edges == 2); - points2D[0].x = tgpi->top[0]; - points2D[0].y = tgpi->top[1]; + points2D[0].x = (float)tgpi->top[0]; + points2D[0].y = (float)tgpi->top[1]; - points2D[1].x = tgpi->bottom[0]; - points2D[1].y = tgpi->bottom[1]; + points2D[1].x = (float)tgpi->bottom[0]; + points2D[1].y = (float)tgpi->bottom[1]; } /* create an arc */ -static void gp_primitive_arc(tGPDprimitive *tgpi, tGPspoint *points2D) +static void gp_primitive_arc(tGPDprimitive *tgpi, tPGPspoint *points2D) { const int totpoints = tgpi->tot_edges; const float step = M_PI_2 / (float)(totpoints - 1); @@ -313,15 +313,15 @@ static void gp_primitive_arc(tGPDprimitive *tgpi, tGPspoint *points2D) length[1] = end[1] - start[1]; for (int i = 0; i < totpoints; i++) { - tGPspoint *p2d = &points2D[i]; - p2d->x = (int)(start[0] + sinf(a) * length[0]); - p2d->y = (int)(end[1] - cosf(a) * length[1]); + tPGPspoint *p2d = &points2D[i]; + p2d->x = (start[0] + sinf(a) * length[0]); + p2d->y = (end[1] - cosf(a) * length[1]); a += step; } } /* create a circle */ -static void gp_primitive_circle(tGPDprimitive *tgpi, tGPspoint *points2D) +static void gp_primitive_circle(tGPDprimitive *tgpi, tPGPspoint *points2D) { const int totpoints = tgpi->tot_edges; const float step = (2.0f * M_PI) / (float)(totpoints); @@ -336,10 +336,9 @@ static void gp_primitive_circle(tGPDprimitive *tgpi, tGPspoint *points2D) radius[1] = fabsf(((tgpi->bottom[1] - tgpi->top[1]) / 2.0f)); for (int i = 0; i < totpoints; i++) { - tGPspoint *p2d = &points2D[i]; - - p2d->x = (int)(center[0] + cosf(a) * radius[0]); - p2d->y = (int)(center[1] + sinf(a) * radius[1]); + tPGPspoint *p2d = &points2D[i]; + p2d->x = (center[0] + cosf(a) * radius[0]); + p2d->y = (center[1] + sinf(a) * radius[1]); a += step; } } @@ -360,7 +359,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) gps->totpoints = tgpi->tot_edges; /* compute screen-space coordinates for points */ - tGPspoint *points2D = MEM_callocN(sizeof(tGPspoint) * tgpi->tot_edges, "gp primitive points2D"); + tPGPspoint *points2D = MEM_callocN(sizeof(tPGPspoint) * tgpi->tot_edges, "gp primitive points2D"); switch (tgpi->type) { case GP_STROKE_BOX: gp_primitive_rectangle(tgpi, points2D); @@ -385,10 +384,10 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* convert screen-coordinates to 3D coordinates */ for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; - tGPspoint *p2d = &points2D[i]; + tPGPspoint *p2d = &points2D[i]; /* convert screen-coordinates to 3D coordinates */ - gp_stroke_convertcoords_tpoint(tgpi->scene, tgpi->ar, tgpi->ob, tgpi->gpl, p2d, NULL, &pt->x); + gp_stroke_convertcoords_tpoint_primitive(tgpi->scene, tgpi->ar, tgpi->ob, tgpi->gpl, p2d, &pt->x); pt->pressure = 1.0f; pt->strength = tgpi->brush->gpencil_settings->draw_strength; |