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

Method PopulateParameters

trinity/Shader/Tr2Effect.cpp:941–1068  ·  view source on GitHub ↗

--------------------------------------------------------------- PopulateParameters Populates the list of parameters on the mesh using the effect file Visibility annotations default to false, so you need to specifically expose stuff. ---------------------------------------------------------------

Source from the content-addressed store, hash-verified

939// expose stuff.
940// ---------------------------------------------------------------
941bool Tr2Effect::PopulateParameters()
942{
943 CCP_STATS_ZONE( __FUNCTION__ );
944
945 if( !m_shader )
946 {
947 CCP_LOGERR( "Tr2Effect::PopulateParameters: no effect resource loaded." );
948 return false;
949 }
950
951 auto paramAdder = [&]( ITriEffectParameter* p ) {
952 m_parameters.Insert( -1, p );
953 };
954
955 auto resourceAdder = [&]( ITriEffectResourceParameter* p ) {
956 m_resources.Insert( -1, p );
957 };
958
959 auto hasParameter = [&]( const char* name ) -> bool {
960 if( GetParameterByName( name ) )
961 {
962 return true;
963 }
964 for( auto it = m_constParameters.begin(); it != m_constParameters.end(); ++it )
965 {
966 if( strcmp( it->name.c_str(), name ) == 0 )
967 {
968 return true;
969 }
970 }
971 return false;
972 };
973
974 auto& desc = m_shader->GetEffectDescription();
975 for( auto technique = desc.techniques.begin(); technique != desc.techniques.end(); ++technique )
976 {
977 for( auto pass = technique->passes.begin(); pass != technique->passes.end(); ++pass )
978 {
979 for( unsigned i = 0; i != Tr2RenderContextEnum::SHADER_TYPE_COUNT; ++i )
980 {
981 const auto& input = pass->stageInputs[i];
982
983 for( auto constant = input.constants.cbegin(); constant != input.constants.cend(); ++constant )
984 {
985 if( !GetBool( m_shader, constant->name.c_str(), "SasUiVisible" ) )
986 {
987 continue;
988 }
989
990 if( hasParameter( constant->name.c_str() ) )
991 {
992 continue;
993 }
994
995 if( constant->type == Tr2EffectConstant::UINT )
996 {
997 if( auto annotations = m_shader->GetParameterAnnotations( constant->name.c_str() ) )
998 {

Callers

nothing calls this directly

Calls 8

GetBoolFunction · 0.85
ConvertEffectConstantFunction · 0.85
ConvertEffectResourceFunction · 0.85
SetParameterNameMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected