Wiley
January 2, 2023, 1:55pm
1
I have a number of custom objects which is then fed into the DisplayConduit.
I would like to keep them from drawing if they are not viewed by the viewport.
Couldn’t find the correct means to do it.
I tried the RhinoViewport.GetFrustum() method, but couldn’t get any idea about how it functions at all.
Tom_P
January 2, 2023, 3:29pm
2
I think it should be enough to provide / override
CalculateBoundingBox
(there is also an example in the documentation see link above)
check here for background info.
kitjmv
(jmv)
January 2, 2023, 3:48pm
3
Hello,
I recommend Rhino.Display.RhinoViewport.IsVisible
. I use it on hundreds of thousands it works great
jmv
2 Likes
Wiley
January 2, 2023, 3:48pm
4
@Tom_P
Hi Tom!
Thanks for the answer!
unfortunately it only answers my question partially.
How do I know what size my DisplayBoundingBox should be without knowing if the BoundingBox is inside the camera frustum?
I have these objects drawing in the PostDrawObjects. Before drawing, there is a for loop to loop through all the objects in a list.
I need some of the objects that are outside of the camera frustum bounds to not be looped so it doesn’t slow down the display.
Wiley
January 2, 2023, 3:53pm
5
Oh yes that’s it!!
@kitjmv
Thanks so much!!!
kitjmv
(jmv)
January 2, 2023, 3:57pm
6
On the other hand getting the bounding box is slow, I recommend storing the bounding box of your objects in a list (for example) rather than using Geometry.GetBoundingBox(accurate: false)
in your loop
here are the execution percentages for a loop of 260000 objects:
1 Like
mrhe
(Mariusz Hermansdorfer)
January 2, 2023, 5:21pm
7
@kitjmv , what kind of profiling magic is that? Is it Visual Studio? How can you benchmark your code with corresponding percentages of execution time per method call?
kitjmv
(jmv)
January 2, 2023, 5:36pm
8
Mariusz Hermansdorfer:
Visual Studio?
Yes !
I don’t know, but I haven’t read the documentation.
My approach is stupid, if it’s red, it’s not good. If it’s not red, it’s fine
2 Likes
mrhe
(Mariusz Hermansdorfer)
January 2, 2023, 6:59pm
9
Thanks! Learning something new every day!