mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 22:18:29 +00:00
Whenever Camera.roundPixels
was enabled it would use a bitwise operation to truncate the float (x |= 0
) - this has been replaced across all files that used it, with a call to Math.round
instead. This gives far better results when zooming cameras both in and out of a Scene, stopping thin gaps appearing between closely packed Game Objects.
This commit is contained in:
parent
146745057a
commit
6f8759c186
14 changed files with 76 additions and 75 deletions
|
@ -102,6 +102,7 @@
|
|||
* `Graphics.stroke` is a new alias for the `strokePath` method, to keep the calls consistent with the Canvas Rendering Context API.
|
||||
* `Graphics.fill` is a new alias for the `fillPath` method, to keep the calls consistent with the Canvas Rendering Context API.
|
||||
* `LoaderPlugin.sceneManager` is a new property that is a reference to the global Scene Manager, useful for Plugins.
|
||||
* Whenever `Camera.roundPixels` was enabled it would use a bitwise operation to truncate the float (`x |= 0`) - this has been replaced across all files that used it, with a call to `Math.round` instead. This gives far better results when zooming cameras both in and out of a Scene, stopping thin gaps appearing between closely packed Game Objects.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -270,8 +270,8 @@ var Shake = new Class({
|
|||
|
||||
if (this.camera.roundPixels)
|
||||
{
|
||||
this._offsetX |= 0;
|
||||
this._offsetY |= 0;
|
||||
this._offsetX = Math.round(this._offsetX);
|
||||
this._offsetY = Math.round(this._offsetY);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -144,8 +144,8 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc
|
|||
|
||||
if (camera.roundPixels)
|
||||
{
|
||||
x |= 0;
|
||||
y |= 0;
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
}
|
||||
|
||||
ctx.save();
|
||||
|
|
|
@ -273,17 +273,17 @@ var DynamicBitmapTextWebGLRenderer = function (renderer, src, interpolationPerce
|
|||
|
||||
if (roundPixels)
|
||||
{
|
||||
tx0 |= 0;
|
||||
ty0 |= 0;
|
||||
tx0 = Math.round(tx0);
|
||||
ty0 = Math.round(ty0);
|
||||
|
||||
tx1 |= 0;
|
||||
ty1 |= 0;
|
||||
tx1 = Math.round(tx1);
|
||||
ty1 = Math.round(ty1);
|
||||
|
||||
tx2 |= 0;
|
||||
ty2 |= 0;
|
||||
tx2 = Math.round(tx2);
|
||||
ty2 = Math.round(ty2);
|
||||
|
||||
tx3 |= 0;
|
||||
ty3 |= 0;
|
||||
tx3 = Math.round(tx3);
|
||||
ty3 = Math.round(ty3);
|
||||
}
|
||||
|
||||
pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
|
||||
|
|
|
@ -148,8 +148,8 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage,
|
|||
|
||||
if (roundPixels)
|
||||
{
|
||||
x |= 0;
|
||||
y |= 0;
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
}
|
||||
|
||||
ctx.save();
|
||||
|
|
|
@ -203,17 +203,17 @@ var BitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage,
|
|||
|
||||
if (roundPixels)
|
||||
{
|
||||
tx0 |= 0;
|
||||
ty0 |= 0;
|
||||
tx0 = Math.round(tx0);
|
||||
ty0 = Math.round(ty0);
|
||||
|
||||
tx1 |= 0;
|
||||
ty1 |= 0;
|
||||
tx1 = Math.round(tx1);
|
||||
ty1 = Math.round(ty1);
|
||||
|
||||
tx2 |= 0;
|
||||
ty2 |= 0;
|
||||
tx2 = Math.round(tx2);
|
||||
ty2 = Math.round(ty2);
|
||||
|
||||
tx3 |= 0;
|
||||
ty3 |= 0;
|
||||
tx3 = Math.round(tx3);
|
||||
ty3 = Math.round(ty3);
|
||||
}
|
||||
|
||||
pipeline.batchQuad(tx0, ty0, tx1, ty1, tx2, ty2, tx3, ty3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect);
|
||||
|
|
|
@ -78,8 +78,8 @@ var BlitterCanvasRenderer = function (renderer, src, interpolationPercentage, ca
|
|||
{
|
||||
if (roundPixels)
|
||||
{
|
||||
dx |= 0;
|
||||
dy |= 0;
|
||||
dx = Math.round(dx);
|
||||
dy = Math.round(dy);
|
||||
}
|
||||
|
||||
ctx.drawImage(
|
||||
|
|
|
@ -106,11 +106,11 @@ var BlitterWebGLRenderer = function (renderer, src, interpolationPercentage, cam
|
|||
|
||||
if (roundPixels)
|
||||
{
|
||||
tx0 |= 0;
|
||||
ty0 |= 0;
|
||||
tx0 = Math.round(tx0);
|
||||
ty0 = Math.round(ty0);
|
||||
|
||||
tx1 |= 0;
|
||||
ty1 |= 0;
|
||||
tx1 = Math.round(tx1);
|
||||
ty1 = Math.round(ty1);
|
||||
}
|
||||
|
||||
// TL x/y, BL x/y, BR x/y, TR x/y
|
||||
|
|
|
@ -92,8 +92,8 @@ var MeshWebGLRenderer = function (renderer, src, interpolationPercentage, camera
|
|||
|
||||
if (camera.roundPixels)
|
||||
{
|
||||
tx |= 0;
|
||||
ty |= 0;
|
||||
tx = Math.round(tx);
|
||||
ty = Math.round(ty);
|
||||
}
|
||||
|
||||
vertexViewF32[++vertexOffset] = tx;
|
||||
|
|
|
@ -99,8 +99,8 @@ var ParticleManagerCanvasRenderer = function (renderer, emitterManager, interpol
|
|||
|
||||
if (roundPixels)
|
||||
{
|
||||
x |= 0;
|
||||
y |= 0;
|
||||
x = Math.round(x);
|
||||
y = Math.round(y);
|
||||
}
|
||||
|
||||
ctx.drawImage(frame.source.image, cd.x, cd.y, cd.width, cd.height, x, y, cd.width, cd.height);
|
||||
|
|
|
@ -118,17 +118,17 @@ var ParticleManagerWebGLRenderer = function (renderer, emitterManager, interpola
|
|||
|
||||
if (roundPixels)
|
||||
{
|
||||
tx0 |= 0;
|
||||
ty0 |= 0;
|
||||
|
||||
tx1 |= 0;
|
||||
ty1 |= 0;
|
||||
|
||||
tx2 |= 0;
|
||||
ty2 |= 0;
|
||||
|
||||
tx3 |= 0;
|
||||
ty3 |= 0;
|
||||
tx0 = Math.round(tx0);
|
||||
ty0 = Math.round(ty0);
|
||||
|
||||
tx1 = Math.round(tx1);
|
||||
ty1 = Math.round(ty1);
|
||||
|
||||
tx2 = Math.round(tx2);
|
||||
ty2 = Math.round(ty2);
|
||||
|
||||
tx3 = Math.round(tx3);
|
||||
ty3 = Math.round(ty3);
|
||||
}
|
||||
|
||||
var tint = getTint(particle.tint, alpha);
|
||||
|
|
|
@ -362,17 +362,17 @@ var ForwardDiffuseLightPipeline = new Class({
|
|||
|
||||
if (camera.roundPixels)
|
||||
{
|
||||
tx0 |= 0;
|
||||
ty0 |= 0;
|
||||
tx0 = Math.round(tx0);
|
||||
ty0 = Math.round(ty0);
|
||||
|
||||
tx1 |= 0;
|
||||
ty1 |= 0;
|
||||
tx1 = Math.round(tx1);
|
||||
ty1 = Math.round(ty1);
|
||||
|
||||
tx2 |= 0;
|
||||
ty2 |= 0;
|
||||
tx2 = Math.round(tx2);
|
||||
ty2 = Math.round(ty2);
|
||||
|
||||
tx3 |= 0;
|
||||
ty3 |= 0;
|
||||
tx3 = Math.round(tx3);
|
||||
ty3 = Math.round(ty3);
|
||||
}
|
||||
|
||||
this.setTexture2D(texture, 0);
|
||||
|
|
|
@ -606,17 +606,17 @@ var TextureTintPipeline = new Class({
|
|||
|
||||
if (camera.roundPixels)
|
||||
{
|
||||
tx0 |= 0;
|
||||
ty0 |= 0;
|
||||
tx0 = Math.round(tx0);
|
||||
ty0 = Math.round(ty0);
|
||||
|
||||
tx1 |= 0;
|
||||
ty1 |= 0;
|
||||
tx1 = Math.round(tx1);
|
||||
ty1 = Math.round(ty1);
|
||||
|
||||
tx2 |= 0;
|
||||
ty2 |= 0;
|
||||
tx2 = Math.round(tx2);
|
||||
ty2 = Math.round(ty2);
|
||||
|
||||
tx3 |= 0;
|
||||
ty3 |= 0;
|
||||
tx3 = Math.round(tx3);
|
||||
ty3 = Math.round(ty3);
|
||||
}
|
||||
|
||||
this.setTexture2D(texture, 0);
|
||||
|
@ -971,17 +971,17 @@ var TextureTintPipeline = new Class({
|
|||
|
||||
if (camera.roundPixels)
|
||||
{
|
||||
tx0 |= 0;
|
||||
ty0 |= 0;
|
||||
tx0 = Math.round(tx0);
|
||||
ty0 = Math.round(ty0);
|
||||
|
||||
tx1 |= 0;
|
||||
ty1 |= 0;
|
||||
tx1 = Math.round(tx1);
|
||||
ty1 = Math.round(ty1);
|
||||
|
||||
tx2 |= 0;
|
||||
ty2 |= 0;
|
||||
tx2 = Math.round(tx2);
|
||||
ty2 = Math.round(ty2);
|
||||
|
||||
tx3 |= 0;
|
||||
ty3 |= 0;
|
||||
tx3 = Math.round(tx3);
|
||||
ty3 = Math.round(ty3);
|
||||
}
|
||||
|
||||
this.setTexture2D(texture, 0);
|
||||
|
|
|
@ -661,17 +661,17 @@ var StaticTilemapLayer = new Class({
|
|||
|
||||
if (camera.roundPixels)
|
||||
{
|
||||
tx0 |= 0;
|
||||
ty0 |= 0;
|
||||
tx0 = Math.round(tx0);
|
||||
ty0 = Math.round(ty0);
|
||||
|
||||
tx1 |= 0;
|
||||
ty1 |= 0;
|
||||
tx1 = Math.round(tx1);
|
||||
ty1 = Math.round(ty1);
|
||||
|
||||
tx2 |= 0;
|
||||
ty2 |= 0;
|
||||
tx2 = Math.round(tx2);
|
||||
ty2 = Math.round(ty2);
|
||||
|
||||
tx3 |= 0;
|
||||
ty3 |= 0;
|
||||
tx3 = Math.round(tx3);
|
||||
ty3 = Math.round(ty3);
|
||||
}
|
||||
|
||||
var vertexViewF32 = this.vertexViewF32[tilesetIndex];
|
||||
|
|
Loading…
Add table
Reference in a new issue