Oolite
Loading...
Searching...
No Matches
OOPolygonSprite.m File Reference
Include dependency graph for OOPolygonSprite.m:

Go to the source code of this file.

Classes

category  OOPolygonSprite(Private)
struct  TessPolygonData

Macros

#define APIENTRY
#define kCosMitreLimit   0.866f

Typedefs

typedef GLvoid(* TessFuncPtr) ()

Functions

static NSArray * DataArrayToPoints (TessPolygonData *data, NSArray *dataArray)
static NSArray * BuildOutlineContour (NSArray *dataArray, GLfloat width, BOOL inner)
static void SubmitVertices (GLUtesselator *tesselator, TessPolygonData *polygonData, NSArray *contour)
static BOOL GrowTessPolygonData (TessPolygonData *data, size_t capacityHint)
static BOOL AppendVertex (TessPolygonData *data, NSPoint vertex)
static void SVGDumpBegin (TessPolygonData *data)
static void SVGDumpEnd (TessPolygonData *data)
static void SVGDumpBeginGroup (TessPolygonData *data, NSString *name)
static void SVGDumpEndGroup (TessPolygonData *data)
static void SVGDumpAppendBaseContour (TessPolygonData *data, NSArray *points)
static void SVGDumpBeginPrimitive (TessPolygonData *data)
static void SVGDumpEndPrimitive (TessPolygonData *data)
static void SVGDumpAppendTriangle (TessPolygonData *data, NSPoint v0, NSPoint v1, NSPoint v2)
static void APIENTRY TessBeginCallback (GLenum type, void *polygonData)
static void APIENTRY TessVertexCallback (void *vertexData, void *polygonData)
static void APIENTRY TessCombineCallback (GLdouble coords[3], void *vertexData[4], GLfloat weight[4], void **outData, void *polygonData)
static void APIENTRY TessEndCallback (void *polygonData)
static void APIENTRY ErrorCallback (GLenum error, void *polygonData)

Macro Definition Documentation

◆ APIENTRY

#define APIENTRY

◆ kCosMitreLimit

#define kCosMitreLimit   0.866f

Definition at line 53 of file OOPolygonSprite.m.

Referenced by BuildOutlineContour().

Typedef Documentation

◆ TessFuncPtr

typedef GLvoid(* TessFuncPtr) ()

Definition at line 127 of file OOPolygonSprite.m.

Function Documentation

◆ AppendVertex()

BOOL AppendVertex ( TessPolygonData * data,
NSPoint vertex )
static

Definition at line 612 of file OOPolygonSprite.m.

613{
614 NSCParameterAssert(data != NULL);
615
616 if (data->capacity == data->count && !GrowTessPolygonData(data, data->capacity * 2))
617 return NO;
618
619 data->data[data->count * 2] = vertex.x;
620 data->data[data->count * 2 + 1] = vertex.y;
621 data->count++;
622 return YES;
623}
static BOOL GrowTessPolygonData(TessPolygonData *data, size_t capacityHint)

References TessPolygonData::capacity, TessPolygonData::count, TessPolygonData::data, and GrowTessPolygonData().

Referenced by TessVertexCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BuildOutlineContour()

NSArray * BuildOutlineContour ( NSArray * dataArray,
GLfloat width,
BOOL inner )
static

Definition at line 491 of file OOPolygonSprite.m.

