Notifications
Clear all

[Closed] FYI: IntersectRayScene is completely broken with editable poly

I posted this on the Autodesk forum and got no response from Autodesk, so I’m posting here for greater visibility. Hopefully it will save someone from wasting time trying to figure out what’s wrong, and/or motivate someone at Autodesk to get this fixed. DenisT / MaxDoctor has confirmed it’s broken, and we were able to determine it last worked correctly in Max 2016.

Here’s a simple test to reproduce the bug. Run 1-3 and 4, 5 should give the same hit counts, but they do not:

(
delete objects
local r = ray [0,0,0] x_axis
for i = 0 to 4 do (
b = box pos:[i * 30, 0, 0]
–converttomesh b
–converttopoly b
)
hits = intersectRayScene r
format “RUN 1 [box prim +x axis] hits count:%\n” hits.count
)

(
delete objects
local r = ray [0,0,0] x_axis
for i = 0 to 4 do (
b = box pos:[i * 30, 0, 0]
converttomesh b
–converttopoly b
)
hits = intersectRayScene r
format “RUN 2 [editmesh +x axis] hits count:%\n” hits.count
)

(
delete objects
local r = ray [0,0,0] x_axis
for i = 0 to 4 do (
b = box pos:[i * 30, 0, 0]
–converttomesh b
converttopoly b
)
hits = intersectRayScene r
format “RUN 3 [editpoly +x axis] hits count:%\n” hits.count
)

(
delete objects
local r = ray [0,0,0] -x_axis
for i = 0 to 4 do (
b = box pos:[i * 30, 0, 0]
–converttomesh b
–converttopoly b
)
hits = intersectRayScene r
format “RUN 4 [box prim -x axis] hits count:%\n” hits.count
)

(
delete objects
local r = ray [0,0,0] -x_axis
for i = 0 to 4 do (
b = box pos:[i * 30, 0, 0]
–converttomesh b
converttopoly b
)
hits = intersectRayScene r
format “RUN 5 [editpoly -x axis] hits count:%\n” hits.count
)

I thought I’d found a workaround with an alternative method, but today realized it’s also broken.
RayMeshGridIntersect(), and the associated intersectRay function are also buggy, but it’s harder to develop a clear test case.

6 Replies

Thanks man! I spent almost of my day on figuring out the strange result on intersectRayScene (work on poly), and now i know that’s why.

but is it really a bug?

(
	delete objects
	
	b = box()
        r = ray b.center x_axis -- note that ray origin is now inside the box

	converttopoly b	
	format "poly: %\n" (intersectRayScene r).count

	converttomesh b
	addmodifier b (Normalmodifier flip:true)
	format "mesh: %\n" (intersectRayScene r).count
)

max 2014
poly: 0
mesh: 1

max 2020
poly: 1
mesh: 1

Looks like they just added double-sided check for poly

hey Serejah, i’m really confused what if the ray is outside the obj?

I tested something and I use max2018:
if the newer version max added double-sided check for poly, is that still has impact if the ray is outside the obj?Seems the flip normal of mesh didn’t get influence in this situation.

my tests is below, I cannot puzzle out why the poly could make the ray doing intersection against it’s dir?

return sect as #(#($Editable_Poly:Box001 @ [0.000000,0.000000,0.000000], (ray [-12.5,-12.5,0] [0,0,-1])))

    b = box()    --create a box @ [0,0,0] and size is 25*25*25
    convertToPoly b
    r = ray [-12.5,-12.5,25.1][0,0,1]   --make the ray a little bit highier than one of the box' s vert on the top face
    sect = intersectRayScene r

this return sect as an empty array #()

b = box()
r = ray [-12.5,-12.5,25.1][0,0,1]
sect = intersectRayScene r

return sect as an empty array #()

b = box()
convertToMesh b
addmodifier b (normalModifier filp: true)
r = ray [-12.5,-12.5,25.1][0,0,1]
sect = intersectRayScene r

return sect as an empt array as well

b = box()
convertToMesh b
r = ray [-12.5,-12.5,25.1][0,0,1]
sect = intersectRayScene r

it should be flip

sorry, it’s a typo, but flip also return an empty array

Indeed intersectRayScene now also do the checks against ray direction.