Reverted PR #5219 because it breaks camera zooming on tilemaps

This commit is contained in:
Richard Davey 2020-07-14 08:47:52 +01:00
parent f45bde13e1
commit 2a2a2eafe8

View file

@ -6,10 +6,10 @@
/**
* Renders this Game Object with the WebGL Renderer to the given Camera.
*
*
* The object will not render if any of its renderFlags are set or it is being actively filtered out by the Camera.
* This method should not be called directly. It is a utility function of the Render module.
*
*
* A Static Tilemap Layer renders immediately and does not use any batching.
*
* @method Phaser.Tilemaps.StaticTilemapLayer#renderWebGL
@ -20,9 +20,8 @@
* @param {Phaser.Tilemaps.StaticTilemapLayer} src - The Game Object being rendered in this call.
* @param {number} interpolationPercentage - Reserved for future use and custom pipelines.
* @param {Phaser.Cameras.Scene2D.Camera} camera - The Camera that is rendering the Game Object.
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - This transform matrix is defined if the game object is nested
*/
var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera, parentMatrix)
var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPercentage, camera)
{
var tilesets = src.tileset;
@ -31,42 +30,9 @@ var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPerc
renderer.setPipeline(pipeline);
var camMatrix = renderer._tempMatrix1;
var layerMatrix = renderer._tempMatrix2;
var calcMatrix = renderer._tempMatrix3;
layerMatrix.applyITRS(src.x, src.y, src.rotation, src.scaleX, src.scaleY);
camMatrix.copyFrom(camera.matrix);
if (parentMatrix)
{
// Multiply the camera by the parent matrix
camMatrix.multiplyWithOffset(parentMatrix, -camera.scrollX * src.scrollFactorX, -camera.scrollY * src.scrollFactorY);
// Undo the camera scroll
layerMatrix.e = src.x;
layerMatrix.f = src.y;
// Multiply by the layer matrix, store result in calcMatrix
camMatrix.multiply(layerMatrix, calcMatrix);
}
else
{
layerMatrix.e -= camera.scrollX * src.scrollFactorX;
layerMatrix.f -= camera.scrollY * src.scrollFactorY;
// Multiply by the layer matrix, store result in calcMatrix
camMatrix.multiply(layerMatrix, calcMatrix);
}
var modelMatrix = pipeline.modelIdentity().modelMatrix;
modelMatrix[0] = calcMatrix.a;
modelMatrix[1] = calcMatrix.b;
modelMatrix[4] = calcMatrix.c;
modelMatrix[5] = calcMatrix.d;
modelMatrix[12] = calcMatrix.e;
modelMatrix[13] = calcMatrix.f;
pipeline.modelIdentity();
pipeline.modelTranslate(src.x - (camera.scrollX * src.scrollFactorX), src.y - (camera.scrollY * src.scrollFactorY), 0);
pipeline.modelScale(src.scaleX, src.scaleY, 1);
pipeline.viewLoad2D(camera.matrix.matrix);
@ -80,13 +46,13 @@ var StaticTilemapLayerWebGLRenderer = function (renderer, src, interpolationPerc
{
renderer.flush();
}
pipeline.vertexBuffer = src.vertexBuffer[i];
renderer.setPipeline(pipeline);
renderer.setTexture2D(tilesets[i].glTexture, 0);
renderer.gl.drawArrays(pipeline.topology, 0, src.vertexCount[i]);
}
}