Terrev / 3DXML-to-OBJ

https://www.eurobricks.com/forum/index.php?/forums/topic/153050-software-3dxml-to-obj-converts-ldd-model-captures-to-obj/
MIT License
33 stars 0 forks source link

Speed up mesh welding #1

Closed grappigegovert closed 6 years ago

grappigegovert commented 6 years ago

I've changed the mesh welding code to make use of a dictionary to check for duplicates, instead of the nested loop. This will theoretically run in O(n) instead of O(n^2).

I tested this on a model with 1,069,653 verts: With the old code, it got reduced to 367,213 verts in 105.26 seconds, With my new code, it got reduced to 367,230 verts in 0.35 seconds. As you can see, it is significantly faster.

I'm not sure why it deleted 17 vertices less. At first I thought it was because the hashcode function I used was not good enough, but I don't think that's the case.