Jump to content
  • Advertisement
Sign in to follow this  
Spa8nky

[C#] Dealing with parallel rays using this parametric algorithm for octree traversal

This topic is 3091 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks, I'm currently trying to implement a 2D version of an octree traversal algorithm before moving on to 3D. The algorithm is found in the paper titled "An Efficient Parametric Algorithm for Octree Traversal" found here. On the bottom of page 5 (section 3.3) it tells me that: t_xm(o,r) = +∞ OR -∞ depending on whether the ray's origin is less than (x0 + x1) / 2. Is x0 and x1, in this case, the min and max point of the node? In which case I would use the following:
            float txm;
            float tym;

            if (float.IsInfinity(tx0) || float.IsInfinity(tx1))
            {
                txm = ray.Origin.X < (node.MinPoint.X + node.MaxPoint.X) * 0.5f ? float.PositiveInfinity : float.NegativeInfinity;
            }
            else
            {
                txm = 0.5f * (tx0 + tx1);
            }
            if (float.IsInfinity(ty0) || float.IsInfinity(ty1))
            {
                tym = ray.Origin.Y < (node.MinPoint.Y + node.MaxPoint.Y) * 0.5f ? float.PositiveInfinity : float.NegativeInfinity;
            }
            else
            {
                tym = 0.5f * (ty0 + ty1);
            }


Is txm worked out the same way based on comparing both tx0 and tx1 to infinity where:
            Vector2 t0 = node.MinPoint - ray.Origin;
            t0 /= ray.Direction;

            Vector2 t1 = node.MaxPoint - ray.Origin;
            t1 /= ray.Direction;
tx0 = t0.X; tx1 = t1.X; ty0 = t0.Y; ty1 = t0.Y; and the ray's direction is 0 then /0 will equal ±infinity. Or should tx0 and tx1 be compared to +∞ OR -∞ and dealt with separately? In other words, is what I have coded correct? Is there any way of dealing with the parallel case in a better manner and avoiding infinite numbers at all? Thank you.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!