Page MenuHome

Improve mesh hashing for import/export testing.
Needs ReviewPublic

Authored by Philip Holzmann (Foaly) on Apr 6 2018, 11:56 AM.



As preparation for my GSoC project (faster Import/Export), this will improve the import testing.


  • Hashes more data (the old one only hashed the vertex coordinates)
  • Order independent

Hashing is slightly slower, due to hashing more of the mesh's data. (Hashing is still faster than importing.)

Order independence is achieved by sorting the data first, so this might still result in problems for meshes with duplicate vertices.

This diff is not done yet, since I first wanted to ask whether it is okay to do it this way. But the things that are done work.

The big change is hashing the binary data directly instead of converting to a string, which was the really slow part about this. (I intend to test with bigger meshes than those included in the repos already.)

I think the reason for hashing strings was reproducibility on different platforms.
However, since all platforms use IEEE 754 floats as far as I know, when importing floats stored in binary, data should not change at all.
Also, floats stored as text should ideally also round-trip correctly. Nonetheless I have included an option to round.

Also, converting to a string does not really solve the problem of small inaccuracies, because if the binary data is slightly different, it might round to a different number. It just makes it less likely.

Open questions:

  • Is it okay to do it this way?
  • How to hash vertex groups efficiently

Untested parts:

  • Endianess correction

Diff Detail

rB Blender

Event Timeline

Philip Holzmann (Foaly) edited the summary of this revision. (Show Details)

Two files for testing. They both are a uv unwrapped cube, however the data is stored in different order.
With the old code, they get different hashes, with the new code, the hash is equal.

Just something random my eye falls on (by no means is this any serious review of all of the code): the functions xxx2str seem to be misnamed. They are not converting to strings at all, they are converting to bytes, and thus should be named as such.

Now hashing

  • vertices
  • polys
  • edges
  • vgroups
  • vcolors
  • uvs
  • sharp edges
  • material assignments

However mostly not tested yet.