diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 3872d0d..4cf4f3e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -65,6 +65,7 @@ PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; +PIXI.PI_2 = Math.PI * 2; PIXI.RAD_TO_DEG = 180 / Math.PI; PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 3872d0d..4cf4f3e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -65,6 +65,7 @@ PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; +PIXI.PI_2 = Math.PI * 2; PIXI.RAD_TO_DEG = 180 / Math.PI; PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 16f74fe..ce94c7b 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -53,9 +53,9 @@ if(transpose) { array[0] = this.a; - array[1] = this.c; + array[1] = this.b; array[2] = 0; - array[3] = this.b; + array[3] = this.c; array[4] = this.d; array[5] = 0; array[6] = this.tx; @@ -65,9 +65,9 @@ else { array[0] = this.a; - array[1] = this.b; + array[1] = this.c; array[2] = this.tx; - array[3] = this.c; + array[3] = this.b; array[4] = this.d; array[5] = this.ty; array[6] = 0; diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 3872d0d..4cf4f3e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -65,6 +65,7 @@ PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; +PIXI.PI_2 = Math.PI * 2; PIXI.RAD_TO_DEG = 180 / Math.PI; PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 16f74fe..ce94c7b 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -53,9 +53,9 @@ if(transpose) { array[0] = this.a; - array[1] = this.c; + array[1] = this.b; array[2] = 0; - array[3] = this.b; + array[3] = this.c; array[4] = this.d; array[5] = 0; array[6] = this.tx; @@ -65,9 +65,9 @@ else { array[0] = this.a; - array[1] = this.b; + array[1] = this.c; array[2] = this.tx; - array[3] = this.c; + array[3] = this.b; array[4] = this.d; array[5] = this.ty; array[6] = 0; diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index a6fcee3..2e9a399 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -449,39 +449,65 @@ */ PIXI.DisplayObject.prototype.updateTransform = function() { - // TODO OPTIMIZE THIS!! with dirty - if(this.rotation !== this.rotationCache) - { + // create some matrix refs for easy access + var pt = this.parent.worldTransform; + var wt = this.worldTransform; - this.rotationCache = this.rotation; - this._sr = Math.sin(this.rotation); - this._cr = Math.cos(this.rotation); + // temporary matrix variables + var a, b, c, d, tx, ty; + + // TODO create a const for 2_PI + // so if rotation is between 0 then we can simplify the multiplication process.. + if(this.rotation % PIXI.PI_2) + { + // check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes + if(this.rotation !== this.rotationCache) + { + this.rotationCache = this.rotation; + this._sr = Math.sin(this.rotation); + this._cr = Math.cos(this.rotation); + } + + // get the matrix values of the displayobject based on its transform properties.. + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + tx = this.position.x; + ty = this.position.y; + + // concat the parent matrix with the objects transform. + wt.a = a * pt.a + b * pt.c; + wt.b = a * pt.b + b * pt.d; + wt.c = c * pt.a + d * pt.c; + wt.d = c * pt.b + d * pt.d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx; + wt.ty = tx * pt.b + ty * pt.d + pt.ty; + + // check for pivot.. not often used so geared towards that fact! + if(this.pivot.x || this.pivot.y) + { + wt.tx -= this.pivot.x * a + this.pivot.y * c; + wt.ty -= this.pivot.x * b + this.pivot.y * d; + } + } + else + { + // lets do the fast version as we know there is no rotation.. + a = this.scale.x; + d = this.scale.y; + tx = this.position.x; + ty = this.position.y; + + wt.a = pt.a * a; + wt.b = pt.b * d; + wt.c = pt.c * a; + wt.d = pt.d * d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx - this.pivot.x * a; + wt.ty = tx * pt.b + ty * pt.d + pt.ty - this.pivot.y * d; } - // var localTransform = this.localTransform//.toArray(); - var parentTransform = this.parent.worldTransform;//.toArray(); - var worldTransform = this.worldTransform;//.toArray(); - - var px = this.pivot.x; - var py = this.pivot.y; - - var a00 = this._cr * this.scale.x, - a01 = -this._sr * this.scale.y, - a10 = this._sr * this.scale.x, - a11 = this._cr * this.scale.y, - a02 = this.position.x - a00 * px - py * a01, - a12 = this.position.y - a11 * py - px * a10, - b00 = parentTransform.a, b01 = parentTransform.b, - b10 = parentTransform.c, b11 = parentTransform.d; - - worldTransform.a = b00 * a00 + b01 * a10; - worldTransform.b = b00 * a01 + b01 * a11; - worldTransform.tx = b00 * a02 + b01 * a12 + parentTransform.tx; - - worldTransform.c = b10 * a00 + b11 * a10; - worldTransform.d = b10 * a01 + b11 * a11; - worldTransform.ty = b10 * a02 + b11 * a12 + parentTransform.ty; - + // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha; }; diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 3872d0d..4cf4f3e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -65,6 +65,7 @@ PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; +PIXI.PI_2 = Math.PI * 2; PIXI.RAD_TO_DEG = 180 / Math.PI; PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 16f74fe..ce94c7b 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -53,9 +53,9 @@ if(transpose) { array[0] = this.a; - array[1] = this.c; + array[1] = this.b; array[2] = 0; - array[3] = this.b; + array[3] = this.c; array[4] = this.d; array[5] = 0; array[6] = this.tx; @@ -65,9 +65,9 @@ else { array[0] = this.a; - array[1] = this.b; + array[1] = this.c; array[2] = this.tx; - array[3] = this.c; + array[3] = this.b; array[4] = this.d; array[5] = this.ty; array[6] = 0; diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index a6fcee3..2e9a399 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -449,39 +449,65 @@ */ PIXI.DisplayObject.prototype.updateTransform = function() { - // TODO OPTIMIZE THIS!! with dirty - if(this.rotation !== this.rotationCache) - { + // create some matrix refs for easy access + var pt = this.parent.worldTransform; + var wt = this.worldTransform; - this.rotationCache = this.rotation; - this._sr = Math.sin(this.rotation); - this._cr = Math.cos(this.rotation); + // temporary matrix variables + var a, b, c, d, tx, ty; + + // TODO create a const for 2_PI + // so if rotation is between 0 then we can simplify the multiplication process.. + if(this.rotation % PIXI.PI_2) + { + // check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes + if(this.rotation !== this.rotationCache) + { + this.rotationCache = this.rotation; + this._sr = Math.sin(this.rotation); + this._cr = Math.cos(this.rotation); + } + + // get the matrix values of the displayobject based on its transform properties.. + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + tx = this.position.x; + ty = this.position.y; + + // concat the parent matrix with the objects transform. + wt.a = a * pt.a + b * pt.c; + wt.b = a * pt.b + b * pt.d; + wt.c = c * pt.a + d * pt.c; + wt.d = c * pt.b + d * pt.d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx; + wt.ty = tx * pt.b + ty * pt.d + pt.ty; + + // check for pivot.. not often used so geared towards that fact! + if(this.pivot.x || this.pivot.y) + { + wt.tx -= this.pivot.x * a + this.pivot.y * c; + wt.ty -= this.pivot.x * b + this.pivot.y * d; + } + } + else + { + // lets do the fast version as we know there is no rotation.. + a = this.scale.x; + d = this.scale.y; + tx = this.position.x; + ty = this.position.y; + + wt.a = pt.a * a; + wt.b = pt.b * d; + wt.c = pt.c * a; + wt.d = pt.d * d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx - this.pivot.x * a; + wt.ty = tx * pt.b + ty * pt.d + pt.ty - this.pivot.y * d; } - // var localTransform = this.localTransform//.toArray(); - var parentTransform = this.parent.worldTransform;//.toArray(); - var worldTransform = this.worldTransform;//.toArray(); - - var px = this.pivot.x; - var py = this.pivot.y; - - var a00 = this._cr * this.scale.x, - a01 = -this._sr * this.scale.y, - a10 = this._sr * this.scale.x, - a11 = this._cr * this.scale.y, - a02 = this.position.x - a00 * px - py * a01, - a12 = this.position.y - a11 * py - px * a10, - b00 = parentTransform.a, b01 = parentTransform.b, - b10 = parentTransform.c, b11 = parentTransform.d; - - worldTransform.a = b00 * a00 + b01 * a10; - worldTransform.b = b00 * a01 + b01 * a11; - worldTransform.tx = b00 * a02 + b01 * a12 + parentTransform.tx; - - worldTransform.c = b10 * a00 + b11 * a10; - worldTransform.d = b10 * a01 + b11 * a11; - worldTransform.ty = b10 * a02 + b11 * a12 + parentTransform.ty; - + // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha; }; diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index cffecce..a39f49e 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -333,18 +333,18 @@ { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, - this.worldTransform.tx | 0, - this.worldTransform.ty | 0); + (this.worldTransform.tx* renderSession.resolution) | 0, + (this.worldTransform.ty* renderSession.resolution) | 0); } else { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, this.worldTransform.tx * renderSession.resolution, this.worldTransform.ty * renderSession.resolution); diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 3872d0d..4cf4f3e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -65,6 +65,7 @@ PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; +PIXI.PI_2 = Math.PI * 2; PIXI.RAD_TO_DEG = 180 / Math.PI; PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 16f74fe..ce94c7b 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -53,9 +53,9 @@ if(transpose) { array[0] = this.a; - array[1] = this.c; + array[1] = this.b; array[2] = 0; - array[3] = this.b; + array[3] = this.c; array[4] = this.d; array[5] = 0; array[6] = this.tx; @@ -65,9 +65,9 @@ else { array[0] = this.a; - array[1] = this.b; + array[1] = this.c; array[2] = this.tx; - array[3] = this.c; + array[3] = this.b; array[4] = this.d; array[5] = this.ty; array[6] = 0; diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index a6fcee3..2e9a399 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -449,39 +449,65 @@ */ PIXI.DisplayObject.prototype.updateTransform = function() { - // TODO OPTIMIZE THIS!! with dirty - if(this.rotation !== this.rotationCache) - { + // create some matrix refs for easy access + var pt = this.parent.worldTransform; + var wt = this.worldTransform; - this.rotationCache = this.rotation; - this._sr = Math.sin(this.rotation); - this._cr = Math.cos(this.rotation); + // temporary matrix variables + var a, b, c, d, tx, ty; + + // TODO create a const for 2_PI + // so if rotation is between 0 then we can simplify the multiplication process.. + if(this.rotation % PIXI.PI_2) + { + // check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes + if(this.rotation !== this.rotationCache) + { + this.rotationCache = this.rotation; + this._sr = Math.sin(this.rotation); + this._cr = Math.cos(this.rotation); + } + + // get the matrix values of the displayobject based on its transform properties.. + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + tx = this.position.x; + ty = this.position.y; + + // concat the parent matrix with the objects transform. + wt.a = a * pt.a + b * pt.c; + wt.b = a * pt.b + b * pt.d; + wt.c = c * pt.a + d * pt.c; + wt.d = c * pt.b + d * pt.d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx; + wt.ty = tx * pt.b + ty * pt.d + pt.ty; + + // check for pivot.. not often used so geared towards that fact! + if(this.pivot.x || this.pivot.y) + { + wt.tx -= this.pivot.x * a + this.pivot.y * c; + wt.ty -= this.pivot.x * b + this.pivot.y * d; + } + } + else + { + // lets do the fast version as we know there is no rotation.. + a = this.scale.x; + d = this.scale.y; + tx = this.position.x; + ty = this.position.y; + + wt.a = pt.a * a; + wt.b = pt.b * d; + wt.c = pt.c * a; + wt.d = pt.d * d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx - this.pivot.x * a; + wt.ty = tx * pt.b + ty * pt.d + pt.ty - this.pivot.y * d; } - // var localTransform = this.localTransform//.toArray(); - var parentTransform = this.parent.worldTransform;//.toArray(); - var worldTransform = this.worldTransform;//.toArray(); - - var px = this.pivot.x; - var py = this.pivot.y; - - var a00 = this._cr * this.scale.x, - a01 = -this._sr * this.scale.y, - a10 = this._sr * this.scale.x, - a11 = this._cr * this.scale.y, - a02 = this.position.x - a00 * px - py * a01, - a12 = this.position.y - a11 * py - px * a10, - b00 = parentTransform.a, b01 = parentTransform.b, - b10 = parentTransform.c, b11 = parentTransform.d; - - worldTransform.a = b00 * a00 + b01 * a10; - worldTransform.b = b00 * a01 + b01 * a11; - worldTransform.tx = b00 * a02 + b01 * a12 + parentTransform.tx; - - worldTransform.c = b10 * a00 + b11 * a10; - worldTransform.d = b10 * a01 + b11 * a11; - worldTransform.ty = b10 * a02 + b11 * a12 + parentTransform.ty; - + // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha; }; diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index cffecce..a39f49e 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -333,18 +333,18 @@ { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, - this.worldTransform.tx | 0, - this.worldTransform.ty | 0); + (this.worldTransform.tx* renderSession.resolution) | 0, + (this.worldTransform.ty* renderSession.resolution) | 0); } else { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, this.worldTransform.tx * renderSession.resolution, this.worldTransform.ty * renderSession.resolution); diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index c53833c..dd732f1 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -22,6 +22,8 @@ * @constructor * @param texture {Texture} */ + +//TODO RENAME to PARTICLE CONTAINER? PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -121,7 +123,7 @@ { if(isRotated) { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); isRotated = false; } @@ -148,11 +150,11 @@ if (renderSession.roundPixels) { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); } else { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx, childTransform.ty); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx, childTransform.ty); } context.drawImage(texture.baseTexture.source, diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 3872d0d..4cf4f3e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -65,6 +65,7 @@ PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; +PIXI.PI_2 = Math.PI * 2; PIXI.RAD_TO_DEG = 180 / Math.PI; PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 16f74fe..ce94c7b 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -53,9 +53,9 @@ if(transpose) { array[0] = this.a; - array[1] = this.c; + array[1] = this.b; array[2] = 0; - array[3] = this.b; + array[3] = this.c; array[4] = this.d; array[5] = 0; array[6] = this.tx; @@ -65,9 +65,9 @@ else { array[0] = this.a; - array[1] = this.b; + array[1] = this.c; array[2] = this.tx; - array[3] = this.c; + array[3] = this.b; array[4] = this.d; array[5] = this.ty; array[6] = 0; diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index a6fcee3..2e9a399 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -449,39 +449,65 @@ */ PIXI.DisplayObject.prototype.updateTransform = function() { - // TODO OPTIMIZE THIS!! with dirty - if(this.rotation !== this.rotationCache) - { + // create some matrix refs for easy access + var pt = this.parent.worldTransform; + var wt = this.worldTransform; - this.rotationCache = this.rotation; - this._sr = Math.sin(this.rotation); - this._cr = Math.cos(this.rotation); + // temporary matrix variables + var a, b, c, d, tx, ty; + + // TODO create a const for 2_PI + // so if rotation is between 0 then we can simplify the multiplication process.. + if(this.rotation % PIXI.PI_2) + { + // check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes + if(this.rotation !== this.rotationCache) + { + this.rotationCache = this.rotation; + this._sr = Math.sin(this.rotation); + this._cr = Math.cos(this.rotation); + } + + // get the matrix values of the displayobject based on its transform properties.. + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + tx = this.position.x; + ty = this.position.y; + + // concat the parent matrix with the objects transform. + wt.a = a * pt.a + b * pt.c; + wt.b = a * pt.b + b * pt.d; + wt.c = c * pt.a + d * pt.c; + wt.d = c * pt.b + d * pt.d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx; + wt.ty = tx * pt.b + ty * pt.d + pt.ty; + + // check for pivot.. not often used so geared towards that fact! + if(this.pivot.x || this.pivot.y) + { + wt.tx -= this.pivot.x * a + this.pivot.y * c; + wt.ty -= this.pivot.x * b + this.pivot.y * d; + } + } + else + { + // lets do the fast version as we know there is no rotation.. + a = this.scale.x; + d = this.scale.y; + tx = this.position.x; + ty = this.position.y; + + wt.a = pt.a * a; + wt.b = pt.b * d; + wt.c = pt.c * a; + wt.d = pt.d * d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx - this.pivot.x * a; + wt.ty = tx * pt.b + ty * pt.d + pt.ty - this.pivot.y * d; } - // var localTransform = this.localTransform//.toArray(); - var parentTransform = this.parent.worldTransform;//.toArray(); - var worldTransform = this.worldTransform;//.toArray(); - - var px = this.pivot.x; - var py = this.pivot.y; - - var a00 = this._cr * this.scale.x, - a01 = -this._sr * this.scale.y, - a10 = this._sr * this.scale.x, - a11 = this._cr * this.scale.y, - a02 = this.position.x - a00 * px - py * a01, - a12 = this.position.y - a11 * py - px * a10, - b00 = parentTransform.a, b01 = parentTransform.b, - b10 = parentTransform.c, b11 = parentTransform.d; - - worldTransform.a = b00 * a00 + b01 * a10; - worldTransform.b = b00 * a01 + b01 * a11; - worldTransform.tx = b00 * a02 + b01 * a12 + parentTransform.tx; - - worldTransform.c = b10 * a00 + b11 * a10; - worldTransform.d = b10 * a01 + b11 * a11; - worldTransform.ty = b10 * a02 + b11 * a12 + parentTransform.ty; - + // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha; }; diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index cffecce..a39f49e 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -333,18 +333,18 @@ { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, - this.worldTransform.tx | 0, - this.worldTransform.ty | 0); + (this.worldTransform.tx* renderSession.resolution) | 0, + (this.worldTransform.ty* renderSession.resolution) | 0); } else { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, this.worldTransform.tx * renderSession.resolution, this.worldTransform.ty * renderSession.resolution); diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index c53833c..dd732f1 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -22,6 +22,8 @@ * @constructor * @param texture {Texture} */ + +//TODO RENAME to PARTICLE CONTAINER? PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -121,7 +123,7 @@ { if(isRotated) { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); isRotated = false; } @@ -148,11 +150,11 @@ if (renderSession.roundPixels) { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); } else { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx, childTransform.ty); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx, childTransform.ty); } context.drawImage(texture.baseTexture.source, diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index ad6d27d..dcd9dd2 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -184,11 +184,11 @@ if (renderSession.roundPixels) { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx | 0, transform.ty | 0); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx | 0, transform.ty | 0); } else { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); } var strip = this; diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 3872d0d..4cf4f3e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -65,6 +65,7 @@ PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; +PIXI.PI_2 = Math.PI * 2; PIXI.RAD_TO_DEG = 180 / Math.PI; PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 16f74fe..ce94c7b 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -53,9 +53,9 @@ if(transpose) { array[0] = this.a; - array[1] = this.c; + array[1] = this.b; array[2] = 0; - array[3] = this.b; + array[3] = this.c; array[4] = this.d; array[5] = 0; array[6] = this.tx; @@ -65,9 +65,9 @@ else { array[0] = this.a; - array[1] = this.b; + array[1] = this.c; array[2] = this.tx; - array[3] = this.c; + array[3] = this.b; array[4] = this.d; array[5] = this.ty; array[6] = 0; diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index a6fcee3..2e9a399 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -449,39 +449,65 @@ */ PIXI.DisplayObject.prototype.updateTransform = function() { - // TODO OPTIMIZE THIS!! with dirty - if(this.rotation !== this.rotationCache) - { + // create some matrix refs for easy access + var pt = this.parent.worldTransform; + var wt = this.worldTransform; - this.rotationCache = this.rotation; - this._sr = Math.sin(this.rotation); - this._cr = Math.cos(this.rotation); + // temporary matrix variables + var a, b, c, d, tx, ty; + + // TODO create a const for 2_PI + // so if rotation is between 0 then we can simplify the multiplication process.. + if(this.rotation % PIXI.PI_2) + { + // check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes + if(this.rotation !== this.rotationCache) + { + this.rotationCache = this.rotation; + this._sr = Math.sin(this.rotation); + this._cr = Math.cos(this.rotation); + } + + // get the matrix values of the displayobject based on its transform properties.. + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + tx = this.position.x; + ty = this.position.y; + + // concat the parent matrix with the objects transform. + wt.a = a * pt.a + b * pt.c; + wt.b = a * pt.b + b * pt.d; + wt.c = c * pt.a + d * pt.c; + wt.d = c * pt.b + d * pt.d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx; + wt.ty = tx * pt.b + ty * pt.d + pt.ty; + + // check for pivot.. not often used so geared towards that fact! + if(this.pivot.x || this.pivot.y) + { + wt.tx -= this.pivot.x * a + this.pivot.y * c; + wt.ty -= this.pivot.x * b + this.pivot.y * d; + } + } + else + { + // lets do the fast version as we know there is no rotation.. + a = this.scale.x; + d = this.scale.y; + tx = this.position.x; + ty = this.position.y; + + wt.a = pt.a * a; + wt.b = pt.b * d; + wt.c = pt.c * a; + wt.d = pt.d * d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx - this.pivot.x * a; + wt.ty = tx * pt.b + ty * pt.d + pt.ty - this.pivot.y * d; } - // var localTransform = this.localTransform//.toArray(); - var parentTransform = this.parent.worldTransform;//.toArray(); - var worldTransform = this.worldTransform;//.toArray(); - - var px = this.pivot.x; - var py = this.pivot.y; - - var a00 = this._cr * this.scale.x, - a01 = -this._sr * this.scale.y, - a10 = this._sr * this.scale.x, - a11 = this._cr * this.scale.y, - a02 = this.position.x - a00 * px - py * a01, - a12 = this.position.y - a11 * py - px * a10, - b00 = parentTransform.a, b01 = parentTransform.b, - b10 = parentTransform.c, b11 = parentTransform.d; - - worldTransform.a = b00 * a00 + b01 * a10; - worldTransform.b = b00 * a01 + b01 * a11; - worldTransform.tx = b00 * a02 + b01 * a12 + parentTransform.tx; - - worldTransform.c = b10 * a00 + b11 * a10; - worldTransform.d = b10 * a01 + b11 * a11; - worldTransform.ty = b10 * a02 + b11 * a12 + parentTransform.ty; - + // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha; }; diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index cffecce..a39f49e 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -333,18 +333,18 @@ { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, - this.worldTransform.tx | 0, - this.worldTransform.ty | 0); + (this.worldTransform.tx* renderSession.resolution) | 0, + (this.worldTransform.ty* renderSession.resolution) | 0); } else { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, this.worldTransform.tx * renderSession.resolution, this.worldTransform.ty * renderSession.resolution); diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index c53833c..dd732f1 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -22,6 +22,8 @@ * @constructor * @param texture {Texture} */ + +//TODO RENAME to PARTICLE CONTAINER? PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -121,7 +123,7 @@ { if(isRotated) { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); isRotated = false; } @@ -148,11 +150,11 @@ if (renderSession.roundPixels) { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); } else { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx, childTransform.ty); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx, childTransform.ty); } context.drawImage(texture.baseTexture.source, diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index ad6d27d..dcd9dd2 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -184,11 +184,11 @@ if (renderSession.roundPixels) { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx | 0, transform.ty | 0); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx | 0, transform.ty | 0); } else { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); } var strip = this; diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index f5ebe21..dc85b96 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -742,8 +742,8 @@ var resolution = renderSession.resolution; context.setTransform(transform.a * resolution, - transform.c * resolution, transform.b * resolution, + transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution); diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 3872d0d..4cf4f3e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -65,6 +65,7 @@ PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; +PIXI.PI_2 = Math.PI * 2; PIXI.RAD_TO_DEG = 180 / Math.PI; PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 16f74fe..ce94c7b 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -53,9 +53,9 @@ if(transpose) { array[0] = this.a; - array[1] = this.c; + array[1] = this.b; array[2] = 0; - array[3] = this.b; + array[3] = this.c; array[4] = this.d; array[5] = 0; array[6] = this.tx; @@ -65,9 +65,9 @@ else { array[0] = this.a; - array[1] = this.b; + array[1] = this.c; array[2] = this.tx; - array[3] = this.c; + array[3] = this.b; array[4] = this.d; array[5] = this.ty; array[6] = 0; diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index a6fcee3..2e9a399 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -449,39 +449,65 @@ */ PIXI.DisplayObject.prototype.updateTransform = function() { - // TODO OPTIMIZE THIS!! with dirty - if(this.rotation !== this.rotationCache) - { + // create some matrix refs for easy access + var pt = this.parent.worldTransform; + var wt = this.worldTransform; - this.rotationCache = this.rotation; - this._sr = Math.sin(this.rotation); - this._cr = Math.cos(this.rotation); + // temporary matrix variables + var a, b, c, d, tx, ty; + + // TODO create a const for 2_PI + // so if rotation is between 0 then we can simplify the multiplication process.. + if(this.rotation % PIXI.PI_2) + { + // check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes + if(this.rotation !== this.rotationCache) + { + this.rotationCache = this.rotation; + this._sr = Math.sin(this.rotation); + this._cr = Math.cos(this.rotation); + } + + // get the matrix values of the displayobject based on its transform properties.. + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + tx = this.position.x; + ty = this.position.y; + + // concat the parent matrix with the objects transform. + wt.a = a * pt.a + b * pt.c; + wt.b = a * pt.b + b * pt.d; + wt.c = c * pt.a + d * pt.c; + wt.d = c * pt.b + d * pt.d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx; + wt.ty = tx * pt.b + ty * pt.d + pt.ty; + + // check for pivot.. not often used so geared towards that fact! + if(this.pivot.x || this.pivot.y) + { + wt.tx -= this.pivot.x * a + this.pivot.y * c; + wt.ty -= this.pivot.x * b + this.pivot.y * d; + } + } + else + { + // lets do the fast version as we know there is no rotation.. + a = this.scale.x; + d = this.scale.y; + tx = this.position.x; + ty = this.position.y; + + wt.a = pt.a * a; + wt.b = pt.b * d; + wt.c = pt.c * a; + wt.d = pt.d * d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx - this.pivot.x * a; + wt.ty = tx * pt.b + ty * pt.d + pt.ty - this.pivot.y * d; } - // var localTransform = this.localTransform//.toArray(); - var parentTransform = this.parent.worldTransform;//.toArray(); - var worldTransform = this.worldTransform;//.toArray(); - - var px = this.pivot.x; - var py = this.pivot.y; - - var a00 = this._cr * this.scale.x, - a01 = -this._sr * this.scale.y, - a10 = this._sr * this.scale.x, - a11 = this._cr * this.scale.y, - a02 = this.position.x - a00 * px - py * a01, - a12 = this.position.y - a11 * py - px * a10, - b00 = parentTransform.a, b01 = parentTransform.b, - b10 = parentTransform.c, b11 = parentTransform.d; - - worldTransform.a = b00 * a00 + b01 * a10; - worldTransform.b = b00 * a01 + b01 * a11; - worldTransform.tx = b00 * a02 + b01 * a12 + parentTransform.tx; - - worldTransform.c = b10 * a00 + b11 * a10; - worldTransform.d = b10 * a01 + b11 * a11; - worldTransform.ty = b10 * a02 + b11 * a12 + parentTransform.ty; - + // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha; }; diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index cffecce..a39f49e 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -333,18 +333,18 @@ { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, - this.worldTransform.tx | 0, - this.worldTransform.ty | 0); + (this.worldTransform.tx* renderSession.resolution) | 0, + (this.worldTransform.ty* renderSession.resolution) | 0); } else { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, this.worldTransform.tx * renderSession.resolution, this.worldTransform.ty * renderSession.resolution); diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index c53833c..dd732f1 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -22,6 +22,8 @@ * @constructor * @param texture {Texture} */ + +//TODO RENAME to PARTICLE CONTAINER? PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -121,7 +123,7 @@ { if(isRotated) { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); isRotated = false; } @@ -148,11 +150,11 @@ if (renderSession.roundPixels) { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); } else { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx, childTransform.ty); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx, childTransform.ty); } context.drawImage(texture.baseTexture.source, diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index ad6d27d..dcd9dd2 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -184,11 +184,11 @@ if (renderSession.roundPixels) { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx | 0, transform.ty | 0); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx | 0, transform.ty | 0); } else { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); } var strip = this; diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index f5ebe21..dc85b96 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -742,8 +742,8 @@ var resolution = renderSession.resolution; context.setTransform(transform.a * resolution, - transform.c * resolution, transform.b * resolution, + transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution); diff --git a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js index 10a5f82..0c0d5bc 100644 --- a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js +++ b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js @@ -31,8 +31,8 @@ var resolution = renderSession.resolution; context.setTransform(transform.a * resolution, - transform.c * resolution, transform.b * resolution, + transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution); diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 3872d0d..4cf4f3e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -65,6 +65,7 @@ PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; +PIXI.PI_2 = Math.PI * 2; PIXI.RAD_TO_DEG = 180 / Math.PI; PIXI.DEG_TO_RAD = Math.PI / 180; diff --git a/src/pixi/core/Matrix.js b/src/pixi/core/Matrix.js index 16f74fe..ce94c7b 100644 --- a/src/pixi/core/Matrix.js +++ b/src/pixi/core/Matrix.js @@ -53,9 +53,9 @@ if(transpose) { array[0] = this.a; - array[1] = this.c; + array[1] = this.b; array[2] = 0; - array[3] = this.b; + array[3] = this.c; array[4] = this.d; array[5] = 0; array[6] = this.tx; @@ -65,9 +65,9 @@ else { array[0] = this.a; - array[1] = this.b; + array[1] = this.c; array[2] = this.tx; - array[3] = this.c; + array[3] = this.b; array[4] = this.d; array[5] = this.ty; array[6] = 0; diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index a6fcee3..2e9a399 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -449,39 +449,65 @@ */ PIXI.DisplayObject.prototype.updateTransform = function() { - // TODO OPTIMIZE THIS!! with dirty - if(this.rotation !== this.rotationCache) - { + // create some matrix refs for easy access + var pt = this.parent.worldTransform; + var wt = this.worldTransform; - this.rotationCache = this.rotation; - this._sr = Math.sin(this.rotation); - this._cr = Math.cos(this.rotation); + // temporary matrix variables + var a, b, c, d, tx, ty; + + // TODO create a const for 2_PI + // so if rotation is between 0 then we can simplify the multiplication process.. + if(this.rotation % PIXI.PI_2) + { + // check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes + if(this.rotation !== this.rotationCache) + { + this.rotationCache = this.rotation; + this._sr = Math.sin(this.rotation); + this._cr = Math.cos(this.rotation); + } + + // get the matrix values of the displayobject based on its transform properties.. + a = this._cr * this.scale.x; + b = this._sr * this.scale.x; + c = -this._sr * this.scale.y; + d = this._cr * this.scale.y; + tx = this.position.x; + ty = this.position.y; + + // concat the parent matrix with the objects transform. + wt.a = a * pt.a + b * pt.c; + wt.b = a * pt.b + b * pt.d; + wt.c = c * pt.a + d * pt.c; + wt.d = c * pt.b + d * pt.d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx; + wt.ty = tx * pt.b + ty * pt.d + pt.ty; + + // check for pivot.. not often used so geared towards that fact! + if(this.pivot.x || this.pivot.y) + { + wt.tx -= this.pivot.x * a + this.pivot.y * c; + wt.ty -= this.pivot.x * b + this.pivot.y * d; + } + } + else + { + // lets do the fast version as we know there is no rotation.. + a = this.scale.x; + d = this.scale.y; + tx = this.position.x; + ty = this.position.y; + + wt.a = pt.a * a; + wt.b = pt.b * d; + wt.c = pt.c * a; + wt.d = pt.d * d; + wt.tx = tx * pt.a + ty * pt.c + pt.tx - this.pivot.x * a; + wt.ty = tx * pt.b + ty * pt.d + pt.ty - this.pivot.y * d; } - // var localTransform = this.localTransform//.toArray(); - var parentTransform = this.parent.worldTransform;//.toArray(); - var worldTransform = this.worldTransform;//.toArray(); - - var px = this.pivot.x; - var py = this.pivot.y; - - var a00 = this._cr * this.scale.x, - a01 = -this._sr * this.scale.y, - a10 = this._sr * this.scale.x, - a11 = this._cr * this.scale.y, - a02 = this.position.x - a00 * px - py * a01, - a12 = this.position.y - a11 * py - px * a10, - b00 = parentTransform.a, b01 = parentTransform.b, - b10 = parentTransform.c, b11 = parentTransform.d; - - worldTransform.a = b00 * a00 + b01 * a10; - worldTransform.b = b00 * a01 + b01 * a11; - worldTransform.tx = b00 * a02 + b01 * a12 + parentTransform.tx; - - worldTransform.c = b10 * a00 + b11 * a10; - worldTransform.d = b10 * a01 + b11 * a11; - worldTransform.ty = b10 * a02 + b11 * a12 + parentTransform.ty; - + // multiply the alphas.. this.worldAlpha = this.alpha * this.parent.worldAlpha; }; diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index cffecce..a39f49e 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -333,18 +333,18 @@ { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, - this.worldTransform.tx | 0, - this.worldTransform.ty | 0); + (this.worldTransform.tx* renderSession.resolution) | 0, + (this.worldTransform.ty* renderSession.resolution) | 0); } else { renderSession.context.setTransform( this.worldTransform.a, - this.worldTransform.c, this.worldTransform.b, + this.worldTransform.c, this.worldTransform.d, this.worldTransform.tx * renderSession.resolution, this.worldTransform.ty * renderSession.resolution); diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index c53833c..dd732f1 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -22,6 +22,8 @@ * @constructor * @param texture {Texture} */ + +//TODO RENAME to PARTICLE CONTAINER? PIXI.SpriteBatch = function(texture) { PIXI.DisplayObjectContainer.call( this); @@ -121,7 +123,7 @@ { if(isRotated) { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); isRotated = false; } @@ -148,11 +150,11 @@ if (renderSession.roundPixels) { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx | 0, childTransform.ty | 0); } else { - context.setTransform(childTransform.a, childTransform.c, childTransform.b, childTransform.d, childTransform.tx, childTransform.ty); + context.setTransform(childTransform.a, childTransform.b, childTransform.c, childTransform.d, childTransform.tx, childTransform.ty); } context.drawImage(texture.baseTexture.source, diff --git a/src/pixi/extras/Strip.js b/src/pixi/extras/Strip.js index ad6d27d..dcd9dd2 100644 --- a/src/pixi/extras/Strip.js +++ b/src/pixi/extras/Strip.js @@ -184,11 +184,11 @@ if (renderSession.roundPixels) { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx | 0, transform.ty | 0); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx | 0, transform.ty | 0); } else { - context.setTransform(transform.a, transform.c, transform.b, transform.d, transform.tx, transform.ty); + context.setTransform(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); } var strip = this; diff --git a/src/pixi/primitives/Graphics.js b/src/pixi/primitives/Graphics.js index f5ebe21..dc85b96 100644 --- a/src/pixi/primitives/Graphics.js +++ b/src/pixi/primitives/Graphics.js @@ -742,8 +742,8 @@ var resolution = renderSession.resolution; context.setTransform(transform.a * resolution, - transform.c * resolution, transform.b * resolution, + transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution); diff --git a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js index 10a5f82..0c0d5bc 100644 --- a/src/pixi/renderers/canvas/utils/CanvasMaskManager.js +++ b/src/pixi/renderers/canvas/utils/CanvasMaskManager.js @@ -31,8 +31,8 @@ var resolution = renderSession.resolution; context.setTransform(transform.a * resolution, - transform.c * resolution, transform.b * resolution, + transform.c * resolution, transform.d * resolution, transform.tx * resolution, transform.ty * resolution); diff --git a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js index e30cd4f..4eebf8d 100755 --- a/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js +++ b/src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js @@ -198,12 +198,12 @@ var worldTransform = sprite.worldTransform; - var a = worldTransform.a / resolution;//[0]; - var b = worldTransform.c / resolution;//[3]; - var c = worldTransform.b / resolution;//[1]; - var d = worldTransform.d / resolution;//[4]; - var tx = worldTransform.tx;//[2]; - var ty = worldTransform.ty;///[5]; + var a = worldTransform.a / resolution; + var b = worldTransform.b / resolution; + var c = worldTransform.c / resolution; + var d = worldTransform.d / resolution; + var tx = worldTransform.tx; + var ty = worldTransform.ty; // xy verticies[index++] = a * w1 + c * h1 + tx; @@ -325,8 +325,8 @@ var worldTransform = tilingSprite.worldTransform; var a = worldTransform.a / resolution;//[0]; - var b = worldTransform.c / resolution;//[3]; - var c = worldTransform.b / resolution;//[1]; + var b = worldTransform.b / resolution;//[3]; + var c = worldTransform.c / resolution;//[1]; var d = worldTransform.d / resolution;//[4]; var tx = worldTransform.tx;//[2]; var ty = worldTransform.ty;///[5];