Skip to content

Commit aef538d

Browse files
committed
Added parent transform matrix to Light2D pipieline to allow support for containers
1 parent e25f420 commit aef538d

1 file changed

Lines changed: 40 additions & 30 deletions

File tree

src/renderer/webgl/pipelines/ForwardDiffuseLightPipeline.js

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -127,22 +127,23 @@ var ForwardDiffuseLightPipeline = new Class({
127127
*
128128
* @param {Phaser.Tilemaps.StaticTilemapLayer} tilemap - [description]
129129
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
130+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
130131
*
131132
*/
132-
drawStaticTilemapLayer: function (tilemap, camera)
133+
drawStaticTilemapLayer: function (tilemap, camera, parentTransformMatrix)
133134
{
134135
var normalTexture = tilemap.texture.dataSource[0];
135136

136137
if (normalTexture)
137138
{
138139
this.renderer.setPipeline(this);
139140
this.setTexture2D(normalTexture.glTexture, 1);
140-
TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera);
141+
TextureTintPipeline.prototype.drawStaticTilemapLayer.call(this, tilemap, camera, parentTransformMatrix);
141142
}
142143
else
143144
{
144145
console.warn('Normal map texture missing for using Light2D pipeline. StaticTilemapLayer rendered with default pipeline.');
145-
this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera);
146+
this.renderer.pipelines.TextureTintPipeline.drawStaticTilemapLayer(tilemap, camera, parentTransformMatrix);
146147
}
147148
},
148149

@@ -154,22 +155,23 @@ var ForwardDiffuseLightPipeline = new Class({
154155
*
155156
* @param {Phaser.GameObjects.Particles.ParticleEmitterManager} emitterManager - [description]
156157
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
158+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
157159
*
158160
*/
159-
drawEmitterManager: function (emitterManager, camera)
161+
drawEmitterManager: function (emitterManager, camera, parentTransformMatrix)
160162
{
161163
var normalTexture = emitterManager.texture.dataSource[0];
162164

163165
if (normalTexture)
164166
{
165167
this.renderer.setPipeline(this);
166168
this.setTexture2D(normalTexture.glTexture, 1);
167-
TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera);
169+
TextureTintPipeline.prototype.drawEmitterManager.call(this, emitterManager, camera, parentTransformMatrix);
168170
}
169171
else
170172
{
171173
console.warn('Normal map texture missing for using Light2D pipeline. EmitterManager rendered with default pipeline.');
172-
this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera);
174+
this.renderer.pipelines.TextureTintPipeline.drawEmitterManager(emitterManager, camera, parentTransformMatrix);
173175
}
174176
},
175177

@@ -181,22 +183,23 @@ var ForwardDiffuseLightPipeline = new Class({
181183
*
182184
* @param {Phaser.GameObjects.Blitter} blitter - [description]
183185
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
186+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
184187
*
185188
*/
186-
drawBlitter: function (blitter, camera)
189+
drawBlitter: function (blitter, camera, parentTransformMatrix)
187190
{
188191
var normalTexture = blitter.texture.dataSource[0];
189192

190193
if (normalTexture)
191194
{
192195
this.renderer.setPipeline(this);
193196
this.setTexture2D(normalTexture.glTexture, 1);
194-
TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera);
197+
TextureTintPipeline.prototype.drawBlitter.call(this, blitter, camera, parentTransformMatrix);
195198
}
196199
else
197200
{
198201
console.warn('Normal map texture missing for using Light2D pipeline. Blitter rendered with default pipeline.');
199-
this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera);
202+
this.renderer.pipelines.TextureTintPipeline.drawBlitter(blitter, camera, parentTransformMatrix);
200203
}
201204
},
202205

