Which one is faster??
And how faster?
If BestContainer is better ,I will replace all NearestChild in atom.
BestContainer and NearestChild?
Moderators: Lavish Software Team, Moderators
-
- GamingTools Subscriber
- Posts: 74
- Joined: Sun Jun 25, 2006 8:29 am
-
- GamingTools Subscriber
- Posts: 74
- Joined: Sun Jun 25, 2006 8:29 am
Uh.. they are different things.
BestContainer is going to be far more efficient on average than if you are using NearestChild for the same purpose. BestContainer is designed to take your "best container" from the last frame ("I am contained by region X") along with your new coordinates, and translate that into a new "best container" for the new frame (it is optimized to track your position). The best case for "best container" is when you are standing still -- it can stop immediately. The algorithm and info about it is found here: http://www.lavishsoft.com/wiki/index.ph ... _Container
NearestChild is going to go through every "Child" of some region, and determine which one is nearest to some point. Standing still and performing NearestChild is still going to perform N checks, not 1 as in the "best container" algorithm. In other words, this is not optimized for tracking. This is more appropriate to use when you have a "best container" that is too broad and you want to narrow it by searching for a region that you're not necessarily *contained by*, just nearby to. For example, your "Best container" might be an entire Universe region (if nothing else in the tree contains you).
If you are calling these many times per frame, you should probably find a way to stop doing that
BestContainer is going to be far more efficient on average than if you are using NearestChild for the same purpose. BestContainer is designed to take your "best container" from the last frame ("I am contained by region X") along with your new coordinates, and translate that into a new "best container" for the new frame (it is optimized to track your position). The best case for "best container" is when you are standing still -- it can stop immediately. The algorithm and info about it is found here: http://www.lavishsoft.com/wiki/index.ph ... _Container
NearestChild is going to go through every "Child" of some region, and determine which one is nearest to some point. Standing still and performing NearestChild is still going to perform N checks, not 1 as in the "best container" algorithm. In other words, this is not optimized for tracking. This is more appropriate to use when you have a "best container" that is too broad and you want to narrow it by searching for a region that you're not necessarily *contained by*, just nearby to. For example, your "Best container" might be an entire Universe region (if nothing else in the tree contains you).
If you are calling these many times per frame, you should probably find a way to stop doing that