492{
493 NSUInteger i, count = [dataArray count];
494 if (count < 2)
495 return dataArray;
496
497 /*
498 Generate inner or outer boundary for a contour, offset by the specified
499 width inwards/outwards from the line. At anticlockwise (convex) corners
500 sharper than acos(kCosMitreLimit), the corner is mitred, i.e. an
501 additional line segment is generated so the outline doesn't protrude
502 arbitratrily far.
503
504 Overview of the maths:
505 For each vertex, we consider a normalized vector A from the previous
506 vertex and a normalized vector B to the next vertex. (These are always
507 defined since the polygons are closed.)
508
509 The dot product of A and B is the cosine of the angle, which we compare
510 to kCosMitreLimit to determine mitreing. If the dot product is exactly
511 1, the vectors are antiparallel and we have a cap; the mitreing case
512 handles this implicitly. (The non-mitreing case would result in a
513 divide-by-zero.)
514
515 Non-mitreing case:
516 To position the vertex, we need a vector N normal to the corner.
517 We observe that A + B is tangent to the corner, and a 90 degree
518 rotation in 2D is trivial. The offset along this line is
519 proportional to the secant of the angle between N and the 90 degree
520 rotation of A (or B; the angle is by definition the same), or
521 width / (N dot rA).
522 Since both N and rA are rotated by ninety degrees in the same
523 direction, we can cut out both rotations (i.e., using the tangent
524 and A) and get the same result.
525
526 Mitreing case:
527 The two new vertices are the original vertex offset by scale along
528 the ninety-degree rotation of A and B respectively.
529 */
530
531 NSPoint prev, current, next;
532 if (inner) {
533 prev = [[dataArray objectAtIndex:0] pointValue];
534 current = [[dataArray objectAtIndex:count - 1] pointValue];
535 next = [[dataArray objectAtIndex:count - 2] pointValue];
536 } else {
537 prev = [[dataArray objectAtIndex:count - 1] pointValue];
538 current = [[dataArray objectAtIndex:0] pointValue];
539 next = [[dataArray objectAtIndex:1] pointValue];
540 }
541
542 NSMutableArray* result = [NSMutableArray arrayWithCapacity:count];
543
544 for (i = 0; i < count; i++) {
545 NSPoint a = PtNormal(PtSub(current, prev));
546 NSPoint b = PtNormal(PtSub(next, current));
547
548 CGFloat dot = PtDot(a, b);
549 BOOL clockwise = PtCross(a, b) < 0.0f;
550
551 if (-dot < kCosMitreLimit || !clockwise) {
552 // Non-mitreing case.
553 NSPoint t = PtNormal(PtAdd(a, b));
554 NSPoint v = PtScale(PtRotACW(t), width / PtDot(t, a));
555
556 if (!isnan(v.x) && !isnan(v.y)) {
557 [result addObject:[NSValue valueWithPoint:PtAdd(v, current)]];
558 }
559 } else {
560 // Mitreing case.
561 NSPoint v1 = PtScale(PtAdd(PtRotACW(a), a), width);
562 NSPoint v2 = PtScale(PtSub(PtRotACW(b), b), width);
563
564 if (!isnan(v1.x) && !isnan(v1.y)) {
565 [result addObject:[NSValue valueWithPoint:PtAdd(v1, current)]];
566 }
567 if (!isnan(v2.x) && !isnan(v2.y)) {
568 [result addObject:[NSValue valueWithPoint:PtAdd(v2, current)]];
569 }
570 }
571
572 prev = current;
573 current = next;
574
575 if (inner) {
576 next = [[dataArray objectAtIndex:(count * 2 - 3 - i) % count] pointValue];
577 } else {
578 next = [[dataArray objectAtIndex:(i + 2) % count] pointValue];
579 }
580 }
581
582 return result;
583}
unsigned count
OOINLINE CGFloat PtDot(NSPoint a, NSPoint b)
OOINLINE NSPoint PtScale(NSPoint p, CGFloat scale)
OOINLINE NSPoint PtSub(NSPoint a, NSPoint b)
OOINLINE NSPoint PtRotACW(NSPoint p)
OOINLINE NSPoint PtNormal(NSPoint p)
OOINLINE CGFloat PtCross(NSPoint a, NSPoint b)
OOINLINE NSPoint PtAdd(NSPoint a, NSPoint b)
Definition OOPointMaths.h:5
#define kCosMitreLimit

References count, kCosMitreLimit, PtAdd(), PtCross(), PtDot(), PtNormal(), PtRotACW(), PtScale(), and PtSub().

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DataArrayToPoints()

NSArray * DataArrayToPoints ( TessPolygonData * data,
NSArray * dataArray )
static

Definition at line 426 of file OOPolygonSprite.m.

