MCPcopy Create free account
hub / github.com/carbonengine/trinity / AddMiterJoint

Method AddMiterJoint

trinity/Sprite2d/Tr2Sprite2dLineTrace.cpp:637–740  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

635}
636
637void Tr2Sprite2dLineTrace::AddMiterJoint(
638 Tr2Sprite2dScene* renderer,
639 float capAngleTo,
640 Tr2Sprite2dVertexBase v2,
641 Tr2Sprite2dVertexBase v3,
642 Vector2 normal,
643 Color color,
644 bool isAA,
645 float pixelWidthInTexels,
646 float halfWidth )
647{
648 uint16_t fanBase;
649 Vector2 basePoint, topPoint;
650 auto fanVertexBase = m_renderVertices.size();
651 float sign = 1.0f;
652
653 // Determine fan base point
654 if( capAngleTo < 0.0f )
655 {
656 fanBase = 2 + (uint16_t)fanVertexBase - 4;
657 basePoint = v2.position.GetXY();
658 topPoint = v3.position.GetXY();
659 sign = -1.0f;
660 }
661 else if( capAngleTo > 0.0f )
662 {
663 fanBase = 3 + (uint16_t)fanVertexBase - 4;
664 basePoint = v3.position.GetXY();
665 topPoint = v2.position.GetXY();
666 }
667
668 // calculate joint angle
669 float startAngle = atan2( normal.y, normal.x );
670 float endAngle = startAngle + capAngleTo;
671
672 // Create vertexes
673 Tr2Sprite2dVertexBase* fanVerts = static_cast<Tr2Sprite2dVertexBase*>( CCP_MALLOC(
674 "Tr2Sprite2dLineTrace/fanVerts",
675 sizeof( Tr2Sprite2dVertexBase ) ) );
676 Tr2Sprite2dVertexBase* currentVertex = fanVerts;
677
678 // Construct outer joint vertexes
679 uint16_t vertexCount = (uint16_t)m_renderVertices.size();
680
681 // Create vertex
682 Tr2Sprite2dVertexBase& v = *currentVertex++;
683 Vector2 p = GetMiterPoint( halfWidth, basePoint, startAngle, endAngle, sign );
684 v.position.x = p.x;
685 v.position.y = p.y;
686 v.position.z = m_depth;
687 v.color = color;
688
689 // Set texture coordinates
690 if( isAA )
691 {
692 if( sign > 0.0f )
693 v.texCoord[1] = Vector2( 1.0f + pixelWidthInTexels, m_lineWidth );
694 else

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
PrepareTriangleVertsMethod · 0.80

Tested by

no test coverage detected