Code: +void LLMeshSkinInfo::updateHash() +{ + // When the mesh UUID is known (which is always the case for LLMeshSkinInfo + // instances created by the mesh repository), use its 64 bits digest; there + // is no need to hash anything else, since a skin with the same UUID always + // got the same joints, inverse bind matrix, etc. HB + if (mMeshID.notNull()) + { + mHash = mMeshID.getDigest64(); + return; + } + + LLMD5 hash; + + // Hash joint names (like in LL's performance viewer). HB + for (U32 i = 0, count = mJointNames.size(); i < count; ++i) + { + hash.update(mJointNames[i]); + } + + // Hash joint keys (LL's performance viewer uses joint numbers instead). HB + hash.update((U8*)mJointKeys.data(), sizeof(U32) * mJointKeys.size()); + + // Hash inverse bind matrix (like in LL's performance viewer). + // Note: there should be no padding/aligment issue between elements in the + // mInvBindMatrix LLMatrix4s vector, given that an LLMatrix4 is represented + // by 16 32 bits values (64 bytes). So we can save a loop here and hash the + // whole vector as one contiguous block of data. HB + hash.update((U8*)mInvBindMatrix.data(), + sizeof(LLMatrix4) * mInvBindMatrix.size()); + + hash.finalize(); + + U64 digest[2]; // 128 bits (16 bytes) buffer for LLMD5::raw_digest() + hash.raw_digest((U8*)digest); + // Further digest to 64 bits only. LL's original code ignores digest[1], + // which gives a less good quality digest than XORing the two 64 bits words + // like I what am doing here. HB + mHash = digest[0] ^ digest[1]; +}
|