This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 157e3c09faf8bc7f46b27c231e2fba9f4e409ff8 (commit) via bcfc8e661f36485e4a0bd0ffbabc7eb54a6acb47 (commit) from 725b6c106fdb6f78b7eb3dfef2192182b30233ff (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/157e3c09faf8bc7f46b27c231e2fba9f4e409...
commit 157e3c09faf8bc7f46b27c231e2fba9f4e409ff8 Merge: bcfc8e6 725b6c1 Author: Jiri BlueBear Dluhos jiri.bluebear.dluhos@gmail.com Date: Fri Dec 7 23:00:37 2012 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/bcfc8e661f36485e4a0bd0ffbabc7eb54a6ac...
commit bcfc8e661f36485e4a0bd0ffbabc7eb54a6acb47 Author: Jiri BlueBear Dluhos jiri.bluebear.dluhos@gmail.com Date: Fri Dec 7 22:58:26 2012 +0100
Fixed (maybe) off-by-half error in polygon vertices.
diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c index ed75a27..fb4b03f 100644 --- a/libs/gfx/GP_Polygon.c +++ b/libs/gfx/GP_Polygon.c @@ -128,22 +128,33 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int vertex_count, struct GP_PolygonEdge *edge; struct GP_PolygonEdge edges[vertex_count];
+ + /* Build edge structures for each vertex-vertex connection. + * NOTE: Each vertex is in fact in the middle of the pixel, so + * add 0.5 to both coordinates. + */ int i; for (i = 0; i < (int)vertex_count - 1; i++) { edge = edges + i; - GP_InitEdge(edge, xy[2*i], xy[2*i + 1], - xy[2*i + 2], xy[2*i + 3]); + GP_InitEdge(edge, + 0.5f + xy[2*i], 0.5f + xy[2*i + 1], + 0.5f + xy[2*i + 2], 0.5f + xy[2*i + 3]); ymin = fminf(ymin, edge->ymin); ymax = fmaxf(ymax, edge->ymax); }
/* the last edge (from the last point to the first one) */ edge = edges + vertex_count - 1; - GP_InitEdge(edge, xy[2*i], xy[2*i + 1], xy[0], xy[1]); + GP_InitEdge(edge, + 0.5f + xy[2*i], 0.5f + xy[2*i + 1], + 0.5f + xy[0], 0.5f + xy[1]);
+ /* For each scanline, compute intersections with all edges + * and draw a horizontal line segment between the intersections. + */ float intersections[vertex_count]; int y; - for (y = (int) ymin; y < (int) ymax; y++) { + for (y = (int) ymin; y <= (int) ymax; y++) { int inter_count = GP_ComputeScanline(intersections, edges, vertex_count, y + 0.5f); for (i = 0; i < inter_count; i+=2) { GP_HLine_Raw(context, intersections[i], intersections[i + 1], y, pixel); @@ -176,10 +187,10 @@ void GP_Polygon_Raw(GP_Context *context, unsigned int vertex_count,
GP_Coord prev_x = xy[2 * vertex_count - 2]; GP_Coord prev_y = xy[2 * vertex_count - 1]; - + for (i = 0; i < vertex_count; i++) { GP_Coord x = xy[2 * i]; - GP_Coord y = xy[2 * i + 1]; + GP_Coord y = xy[2 * i + 1];
GP_Line_Raw(context, prev_x, prev_y, x, y, pixel);
@@ -196,12 +207,12 @@ void GP_Polygon(GP_Context *context, unsigned int vertex_count,
GP_Coord prev_x = xy[2 * vertex_count - 2]; GP_Coord prev_y = xy[2 * vertex_count - 1]; - + GP_TRANSFORM_POINT(context, prev_x, prev_y);
for (i = 0; i < vertex_count; i++) { GP_Coord x = xy[2 * i]; - GP_Coord y = xy[2 * i + 1]; + GP_Coord y = xy[2 * i + 1];
GP_TRANSFORM_POINT(context, x, y);
-----------------------------------------------------------------------
Summary of changes: libs/gfx/GP_Polygon.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.