Implement skipping features for 1by1 hit detection
This commit is contained in:
@@ -672,8 +672,8 @@ ol.render.webgl.ImageReplay.prototype.replay = function(context,
|
|||||||
this.drawReplay_(gl, context, skippedFeaturesHash);
|
this.drawReplay_(gl, context, skippedFeaturesHash);
|
||||||
} else {
|
} else {
|
||||||
// draw feature by feature for the hit-detection
|
// draw feature by feature for the hit-detection
|
||||||
result = this.drawHitDetectionReplay_(gl, context, featureCallback,
|
result = this.drawHitDetectionReplay_(gl, context, skippedFeaturesHash,
|
||||||
oneByOne, opt_hitExtent);
|
featureCallback, oneByOne, opt_hitExtent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// disable the vertex attrib arrays
|
// disable the vertex attrib arrays
|
||||||
@@ -803,6 +803,7 @@ ol.render.webgl.ImageReplay.prototype.drawElements_ = function(
|
|||||||
* @private
|
* @private
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
|
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||||
* @param {function(ol.Feature): T|undefined} featureCallback Feature callback.
|
* @param {function(ol.Feature): T|undefined} featureCallback Feature callback.
|
||||||
* @param {boolean} oneByOne Draw features one-by-one for the hit-detecion.
|
* @param {boolean} oneByOne Draw features one-by-one for the hit-detecion.
|
||||||
* @param {ol.Extent=} opt_hitExtent Hit extent: Only features intersecting
|
* @param {ol.Extent=} opt_hitExtent Hit extent: Only features intersecting
|
||||||
@@ -811,7 +812,8 @@ ol.render.webgl.ImageReplay.prototype.drawElements_ = function(
|
|||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplay_ =
|
ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplay_ =
|
||||||
function(gl, context, featureCallback, oneByOne, opt_hitExtent) {
|
function(gl, context, skippedFeaturesHash, featureCallback, oneByOne,
|
||||||
|
opt_hitExtent) {
|
||||||
goog.asserts.assert(this.hitDetectionTextures_.length ===
|
goog.asserts.assert(this.hitDetectionTextures_.length ===
|
||||||
this.hitDetectionGroupIndices_.length);
|
this.hitDetectionGroupIndices_.length);
|
||||||
var elementType = context.hasOESElementIndexUint ?
|
var elementType = context.hasOESElementIndexUint ?
|
||||||
@@ -824,8 +826,9 @@ ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplay_ =
|
|||||||
elementType, elementSize);
|
elementType, elementSize);
|
||||||
} else {
|
} else {
|
||||||
// draw hit-detection features one by one
|
// draw hit-detection features one by one
|
||||||
return this.drawHitDetectionReplayOneByOne_(gl, context, featureCallback,
|
return this.drawHitDetectionReplayOneByOne_(gl, context,
|
||||||
elementType, elementSize, opt_hitExtent);
|
skippedFeaturesHash, featureCallback, elementType, elementSize,
|
||||||
|
opt_hitExtent);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -866,6 +869,7 @@ ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayAll_ =
|
|||||||
* @private
|
* @private
|
||||||
* @param {WebGLRenderingContext} gl gl.
|
* @param {WebGLRenderingContext} gl gl.
|
||||||
* @param {ol.webgl.Context} context Context.
|
* @param {ol.webgl.Context} context Context.
|
||||||
|
* @param {Object} skippedFeaturesHash Ids of features to skip.
|
||||||
* @param {function(ol.Feature): T|undefined} featureCallback Feature callback.
|
* @param {function(ol.Feature): T|undefined} featureCallback Feature callback.
|
||||||
* @param {number} elementType Element type.
|
* @param {number} elementType Element type.
|
||||||
* @param {number} elementSize Element size.
|
* @param {number} elementSize Element size.
|
||||||
@@ -875,9 +879,9 @@ ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayAll_ =
|
|||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne_ =
|
ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne_ =
|
||||||
function(gl, context, featureCallback, elementType, elementSize,
|
function(gl, context, skippedFeaturesHash, featureCallback,
|
||||||
opt_hitExtent) {
|
elementType, elementSize, opt_hitExtent) {
|
||||||
var i, groupStart, numItems, start, end, feature;
|
var i, groupStart, numItems, start, end, feature, featureUid;
|
||||||
var featureIndex = this.startIndices_.length - 1;
|
var featureIndex = this.startIndices_.length - 1;
|
||||||
|
|
||||||
for (i = this.hitDetectionTextures_.length - 1; i >= 0; --i) {
|
for (i = this.hitDetectionTextures_.length - 1; i >= 0; --i) {
|
||||||
@@ -891,9 +895,11 @@ ol.render.webgl.ImageReplay.prototype.drawHitDetectionReplayOneByOne_ =
|
|||||||
start = this.startIndices_[featureIndex];
|
start = this.startIndices_[featureIndex];
|
||||||
numItems = end - start;
|
numItems = end - start;
|
||||||
feature = this.startIndicesFeature_[featureIndex];
|
feature = this.startIndicesFeature_[featureIndex];
|
||||||
|
featureUid = goog.getUid(feature).toString();
|
||||||
|
|
||||||
if (!goog.isDef(opt_hitExtent) || ol.extent.intersects(
|
if (!goog.isDef(skippedFeaturesHash[featureUid]) &&
|
||||||
opt_hitExtent, feature.getGeometry().getExtent())) {
|
(!goog.isDef(opt_hitExtent) || ol.extent.intersects(
|
||||||
|
opt_hitExtent, feature.getGeometry().getExtent()))) {
|
||||||
var offsetInBytes = start * elementSize;
|
var offsetInBytes = start * elementSize;
|
||||||
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
||||||
gl.drawElements(
|
gl.drawElements(
|
||||||
|
|||||||
Reference in New Issue
Block a user