@@ -208,22 +211,23 @@ var ForwardDiffuseLightPipeline = new Class({
208211
*
209212
* @param {Phaser.GameObjects.Sprite} sprite - [description]
210213
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
214+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
211215
*
212216
*/
213-
batchSprite: function (sprite, camera)
217+
batchSprite: function (sprite, camera, parentTransformMatrix)
214218
{
215219
var normalTexture = sprite.texture.dataSource[0];
216220

217221
if (normalTexture)
218222
{
219223
this.renderer.setPipeline(this);
220224
this.setTexture2D(normalTexture.glTexture, 1);
221-
TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera);
225+
TextureTintPipeline.prototype.batchSprite.call(this, sprite, camera, parentTransformMatrix);
222226
}
223227
else
224228
{
225229
console.warn('Normal map texture missing for using Light2D pipeline. Sprite rendered with default pipeline.');
226-
this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera);
230+
this.renderer.pipelines.TextureTintPipeline.batchSprite(sprite, camera, parentTransformMatrix);
227231
}
228232
},
229233

@@ -235,22 +239,23 @@ var ForwardDiffuseLightPipeline = new Class({
235239
*
236240
* @param {Phaser.GameObjects.Mesh} mesh - [description]
237241
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
242+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
238243
*
239244
*/
240-
batchMesh: function (mesh, camera)
245+
batchMesh: function (mesh, camera, parentTransformMatrix)
241246
{
242247
var normalTexture = mesh.texture.dataSource[0];
243248

244249
if (normalTexture)
245250
{
246251
this.renderer.setPipeline(this);
247252
this.setTexture2D(normalTexture.glTexture, 1);
248-
TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera);
253+
TextureTintPipeline.prototype.batchMesh.call(this, mesh, camera, parentTransformMatrix);
249254
}
250255
else
251256
{
252257
console.warn('Normal map texture missing for using Light2D pipeline. Mesh rendered with default pipeline.');
253-
this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera);
258+
this.renderer.pipelines.TextureTintPipeline.batchMesh(mesh, camera, parentTransformMatrix);
254259

255260
}
256261
},
@@ -263,22 +268,23 @@ var ForwardDiffuseLightPipeline = new Class({
263268
*
264269
* @param {Phaser.GameObjects.BitmapText} bitmapText - [description]
265270
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
271+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
266272
*
267273
*/
268-
batchBitmapText: function (bitmapText, camera)
274+
batchBitmapText: function (bitmapText, camera, parentTransformMatrix)
269275
{
270276
var normalTexture = bitmapText.texture.dataSource[0];
271277

272278
if (normalTexture)
273279
{
274280
this.renderer.setPipeline(this);
275281
this.setTexture2D(normalTexture.glTexture, 1);
276-
TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera);
282+
TextureTintPipeline.prototype.batchBitmapText.call(this, bitmapText, camera, parentTransformMatrix);
277283
}
278284
else
279285
{
280286
console.warn('Normal map texture missing for using Light2D pipeline. BitmapText rendered with default pipeline.');
281-
this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera);
287+
this.renderer.pipelines.TextureTintPipeline.batchBitmapText(bitmapText, camera, parentTransformMatrix);
282288
}
283289
},
284290

@@ -290,22 +296,23 @@ var ForwardDiffuseLightPipeline = new Class({
290296
*
291297
* @param {Phaser.GameObjects.DynamicBitmapText} bitmapText - [description]
292298
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
299+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
293300
*
294301
*/
295-
batchDynamicBitmapText: function (bitmapText, camera)
302+
batchDynamicBitmapText: function (bitmapText, camera, parentTransformMatrix)
296303
{
297304
var normalTexture = bitmapText.texture.dataSource[0];
298305

299306
if (normalTexture)
300307
{
301308
this.renderer.setPipeline(this);
302309
this.setTexture2D(normalTexture.glTexture, 1);
303-
TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera);
310+
TextureTintPipeline.prototype.batchDynamicBitmapText.call(this, bitmapText, camera, parentTransformMatrix);
304311
}
305312
else
306313
{
307314
console.warn('Normal map texture missing for using Light2D pipeline. DynamicBitmapText rendered with default pipeline.');
308-
this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera);
315+
this.renderer.pipelines.TextureTintPipeline.batchDynamicBitmapText(bitmapText, camera, parentTransformMatrix);
309316
}
310317
},
311318

