Partial update of the content of an AIS_InteractiveContext

Hello,
is there a way to update just some AIS_InteractiveObject within an AIS_InteractiveContext when the ->UpdateCurrentViewer() method is called?
In my application upon certain circumstances, I need to call repetitively this method in order to update something that changes its aspect very often (upon mouse movement): if the scene happens to be (very) crowded, the call is (very) time consuming and the update is not smooth, resulting in a certain lag. Is there a way to reduce the amount of objects to be updated in order to keep the drawing time reasonable? Or is there a smarter way to achieve this?
Many thanks in advance.

Gianluca

Kirill Gavrilov's picture

You may put your object into Immediate Layer (like Graphic3d_ZLayerId_Top) and make partial view redraws via V3d_View::RedrawImmediate(). This would require extra care to avoid visual artifacts. See also related article and "Display of complex scene and animation" sample coming with Draw Harness.

Another option could be profiling your current approach and consider performance improvements that would improve framerate in general, not only for updating some object.

Gianluca Antoniacci's picture

Hello Kirill,
many thanks for your hint.
Just a couple of doubts:
- what if I have many object lying onto "default" layer? Are they affected by RedrawImmediate? In fact, I set the Top layer only for my rubber geometry, but its movement, when the scene is very crowded seems to be similar to the redraw mechanism. Am I missing something?
- what is the difference among all those layers? When should I use this or that layer?

As usual, many thanks for everything

Gianluca

Kirill Gavrilov's picture

what is the difference among all those layers

Take a look into documentation. Graphic3d_ZLayerId enumeration defines built-in layers, but their properties could be modified, and more layers could be inserted when needed.

In fact, I set the Top layer only for my rubber geometry, but its movement, when the scene is very crowded seems to be similar to the redraw mechanism.

Make sure that moving rubber band is not followed by full Redraw() and RedrawImmediate() is only called. And if camera has been changed or V3d_View::Invalidate() has been called in-between - RedrawImmediate() will redirect to Redraw() implicitly. For example, take a look onto CAD Assistant - for a scene on screenshot below, GPU is able to draw only 30 FPS for the full geometry, but drawing AIS_RubberBand on top works at 60 FPS (numbers in brackets are while drawing only immediate layers). Graphic3d_RenderingParams::CollectedStats / ::ToShowStats could be helpful to see how 3D Viewer is actually updated.