Intersection / Ray Intersect issue

Hi, I was trying to make a script which can do an accurate intersection for some purpose.

I've tried 2 simple methods:

Method 1:

r = ray $Point_A_fail.position $Point_B_fail.position 
rayInterSectObj = intersectRayScene r
-- result is an empty array

Using method 1 has issue that in most of cases it does not catch the ray intersecting object.
Attached max file has both sets one that works another that doesn't.

Method 2:

intersects $Poly_A $Poly_B
-- returns true, but truth is that these objects are not intersecting

This method is very simple throwing boolean value intersecting or not, but this is not working accurately.
Attached max file have the objects to execute this code.

Someone please suggest me some way to do the intersection or raycasting accurately.
or tell me if I have done something wrong.

Thanks

AttachmentSize
ray_intersection_scene.max404 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
TsveTan's picture

+

I think intersectRay, intersectRayEx and intersectRayScene work on editable meshes only, for polys they fail or are not accurate enough, and your definition is wrong as jahman state.

jahman's picture

.

ray $Point_A_fail.position $Point_B_fail.position
This is definitely wrong way of defining a ray. Ray is defined with origin position and direction. Direction is a normalized unit vector.

Intersects function checks whether bounding boxes of two nodes are intersecting.

ps.
If you need to check whether two meshes intersect you can use Volume Select modifier for that purpose. Try searching on cgsociety forum for example script

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.