|
@@ -19400,8 +19400,11 @@ var BABYLON;
|
|
|
* @see http://doc.babylonjs.com/features/occlusionquery
|
|
|
*/
|
|
|
_this.occlusionRetryCount = -1;
|
|
|
+ /** @hidden */
|
|
|
_this._occlusionInternalRetryCounter = 0;
|
|
|
+ /** @hidden */
|
|
|
_this._isOccluded = false;
|
|
|
+ /** @hidden */
|
|
|
_this._isOcclusionQueryInProgress = false;
|
|
|
_this._visibility = 1.0;
|
|
|
/** Gets or sets the alpha index used to sort transparent meshes
|
|
@@ -21269,45 +21272,7 @@ var BABYLON;
|
|
|
};
|
|
|
/** @hidden */
|
|
|
AbstractMesh.prototype._checkOcclusionQuery = function () {
|
|
|
- var engine = this.getEngine();
|
|
|
- if (engine.webGLVersion < 2 || this.occlusionType === AbstractMesh.OCCLUSION_TYPE_NONE) {
|
|
|
- this._isOccluded = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
|
|
|
- var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
|
|
|
- if (isOcclusionQueryAvailable) {
|
|
|
- var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
|
|
|
- this._isOcclusionQueryInProgress = false;
|
|
|
- this._occlusionInternalRetryCounter = 0;
|
|
|
- this._isOccluded = occlusionQueryResult === 1 ? false : true;
|
|
|
- }
|
|
|
- else {
|
|
|
- this._occlusionInternalRetryCounter++;
|
|
|
- if (this.occlusionRetryCount !== -1 && this._occlusionInternalRetryCounter > this.occlusionRetryCount) {
|
|
|
- this._isOcclusionQueryInProgress = false;
|
|
|
- this._occlusionInternalRetryCounter = 0;
|
|
|
- // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
|
|
|
- // if strict continue the last state of the object.
|
|
|
- this._isOccluded = this.occlusionType === AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC ? false : this._isOccluded;
|
|
|
- }
|
|
|
- else {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // Todo. Move into an occlusion query component.
|
|
|
- var scene = this.getScene();
|
|
|
- if (scene.getBoundingBoxRenderer) {
|
|
|
- var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
|
|
|
- if (!this._occlusionQuery) {
|
|
|
- this._occlusionQuery = engine.createQuery();
|
|
|
- }
|
|
|
- engine.beginOcclusionQuery(this.occlusionQueryAlgorithmType, this._occlusionQuery);
|
|
|
- occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
|
|
|
- engine.endOcclusionQuery(this.occlusionQueryAlgorithmType);
|
|
|
- this._isOcclusionQueryInProgress = true;
|
|
|
- }
|
|
|
+ this._isOccluded = false;
|
|
|
};
|
|
|
/** No occlusion */
|
|
|
AbstractMesh.OCCLUSION_TYPE_NONE = 0;
|
|
@@ -41104,8 +41069,13 @@ var BABYLON;
|
|
|
if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
|
|
|
var shadowGenerator = light.getShadowGenerator();
|
|
|
if (shadowGenerator) {
|
|
|
- shadowEnabled = true;
|
|
|
- shadowGenerator.prepareDefines(defines, lightIndex);
|
|
|
+ var shadowMap = shadowGenerator.getShadowMapForRendering();
|
|
|
+ if (shadowMap) {
|
|
|
+ if (shadowMap.renderList && shadowMap.renderList.length > 0) {
|
|
|
+ shadowEnabled = true;
|
|
|
+ shadowGenerator.prepareDefines(defines, lightIndex);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (light.lightmapMode != BABYLON.Light.LIGHTMAP_DEFAULT) {
|
|
@@ -104552,6 +104522,51 @@ var BABYLON;
|
|
|
BABYLON.Engine.prototype._getGlAlgorithmType = function (algorithmType) {
|
|
|
return algorithmType === BABYLON.AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
|
|
|
};
|
|
|
+ // We also need to update AbstractMesh as there is a portion of the code there
|
|
|
+ BABYLON.AbstractMesh.prototype._checkOcclusionQuery = function () {
|
|
|
+ var engine = this.getEngine();
|
|
|
+ if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
|
|
|
+ this._isOccluded = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (engine.webGLVersion < 2 || this.occlusionType === BABYLON.AbstractMesh.OCCLUSION_TYPE_NONE) {
|
|
|
+ this._isOccluded = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
|
|
|
+ var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
|
|
|
+ if (isOcclusionQueryAvailable) {
|
|
|
+ var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
|
|
|
+ this._isOcclusionQueryInProgress = false;
|
|
|
+ this._occlusionInternalRetryCounter = 0;
|
|
|
+ this._isOccluded = occlusionQueryResult === 1 ? false : true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this._occlusionInternalRetryCounter++;
|
|
|
+ if (this.occlusionRetryCount !== -1 && this._occlusionInternalRetryCounter > this.occlusionRetryCount) {
|
|
|
+ this._isOcclusionQueryInProgress = false;
|
|
|
+ this._occlusionInternalRetryCounter = 0;
|
|
|
+ // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
|
|
|
+ // if strict continue the last state of the object.
|
|
|
+ this._isOccluded = this.occlusionType === BABYLON.AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC ? false : this._isOccluded;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var scene = this.getScene();
|
|
|
+ if (scene.getBoundingBoxRenderer) {
|
|
|
+ var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
|
|
|
+ if (!this._occlusionQuery) {
|
|
|
+ this._occlusionQuery = engine.createQuery();
|
|
|
+ }
|
|
|
+ engine.beginOcclusionQuery(this.occlusionQueryAlgorithmType, this._occlusionQuery);
|
|
|
+ occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
|
|
|
+ engine.endOcclusionQuery(this.occlusionQueryAlgorithmType);
|
|
|
+ this._isOcclusionQueryInProgress = true;
|
|
|
+ }
|
|
|
+ };
|
|
|
})(BABYLON || (BABYLON = {}));
|
|
|
|
|
|
//# sourceMappingURL=babylon.engine.occlusionQuery.js.map
|