How can I test if an object is within the active viewport?

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.

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.

Hello,
I recommend Rhino.Display.RhinoViewport.IsVisible. I use it on hundreds of thousands it works great
jmv

2 Likes

@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.

Oh yes that’s it!!
@kitjmv
Thanks so much!!!

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

@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?

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 :slight_smile:

2 Likes

Thanks! Learning something new every day!