If you use 0.0000000000000001d0 or 0.0000000000000001 instead it seems to keep the performance. But if you use 0.0d0 the performance drops again.
I’ve just found another bug in Max 2017 Mesh::IntersectRay(Ray &ray, float &at, Point3 &norm, DWORD &fi, Point3 &bary) method. When the ray lies exactly on an edge with 2 faces (so not an open edge) it often returns mismatched pair of face index and barycoords (fi of face_1 and bary of face_2). I don’t think I need to say how much time I lost trying to figure out what is going on with my plugin compiled for Max 2017…
Not sure if this is related since it’s a different function call, but the timeline is consistent with changes made for Max 2017 so it doesn’t seem like co-incidence. Like the OP, I wasted many hours to get to the conclusion that it’s broken.
Intersectrayscene() is also broken with editable poly objects:
@Tamyl Hi, I’ve had the chance to investigate intersectray performance. I know this doesn’t help your specific use case, but subsequent raycasts are now multithreaded and can run up to ~3x faster on a many core CPU when casting on heavy meshes.
As you know, the first raycast creates a kd tree underneath the hood. This is already multi-threaded, and the remaining hot algorithms are reaching the limits of what we can do to accelerate them. I hope to revisit this in the future however, all is not lost.
@Senorpablo Hi, I’ve ran the script you included in your other forum post on our latest beta build and I get 5 hits for every run. It seems like your issue was fixed after all. I’ll be adding your script to our test suite, so we can guarantee this doesn’t break again. Ty for providing an easy repro!
Good day o/
Hello folks,
Today 2021.1 releases with more fixes and tweaks to raycasting.
I fixed the remaining known issues with raycasting in terms of bugs. This release should be very solid for all types of raycasting scenarios. Please [please please] report any new bugs you find in IntersectRay & friends (the best for us is a repro scene + video or maxscript).
We’ve tweaked performance characteristics (multi-threading) of raycasting since some users with less powerful PCs were experiencing slowdowns. We also worked on micro-optimizing constructing our KDTree, so that may accelerate things in some scenarios. We are keeping an eye out and will continue tweaking things until we are satisfied with the result.
Again, thx for reporting these things & keep making cool art!
Philippe
Blockquote
Philippe,
Thank you for your diligence and apparent enthusiasm in getting this fixed and improved. It’s refreshing.
It can be of interest to many people if you comment on the maxscript/phyton group on facebook