我使用的Java2D绘制在我已经实现通过调用包含(MousePoint)为每个对象/形状,这工作,但采摘的那一刻起简单的图形线性扩展。
I am using java2d to draw a simple graph at the moment I have implemented picking by calling contains(MousePoint) for each object/shape, this works but scales linearly.
有没有更有效的在Java2D的采摘方法是什么?
Is there a more efficient method for picking in java2d?
推荐答案
是的,但是完整的答案就太长了这个空间。
Yes, although the full answer would be too long for this space.
首先,除非你有一个的很多的节点,然后直线将最有可能被罚款,你不应该改变什么的除非的性能已经看到吃亏。
First of all, unless you have a lot of nodes, then linear will most likely be fine, and you shouldn't change anything unless performance is already seen to suffer.
二,你想要什么,在一般情况下,是应用了某种层次分解,如四叉树。这是使用更多的存储器(和更多的时间前面,在搜索过程中摊销),以消除在一个所谓的宽泛阶段从考虑的项目的方式。一些尽职调查在网络上会有所帮助,因为会把书实时碰撞检测,由克里斯特埃里克松。
Second, what you want, in general, is to apply some sort of hierarchical decomposition, such as a quadtree. This is a way of using more memory (and more time up front, amortized during searches) to eliminate items from consideration in a so-called "broad phase". Some diligence on the web will help, as will the book "Real-Time Collision Detection", by Christer Ericson.
相关推荐
最新文章