BaseCamera.renderRoundPixels is a new read-only property that is set during the Camera preRender method every frame. It is true if the Camera is set to render round pixels and the zoom values are integers, otherwise it is false. This is then fed into the MultiPipeline when rendering sprites and textures.

This commit is contained in:
Richard Davey 2024-10-11 00:08:00 +01:00
parent 13177a4e4a
commit 8e432aee8d
No known key found for this signature in database
2 changed files with 20 additions and 1 deletions

View file

@ -517,6 +517,22 @@ var BaseCamera = new Class({
* @since 3.60.0
*/
this.isSceneCamera = true;
/**
* Can this Camera render rounded pixel values?
*
* This property is updated during the `preRender` method and should not be
* set directly. It is set based on the `roundPixels` property of the Camera
* combined with the zoom level. If the zoom is an integer then the WebGL
* Renderer can apply rounding during rendering.
*
* @name Phaser.Cameras.Scene2D.BaseCamera#renderRoundPixels
* @type {boolean}
* @readonly
* @default true
* @since 3.86.0
*/
this.renderRoundPixels = true;
},
/**

View file

@ -501,6 +501,8 @@ var Camera = new Class({
var zoomY = this.zoomY;
var matrix = this.matrix;
this.renderRoundPixels = (this.roundPixels && Number.isInteger(zoomX) && Number.isInteger(zoomY));
var originX = width * this.originX;
var originY = height * this.originY;
@ -589,7 +591,8 @@ var Camera = new Class({
Math.floor(this.x + originX + 0.5),
Math.floor(this.y + originY + 0.5),
this.rotation,
zoomX, zoomY);
zoomX, zoomY
);
matrix.translate(-originX, -originY);