-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/iterative #59
base: v1
Are you sure you want to change the base?
Conversation
Feature/multiboolean
Same problem with the creation of the BSP occurrs when serializing BSP to buffer. It was a recursive function. Now serialization and deserialization of arraybuffer is iterative (non recursive). Tests passed. |
@chandlerprall after extensive benchmarking iterative algorithm is slowler than recursive. Recursive version (current version) reaches maximum recursivity (both in Chrome and Firefox) as soon as meshes have many triangles. I have not managed to get the same speed with v1 that I get with master branch version (with iterative algrorithm, choosing triangles[0] as divider and lowing EPSILON to 1e-5) The WASM version needs to be iterative (for same reason) and again, computation time is greater than master branch algorithm (although faster than js v1) These are my conclusions. We (bitbloq) will stick to master branch algorithm by now, and keep on working on v1 around november (we have a planned release on october). |
Thanks for the feedback, and the PRs! It's really strange that the iterative approach is slower, I'll try to find some time to dig into that. I believe main difference now between |
Hi, In any case, as you said, maybe it's worth going back to triangles, as v1 keeps being slowler than master. Also, in case you want to stick with recursion, this reading might be interesting (I have not tested it myself) https://medium.com/openmindonline/js-monday-06-adopting-memory-safe-recursion-d26dcee409c9 |
@avalero you working on a WASM port? Is that direct crosscompilation from Typescript, or in C/CPP or Rust or something? |
@johncalvinyoung is C++, It's far from being production ready, but I got it to make some basic CSG operations. Then I got problems with stack (at the end you have a recursive js function). I should port it to iterative and check performance. My problem was that the cost (in time) of serializing and deserializing the geometries from js -> wasm and from wasm -> js . At then end, the time spent de/serlializing geometries dit not allow to get an overall better computation time (which was my main goal). You can check the code here https://github.com/avalero/wasmCSG |
@avalero that's really cool. I took a quick look, and got it to build locally. Been working on another port of CSG stuff to WASM (albeit an existing CPP port of CSG.js) and didn't get correct results, sadly. So I'll take a look at yours. |
Well, it would be just great if can make it work. And I am sure @chandlerprall could also help, at the end, it's his algorithm. |
The addTriangles recursive function gives a
heap size exceeded exception
when computing BSP over meshes with many triangles (max recursivility exceeded).I have transformed the BSP Tree creation to an iterative function
addTrianglesIterative()
, so that it does not give that problem.