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

Method DrawCapsule

trinity/Tr2DebugRenderer.cpp:443–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443void Tr2DebugRenderer::DrawCapsule( Tr2DebugObjectReference owner, const Matrix& transform, float radius, float height, uint32_t segments, Effect effect, Tr2DebugColor color )
444{
445 if( segments < 3 )
446 {
447 segments = 3;
448 }
449
450 std::vector<Vector2> vertices;
451 vertices.reserve( segments * 2 );
452 std::vector<Vector2> normals;
453 normals.reserve( ( segments * 2 - 1 ) * 2 );
454
455 for( uint32_t i = 0; i < segments; ++i )
456 {
457 float alpha = float( i ) / float( segments - 1 ) * XM_PI / 2;
458 vertices.push_back( Vector2( -cos( alpha ) * radius - height / 2, sin( alpha ) * radius ) );
459 normals.push_back( Vector2( -cos( alpha ), sin( alpha ) ) );
460 if( i )
461 {
462 normals.push_back( Vector2( -cos( alpha ), sin( alpha ) ) );
463 }
464 }
465 for( uint32_t i = 0; i < segments; ++i )
466 {
467 float alpha = XM_PI / 2 - float( i ) / float( segments - 1 ) * XM_PI / 2;
468 vertices.push_back( Vector2( cos( alpha ) * radius + height / 2, sin( alpha ) * radius ) );
469 normals.push_back( Vector2( cos( alpha ), sin( alpha ) ) );
470 if( i + 1 < segments )
471 {
472 normals.push_back( Vector2( cos( alpha ), sin( alpha ) ) );
473 }
474 }
475
476 DrawExtrusionShape( owner, transform, &vertices[0], &normals[0], uint32_t( vertices.size() ), segments, effect, color );
477}
478
479void Tr2DebugRenderer::DrawCapsule( Tr2DebugObjectReference owner, const Vector3& cap0, const Vector3& cap1, float radius, uint32_t segments, Effect effect, Tr2DebugColor color )
480{

Callers

nothing calls this directly

Calls 2

LineTransformFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected