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 2cf30f8101ea618085a197ea6bb8bad9d5cb0708 (commit) via 1f85f38df0b1e641ff42cd36279162436e74fcb0 (commit) via bee55d2f8ce82f2cae2ad16fa0f61af7aa9801da (commit) from fd8d609eb63fb8753bcbf69c882a9b9b4b58e966 (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/2cf30f8101ea618085a197ea6bb8bad9d5cb0...
commit 2cf30f8101ea618085a197ea6bb8bad9d5cb0708 Merge: 1f85f38 fd8d609 Author: Jiri BlueBear Dluhos jiri.bluebear.dluhos@gmail.com Date: Sun Dec 9 17:30:23 2012 +0100
Merge branch 'master' of ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/1f85f38df0b1e641ff42cd36279162436e74f...
commit 1f85f38df0b1e641ff42cd36279162436e74fcb0 Author: Jiri BlueBear Dluhos jiri.bluebear.dluhos@gmail.com Date: Sun Dec 9 17:28:27 2012 +0100
Slightly better handling of joints in GP_FillPolygon().
diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c index 3b7c2e7..2114006 100644 --- a/libs/gfx/GP_Polygon.c +++ b/libs/gfx/GP_Polygon.c @@ -66,17 +66,22 @@ static void GP_InitEdge(struct GP_PolygonEdge *edge, float x1, float y1, edge->dx_by_dy = dx / dy; }
+static int GP_IsEdgeHorizontal(struct GP_PolygonEdge *edge) +{ + return ((edge->ymax - edge->ymin) < GP_HORIZ_DY_THRESHOLD); +} + /* Computes an intersection of the specified scanline with the given edge. * If successful, returns 1 and stores the resulting X coordinate into result_x. * If failed (the edge does not intersect), 0 is returned. - * Horizontal edges are considered to never intersect. + * Horizontal edges are ignored at this point (result is always 0). */ static int GP_ComputeIntersection(float *result_x, struct GP_PolygonEdge *edge, float y) { if (y<edge->ymin || y>edge->ymax) return 0; /* outside the edge Y range */
- if (edge->ymax - edge->ymin < GP_HORIZ_DY_THRESHOLD) + if (GP_IsEdgeHorizontal(edge)) return 0; /* ignore horizontal edges */
*result_x = edge->x1 + (y-edge->y1)*edge->dx_by_dy; @@ -112,6 +117,18 @@ static int GP_ComputeScanline(float *results, struct GP_PolygonEdge *edges, struct GP_PolygonEdge *edge = edges + edge_index; float x;
+ /* + * Horizontal edges match either as a whole (yielding two + * intersections), or not at all. + */ + if (GP_IsEdgeHorizontal(edge)) { + if (fabsf(edge->ymin - y) < 0.00001f) { + results[result_index++] = GP_MIN(edge->x1, edge->x2); + results[result_index++] = GP_MAX(edge->x1, edge->x2); + } + continue; + } + if (GP_ComputeIntersection(&x, edge, y)) { results[result_index++] = x; } @@ -127,7 +144,7 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int vertex_count, { float ymin = HUGE_VALF, ymax = -HUGE_VALF; struct GP_PolygonEdge *edge; - struct GP_PolygonEdge edges[vertex_count]; + struct GP_PolygonEdge edges[2*vertex_count];
/* Build edge structures for each vertex-vertex connection.
http://repo.or.cz/w/gfxprim.git/commit/bee55d2f8ce82f2cae2ad16fa0f61af7aa980...
commit bee55d2f8ce82f2cae2ad16fa0f61af7aa9801da Author: Jiri BlueBear Dluhos jiri.bluebear.dluhos@gmail.com Date: Sun Dec 9 17:07:58 2012 +0100
Fixed an assertion crash in FillPolygon.
diff --git a/libs/gfx/GP_Polygon.c b/libs/gfx/GP_Polygon.c index 0901922..3b7c2e7 100644 --- a/libs/gfx/GP_Polygon.c +++ b/libs/gfx/GP_Polygon.c @@ -28,6 +28,7 @@ #include <math.h>
#include "core/GP_Transform.h" +#include "core/GP_GetPutPixel.h"
#include "GP_Line.h" #include "GP_HLine.h" @@ -157,10 +158,24 @@ void GP_FillPolygon_Raw(GP_Context *context, unsigned int vertex_count, for (y = (int) ymin; y <= (int) ymax; y++) { int inter_count = GP_ComputeScanline(intersections, edges, vertex_count, y + 0.5f);
- GP_ASSERT(inter_count % 2 == 0, "odd number of intersections!"); - - for (i = 0; i < inter_count; i+=2) { - GP_HLine_Raw(context, intersections[i], intersections[i + 1], y, pixel); + i = 0; + for (;;) { + if (i >= inter_count) break; + float start = intersections[i++]; + if (i >= inter_count) { + + /* a solo vertex or a single-point intersection */ + GP_PutPixel_Raw(context, start, y, pixel); + break; + } + float end = intersections[i++]; + if (start == end) { + + /* two intersections - edge joint */ + if (i >= inter_count) break; + end = intersections[i++]; + } + GP_HLine_Raw(context, start, end, y, pixel); } } }
-----------------------------------------------------------------------
Summary of changes: libs/gfx/GP_Polygon.c | 46 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 39 insertions(+), 7 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.