IntersectRayScene completely broken with editable poly!?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've spent hours trying to get IntersectRayScene to work properly. Can someone verify if this is broken or if I'm just losing my mind?
According to the documentation for IntersectRay (IntersectRayScene doesn't go into detail), back faces are ignored:
"Returns undefined if the ray does not intersect the node, the faces it does intersect point away from the ray's position, or the node does not have a surface."
If I use the included example:
( local r = ray [0,0,0] [1,0,0]--define a ray along X for i = 0 to 4 do--loop 5 times ( box pos:[i * 30, 0,0]--create a box ) local hits = intersectRayScene r--intersect withscene print hits --Misses box 1 because ray originates inside the box )
I get 4 hits when I run this as-is, and it does appear to ignore back faces as the comment on the last line of code suggests. However, if I convert these boxes to editable poly and comment out the box creation line, and run again, I get 5 hits! As if back faces are not ignored for editable poly objects. Naturally this is a problem because editable poly objects are extremely common. Editable Mesh objects seem to work properly.
But wait, there's more! So long as the boxes remain primitives, the ray appears to work as a ray. That is, it starts at a point and goes in one direction only. But! If there are editable poly objects in the scene, the ray no longer behaves as a one directional ray, and instead appears to cast in both directions!
To test, run the example again to generate box primitives, then move the 4 boxes in +x to -x. Run again and you get 0 hits. All the faces are back facing, or in the other direction of the cast ray. Convert any of those 4 boxes to editable poly, and now you'll get hits, even though the ray is being cast in the opposite direction(+x).
I have this issue in both Max 2018.3 and 2020.1.