tr[t1].hi = tr[t2].hi = tr[t4].lo = qs[i1].yval;
tr[t1].lo = tr[t2].lo = tr[t3].hi = qs[i3].yval;
- tr[t4].hi.y = (double) (INFINITY);
- tr[t4].hi.x = (double) (INFINITY);
- tr[t3].lo.y = (double) -1* (INFINITY);
- tr[t3].lo.x = (double) -1* (INFINITY);
+ tr[t4].hi.y = (float) (INFINITY);
+ tr[t4].hi.x = (float) (INFINITY);
+ tr[t3].lo.y = (float) -1* (INFINITY);
+ tr[t3].lo.x = (float) -1* (INFINITY);
tr[t1].rseg = tr[t2].lseg = segnum;
tr[t1].u0 = tr[t2].u0 = t4;
tr[t1].d0 = tr[t2].d0 = t3;
point_t *v;
{
segment_t *s = &seg[segnum];
- double area;
+ float area;
if (_greater_than(&s->v1, &s->v0)) /* seg. going upwards */
{
else
{
int tmpseg = tr[tr[t].d0].rseg;
- double y0, yt;
+ float y0, yt;
point_t tmppt;
int tnext, i_d0, i_d1;
#include <sys/time.h>
#include <math.h>
-#ifdef __STDC__
-extern double log2(double);
+/*#ifdef __STDC__
+extern float log2(float);
#else
-extern double log2();
-#endif
+extern float log2();
+#endif*/
static int choose_idx;
static int permute[SEGSIZE];
int n;
{
register int i;
- double v;
+ float v;
- for (i = 0, v = (double) n; v >= 1; i++)
+ for (i = 0, v = (float) n; v >= 1; i++)
v = log2(v);
return (i - 1);
int h;
{
register int i;
- double v;
+ float v;
for (i = 0, v = (int) n; i < h; i++)
v = log2(v);
- return (int) ceil((double) 1.0*n/v);
+ return (int) ceil((float) 1.0*n/v);
}
#include "vkvg_surface_internal.h"
#include "vkvg_pattern.h"
#include "vkh_queue.h"
+#include "seidel/interface.h"
#ifdef DEBUG
static vec2 debugLinePoints[1000];
uint32_t pathPointCount = lastPtIdx - ctx->pathes[ptrPath] + 1;
uint32_t firstVertIdx = ctx->vertCount;
- ear_clip_point ecps[pathPointCount];
- uint32_t ecps_count = pathPointCount;
- uint32_t i = 0;
+ float triIn[pathPointCount+1][2];
+ memcpy(&triIn[1], &ctx->points[firstPtIdx], 2* sizeof(float) * pathPointCount);
+ int cpt[] = {pathPointCount};
+ int triOut[pathPointCount-2][3];
- //init points link list
- while (i < pathPointCount-1){
+ triangulate_polygon(1, cpt, triIn, triOut);
+
+
+ for (int i=0; i<pathPointCount;i++){
v.pos = ctx->points[i+firstPtIdx];
- ear_clip_point ecp = {v.pos, i+firstVertIdx, &ecps[i+1]};
- ecps[i] = ecp;
_add_vertex(ctx, v);
- i++;
}
- v.pos = ctx->points[i+firstPtIdx];
- ear_clip_point ecp = {v.pos, i+firstVertIdx, ecps};
- ecps[i] = ecp;
- _add_vertex(ctx, v);
-
- ear_clip_point* ecp_current = ecps;
-
- while (ecps_count > 3) {
- ear_clip_point* v0 = ecp_current->next,
- *v1 = ecp_current, *v2 = ecp_current->next->next;
- if (ecp_zcross (v0, v2, v1)<0){
- ecp_current = ecp_current->next;
- continue;
- }
- ear_clip_point* vP = v2->next;
- bool isEar = true;
- while (vP!=v1){
- if (ptInTriangle (vP->pos, v0->pos, v2->pos, v1->pos)){
- isEar = false;
- break;
- }
- vP = vP->next;
- }
- if (isEar){
- _add_triangle_indices (ctx, v0->idx, v1->idx, v2->idx);
- v1->next = v2;
- ecps_count --;
- }else
- ecp_current = ecp_current->next;
+
+ firstVertIdx--;//indices start at 1
+ for (int i=0; i<pathPointCount-2;i++){
+ _add_triangle_indices (ctx,
+ triOut[i][2] + firstVertIdx,
+ triOut[i][1] + firstVertIdx,
+ triOut[i][0] + firstVertIdx);
}
- if (ecps_count == 3)
- _add_triangle_indices(ctx, ecp_current->next->idx, ecp_current->idx, ecp_current->next->next->idx);
ptrPath+=2;
}