Skip to content
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

Iterator with tmin/tmax and ray shortening #66

Open
mdesmedt opened this issue May 2, 2021 · 4 comments
Open

Iterator with tmin/tmax and ray shortening #66

mdesmedt opened this issue May 2, 2021 · 4 comments

Comments

@mdesmedt
Copy link
Contributor

mdesmedt commented May 2, 2021

Currently traverse() and traverse_iterator() visit every node along an infinite ray. The application however has information which could reduce traversal steps:

  • Provide a tmin/tmax with the ray and test ray/AABB distance against this range.
  • When the app is looking for the smallest t along the ray (common) it can shorten the ray during traversal tmax=min(tmax,t)

Implementing an iterator which supports tmin/tmax as well as making these mutable to shorten the ray during traversal would help performance in many apps.

@svenstaro
Copy link
Owner

Is this a dup of #56?

@mdesmedt
Copy link
Contributor Author

mdesmedt commented May 2, 2021

Is this a dup of #56?

I don't believe so. #56 asks for "what is the closest object/s in the BVH to arbitrary points".

This request is mostly for adding ray shortening to the traversal. It could look something like:

let iter = bvh.traverse_iterator(ray)
for shape in iter {
    let hitinfo = do_full_intersection(ray, shape);
    if hitinfo.hit {
        iter.shorten_ray(hitinfo.t);
    }
}

@mdesmedt
Copy link
Contributor Author

mdesmedt commented May 2, 2021

I gave this some thought. I think the only way to safely do this is to pass an Rc<RefCell<Ray>> to the iterator, which adds a lot of overhead during traversal. And computing t per box is also extra cycles. So unless we add unsafe code (not a fan) or can think of another approach this is probably not worth it. Some form of SIMD is probably still the best option for perf gain.

@tavianator
Copy link
Contributor

And computing t per box is also extra cycles

That's not really true, the slab method computes t anyway.

@marstaik marstaik mentioned this issue May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants