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

Method GatherSprites

trinity/Sprite2d/Tr2Sprite2dLine.cpp:31–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void Tr2Sprite2dLine::GatherSprites( Tr2Sprite2dScene* renderer )
32{
33 CCP_STATS_ZONE( __FUNCTION__ );
34
35 if( !m_display || ( m_spriteEffect == TR2_SFX_NONE ) )
36 {
37 return;
38 }
39
40 if( m_isDirty )
41 {
42 if( !ValidateAndSetTextures( renderer ) )
43 {
44 return;
45 }
46
47 renderer->SetSpriteEffect( m_spriteEffect );
48 renderer->SetTileMode( S2D_TS_TILE_X | S2D_TS_TILE_Y );
49
50 SetRegularRenderState( renderer );
51
52 Vector2 from = m_translationFrom + m_translation;
53 Vector2 to = m_translationTo + m_translation;
54
55 Vector2 d = m_translationTo - m_translationFrom;
56 float segmentLength = Length( d );
57 d = Normalize( d );
58
59 // Rotate 90 degrees
60 Vector2 normal;
61 normal.x = d.y;
62 normal.y = -d.x;
63
64 float halfWidthFrom = 0.5f * m_widthFrom;
65 float halfWidthTo = 0.5f * m_widthTo;
66
67 // Anti-aliased lines are rendered with a quad that is larger. This is then
68 // compensated for in the pixel shader, using the extra pixels to fill in
69 // alpha values to do the anti-aliasing
70
71 bool isAA = m_spriteEffect == TR2_SFX_FILL_AA;
72 float pixelWidthFromInTexels;
73 float pixelWidthToInTexels;
74 if( isAA )
75 {
76 halfWidthFrom += 2.0f;
77 halfWidthTo += 2.0f;
78
79 pixelWidthFromInTexels = 1.0f / ( m_widthFrom + 4.0f );
80 pixelWidthToInTexels = 1.0f / ( m_widthTo + 4.0f );
81 }
82
83 float texOffset1 = m_textureOffsetBase - m_textureOffset;
84 float texOffset2 = m_textureOffsetBase + segmentLength / m_textureWidth - m_textureOffset;
85
86 Tr2Sprite2dVertexBase verts[4];
87
88 Tr2Sprite2dVertexBase& v0 = verts[0];

Callers

nothing calls this directly

Calls 5

LengthFunction · 0.85
SetSpriteEffectMethod · 0.80
SetTileModeMethod · 0.80
PrepareTriangleVertsMethod · 0.80
RenderTriangleVertsMethod · 0.80

Tested by

no test coverage detected