427{
428 /* This converts an icon definition in the form of an array of array of
429 numbers to internal data in the form of an array of arrays of NSValues
430 containing NSPoint data. In addition to repacking the data, it performs
431 the following data processing:
432 * Sequences of duplicate vertices are removed (including across the
433 beginning and end, in case of manually closed contours).
434 * Vertices containing nans or infinities are skipped, Just In Case.
435 * The signed area of each contour is calculated; if it is negative,
436 the contour is clockwise, and we need to flip it.
437 */
438
439 SVGDumpBeginGroup(data, @"Base contours");
440
441 NSUInteger polyIter, polyCount = [dataArray count];
442 NSArray* subArrays[polyCount];
443
444 for (polyIter = 0; polyIter < polyCount; polyIter++) {
445 NSArray* polyDef = [dataArray objectAtIndex:polyIter];
446 NSUInteger vertIter, vertCount = [polyDef count] / 2;
447 NSMutableArray* newPolyDef = [NSMutableArray arrayWithCapacity:vertCount];
448 CGFloat area = 0;
449
450 CGFloat oldX = [polyDef oo_doubleAtIndex:(vertCount - 1) * 2];
451 CGFloat oldY = [polyDef oo_doubleAtIndex:(vertCount - 1) * 2 + 1];
452
453 for (vertIter = 0; vertIter < vertCount; vertIter++) {
454 CGFloat x = [polyDef oo_doubleAtIndex:vertIter * 2];
455 CGFloat y = [polyDef oo_doubleAtIndex:vertIter * 2 + 1];
456
457 // Skip bad or duplicate vertices.
458 if (x == oldX && y == oldY)
459 continue;
460 if (isnan(x) || isnan(y))
461 continue;
462 if (!isfinite(x) || !isfinite(y))
463 continue;
464
465 area += x * oldY - oldX * y;
466
467 oldX = x;
468 oldY = y;
469
470 [newPolyDef addObject:[NSValue valueWithPoint:NSMakePoint(x, y)]];
471 }
472
473 // Eliminate duplicates at ends - the initialization of oldX and oldY will catch one pair, but not extra-silly cases.
474 while ([newPolyDef count] > 1 && [[newPolyDef objectAtIndex:0] isEqual:[newPolyDef lastObject]]) {
475 [newPolyDef removeLastObject];
476 }
477
478 if (area >= 0) {
479 subArrays[polyIter] = newPolyDef;
480 } else {
481 subArrays[polyIter] = [[newPolyDef reverseObjectEnumerator] allObjects];
482 }
483
484 SVGDumpAppendBaseContour(data, subArrays[polyIter]);
485 }
486
487 SVGDumpEndGroup(data);
488 return [NSArray arrayWithObjects:subArrays count:polyCount];
489}
static void SVGDumpBeginGroup(TessPolygonData *data, NSString *name)
static void SVGDumpAppendBaseContour(TessPolygonData *data, NSArray *points)
static void SVGDumpEndGroup(TessPolygonData *data)
float y
float x

References count, SVGDumpAppendBaseContour(), SVGDumpBeginGroup(), SVGDumpEndGroup(), x, and y.

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ErrorCallback()

void APIENTRY ErrorCallback ( GLenum error,
void * polygonData )
static

Definition at line 740 of file OOPolygonSprite.m.

741{
742 TessPolygonData* data = polygonData;
743 NSCParameterAssert(data != NULL);
744
745 NSString* name = @"";
746#ifndef NDEBUG
747 name = [NSString stringWithFormat:@" \"%@\"", data->name];
748#endif
749
750 char* errStr = (char*)gluErrorString(error);
751
752 OOLog(@"polygonSprite.tesselate.error", @"Error %s (%u) while tesselating polygon%@.", errStr, error, name);
753 data->OK = NO;
754}
#define OOLog(class, format,...)
Definition OOLogging.h:84

References APIENTRY, TessPolygonData::OK, and OOLog.

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the caller graph for this function:

◆ GrowTessPolygonData()

BOOL GrowTessPolygonData ( TessPolygonData * data,
size_t capacityHint )
static

Definition at line 585 of file OOPolygonSprite.m.

586{
587 NSCParameterAssert(data != NULL);
588
589 size_t minCapacity = data->capacity + 1;
590 size_t desiredCapacity = MAX(capacityHint, minCapacity);
591 size_t newCapacity = 0;
592 GLfloat* newData = realloc(data->data, desiredCapacity * sizeof(GLfloat) * 2);
593 if (newData != NULL) {
594 newCapacity = desiredCapacity;
595 } else {
596 desiredCapacity = minCapacity;
597 newData = realloc(data->data, desiredCapacity * sizeof(GLfloat) * 2);
598 if (newData != NULL)
599 newCapacity = desiredCapacity;
600 }
601
602 if (newData == NULL)
603 return NO;
604
605 NSCAssert(newCapacity > data->capacity, @"Buffer regrow logic error");
606
607 data->data = newData;
608 data->capacity = newCapacity;
609 return YES;
610}
#define MAX(A, B)
Definition OOMaths.h:94

References TessPolygonData::capacity, TessPolygonData::data, and MAX.

Referenced by AppendVertex(), and OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the caller graph for this function:

◆ SubmitVertices()

void SubmitVertices ( GLUtesselator * tesselator,
TessPolygonData * polygonData,
NSArray * contour )
static

Definition at line 408 of file OOPolygonSprite.m.

409{
410 NSUInteger vertexCount = [contour count], vertexIndex;
411 if (vertexCount > 2) {
412 gluTessBeginContour(tesselator);
413
414 for (vertexIndex = 0; vertexIndex < vertexCount && polygonData->OK; vertexIndex++) {
415 NSValue* pointValue = [contour objectAtIndex:vertexIndex];
416 NSPoint p = [pointValue pointValue];
417 GLdouble vert[3] = { p.x, p.y, 0.0 };
418
419 gluTessVertex(tesselator, vert, pointValue);
420 }
421
422 gluTessEndContour(tesselator);
423 }
424}

References TessPolygonData::OK.

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the caller graph for this function:

◆ SVGDumpAppendBaseContour()

void SVGDumpAppendBaseContour ( TessPolygonData * data,
NSArray * points )
static

Definition at line 796 of file OOPolygonSprite.m.

797{
798 if (data->debugSVG == nil)
799 return;
800
801 NSString* groupName = [NSString stringWithFormat:@"contour %u", data->svgID++];
802 [data->debugSVG appendFormat:@"\t\t<g id=\"%@\" stroke=\"#BBB\" fill=\"none\">\n\t\t<path stroke-width=\"0.05\" d=\"", groupName];
803
804 NSUInteger i, count = [points count];
805 for (i = 0; i < count; i++) {
806 NSPoint p = [[points objectAtIndex:i] pointValue];
807 [data->debugSVG appendFormat:@"%c %f %f ", (i == 0) ? 'M' : 'L', p.x, -p.y];
808 }
809
810 // Close and add a circle at the first vertex. (SVG has support for end markers, but this isn’t reliable across implementations.)
811 NSPoint p = [[points objectAtIndex:0] pointValue];
812 [data->debugSVG appendFormat:@"z\"/>\n\t\t\t<circle cx=\"%f\" cy=\"%f\" r=\"0.1\" fill=\"#BBB\" stroke=\"none\"/>\n\t\t</g>\n", p.x, -p.y];
813}
return nil
NSMutableString * debugSVG

References count, TessPolygonData::debugSVG, and nil.

Referenced by DataArrayToPoints().

Here is the caller graph for this function:

◆ SVGDumpAppendTriangle()

void SVGDumpAppendTriangle ( TessPolygonData * data,
NSPoint v0,
NSPoint v1,
NSPoint v2 )
static

Definition at line 856 of file OOPolygonSprite.m.

857{
858 if (data->debugSVG == nil)
859 return;
860 [data->debugSVG appendFormat:@"\t\t\t<path d=\"M %f %f L %f %f L %f %f z\"/>\n", v0.x, -v0.y, v1.x, -v1.y, v2.x, -v2.y];
861}

References TessPolygonData::debugSVG, and nil.

Referenced by TessVertexCallback().

Here is the caller graph for this function:

◆ SVGDumpBegin()

void SVGDumpBegin ( TessPolygonData * data)
static

Definition at line 760 of file OOPolygonSprite.m.

761{
762 DESTROY(data->debugSVG);
763 data->debugSVG = [[NSMutableString alloc] initWithString:
764 @"<?xml version=\"1.0\" standalone=\"no\"?>\n"
765 "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
766 "<svg viewBox=\"-5 -5 10 10\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"
767 "\t<desc>Oolite polygon sprite debug dump.</desc>\n"
768 "\t\n"];
769}
#define DESTROY(x)

References TessPolygonData::debugSVG, and DESTROY.

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the caller graph for this function:

◆ SVGDumpBeginGroup()

void SVGDumpBeginGroup ( TessPolygonData * data,
NSString * name )
static

Definition at line 781 of file OOPolygonSprite.m.

