I wonder if there were some changes in MeshRay intersection logic since version 6?
I have some unpredictable results with sunlight calculation in my grasshopper plugin in Rhino 7. The plugin uses mesh boxes representing buildings and a bunch of vectors for sun rays. The final goal is to calculate the number of unobstructed sun rays.
The algorithm is basically following:
Extrusion ex = Extrusion.Create(crv, height, false);
var brep = ex.ToBrep();
var mesh = Mesh.CreateFromBrep(brep, MeshingParameters.FastRenderMesh);
mesh.Vertices.CombineIdentical(true, true);
mesh.Compact();
double result = Intersection.MeshRay(mesh, ray);
Since my client started using Rhino 7 there have been some mistakes with intersection between sunlight vectors and meshes. I haven’t figured out yet where exactly the problem is but it seems to be somewhere between Extrusion.Create(), Extrusion.ToBrep() Mesh.CreateFromBrep() and MeshRay().
Is there something in particular I should pay more attention to?
The problem is that your geometry is “infinitely” far away from the origin, a longstanding well known issue. Move it near the origin and it works fine.
It looks like moving closer to center can indeed solve this issue.
But the problem is that if you open that test file in Rhino 6 it would work fine regardless of location. And I can’t easily scale down everything in my project because all the dimensions are interconnected with other rhino and revit-plugins. Scaling would involve re-writing and debugging a lot of code.
It would also be quite inconvenient to use meters because I work with buildings and export everything to revit. The location is so off-centered because it uses GIS data with a city center as the origin. Depending on the site location buildings can be quite close to the origin as well as far away.
It’s a bit frustrating that my perfectly working Rhino 6 projects suddenly became incompatible with the new release.
I sympathize with your frustration that R7 breaks models that work fine in R6. Same thing happened going from R5 to R6. McNeel doesn’t care and that is way beyond annoying…
However, I don’t have much sympathy for using coordinate values and dimensions that are so extremely large. Good luck.