use own inline hash_combine function

pull/228/head
Bret Curtis 8 years ago
parent fb7479c194
commit f0b21cca22

@ -209,13 +209,21 @@ namespace SceneUtil
mLights.push_back(l);
}
/* similar to the boost::hash_combine */
template <class T>
inline void hash_combine(std::size_t& seed, const T& v)
{
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
}
osg::ref_ptr<osg::StateSet> LightManager::getLightListStateSet(const LightList &lightList, unsigned int frameNum)
{
// possible optimization: return a StateSet containing all requested lights plus some extra lights (if a suitable one exists)
size_t hash = 0;
for (unsigned int i=0; i<lightList.size();++i)
hash = hash ^ (lightList[i]->mLightSource->getId() << 1); // or use boost::hash_combine
// original: boost::hash_combine(hash, lightList[i]->mLightSource->getId());
hash_combine(hash, lightList[i]->mLightSource->getId());
LightStateSetMap& stateSetCache = mStateSetCache[frameNum%2];

Loading…
Cancel
Save