| 602 | } |
| 603 | |
| 604 | void Tr2DebugRenderer::DrawSphereArrow( Tr2DebugObjectReference owner, const Vector3& center, const Vector3& direction, float radius, uint32_t segments, Effect effect, Tr2DebugColor color ) |
| 605 | { |
| 606 | if( segments < 3 ) |
| 607 | { |
| 608 | segments = 3; |
| 609 | } |
| 610 | |
| 611 | Matrix transform = LineTransform( center - direction, center + direction ); |
| 612 | |
| 613 | std::vector<Vector2> vertices; |
| 614 | vertices.reserve( segments + 4 ); |
| 615 | std::vector<Vector2> normals; |
| 616 | normals.reserve( ( segments + 4 - 1 ) * 2 ); |
| 617 | |
| 618 | float arrowRadius = radius / 5; |
| 619 | |
| 620 | float threshold = std::asin( arrowRadius / radius ); |
| 621 | for( uint32_t i = 0; i < segments; ++i ) |
| 622 | { |
| 623 | float angle = XM_PI - float( i ) / float( segments - 1 ) * XM_PI; |
| 624 | bool done = false; |
| 625 | if( angle < threshold ) |
| 626 | { |
| 627 | angle = threshold; |
| 628 | done = true; |
| 629 | } |
| 630 | |
| 631 | vertices.push_back( Vector2( cos( angle ) * radius, sin( angle ) * radius ) ); |
| 632 | normals.push_back( Vector2( cos( angle ), sin( angle ) ) ); |
| 633 | if( i && !done ) |
| 634 | { |
| 635 | normals.push_back( Vector2( cos( angle ), sin( angle ) ) ); |
| 636 | } |
| 637 | if( done ) |
| 638 | { |
| 639 | break; |
| 640 | } |
| 641 | } |
| 642 | normals.push_back( Vector2( 0, 1 ) ); |
| 643 | vertices.push_back( Vector2( 2 * radius, arrowRadius ) ); |
| 644 | normals.push_back( Vector2( 0, 1 ) ); |
| 645 | |
| 646 | normals.push_back( Vector2( -1, 0 ) ); |
| 647 | vertices.push_back( Vector2( 2 * radius, 2 * arrowRadius ) ); |
| 648 | normals.push_back( Vector2( -1, 0 ) ); |
| 649 | |
| 650 | vertices.push_back( Vector2( 2 * radius + 3 * arrowRadius, 0 ) ); |
| 651 | Vector2 n = LineNormal( vertices[vertices.size() - 2], vertices[vertices.size() - 1] ); |
| 652 | normals.push_back( n ); |
| 653 | normals.push_back( n ); |
| 654 | |
| 655 | DrawExtrusionShape( owner, transform, &vertices[0], &normals[0], uint32_t( vertices.size() ), segments, effect, color ); |
| 656 | } |
| 657 | |
| 658 | void Tr2DebugRenderer::DrawAxis( Tr2DebugObjectReference owner, const Matrix& transform, Effect effect ) |
| 659 | { |
no test coverage detected