diff --git a/irr/include/SMaterial.h b/irr/include/SMaterial.h index d48328a31..d5b9341f4 100644 --- a/irr/include/SMaterial.h +++ b/irr/include/SMaterial.h @@ -483,9 +483,15 @@ struct std::hash /// @brief std::hash specialization for video::SMaterial std::size_t operator()(const irr::video::SMaterial &m) const noexcept { - // basic implementation that hashes the two things most likely to differ - auto h1 = std::hash{}(m.getTexture(0)); - auto h2 = std::hash{}(m.MaterialType); - return (h1 << 1) ^ h2; + std::size_t ret = 0; + for (auto h : { // the three members most likely to differ + std::hash{}(m.getTexture(0)), + std::hash{}(m.MaterialType), + std::hash{}(m.ColorParam.color) + }) { + ret += h; + ret ^= (ret << 6) + (ret >> 2); // distribute bits + } + return ret; } };