782{
783 if (data->debugSVG == nil)
784 return;
785
786 [data->debugSVG appendFormat:@"\t<g id=\"%@ %u\">\n", name, data->svgID++];
787}

References TessPolygonData::debugSVG, and nil.

Referenced by DataArrayToPoints(), and OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the caller graph for this function:

◆ SVGDumpBeginPrimitive()

void SVGDumpBeginPrimitive ( TessPolygonData * data)
static

Definition at line 815 of file OOPolygonSprite.m.

816{
817 if (data->debugSVG == nil)
818 return;
819
820 NSString* groupName = @"Unknown primitive";
821 switch (data->mode) {
822 case GL_TRIANGLES:
823 groupName = @"Triangle soup";
824 break;
825
826 case GL_TRIANGLE_FAN:
827 groupName = @"Triangle fan";
828 break;
829
830 case GL_TRIANGLE_STRIP:
831 groupName = @"Triangle strip";
832 break;
833 }
834 groupName = [groupName stringByAppendingFormat:@" %u", data->svgID++];
835
836 // Pick random colour for the primitive.
837 uint8_t red = (Ranrot() & 0x3F) + 0x20;
838 uint8_t green = (Ranrot() & 0x3F) + 0x20;
839 uint8_t blue = (Ranrot() & 0x3F) + 0x20;
840 if (!data->generatingOutline) {
841 red += 0x80;
842 green += 0x80;
843 blue += 0x80;
844 }
845
846 [data->debugSVG appendFormat:@"\t\t<g id=\"%@\" fill=\"#%2X%2X%2X\" fill-opacity=\"0.3\" stroke=\"%@\" stroke-width=\"0.01\">\n", groupName, red, green, blue, data->generatingOutline ? @"#060" : @"#008"];
847}
unsigned Ranrot(void)

References TessPolygonData::debugSVG, TessPolygonData::generatingOutline, TessPolygonData::mode, nil, and Ranrot().

Referenced by TessBeginCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SVGDumpEnd()

void SVGDumpEnd ( TessPolygonData * data)
static

Definition at line 771 of file OOPolygonSprite.m.

772{
773 if (data->debugSVG == nil)
774 return;
775
776 [data->debugSVG appendString:@"</svg>\n"];
777 [ResourceManager writeDiagnosticString:data->debugSVG toFileNamed:[NSString stringWithFormat:@"Polygon Sprites/%@.svg", data->name]];
778 DESTROY(data->debugSVG);
779}

References TessPolygonData::debugSVG, DESTROY, nil, and ResourceManager::writeDiagnosticString:toFileNamed:.

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SVGDumpEndGroup()

void SVGDumpEndGroup ( TessPolygonData * data)
static

Definition at line 789 of file OOPolygonSprite.m.

790{
791 if (data->debugSVG == nil)
792 return;
793 [data->debugSVG appendString:@"\t</g>\n"];
794}

References TessPolygonData::debugSVG, and nil.

Referenced by DataArrayToPoints(), and OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the caller graph for this function:

◆ SVGDumpEndPrimitive()

void SVGDumpEndPrimitive ( TessPolygonData * data)
static

Definition at line 849 of file OOPolygonSprite.m.

850{
851 if (data->debugSVG == nil)
852 return;
853 [data->debugSVG appendString:@"\t\t</g>\n"];
854}

References TessPolygonData::debugSVG, and nil.

Referenced by TessEndCallback().

Here is the caller graph for this function:

◆ TessBeginCallback()

void APIENTRY TessBeginCallback ( GLenum type,
void * polygonData )
static

Definition at line 625 of file OOPolygonSprite.m.

626{
627 TessPolygonData* data = polygonData;
628 NSCParameterAssert(data != NULL);
629
630 data->mode = type;
631 data->vCount = 0;
632
634}
static void SVGDumpBeginPrimitive(TessPolygonData *data)

References APIENTRY, TessPolygonData::mode, SVGDumpBeginPrimitive(), and TessPolygonData::vCount.

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TessCombineCallback()

void APIENTRY TessCombineCallback ( GLdouble coords[3],
void * vertexData[4],
GLfloat weight[4],
void ** outData,
void * polygonData )
static

Definition at line 723 of file OOPolygonSprite.m.

724{
725 NSPoint point = { coords[0], coords[1] };
726 *outData = [NSValue valueWithPoint:point];
727}

