I agree if it was just a single raycast, but it is loop.
And If I remember correctly someone from AD claimed that consecutive ray intersections now should be much faster since new kd-tree was implemented. Why they decided not to give any control over it to third-party developers remains unknown. Or maybe it’s just not documented yet.
Another test. Now it’s also using RayMeshGridIntersect on teapot with 100 segments. Clean 2020 max with no updates installed.
Time: 0.058sec. Mem: 264612L – Embree
Time: 1.598sec. Mem: 212L – RayMeshGridIntersect
Time: 76.975sec. Mem: 28104L – IntersectRay
g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance obj = g.animatable.getanimbyhandle (getHandleByAnim tri) -- .<System.Boolean> IntersectRay <System.Int32>t <Autodesk.Max.IRay>r <System.Single&>at <Autodesk.Max.IPoint3>norm objIntersectRay = obj.IntersectRay hit_normal = g.point3.create() dist = 0.0 fn MakeRayNative pos dir tm = ( _pos = pos * tm _dir = dir * tm g.ray.create (g.point3.create _pos.x _pos.y _pos.z) (g.point3.create _dir.x _dir.y _dir.z) ) t1=timestamp();hf = heapfree seed 321321 pts = for i = 1 to 1000 collect ( ray_pos = (random tea.min tea.max) * 0.75 ray_pos.z = 150 intersection = objIntersectRay 0 (MakeRayNative ray_pos -z_axis tea_itm) dist hit_normal ) format "Time: %sec. Mem: %\n" ((timestamp()-t1)/1000 as float) (hf-heapfree)
Time: 78.969sec. Mem: 600312L – same as mxs IntersectRay. No surprise
For poly it is 5-6x times slower than Embree in a loop of 1000 iterations.
But in general it is actually faster than before for both mesh and poly. For objects it is slower than before
1000 iterations of IntersectRay
Time: 76.043sec. Mem: 28104L as object
Time: 0.299sec. Mem: 28104L as poly
Time: 0.182sec. Mem: 28104L as mesh
Time: 9.39sec. Mem: 26624L as object
Time: 36.487sec. Mem: 26624L as poly
Time: 4.432sec. Mem: 26624L as mesh