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

Method DrawArrow

trinity/Tr2DebugRenderer.cpp:485–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483}
484
485void Tr2DebugRenderer::DrawArrow( Tr2DebugObjectReference owner, const Vector3& start, const Vector3& end, float radius, float pointerLength, uint32_t segments, Effect effect, Tr2DebugColor color )
486{
487 Matrix transform = LineTransform( start, end );
488
489 float length = XMVectorGetX( XMVector3Length( start - end ) );
490
491 if( radius <= 0 )
492 {
493 radius = length * pointerLength * 0.15f;
494
495 const Vector2 vertices[] = {
496 Vector2( length / 2 - pointerLength * length, 0 ),
497 Vector2( length / 2 - pointerLength * length, radius * 2 ),
498 Vector2( length / 2, 0 )
499 };
500 Vector2 n = LineNormal( vertices[1], vertices[2] );
501 const Vector2 normals[] = {
502 Vector2( -1, 0 ),
503 Vector2( -1, 0 ),
504 n,
505 n
506 };
507 DrawExtrusionShape( owner, transform, vertices, normals, sizeof( vertices ) / sizeof( vertices[0] ), segments, effect, color );
508 DrawLine( owner, start, start + transform.GetY() * length * ( 1 - pointerLength ), color );
509 }
510 else
511 {
512 const Vector2 vertices[] = {
513 Vector2( -length / 2, 0 ),
514 Vector2( -length / 2, radius ),
515 Vector2( length / 2 - pointerLength * length, radius ),
516 Vector2( length / 2 - pointerLength * length, radius * 2 ),
517 Vector2( length / 2, 0 )
518 };
519 Vector2 n = LineNormal( vertices[2], vertices[3] );
520 const Vector2 normals[] = {
521 Vector2( -1, 0 ),
522 Vector2( -1, 0 ),
523 Vector2( 0, 1 ),
524 Vector2( 0, 1 ),
525 Vector2( 0, 1 ),
526 Vector2( 0, 1 ),
527 Vector2( -1, 0 ),
528 Vector2( -1, 0 ),
529 n,
530 n
531 };
532 DrawExtrusionShape( owner, transform, vertices, normals, sizeof( vertices ) / sizeof( vertices[0] ), segments, effect, color );
533 }
534}
535
536void Tr2DebugRenderer::DrawDoubleArrow( Tr2DebugObjectReference owner, const Vector3& start, const Vector3& end, float radius, float pointerLength, uint32_t segments, Effect effect, Tr2DebugColor color )
537{

Callers 1

RenderDebugInfoMethod · 0.80

Calls 3

LineTransformFunction · 0.85
LineNormalFunction · 0.85
GetYMethod · 0.45

Tested by

no test coverage detected