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

Method PrepareTriangleVerts

trinity/Sprite2d/Tr2Sprite2dScene.cpp:925–998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

923}
924
925bool Tr2Sprite2dScene::PrepareTriangleVerts( Tr2Sprite2dD3DVertex* destVerts, Tr2Sprite2dVertexBase* verts, unsigned int stride, unsigned int vertexCount )
926{
927 CCP_STATS_ZONE( __FUNCTION__ );
928
929 if( !TexturesReady() )
930 {
931 CCP_STATS_INC( spriteSceneTextureNotReady );
932 return false;
933 }
934
935 //
936 // First gather all data we're setting or using to adjust vertices, then iterate over
937 // all verts and set the data. It's very important that we only iterate once over
938 // the vertices and update their fields in the right order for optimal cache behavior.
939 //
940
941 //
942 // Process the vertices into the vertex buffer
943 //
944
945 Tr2Sprite2dVertexBase* curVertex = verts;
946 for( unsigned int i = 0; i < vertexCount; ++i )
947 {
948 destVerts->position.x = curVertex->position.x;
949 destVerts->position.y = curVertex->position.y;
950 destVerts->position.z = curVertex->position.z;
951
952 destVerts->color.r = curVertex->color.r * m_color.r;
953 destVerts->color.g = curVertex->color.g * m_color.g;
954 destVerts->color.b = curVertex->color.b * m_color.b;
955 destVerts->color.a = curVertex->color.a * m_color.a;
956
957 for( int ix = 0; ix < m_numTexturesUsed; ++ix )
958 {
959 TextureSetting& texSettings = m_textureSettings[ix];
960
961 Vector2 dstUV;
962 if( texSettings.useTransform )
963 {
964 // Apply texture transformation
965 float x = curVertex->texCoord[ix].x;
966 float y = curVertex->texCoord[ix].y;
967 Vector4 uv( x, y, 0.0f, 1.0f );
968 uv = Transform( uv, texSettings.transform );
969 dstUV.x = uv.x * texSettings.textureWindow.z + texSettings.textureWindow.x;
970 dstUV.y = uv.y * texSettings.textureWindow.w + texSettings.textureWindow.y;
971 }
972 else
973 {
974 dstUV.x = curVertex->texCoord[ix].x * texSettings.textureWindow.z + texSettings.textureWindow.x;
975 dstUV.y = curVertex->texCoord[ix].y * texSettings.textureWindow.w + texSettings.textureWindow.y;
976 }
977 destVerts->texCoord[ix] = dstUV;
978 }
979
980 if( m_isAntiAliased )
981 {
982 destVerts->texCoord[0] = curVertex->texCoord[0];

Callers 9

GatherSpritesMethod · 0.80
GatherSpritesMethod · 0.80
GatherSpritesMethod · 0.80
AddSegmentMethod · 0.80
AddRoundJointMethod · 0.80
AddMiterJointMethod · 0.80
GatherSpritesMethod · 0.80
GatherSpritesMethod · 0.80
GatherSpritesMethod · 0.80

Calls 1

PackBlendModeFunction · 0.85

Tested by

no test coverage detected