diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index 3256176..a98e203 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -83,7 +83,7 @@ { var child = children[i]; - if(child.visible) { +// if(child.visible) { // push all interactive bits if(child.interactive) { @@ -105,7 +105,7 @@ this.collectInteractiveSprite(child, iParent); } } - } +// } } } @@ -185,7 +185,10 @@ for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(!item.visible)continue; + + + + //if(!item.visible)continue; // OPTIMISATION - only calculate every time if the mousemove function exists.. // OK so.. does the object have any other interactive functions? @@ -368,7 +371,7 @@ { var global = interactionData.global; - if(!item.visible)return false; + if(item.vcount !== PIXI.visibleCount)return false; var isSprite = (item instanceof PIXI.Sprite), worldTransform = item.worldTransform, diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index 3256176..a98e203 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -83,7 +83,7 @@ { var child = children[i]; - if(child.visible) { +// if(child.visible) { // push all interactive bits if(child.interactive) { @@ -105,7 +105,7 @@ this.collectInteractiveSprite(child, iParent); } } - } +// } } } @@ -185,7 +185,10 @@ for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(!item.visible)continue; + + + + //if(!item.visible)continue; // OPTIMISATION - only calculate every time if the mousemove function exists.. // OK so.. does the object have any other interactive functions? @@ -368,7 +371,7 @@ { var global = interactionData.global; - if(!item.visible)return false; + if(item.vcount !== PIXI.visibleCount)return false; var isSprite = (item instanceof PIXI.Sprite), worldTransform = item.worldTransform, diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index cc31157..84326a3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -492,7 +492,7 @@ PIXI.DisplayObject.prototype.updateTransform = function() { // TODO OPTIMIZE THIS!! with dirty - if(this.rotation != this.rotationCache) + if(this.rotation !== this.rotationCache) { this.rotationCache = this.rotation; this._sr = Math.sin(this.rotation); @@ -534,5 +534,9 @@ // because we are using affine transformation, we can optimise the matrix concatenation process.. wooo! // mat3.multiply(this.localTransform, this.parent.worldTransform, this.worldTransform); this.worldAlpha = this.alpha * this.parent.worldAlpha; + + this.vcount = PIXI.visibleCount; } + +PIXI.visibleCount = 0; \ No newline at end of file diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index 3256176..a98e203 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -83,7 +83,7 @@ { var child = children[i]; - if(child.visible) { +// if(child.visible) { // push all interactive bits if(child.interactive) { @@ -105,7 +105,7 @@ this.collectInteractiveSprite(child, iParent); } } - } +// } } } @@ -185,7 +185,10 @@ for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(!item.visible)continue; + + + + //if(!item.visible)continue; // OPTIMISATION - only calculate every time if the mousemove function exists.. // OK so.. does the object have any other interactive functions? @@ -368,7 +371,7 @@ { var global = interactionData.global; - if(!item.visible)return false; + if(item.vcount !== PIXI.visibleCount)return false; var isSprite = (item instanceof PIXI.Sprite), worldTransform = item.worldTransform, diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index cc31157..84326a3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -492,7 +492,7 @@ PIXI.DisplayObject.prototype.updateTransform = function() { // TODO OPTIMIZE THIS!! with dirty - if(this.rotation != this.rotationCache) + if(this.rotation !== this.rotationCache) { this.rotationCache = this.rotation; this._sr = Math.sin(this.rotation); @@ -534,5 +534,9 @@ // because we are using affine transformation, we can optimise the matrix concatenation process.. wooo! // mat3.multiply(this.localTransform, this.parent.worldTransform, this.worldTransform); this.worldAlpha = this.alpha * this.parent.worldAlpha; + + this.vcount = PIXI.visibleCount; } + +PIXI.visibleCount = 0; \ No newline at end of file diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index 0713205..45a98ba 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -127,9 +127,18 @@ if(this.texture.baseTexture != texture.baseTexture) { this.textureChange = true; + + if(this.__renderGroup) + { + this.texture = texture; + this.__renderGroup.updateTexture(this); + } + } + else + { + this.texture = texture; } - this.texture = texture; this.updateFrame = true; } diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index 3256176..a98e203 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -83,7 +83,7 @@ { var child = children[i]; - if(child.visible) { +// if(child.visible) { // push all interactive bits if(child.interactive) { @@ -105,7 +105,7 @@ this.collectInteractiveSprite(child, iParent); } } - } +// } } } @@ -185,7 +185,10 @@ for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(!item.visible)continue; + + + + //if(!item.visible)continue; // OPTIMISATION - only calculate every time if the mousemove function exists.. // OK so.. does the object have any other interactive functions? @@ -368,7 +371,7 @@ { var global = interactionData.global; - if(!item.visible)return false; + if(item.vcount !== PIXI.visibleCount)return false; var isSprite = (item instanceof PIXI.Sprite), worldTransform = item.worldTransform, diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index cc31157..84326a3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -492,7 +492,7 @@ PIXI.DisplayObject.prototype.updateTransform = function() { // TODO OPTIMIZE THIS!! with dirty - if(this.rotation != this.rotationCache) + if(this.rotation !== this.rotationCache) { this.rotationCache = this.rotation; this._sr = Math.sin(this.rotation); @@ -534,5 +534,9 @@ // because we are using affine transformation, we can optimise the matrix concatenation process.. wooo! // mat3.multiply(this.localTransform, this.parent.worldTransform, this.worldTransform); this.worldAlpha = this.alpha * this.parent.worldAlpha; + + this.vcount = PIXI.visibleCount; } + +PIXI.visibleCount = 0; \ No newline at end of file diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index 0713205..45a98ba 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -127,9 +127,18 @@ if(this.texture.baseTexture != texture.baseTexture) { this.textureChange = true; + + if(this.__renderGroup) + { + this.texture = texture; + this.__renderGroup.updateTexture(this); + } + } + else + { + this.texture = texture; } - this.texture = texture; this.updateFrame = true; } diff --git a/src/pixi/renderers/webgl/WebGLBatch.js b/src/pixi/renderers/webgl/WebGLBatch.js index 7d15d01..56d0717 100644 --- a/src/pixi/renderers/webgl/WebGLBatch.js +++ b/src/pixi/renderers/webgl/WebGLBatch.js @@ -423,7 +423,7 @@ while(displayObject) { - if(displayObject.worldVisible) + if(displayObject.vcount === PIXI.visibleCount) { width = displayObject.texture.frame.width; height = displayObject.texture.frame.height; diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index 3256176..a98e203 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -83,7 +83,7 @@ { var child = children[i]; - if(child.visible) { +// if(child.visible) { // push all interactive bits if(child.interactive) { @@ -105,7 +105,7 @@ this.collectInteractiveSprite(child, iParent); } } - } +// } } } @@ -185,7 +185,10 @@ for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(!item.visible)continue; + + + + //if(!item.visible)continue; // OPTIMISATION - only calculate every time if the mousemove function exists.. // OK so.. does the object have any other interactive functions? @@ -368,7 +371,7 @@ { var global = interactionData.global; - if(!item.visible)return false; + if(item.vcount !== PIXI.visibleCount)return false; var isSprite = (item instanceof PIXI.Sprite), worldTransform = item.worldTransform, diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index cc31157..84326a3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -492,7 +492,7 @@ PIXI.DisplayObject.prototype.updateTransform = function() { // TODO OPTIMIZE THIS!! with dirty - if(this.rotation != this.rotationCache) + if(this.rotation !== this.rotationCache) { this.rotationCache = this.rotation; this._sr = Math.sin(this.rotation); @@ -534,5 +534,9 @@ // because we are using affine transformation, we can optimise the matrix concatenation process.. wooo! // mat3.multiply(this.localTransform, this.parent.worldTransform, this.worldTransform); this.worldAlpha = this.alpha * this.parent.worldAlpha; + + this.vcount = PIXI.visibleCount; } + +PIXI.visibleCount = 0; \ No newline at end of file diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index 0713205..45a98ba 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -127,9 +127,18 @@ if(this.texture.baseTexture != texture.baseTexture) { this.textureChange = true; + + if(this.__renderGroup) + { + this.texture = texture; + this.__renderGroup.updateTexture(this); + } + } + else + { + this.texture = texture; } - this.texture = texture; this.updateFrame = true; } diff --git a/src/pixi/renderers/webgl/WebGLBatch.js b/src/pixi/renderers/webgl/WebGLBatch.js index 7d15d01..56d0717 100644 --- a/src/pixi/renderers/webgl/WebGLBatch.js +++ b/src/pixi/renderers/webgl/WebGLBatch.js @@ -423,7 +423,7 @@ while(displayObject) { - if(displayObject.worldVisible) + if(displayObject.vcount === PIXI.visibleCount) { width = displayObject.texture.frame.width; height = displayObject.texture.frame.height; diff --git a/src/pixi/renderers/webgl/WebGLRenderGroup.js b/src/pixi/renderers/webgl/WebGLRenderGroup.js index 0a12de3..557347f 100644 --- a/src/pixi/renderers/webgl/WebGLRenderGroup.js +++ b/src/pixi/renderers/webgl/WebGLRenderGroup.js @@ -67,30 +67,35 @@ gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); // TODO remove this by replacing visible with getter setters.. - this.checkVisibility(this.root, this.root.visible); + //this.checkVisibility(this.root, this.root.visible); // will render all the elements in the group var renderable; - for (var i=0; i < this.batchs.length; i++) { + renderable = this.batchs[i]; if(renderable instanceof PIXI.WebGLBatch) { this.batchs[i].render(); + continue; } - else if(renderable instanceof PIXI.TilingSprite) + + // non sprite batch.. + var worldVisible = renderable.vcount === PIXI.visibleCount; + + if(renderable instanceof PIXI.TilingSprite) { - if(renderable.worldVisible)this.renderTilingSprite(renderable, projection); + if(worldVisible)this.renderTilingSprite(renderable, projection); } else if(renderable instanceof PIXI.Strip) { - if(renderable.worldVisible)this.renderStrip(renderable, projection); + if(worldVisible)this.renderStrip(renderable, projection); } else if(renderable instanceof PIXI.Graphics) { - if(renderable.worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection);//, projectionMatrix); + if(worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection);//, projectionMatrix); } else if(renderable instanceof PIXI.FilterBlock) { @@ -145,7 +150,7 @@ PIXI.WebGLRenderer.updateTextures(); var gl = this.gl; - this.checkVisibility(displayObject, displayObject.visible); + //this.checkVisibility(displayObject, displayObject.visible); // gl.uniformMatrix4fv(PIXI.shaderProgram.mvMatrixUniform, false, projectionMatrix); gl.uniform2f(PIXI.shaderProgram.projectionVector, projection.x, projection.y); @@ -302,21 +307,23 @@ */ PIXI.WebGLRenderGroup.prototype.renderSpecial = function(renderable, projection) { + var worldVisible = renderable.vcount === PIXI.visibleCount + if(renderable instanceof PIXI.TilingSprite) { - if(renderable.worldVisible)this.renderTilingSprite(renderable, projection); + if(worldVisible)this.renderTilingSprite(renderable, projection); } else if(renderable instanceof PIXI.Strip) { - if(renderable.worldVisible)this.renderStrip(renderable, projection); + if(worldVisible)this.renderStrip(renderable, projection); } else if(renderable instanceof PIXI.CustomRenderable) { - if(renderable.worldVisible) renderable.renderWebGL(this, projection); + if(worldVisible) renderable.renderWebGL(this, projection); } else if(renderable instanceof PIXI.Graphics) { - if(renderable.worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection); + if(worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection); } else if(renderable instanceof PIXI.FilterBlock) { @@ -356,6 +363,8 @@ * @param globalVisible {Boolean} * @private */ + +/* PIXI.WebGLRenderGroup.prototype.checkVisibility = function(displayObject, globalVisible) { // give the dp a reference to its renderGroup... @@ -366,14 +375,15 @@ var child = children[i]; // TODO optimize... should'nt need to loop through everything all the time - child.worldVisible = child.visible && globalVisible; + // child.worldVisible = child.visible && globalVisible; // everything should have a batch! // time to see whats new! if(child.textureChange) { child.textureChange = false; - if(child.worldVisible)this.updateTexture(child); + //if(child.worldVisible) + //this.updateTexture(child); // update texture!! } @@ -382,7 +392,7 @@ this.checkVisibility(child, child.worldVisible); } }; -} +}*/ /** * Updates a webgl texture diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index 3256176..a98e203 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -83,7 +83,7 @@ { var child = children[i]; - if(child.visible) { +// if(child.visible) { // push all interactive bits if(child.interactive) { @@ -105,7 +105,7 @@ this.collectInteractiveSprite(child, iParent); } } - } +// } } } @@ -185,7 +185,10 @@ for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(!item.visible)continue; + + + + //if(!item.visible)continue; // OPTIMISATION - only calculate every time if the mousemove function exists.. // OK so.. does the object have any other interactive functions? @@ -368,7 +371,7 @@ { var global = interactionData.global; - if(!item.visible)return false; + if(item.vcount !== PIXI.visibleCount)return false; var isSprite = (item instanceof PIXI.Sprite), worldTransform = item.worldTransform, diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index cc31157..84326a3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -492,7 +492,7 @@ PIXI.DisplayObject.prototype.updateTransform = function() { // TODO OPTIMIZE THIS!! with dirty - if(this.rotation != this.rotationCache) + if(this.rotation !== this.rotationCache) { this.rotationCache = this.rotation; this._sr = Math.sin(this.rotation); @@ -534,5 +534,9 @@ // because we are using affine transformation, we can optimise the matrix concatenation process.. wooo! // mat3.multiply(this.localTransform, this.parent.worldTransform, this.worldTransform); this.worldAlpha = this.alpha * this.parent.worldAlpha; + + this.vcount = PIXI.visibleCount; } + +PIXI.visibleCount = 0; \ No newline at end of file diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index 0713205..45a98ba 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -127,9 +127,18 @@ if(this.texture.baseTexture != texture.baseTexture) { this.textureChange = true; + + if(this.__renderGroup) + { + this.texture = texture; + this.__renderGroup.updateTexture(this); + } + } + else + { + this.texture = texture; } - this.texture = texture; this.updateFrame = true; } diff --git a/src/pixi/renderers/webgl/WebGLBatch.js b/src/pixi/renderers/webgl/WebGLBatch.js index 7d15d01..56d0717 100644 --- a/src/pixi/renderers/webgl/WebGLBatch.js +++ b/src/pixi/renderers/webgl/WebGLBatch.js @@ -423,7 +423,7 @@ while(displayObject) { - if(displayObject.worldVisible) + if(displayObject.vcount === PIXI.visibleCount) { width = displayObject.texture.frame.width; height = displayObject.texture.frame.height; diff --git a/src/pixi/renderers/webgl/WebGLRenderGroup.js b/src/pixi/renderers/webgl/WebGLRenderGroup.js index 0a12de3..557347f 100644 --- a/src/pixi/renderers/webgl/WebGLRenderGroup.js +++ b/src/pixi/renderers/webgl/WebGLRenderGroup.js @@ -67,30 +67,35 @@ gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); // TODO remove this by replacing visible with getter setters.. - this.checkVisibility(this.root, this.root.visible); + //this.checkVisibility(this.root, this.root.visible); // will render all the elements in the group var renderable; - for (var i=0; i < this.batchs.length; i++) { + renderable = this.batchs[i]; if(renderable instanceof PIXI.WebGLBatch) { this.batchs[i].render(); + continue; } - else if(renderable instanceof PIXI.TilingSprite) + + // non sprite batch.. + var worldVisible = renderable.vcount === PIXI.visibleCount; + + if(renderable instanceof PIXI.TilingSprite) { - if(renderable.worldVisible)this.renderTilingSprite(renderable, projection); + if(worldVisible)this.renderTilingSprite(renderable, projection); } else if(renderable instanceof PIXI.Strip) { - if(renderable.worldVisible)this.renderStrip(renderable, projection); + if(worldVisible)this.renderStrip(renderable, projection); } else if(renderable instanceof PIXI.Graphics) { - if(renderable.worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection);//, projectionMatrix); + if(worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection);//, projectionMatrix); } else if(renderable instanceof PIXI.FilterBlock) { @@ -145,7 +150,7 @@ PIXI.WebGLRenderer.updateTextures(); var gl = this.gl; - this.checkVisibility(displayObject, displayObject.visible); + //this.checkVisibility(displayObject, displayObject.visible); // gl.uniformMatrix4fv(PIXI.shaderProgram.mvMatrixUniform, false, projectionMatrix); gl.uniform2f(PIXI.shaderProgram.projectionVector, projection.x, projection.y); @@ -302,21 +307,23 @@ */ PIXI.WebGLRenderGroup.prototype.renderSpecial = function(renderable, projection) { + var worldVisible = renderable.vcount === PIXI.visibleCount + if(renderable instanceof PIXI.TilingSprite) { - if(renderable.worldVisible)this.renderTilingSprite(renderable, projection); + if(worldVisible)this.renderTilingSprite(renderable, projection); } else if(renderable instanceof PIXI.Strip) { - if(renderable.worldVisible)this.renderStrip(renderable, projection); + if(worldVisible)this.renderStrip(renderable, projection); } else if(renderable instanceof PIXI.CustomRenderable) { - if(renderable.worldVisible) renderable.renderWebGL(this, projection); + if(worldVisible) renderable.renderWebGL(this, projection); } else if(renderable instanceof PIXI.Graphics) { - if(renderable.worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection); + if(worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection); } else if(renderable instanceof PIXI.FilterBlock) { @@ -356,6 +363,8 @@ * @param globalVisible {Boolean} * @private */ + +/* PIXI.WebGLRenderGroup.prototype.checkVisibility = function(displayObject, globalVisible) { // give the dp a reference to its renderGroup... @@ -366,14 +375,15 @@ var child = children[i]; // TODO optimize... should'nt need to loop through everything all the time - child.worldVisible = child.visible && globalVisible; + // child.worldVisible = child.visible && globalVisible; // everything should have a batch! // time to see whats new! if(child.textureChange) { child.textureChange = false; - if(child.worldVisible)this.updateTexture(child); + //if(child.worldVisible) + //this.updateTexture(child); // update texture!! } @@ -382,7 +392,7 @@ this.checkVisibility(child, child.worldVisible); } }; -} +}*/ /** * Updates a webgl texture diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index bc92f54..276426b 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -135,7 +135,6 @@ // TODO make this work // dont think this is needed any more? //if(this.__stage)this.checkVisibility(this.__stage, false) - this.__stage = stage; this.stageRenderGroup.setRenderable(stage); } @@ -156,6 +155,7 @@ //this.checkVisibility(stage, true); // update the scene graph + PIXI.visibleCount++; stage.updateTransform(); var gl = this.gl; diff --git a/src/pixi/InteractionManager.js b/src/pixi/InteractionManager.js index 3256176..a98e203 100644 --- a/src/pixi/InteractionManager.js +++ b/src/pixi/InteractionManager.js @@ -83,7 +83,7 @@ { var child = children[i]; - if(child.visible) { +// if(child.visible) { // push all interactive bits if(child.interactive) { @@ -105,7 +105,7 @@ this.collectInteractiveSprite(child, iParent); } } - } +// } } } @@ -185,7 +185,10 @@ for (var i = 0; i < length; i++) { var item = this.interactiveItems[i]; - if(!item.visible)continue; + + + + //if(!item.visible)continue; // OPTIMISATION - only calculate every time if the mousemove function exists.. // OK so.. does the object have any other interactive functions? @@ -368,7 +371,7 @@ { var global = interactionData.global; - if(!item.visible)return false; + if(item.vcount !== PIXI.visibleCount)return false; var isSprite = (item instanceof PIXI.Sprite), worldTransform = item.worldTransform, diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index cc31157..84326a3 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -492,7 +492,7 @@ PIXI.DisplayObject.prototype.updateTransform = function() { // TODO OPTIMIZE THIS!! with dirty - if(this.rotation != this.rotationCache) + if(this.rotation !== this.rotationCache) { this.rotationCache = this.rotation; this._sr = Math.sin(this.rotation); @@ -534,5 +534,9 @@ // because we are using affine transformation, we can optimise the matrix concatenation process.. wooo! // mat3.multiply(this.localTransform, this.parent.worldTransform, this.worldTransform); this.worldAlpha = this.alpha * this.parent.worldAlpha; + + this.vcount = PIXI.visibleCount; } + +PIXI.visibleCount = 0; \ No newline at end of file diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index 0713205..45a98ba 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -127,9 +127,18 @@ if(this.texture.baseTexture != texture.baseTexture) { this.textureChange = true; + + if(this.__renderGroup) + { + this.texture = texture; + this.__renderGroup.updateTexture(this); + } + } + else + { + this.texture = texture; } - this.texture = texture; this.updateFrame = true; } diff --git a/src/pixi/renderers/webgl/WebGLBatch.js b/src/pixi/renderers/webgl/WebGLBatch.js index 7d15d01..56d0717 100644 --- a/src/pixi/renderers/webgl/WebGLBatch.js +++ b/src/pixi/renderers/webgl/WebGLBatch.js @@ -423,7 +423,7 @@ while(displayObject) { - if(displayObject.worldVisible) + if(displayObject.vcount === PIXI.visibleCount) { width = displayObject.texture.frame.width; height = displayObject.texture.frame.height; diff --git a/src/pixi/renderers/webgl/WebGLRenderGroup.js b/src/pixi/renderers/webgl/WebGLRenderGroup.js index 0a12de3..557347f 100644 --- a/src/pixi/renderers/webgl/WebGLRenderGroup.js +++ b/src/pixi/renderers/webgl/WebGLRenderGroup.js @@ -67,30 +67,35 @@ gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); // TODO remove this by replacing visible with getter setters.. - this.checkVisibility(this.root, this.root.visible); + //this.checkVisibility(this.root, this.root.visible); // will render all the elements in the group var renderable; - for (var i=0; i < this.batchs.length; i++) { + renderable = this.batchs[i]; if(renderable instanceof PIXI.WebGLBatch) { this.batchs[i].render(); + continue; } - else if(renderable instanceof PIXI.TilingSprite) + + // non sprite batch.. + var worldVisible = renderable.vcount === PIXI.visibleCount; + + if(renderable instanceof PIXI.TilingSprite) { - if(renderable.worldVisible)this.renderTilingSprite(renderable, projection); + if(worldVisible)this.renderTilingSprite(renderable, projection); } else if(renderable instanceof PIXI.Strip) { - if(renderable.worldVisible)this.renderStrip(renderable, projection); + if(worldVisible)this.renderStrip(renderable, projection); } else if(renderable instanceof PIXI.Graphics) { - if(renderable.worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection);//, projectionMatrix); + if(worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection);//, projectionMatrix); } else if(renderable instanceof PIXI.FilterBlock) { @@ -145,7 +150,7 @@ PIXI.WebGLRenderer.updateTextures(); var gl = this.gl; - this.checkVisibility(displayObject, displayObject.visible); + //this.checkVisibility(displayObject, displayObject.visible); // gl.uniformMatrix4fv(PIXI.shaderProgram.mvMatrixUniform, false, projectionMatrix); gl.uniform2f(PIXI.shaderProgram.projectionVector, projection.x, projection.y); @@ -302,21 +307,23 @@ */ PIXI.WebGLRenderGroup.prototype.renderSpecial = function(renderable, projection) { + var worldVisible = renderable.vcount === PIXI.visibleCount + if(renderable instanceof PIXI.TilingSprite) { - if(renderable.worldVisible)this.renderTilingSprite(renderable, projection); + if(worldVisible)this.renderTilingSprite(renderable, projection); } else if(renderable instanceof PIXI.Strip) { - if(renderable.worldVisible)this.renderStrip(renderable, projection); + if(worldVisible)this.renderStrip(renderable, projection); } else if(renderable instanceof PIXI.CustomRenderable) { - if(renderable.worldVisible) renderable.renderWebGL(this, projection); + if(worldVisible) renderable.renderWebGL(this, projection); } else if(renderable instanceof PIXI.Graphics) { - if(renderable.worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection); + if(worldVisible && renderable.renderable) PIXI.WebGLGraphics.renderGraphics(renderable, projection); } else if(renderable instanceof PIXI.FilterBlock) { @@ -356,6 +363,8 @@ * @param globalVisible {Boolean} * @private */ + +/* PIXI.WebGLRenderGroup.prototype.checkVisibility = function(displayObject, globalVisible) { // give the dp a reference to its renderGroup... @@ -366,14 +375,15 @@ var child = children[i]; // TODO optimize... should'nt need to loop through everything all the time - child.worldVisible = child.visible && globalVisible; + // child.worldVisible = child.visible && globalVisible; // everything should have a batch! // time to see whats new! if(child.textureChange) { child.textureChange = false; - if(child.worldVisible)this.updateTexture(child); + //if(child.worldVisible) + //this.updateTexture(child); // update texture!! } @@ -382,7 +392,7 @@ this.checkVisibility(child, child.worldVisible); } }; -} +}*/ /** * Updates a webgl texture diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index bc92f54..276426b 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -135,7 +135,6 @@ // TODO make this work // dont think this is needed any more? //if(this.__stage)this.checkVisibility(this.__stage, false) - this.__stage = stage; this.stageRenderGroup.setRenderable(stage); } @@ -156,6 +155,7 @@ //this.checkVisibility(stage, true); // update the scene graph + PIXI.visibleCount++; stage.updateTransform(); var gl = this.gl; diff --git a/src/pixi/textures/RenderTexture.js b/src/pixi/textures/RenderTexture.js index 523a1e1..25b2cfe 100644 --- a/src/pixi/textures/RenderTexture.js +++ b/src/pixi/textures/RenderTexture.js @@ -92,15 +92,7 @@ // create a projection matrix.. this.projection = new PIXI.Point(this.width/2 , this.height/2); -/* - this.projectionMatrix = PIXI.mat4.create(); - this.projectionMatrix[5] = 2/this.height// * 0.5; - this.projectionMatrix[13] = -1; - - this.projectionMatrix[0] = 2/this.width; - this.projectionMatrix[12] = -1; -*/ // set the correct render function.. this.render = this.renderWebGL; @@ -114,10 +106,6 @@ this.width = width; this.height = height; - //this.frame.width = this.width - //this.frame.height = this.height; - - if(PIXI.gl) { this.projection.x = this.width/2 @@ -194,8 +182,9 @@ displayObject.worldTransform[5] -= position.y; } - - + PIXI.visibleCount++; + displayObject.vcount = PIXI.visibleCount; + for(var i=0,j=children.length; i