V
V
Vitaly2018-03-13 00:09:28
C++ / C#
Vitaly, 2018-03-13 00:09:28

In what ways can you speed up the work with objects on the stage at a large distance?

There is a working implementation of a 2D scene graph (Which is being built as a more optimized replacement for QGraphicsScene). All elements in it are indexed using the QuadTree algorithm (an implementation of Loose-Quadtree). The scene is capable of storing more than a million different elements, and at a normal scale it gives close to zero load on the processor when working with elements (selection, dragging, adding elements, scrolling the scene, etc.). (The same number of elements and the same operations in QGraphicsScene are very sub-optimal regardless of the indexing and rendering update settings).
However, with a strong zoom removal, naturally, a much larger number of elements than usual (approximately 20k~100k) fall into the field of view. And, accordingly, by selecting 15-30 thousand elements from them, and by dragging them, strong lags appear. This is obvious, since the states of all 30k elements are being updated simultaneously, as well as the redrawing of all the remaining 100k (the redrawing can be optimized by selective rendering by zones).
Question. What methods can be applied to more or less optimize the performance of working with a scene with a strong zoom removal?
Specifically, dragging huge groups of elements. As an option, I want to try to draw a giant group of selected elements (for example, more than 10k) as a zoned rectangle, without performing the movement itself until the moment the mouse button is released. But I'm wondering if there are better ways?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tsarevfs, 2018-03-13
@tsarevfs

1. Loding - do not show or allow to highlight small objects at this scale.
2. Clustering. We unite close objects into groups by proximity. For example, this is how markers work on Yandex maps. If performance is limited by updating many objects, you can make the bulk update asynchronous and lazy.
3. You can do something in between 1 and 2. If the scene graph groups objects logically well, then you can write loding for these nodes. For example, at the top level we have a car, when zoomed in, we can select and move individual nodes: doors, wheels...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question