summaryrefslogtreecommitdiff
path: root/indra/llprimitive/llmaterialid.h
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2023-08-23 22:28:01 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2023-08-23 22:28:01 +0300
commitd08859f3f4ba8ed68d018fba033b652926d1bf6b (patch)
treefd62430b9a2987ca2eab8a8f08114f113de84120 /indra/llprimitive/llmaterialid.h
parentf40b85c4f495b9079991c41a26b76d397a6168ae (diff)
parentd454512050e636a19e4b7545515dea4f4b1bbf0d (diff)
Merge branch 'main' into DRTVWR-587-maint-V
# Conflicts: # autobuild.xml
Diffstat (limited to 'indra/llprimitive/llmaterialid.h')
-rw-r--r--indra/llprimitive/llmaterialid.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/indra/llprimitive/llmaterialid.h b/indra/llprimitive/llmaterialid.h
index ee663f8f99..c66e3e30a3 100644
--- a/indra/llprimitive/llmaterialid.h
+++ b/indra/llprimitive/llmaterialid.h
@@ -66,6 +66,14 @@ public:
static const LLMaterialID null;
+ // Returns a 64 bits digest of the material Id, by XORing its two 64 bits
+ // long words. HB
+ inline U64 getDigest64() const
+ {
+ U64* tmp = (U64*)mID;
+ return tmp[0] ^ tmp[1];
+ }
+
private:
void parseFromBinary(const LLSD::Binary& pMaterialID);
void copyFromOtherMaterialID(const LLMaterialID& pOtherMaterialID);
@@ -74,5 +82,23 @@ private:
U8 mID[MATERIAL_ID_SIZE];
} ;
+// std::hash implementation for LLMaterialID
+namespace std
+{
+ template<> struct hash<LLMaterialID>
+ {
+ inline size_t operator()(const LLMaterialID& id) const noexcept
+ {
+ return (size_t)id.getDigest64();
+ }
+ };
+}
+
+// For use with boost containers.
+inline size_t hash_value(const LLMaterialID& id) noexcept
+{
+ return (size_t)id.getDigest64();
+}
+
#endif // LL_LLMATERIALID_H