Optimizing interactivity

25.09.2007 Anton Volkov

I would like to share our approach to 3D-objects interactivity optimizing. Long time ago in the second version engine we used standard MouseEvents to get mouse events from 3D-objects. However, when we tested with 1-2 thousands polygons where each one is an event listener, we realized that standard mechanism is too slow. Moving mouse above objects slowed FPS from 100 to 50.

That was not good, so we decided to create our own system. The point is that all the polygons are ordinary Shapes (it gives some performance by itself), and the camera has hit-area. When recieving mouse event at this area, we mathematically analize, which polygons are in this sector (see example of “bound map”). Then we find closest polygon and look for intersection between “ray” from “mouse point” to a chosen polygon. Finally we got honest 3D mouse coordinates. And performance stayed at the same FPS.

Leave a Reply