intersectRayScene works strange inside for loop, which can intersect against the ray direction
i am trying to use script to select some specific faces(no obj fully overlap on that face) of a obj, the step is:
1.find all z_axis faces(facenormal = [0,0,1])
2.go through all verts in these faces , and make the ray position = every single vert's position
3.use intersectRayScene to test if the ray on the vert has any intersection with other obj in the scene
the problem is the ray is always point z_axis, but the result of intersectRayScene show the ray also intersect withthe obj below the ray, i mean the ray hit something along with -z_axis, that's really strange.
if anyone can gibe a help that's really appreciate!
r = ray [0,0,0] z_axis offset = z_axis * 0.001 for obj in selection do --go through all obj in the scene ( faceList = #{} upFaces = for f = 1 to polyop.getNumFaces obj where dot (polyop.getFaceNormal obj f) z_axis > 0.999 collect f for f in upFaces do ( intersection = #() fv = polyop.getFaceVerts obj f for v in fv do ( r.pos = polyop.getVert obj v + offset sect = intersectRayScene r --to test if the object intersect with other object in the scene print sect --you can see the ray hit something along -z_axis if sect != undefine do append intersection 1 ) if intersection.count < fv.count do faceList[f] = true --if the face not been fully overlaped, select it as well ) )