| 635 | } |
| 636 | |
| 637 | void 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 |
nothing calls this directly
no test coverage detected