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

Method SetLayout

trinity/Tr2DirectInstanceData.cpp:130–146  ·  view source on GitHub ↗

-------------------------------------------------------------------------------------- Description: Invalidates vertex buffer, prepares instance data for a new vertex format, ensures vertex declaration matches the layout provided, and that all attributes come from stream 0. --------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

128// come from stream 0.
129// --------------------------------------------------------------------------------------
130void Tr2DirectInstanceData::SetLayout( const Tr2VertexDefinition& layout )
131{
132 m_vertexBuffer = Tr2BufferAL();
133 m_stride = 0;
134 m_count = 0;
135 for( auto it = layout.m_items.begin(); it != layout.m_items.end(); ++it )
136 {
137 if( it->m_stream != 0 )
138 {
139 CCP_LOGERR( "Tr2DirectInstanceData: vertex layout needs to reference stream 0 only" );
140 return;
141 }
142 m_stride = std::max( m_stride, it->m_offset + layout.GetDataTypeSizeInBytes( it->m_dataType ) );
143 }
144 m_layout = layout;
145 m_vertexDeclaration = Tr2EffectStateManager::GetVertexDeclarationHandle( m_layout );
146}
147
148// --------------------------------------------------------------------------------------
149// Description:

Callers 4

PySetElementLayoutFunction · 0.45
RebuildMethod · 0.45
CreateInstancedMeshMethod · 0.45
ConfigureInstanceDataMethod · 0.45

Calls 5

Tr2BufferALClass · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected