| 64 | } |
| 65 | |
| 66 | StateGraph* ShadowsBin::cullStateGraph( |
| 67 | StateGraph* sg, StateGraph* root, std::unordered_set<StateGraph*>& uninterestingCache, bool cullFaceOverridden) |
| 68 | { |
| 69 | std::vector<StateGraph*> returnPath; |
| 70 | State state; |
| 71 | StateGraph* sgNew = sg; |
| 72 | do |
| 73 | { |
| 74 | if (uninterestingCache.find(sgNew) != uninterestingCache.end()) |
| 75 | break; |
| 76 | returnPath.push_back(sgNew); |
| 77 | sgNew = sgNew->_parent; |
| 78 | } while (sgNew && sgNew != root); |
| 79 | |
| 80 | for (auto itr = returnPath.rbegin(); itr != returnPath.rend(); ++itr) |
| 81 | { |
| 82 | const osg::StateSet* ss = (*itr)->getStateSet(); |
| 83 | if (!ss) |
| 84 | continue; |
| 85 | |
| 86 | accumulateModeState(ss, state.mAlphaBlend, state.mAlphaBlendOverride, GL_BLEND); |
| 87 | |
| 88 | const osg::StateSet::AttributeList& attributes = ss->getAttributeList(); |
| 89 | osg::StateSet::AttributeList::const_iterator found |
| 90 | = attributes.find(std::make_pair(osg::StateAttribute::MATERIAL, 0)); |
| 91 | if (found != attributes.end()) |
| 92 | { |
| 93 | const osg::StateSet::RefAttributePair& rap = found->second; |
| 94 | accumulateState( |
| 95 | state.mMaterial, static_cast<osg::Material*>(rap.first.get()), state.mMaterialOverride, rap.second); |
| 96 | if (state.mMaterial && !materialNeedShadows(state.mMaterial)) |
| 97 | state.mMaterial = nullptr; |
| 98 | } |
| 99 | |
| 100 | found = attributes.find(std::make_pair(osg::StateAttribute::ALPHAFUNC, 0)); |
| 101 | if (found != attributes.end()) |
| 102 | { |
| 103 | // As force shaders is on, we know this is really a RemovedAlphaFunc |
| 104 | const osg::StateSet::RefAttributePair& rap = found->second; |
| 105 | accumulateState(state.mAlphaFunc, static_cast<osg::AlphaFunc*>(rap.first.get()), |
| 106 | state.mAlphaFuncOverride, rap.second); |
| 107 | } |
| 108 | |
| 109 | if (!cullFaceOverridden) |
| 110 | { |
| 111 | // osg::FrontFace specifies triangle winding, not front-face culling. We can't safely reparent anything |
| 112 | // under it unless GL_CULL_FACE is off or we flip face culling. |
| 113 | found = attributes.find(std::make_pair(osg::StateAttribute::FRONTFACE, 0)); |
| 114 | if (found != attributes.end()) |
| 115 | state.mImportantState = true; |
| 116 | } |
| 117 | |
| 118 | if ((*itr) != sg && !state.interesting()) |
| 119 | uninterestingCache.insert(*itr); |
| 120 | } |
| 121 | |
| 122 | if (!state.needShadows()) |
| 123 | return nullptr; |
nothing calls this directly
no test coverage detected