Author Topic: Object3D.rayIntersectsAABB question  (Read 2204 times)

Offline voronwe13

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Object3D.rayIntersectsAABB question
« Reply #15 on: August 12, 2014, 04:26:33 pm »
Okay, I just figured out the calcMinDistance issue....  It's related to the ignoreIfLarger variable.   Since I'm setting the origin of my ray only 10 away from the object, I just put the ignoreIfLarger as 20, since I didn't think it would need to be any larger.   If you take the test code I posted and change that value to 20, or anything less than the distance from the point to the top-left corner, you'll see what I'm talking about. 

I realize now that if I had read the documentation for it more closely, I would have picked up on that sooner.  Although it's kind of weird that it only seems to check one corner of the polygon.
« Last Edit: August 12, 2014, 04:41:57 pm by voronwe13 »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11747
    • View Profile
    • http://www.jpct.net
Re: Object3D.rayIntersectsAABB question
« Reply #16 on: August 12, 2014, 05:22:00 pm »
I see. You don't have to be too conservative with the value that you are using for ignoreIfLarger. As a rule of thumb, take the maximum that you would expect and multiply it by 1.5.
About the AABB-issue: Congratulations! You've found a problem that lurks inside the engine for more than 10 years now. The algorithm can't deal with planes that are exactly in parallel with the direction vector. I'll add a workaround for this to the next release.

Offline voronwe13

  • byte
  • *
  • Posts: 15
    • View Profile
Re: Object3D.rayIntersectsAABB question
« Reply #17 on: August 13, 2014, 04:40:26 pm »
Cool, glad I was able to help you discover a long-hidden bug!   And now that I know what's going on with calcMinDistance, I have everything working the way I want it to.   Thanks for your help!