Is there any solution with C# API to get BVH structure of scene objects?
I guess at least Cycle creates one.
thank you jmv
What is the problem you’re trying to solve, or feature you’re trying to implement? As far as I can see there’s no C# BVH (*) - but other spatial access methods like RTree and Octree may already help?
(*) Embree is a C/C++ library used by Cycles in Blender, see Source/Render/Cycles/BVH - Blender Developer Wiki
Its true, that’s not exactly my problem.
I want to eliminate all objects that are not visible on the screen.
More generally, I want to know the object and the point of intersection under the mouse cursor.
This is for a navigation plugin and intersections should be very fast.
Thanks for the link, I’ll see what I find there.
RhinoCommon provides an R-Tree implementation that should help with that.
yes, I saw the RTree class.
But is there a method to obtain this structure of the objects in the scene?
I don’t even know if we can do a ray traced intersection with an RTree?
Don’t blame me, I’m a newbie
I understand that you might not want to deal with someone else’s code. But if anyone feels like it, I want to optimize this line: Libx.Fix.AutoCameraTarget/Main.cs at master · corbane/Libx.Fix.AutoCameraTarget · GitHub
RhinoViewport.IsVisible(BondingBox) is too slow.
It will not be the optimization of the century. Currently the plugins work well but it still happens that I exceed 100ms which is really the limit from which navigation is unpleasant and where I deactivate the plugin.
You already are collecting bounding boxes of all objects in the scene, if I’m reading your code correctly.
Instead of caching them separately in your own structure use RTree.Insert Method (BoundingBox, Int32) and RTree.Remove Method (BoundingBox, Int32) to keep your R-tree updated.
You can then create a bounding box of the viewport frustum and use RTree.Search Method (BoundingBox, EventHandler(RTreeEventArgs)) to do the check for visibility. Or alternatively you create an R-tree for the frustum and then search for overlaps between the objects R-tree and the camera R-tree: RTree.SearchOverlaps Method .
The page on RTree.Insert Method (Point3d, Int32) has some sample code that may get you pointed in the right direction.
Ok, thanks @nathanletwory !!!
good that makes me things to take! (Thought it would be a quick little development… )