fix asan int overflow in hash

This commit is contained in:
Erwin Coumans
2019-09-05 17:42:18 -07:00
parent 9cf50846d6
commit 74abd99192

View File

@@ -25,7 +25,7 @@ struct b3CustomCollisionFilter
int obB = ((m_objectUniqueIdB & 0xf) << 8); int obB = ((m_objectUniqueIdB & 0xf) << 8);
int linkA = ((m_linkIndexA & 0xff) << 16); int linkA = ((m_linkIndexA & 0xff) << 16);
int linkB = ((m_linkIndexB & 0xff) << 24); int linkB = ((m_linkIndexB & 0xff) << 24);
int key = obA + obB + linkA + linkB; long long int key = obA + obB + linkA + linkB;
// Thomas Wang's hash // Thomas Wang's hash
key += ~(key << 15); key += ~(key << 15);
key ^= (key >> 10); key ^= (key >> 10);
@@ -33,7 +33,7 @@ struct b3CustomCollisionFilter
key ^= (key >> 6); key ^= (key >> 6);
key += ~(key << 11); key += ~(key << 11);
key ^= (key >> 16); key ^= (key >> 16);
return key; return (int) key;
} }
bool equals(const b3CustomCollisionFilter& other) const bool equals(const b3CustomCollisionFilter& other) const
{ {