Permalink
Browse files

Adding distance to forEachInViewport

  • Loading branch information...
1 parent 9419d6a commit 04cabd077f99c7ac785df016a61499c269544b54 @benvanik committed Jul 19, 2012
Showing with 13 additions and 7 deletions.
  1. +3 −1 src/gf/sim/search/listdatabase.js
  2. +10 −6 src/gf/sim/search/spatialdatabase.js
@@ -89,7 +89,9 @@ gf.sim.search.ListDatabase.prototype.forEachInViewport = function(
for (var n = 0; n < this.entities_.length; n++) {
var entity = this.entities_[n];
// TODO(benvanik): test viewport
- if (callback.call(opt_scope || goog.global, this.entities_[n]) === false) {
+ var distance = 0;
+ if (callback.call(opt_scope || goog.global, this.entities_[n], distance) ===
+ false) {
break;
}
}
@@ -87,8 +87,9 @@ gf.sim.search.SpatialDatabase.prototype.removeEntity = goog.abstractMethod;
/**
* Enumerates all entities in the database.
- * @param {!function(!gf.sim.entities.SpatialEntity):boolean|undefined} callback
- * Function to call for each entity. Return false to cancel the enumeration.
+ * @param {!function(!gf.sim.entities.SpatialEntity):(boolean|undefined)}
+ * callback Function to call for each entity. Return false to cancel the
+ * enumeration.
* @param {Object=} opt_scope Scope to call the function in.
*/
gf.sim.search.SpatialDatabase.prototype.forEach = goog.abstractMethod;
@@ -97,8 +98,10 @@ gf.sim.search.SpatialDatabase.prototype.forEach = goog.abstractMethod;
/**
* Enumerates all entities in the database that intersect the given viewport.
* @param {!gf.vec.Viewport} viewport Viewport.
- * @param {!function(!gf.sim.entities.SpatialEntity):boolean|undefined} callback
- * Function to call for each entity. Return false to cancel the enumeration.
+ * @param {!function(!gf.sim.entities.SpatialEntity, number):
+ * (boolean|undefined)} callback Function to call for each entity. Also
+ * contains the distance from the viewport eye point to the entity. Return
+ * false to cancel the enumeration.
* @param {Object=} opt_scope Scope to call the function in.
*/
gf.sim.search.SpatialDatabase.prototype.forEachInViewport = goog.abstractMethod;
@@ -109,8 +112,9 @@ gf.sim.search.SpatialDatabase.prototype.forEachInViewport = goog.abstractMethod;
* bounding sphere.
* @param {!gf.sim.entities.SpatialEntity|!goog.vec.Vec4.Float32}
* entityOrSphere An entity or bounding sphere to test intersection against.
- * @param {!function(!gf.sim.entities.SpatialEntity):boolean|undefined} callback
- * Function to call for each entity. Return false to cancel the enumeration.
+ * @param {!function(!gf.sim.entities.SpatialEntity):(boolean|undefined)}
+ * callback Function to call for each entity. Return false to cancel the
+ * enumeration.
* @param {Object=} opt_scope Scope to call the function in.
*/
gf.sim.search.SpatialDatabase.prototype.forEachIntersecting =

0 comments on commit 04cabd0

Please sign in to comment.