O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A binary space partition tree

The scene constantly keeps a record of the position of the item in its internal binary space partition tree. Thus, on every move of an item, the scene has to update the tree, an operation that can become quite time-consuming, and also memory consuming. This is especially true of scenes with a large number of animated items. On the other hand, the tree enables you to find an item (for example, with items() or itemAt()) incredibly quickly, even if you have thousands of items.

So when you do not need any positional information about the items—this also includes collision detection—you can disable the index function by calling setItemIndexMethod(QGraphicsScene::NoIndex). Be aware, however, that a call to items() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required