@@ -317,22 +324,23 @@ var ForwardDiffuseLightPipeline = new Class({
317324
*
318325
* @param {Phaser.GameObjects.Text} text - [description]
319326
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
327+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
320328
*
321329
*/
322-
batchText: function (text, camera)
330+
batchText: function (text, camera, parentTransformMatrix)
323331
{
324332
var normalTexture = text.texture.dataSource[0];
325333

326334
if (normalTexture)
327335
{
328336
this.renderer.setPipeline(this);
329337
this.setTexture2D(normalTexture.glTexture, 1);
330-
TextureTintPipeline.prototype.batchText.call(this, text, camera);
338+
TextureTintPipeline.prototype.batchText.call(this, text, camera, parentTransformMatrix);
331339
}
332340
else
333341
{
334342
console.warn('Normal map texture missing for using Light2D pipeline. Text rendered with default pipeline.');
335-
this.renderer.pipelines.TextureTintPipeline.batchText(text, camera);
343+
this.renderer.pipelines.TextureTintPipeline.batchText(text, camera, parentTransformMatrix);
336344
}
337345
},
338346

@@ -344,22 +352,23 @@ var ForwardDiffuseLightPipeline = new Class({
344352
*
345353
* @param {Phaser.Tilemaps.DynamicTilemapLayer} tilemapLayer - [description]
346354
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
355+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
347356
*
348357
*/
349-
batchDynamicTilemapLayer: function (tilemapLayer, camera)
358+
batchDynamicTilemapLayer: function (tilemapLayer, camera, parentTransformMatrix)
350359
{
351360
var normalTexture = tilemapLayer.texture.dataSource[0];
352361

353362
if (normalTexture)
354363
{
355364
this.renderer.setPipeline(this);
356365
this.setTexture2D(normalTexture.glTexture, 1);
357-
TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera);
366+
TextureTintPipeline.prototype.batchDynamicTilemapLayer.call(this, tilemapLayer, camera, parentTransformMatrix);
358367
}
359368
else
360369
{
361370
console.warn('Normal map texture missing for using Light2D pipeline. DynamicTilemapLayer rendered with default pipeline.');
362-
this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera);
371+
this.renderer.pipelines.TextureTintPipeline.batchDynamicTilemapLayer(tilemapLayer, camera, parentTransformMatrix);
363372
}
364373
},
365374

@@ -371,22 +380,23 @@ var ForwardDiffuseLightPipeline = new Class({
371380
*
372381
* @param {Phaser.GameObjects.TileSprite} tileSprite - [description]
373382
* @param {Phaser.Cameras.Scene2D.Camera} camera - [description]
383+
* @param {Phaser.GameObjects.Components.TransformMatrix} parentTransformMatrix - [description]
374384
*
375385
*/
376-
batchTileSprite: function (tileSprite, camera)
386+
batchTileSprite: function (tileSprite, camera, parentTransformMatrix)
377387
{
378388
var normalTexture = tileSprite.texture.dataSource[0];
379389

380390
if (normalTexture)
381391
{
382392
this.renderer.setPipeline(this);
383393
this.setTexture2D(normalTexture.glTexture, 1);
384-
TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera);
394+
TextureTintPipeline.prototype.batchTileSprite.call(this, tileSprite, camera, parentTransformMatrix);
385395
}
386396
else
387397
{
388398
console.warn('Normal map texture missing for using Light2D pipeline. TileSprite rendered with default pipeline.');
389-
this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera);
399+
this.renderer.pipelines.TextureTintPipeline.batchTileSprite(tileSprite, camera, parentTransformMatrix);
390400
}
391401
}
392402

0 commit comments

Comments
 (0)