References APIENTRY.

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the caller graph for this function:

◆ TessEndCallback()

void APIENTRY TessEndCallback ( void * polygonData)
static

Definition at line 729 of file OOPolygonSprite.m.

730{
731 TessPolygonData* data = polygonData;
732 NSCParameterAssert(data != NULL);
733
734 data->mode = 0;
735 data->vCount = 0;
736
738}
static void SVGDumpEndPrimitive(TessPolygonData *data)

References APIENTRY, TessPolygonData::mode, SVGDumpEndPrimitive(), and TessPolygonData::vCount.

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TessVertexCallback()

void APIENTRY TessVertexCallback ( void * vertexData,
void * polygonData )
static

Definition at line 636 of file OOPolygonSprite.m.

637{
638 TessPolygonData* data = polygonData;
639 NSValue* vertValue = vertexData;
640 NSCParameterAssert(vertValue != NULL && data != NULL);
641 if (!data->OK)
642 return;
643
644 NSPoint p = [vertValue pointValue];
645 NSPoint vertex = { p.x, p.y };
646 size_t vCount = data->vCount++;
647
648 switch (data->mode) {
649 case GL_TRIANGLES:
650 data->OK = AppendVertex(data, vertex);
651#ifndef NDEBUG
652 switch (vCount % 3) {
653 case 0:
654 data->pending0 = vertex;
655 break;
656
657 case 1:
658 data->pending1 = vertex;
659 break;
660
661 case 2:
662 SVGDumpAppendTriangle(data, data->pending0, data->pending1, vertex);
663 }
664#endif
665 break;
666
667 case GL_TRIANGLE_FAN:
668 if (vCount == 0)
669 data->pending0 = vertex;
670 else if (vCount == 1)
671 data->pending1 = vertex;
672 else {
673 data->OK = AppendVertex(data, data->pending0) && AppendVertex(data, data->pending1) && AppendVertex(data, vertex);
674 SVGDumpAppendTriangle(data, data->pending0, data->pending1, vertex);
675 data->pending1 = vertex;
676 }
677 break;
678
679 case GL_TRIANGLE_STRIP:
680 if (vCount == 0)
681 data->pending0 = vertex;
682 else if (vCount == 1)
683 data->pending1 = vertex;
684 else {
685 /* In order to produce consistent winding, the vertex->triangle
686 order for GL_TRIANGLE_STRIP is:
687 0, 1, 2
688 2, 1, 3
689 2, 3, 4
690 4, 3, 5
691 4, 5, 6
692 6, 5, 7
693 6, 7, 8
694
695 Vertices 0 and 1 are special-cased above, and the first
696 time we get here it's time for the first triangle, which
697 is pending0, pending1, v. v (i.e., vertex 2) then goes into
698 pending0.
699 For the second triangle, the triangle is again pending0,
700 pending1, v, and we then put v (i.e., vertex 3) into
701 pending1.
702 The third triangle follows the same pattern as the first,
703 and the fourthe the same as the second.
704 In other words, after storing each triangle, v goes into
705 pending0 for even vertex indicies, and pending1 for odd
706 vertex indices.
707 */
708 data->OK = AppendVertex(data, data->pending0) && AppendVertex(data, data->pending1) && AppendVertex(data, vertex);
709 SVGDumpAppendTriangle(data, data->pending0, data->pending1, vertex);
710 if ((vCount % 2) == 0)
711 data->pending0 = vertex;
712 else
713 data->pending1 = vertex;
714 }
715 break;
716
717 default:
718 OOLog(@"polygonSprite.tesselate.error", @"Unexpected tesselator primitive mode %u.", data->mode);
719 data->OK = NO;
720 }
721}
static BOOL AppendVertex(TessPolygonData *data, NSPoint vertex)
static void SVGDumpAppendTriangle(TessPolygonData *data, NSPoint v0, NSPoint v1, NSPoint v2)

References APIENTRY, AppendVertex(), TessPolygonData::mode, TessPolygonData::OK, OOLog, TessPolygonData::pending0, TessPolygonData::pending1, SVGDumpAppendTriangle(), and TessPolygonData::vCount.

Referenced by OOPolygonSprite(Private)::loadPolygons:outlineWidth:.

Here is the call graph for this function:
Here is the caller graph for this function: