|
@@ -75,21 +75,37 @@ var __extends = (this && this.__extends) || (function () {
|
|
});
|
|
});
|
|
/**
|
|
/**
|
|
* Removes the defines that shoould be removed when falling back.
|
|
* Removes the defines that shoould be removed when falling back.
|
|
- * @param currentDefines The current define statements for the shader.
|
|
|
|
|
|
+ * @param currentDefines defines the current define statements for the shader.
|
|
|
|
+ * @param effect defines the current effect we try to compile
|
|
* @returns The resulting defines with defines of the current rank removed.
|
|
* @returns The resulting defines with defines of the current rank removed.
|
|
*/
|
|
*/
|
|
- EffectFallbacks.prototype.reduce = function (currentDefines) {
|
|
|
|
|
|
+ EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
|
|
// First we try to switch to CPU skinning
|
|
// First we try to switch to CPU skinning
|
|
- if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0) {
|
|
|
|
|
|
+ if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
|
|
this._mesh.computeBonesUsingShaders = false;
|
|
this._mesh.computeBonesUsingShaders = false;
|
|
currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
|
|
currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
|
|
- BABYLON.Tools.Log("Falling back to CPU skinning for " + this._mesh.name);
|
|
|
|
var scene = this._mesh.getScene();
|
|
var scene = this._mesh.getScene();
|
|
for (var index = 0; index < scene.meshes.length; index++) {
|
|
for (var index = 0; index < scene.meshes.length; index++) {
|
|
var otherMesh = scene.meshes[index];
|
|
var otherMesh = scene.meshes[index];
|
|
- if (otherMesh.material === this._mesh.material && otherMesh.computeBonesUsingShaders && otherMesh.numBoneInfluencers > 0) {
|
|
|
|
|
|
+ if (!otherMesh.material) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (otherMesh.material.getEffect() === effect) {
|
|
otherMesh.computeBonesUsingShaders = false;
|
|
otherMesh.computeBonesUsingShaders = false;
|
|
}
|
|
}
|
|
|
|
+ else {
|
|
|
|
+ for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
|
|
|
|
+ var subMesh = _a[_i];
|
|
|
|
+ var subMeshEffect = subMesh.effect;
|
|
|
|
+ if (subMeshEffect === effect) {
|
|
|
|
+ otherMesh.computeBonesUsingShaders = false;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -665,7 +681,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
}
|
|
}
|
|
if (fallbacks && fallbacks.isMoreFallbacks) {
|
|
if (fallbacks && fallbacks.isMoreFallbacks) {
|
|
BABYLON.Tools.Error("Trying next fallback.");
|
|
BABYLON.Tools.Error("Trying next fallback.");
|
|
- this.defines = fallbacks.reduce(this.defines);
|
|
|
|
|
|
+ this.defines = fallbacks.reduce(this.defines, this);
|
|
this._prepareEffect();
|
|
this._prepareEffect();
|
|
}
|
|
}
|
|
else {
|
|
else {
|