Make mesh.simplify affect mesh evenly

Hey @RaananW
Is it possible to make Mesh.simplify affect more evenly across a mesh?

Made an example showing top & bottom of mesh barely changes,
here; https://playground.babylonjs.com/#1A9AS4#1

(Oddly, in PG it’s both top and bottom, locally for me it’s only bottom of mesh, using same bjs version…)



@aWeirdo our algo is pretty simple, I guess you could generate them offline to ensure the best optim level ???

Also if you see anything to improve in the algo, please do a PR as it would help a lot :slight_smile:

the implementation follows this - Voxel Game Engine Development: Quadric Mesh Simplification with Source Code , but if you find any way to improve it, i will be more than happy to merge it :slight_smile:
I find it weird that it behaves differently locally and online. are ou using es6 or the umd version? is it possible that something doesnt import correctly?

@RaananW
If i get time for it i will :slight_smile:

Edit;
Okay, so the small difference in behavior was on my end, running a geometry cleaning function,
Now i’m thinking it isn’t related to the simplification algorithm at all, but minor geometry bugs like empty indices or indices on a strait line, etc

1 Like

and here it works perfectly after running Mesh.forceSharedVertices();

https://playground.babylonjs.com/#1A9AS4#4

2 Likes

Bumping this…
Something is wrong, i searched and searched but found no bugs in my previously mentioned geometry cleaner.

Thinking simplification algo fails to recognize triangles in some cases…
Here again with a standard cylinder, it refuses to simplify it until you uncomment forceSharedVertices(),
In theory it should also work without ?
Babylon.js Playground

Update;
Turns out it was a floating point issue, updated code to use epsilon. PR
It now works without “forceSharedVertices” while optimizeMesh is enabled.
https://playground.babylonjs.com/#1A9AS4#5