Coder Social home page Coder Social logo

Cancel build +progress monitor about bvh HOT 4 OPEN

madmann91 avatar madmann91 commented on September 27, 2024
Cancel build +progress monitor

from bvh.

Comments (4)

madmann91 avatar madmann91 commented on September 27, 2024 1

It should be possible to implement it, and by the way feel free to submit a PR for review. The issue though is that this requires some sort of knowledge of the build algorithm, in the sense that the notion of "progress" is really not going to be super accurate (it's -- for the most part -- a recursive process and you may not know the cost of building the subtree until you actually do it).

That said, a reasonable assumption that the cost of a subtree of size N is somewhat proportional to N log(N) might make sense. There's still the problem that the mini-tree builder runs in parallel so you have to take care of sending the progress information only once (or at least send it in an ordered fashion somehow). Maybe an atomic number is enough, so that you can start building the BVH, then check the progress at regular intervals by looking at the value held by that atomic.

So all in all it's a pretty complicated implementation for a small feature that, although nice to have, is not strictly necessary. I'll keep that in mind when doing further development work on the library though, if I can find the time for it.

from bvh.

Silverlan avatar Silverlan commented on September 27, 2024

Thanks for the response! Personally I'd be more interested in the ability to cancel anyway, the progress callback would just be nice-to-have.
In my case I have scenes where building the BVH can take several minutes and if the user closes the program during that, they currently have to wait until the BVH building is complete.

I haven't looked too closely at the source code for bvh, but I'll try and see if I can whip up a PR for that in the near future.

from bvh.

madmann91 avatar madmann91 commented on September 27, 2024

For this specific use case, I don't think you need the ability to cancel the build per se. I would imagine that through OS services you can send a kill signal to the process that builds the BVH, without having to wait for the threads to join. If you want to kill your own process on Linux, use kill(getpid(), sig) or raise(sig) (where sig is the signal to send, SIGTERM or SIGKILL).

from bvh.

madmann91 avatar madmann91 commented on September 27, 2024

If you don't want to kill the current process but want to continue executing the program, you could use a subprocess to build the BVH as a work around. This would allow you to kill it before it terminates. The downside is that you'll have to communicate via files or pipes. The serialization API allows you to do that, by sending a stream of bytes over, instead of writing to a file on disk.

from bvh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.