| 49 | } |
| 50 | |
| 51 | Tr2ShaderPtr Tr2EffectRes::GetShader( const Tr2ShaderOption* options, size_t count ) |
| 52 | { |
| 53 | if( !IsGood() ) |
| 54 | { |
| 55 | return nullptr; |
| 56 | } |
| 57 | |
| 58 | if( !Tr2Renderer::IsResourceCreationAllowed() ) |
| 59 | { |
| 60 | return nullptr; |
| 61 | } |
| 62 | |
| 63 | uint32_t multiplier = 1; |
| 64 | uint32_t index = 0; |
| 65 | |
| 66 | for( size_t i = 0; i < m_permutations.size(); ++i ) |
| 67 | { |
| 68 | auto value = m_permutations[i].defaultOption; |
| 69 | |
| 70 | bool foundGlobal = false; |
| 71 | for( auto& opt : GetGlobalEffectOptions() ) |
| 72 | { |
| 73 | if( opt.name == m_permutations[i].name ) |
| 74 | { |
| 75 | auto found = std::find( begin( m_permutations[i].options ), end( m_permutations[i].options ), opt.value ); |
| 76 | if( found != end( m_permutations[i].options ) ) |
| 77 | { |
| 78 | value = found - begin( m_permutations[i].options ); |
| 79 | } |
| 80 | foundGlobal = true; |
| 81 | break; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | if( !foundGlobal ) |
| 86 | { |
| 87 | for( size_t k = 0; k < count; ++k ) |
| 88 | { |
| 89 | if( options[k].name == m_permutations[i].name ) |
| 90 | { |
| 91 | size_t val = -1; |
| 92 | for( size_t j = 0; j < m_permutations[i].options.size(); ++j ) |
| 93 | { |
| 94 | if( m_permutations[i].options[j] == options[k].value ) |
| 95 | { |
| 96 | val = j; |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | if( val == -1 ) |
| 101 | { |
| 102 | CCP_LOGWARN( "Invalid situation value %s for permutation %s in effect %S", options[k].value.c_str(), m_permutations[i].name.c_str(), GetPath() ); |
| 103 | } |
| 104 | else |
| 105 | { |
| 106 | value = val; |
| 107 | } |
| 108 | } |
no test coverage detected