Allow GameObjects to set their own BatchHandler render nodes.

This commit is contained in:
Ben Richards 2024-07-11 15:47:53 +12:00
parent 570533a705
commit abace16646
8 changed files with 30 additions and 14 deletions

View file

@ -35,8 +35,8 @@ var BatchHandlerQuadLight = require('./BatchHandlerQuadLight');
* @memberof Phaser.Renderer.WebGL.RenderNodes
* @constructor
* @since 3.90.0
* @param {Phaser.Renderer.WebGL.WebGLRenderer} manager - The WebGLRenderer instance that owns this handler.
* @param {Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig} config - The configuration object for this handler.
* @param {Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager} manager - The manager that owns this RenderNode.
* @param {Phaser.Types.Renderer.WebGL.RenderNodes.BatchHandlerConfig} [config] - The configuration object for this handler.
*/
var BatchHandlerQuadLightShadow = new Class({
Extends: BatchHandlerQuadLight,

View file

@ -8,7 +8,9 @@ var Map = require('../../../../structs/Map');
var DefaultBitmapTextNodes = new Map([
[ 'Submitter', 'SubmitterQuad' ],
[ 'SubmitterLight', 'SubmitterQuadLight' ]
[ 'SubmitterLight', 'SubmitterQuadLight' ],
[ 'BatchHandler', 'BatchHandlerQuad' ],
[ 'BatchHandlerLight', 'BatchHandlerQuadLight' ]
]);
module.exports = DefaultBitmapTextNodes;

View file

@ -8,7 +8,9 @@ var Map = require('../../../../structs/Map');
var DefaultBlitterNodes = new Map([
[ 'Submitter', 'SubmitterQuad' ],
[ 'SubmitterLight', 'SubmitterQuadLight' ]
[ 'SubmitterLight', 'SubmitterQuadLight' ],
[ 'BatchHandler', 'BatchHandlerQuad' ],
[ 'BatchHandlerLight', 'BatchHandlerQuadLight' ]
]);
module.exports = DefaultBlitterNodes;

View file

@ -9,6 +9,8 @@ var Map = require('../../../../structs/Map');
var DefaultImageNodes = new Map([
[ 'Submitter', 'SubmitterQuad' ],
[ 'SubmitterLight', 'SubmitterQuadLight' ],
[ 'BatchHandler', 'BatchHandlerQuad' ],
[ 'BatchHandlerLight', 'BatchHandlerQuadLight' ],
[ 'Transformer', 'TransformerImage' ],
[ 'Texturer', 'TexturerImage' ]
]);

View file

@ -8,7 +8,9 @@ var Map = require('../../../../structs/Map');
var DefaultParticleEmitterNodes = new Map([
[ 'Submitter', 'SubmitterQuad' ],
[ 'SubmitterLight', 'SubmitterQuadLight' ]
[ 'SubmitterLight', 'SubmitterQuadLight' ],
[ 'BatchHandler', 'BatchHandlerQuad' ],
[ 'BatchHandlerLight', 'BatchHandlerQuadLight' ]
]);
module.exports = DefaultParticleEmitterNodes;

View file

@ -9,6 +9,8 @@ var Map = require('../../../../structs/Map');
var DefaultTilemapLayerNodes = new Map([
[ 'Submitter', 'SubmitterQuad' ],
[ 'SubmitterLight', 'SubmitterQuadLight' ],
[ 'BatchHandler', 'BatchHandlerQuad' ],
[ 'BatchHandlerLight', 'BatchHandlerQuadLight' ],
[ 'Transformer', 'TransformerTile' ]
]);

View file

@ -32,7 +32,7 @@ var getTint = Utils.getTintAppendFloatAlpha;
* @param {object} [config] - The configuration object for this RenderNode.
* @param {string} [config.name='SubmitterQuad'] - The name of this RenderNode.
* @param {string} [config.role='Submitter'] - The expected role of this RenderNode.
* @param {string} [config.batchHandler='BatchHandlerQuad'] - The key of the default batch handler node to use for this RenderNode. This should correspond to a node which extends `BatchHandlerQuad`.
* @param {string} [config.batchHandler='BatchHandler'] - The key of the default batch handler node to use for this RenderNode. This should correspond to a node which extends `BatchHandlerQuad`. It will be derived from the game object whenever the node runs.
*/
var SubmitterQuad = new Class({
Extends: RenderNode,
@ -44,13 +44,13 @@ var SubmitterQuad = new Class({
RenderNode.call(this, config.name, manager);
/**
* The RenderNode used to render data.
* The key of the RenderNode used to render data.
*
* @name Phaser.Renderer.WebGL.RenderNodes.SubmitterQuad#batchHandler
* @type {Phaser.Renderer.WebGL.RenderNodes.BatchHandler}
* @type {string}
* @since 3.90.0
*/
this.batchHandler = manager.getNode(config.batchHandler);
this.batchHandler = config.batchHandler;
},
/**
@ -62,7 +62,7 @@ var SubmitterQuad = new Class({
defaultConfig: {
name: 'SubmitterQuad',
role: 'Submitter',
batchHandler: 'BatchHandlerQuad'
batchHandler: 'BatchHandler'
},
/**
@ -129,7 +129,10 @@ var SubmitterQuad = new Class({
var u1 = uvSource.u1;
var v1 = uvSource.v1;
this.batchHandler.batch(
(
gameObject.customRenderNodes[this.batchHandler] ||
gameObject.defaultRenderNodes[this.batchHandler]
).batch(
drawingContext,
// Use `frame.source.glTexture` instead of `frame.glTexture`

View file

@ -27,7 +27,7 @@ var getTint = Utils.getTintAppendFloatAlpha;
* @param {object} [config] - The configuration object for this RenderNode.
* @param {string} [config.name='SubmitterQuadLight'] - The name of this RenderNode.
* @param {string} [config.role='Submitter'] - The expected role of this RenderNode.
* @param {string} [config.batchHandler='BatchHandlerQuadLight'] - The key of the default batch handler node to use for this RenderNode. This should correspond to a node which extends `BatchHandlerQuadLight`.
* @param {string} [config.batchHandler='BatchHandlerLight'] - The key of the default batch handler node to use for this RenderNode. This should correspond to a node which extends `BatchHandlerQuadLight`. It will be derived from the game object whenever the node runs.
*/
var SubmitterQuadLight = new Class({
Extends: SubmitterQuad,
@ -42,7 +42,7 @@ var SubmitterQuadLight = new Class({
defaultConfig: {
name: 'SubmitterQuadLight',
role: 'Submitter',
batchHandler: 'BatchHandlerQuadLight'
batchHandler: 'BatchHandlerLight'
},
/**
@ -164,7 +164,10 @@ var SubmitterQuadLight = new Class({
}
// Batch the quad.
this.batchHandler.batch(
(
gameObject.customRenderNodes[this.batchHandler] ||
gameObject.defaultRenderNodes[this.batchHandler]
).batch(
drawingContext,
// Use `frame.source.glTexture` instead of `frame.glTexture`