deadsy / sdfx

A simple CAD package using signed distance functions
MIT License
518 stars 52 forks source link

Threads on package import #59

Closed Megidd closed 1 year ago

Megidd commented 1 year ago

Trying to address #56 .

Megidd commented 1 year ago

More tests are required to make sure about potential side effects...

Megidd commented 1 year ago

Test

I ran examples/gyroid example and the results look fine:

I didn't run other examples.

Screenshot_20230109_110439

Screenshot_20230109_110539

Screenshot_20230109_110628

deadsy commented 1 year ago

Looking at the thread code... Moving the setup of the goroutines into the evaluate routine is the wrong thing to do. They only need to be setup once- not on every layer evaluation. ie - they could be setup upon entering the renderer.

In general there a few areas worth considering for optimisation:

1) how long does it take to do a typical SDF evaluation? 2) how long does it take to run marching cubes once you have the corner evaluations? 3) what's the maximum throughput of the triangles on the channel back to the file writer?

1 should be >>> 2.

3 is probably a choke point - go channels are not high bandwidth.

A []*Triangle3 channel is the interface to the file writers but it only has the triangle(s) of a single cube evaluation. If it had a whole bunch of triangles then I think it would be faster.

deadsy commented 1 year ago

Done.

https://github.com/deadsy/sdfx/commit/40b1da67c85a6dfa6c097ce63d813b4a217d49f9

deadsy commented 1 year ago

Done.