Skip to content

Commit 6aba9e7

Browse files
committed
All Shape Game Objects (Rectangle, IsoBox, Star, Polygon, etc) now support rendering in Light2d.
1 parent 786f78e commit 6aba9e7

4 files changed

Lines changed: 18 additions & 32 deletions

File tree

src/gameobjects/shape/FillPathWebGL.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var FillPathWebGL = function (pipeline, calcMatrix, src, alpha, dx, dy)
4848

4949
var tx2 = calcMatrix.getX(x2, y2);
5050
var ty2 = calcMatrix.getY(x2, y2);
51-
51+
5252
pipeline.setTexture2D();
5353

5454
pipeline.batchTri(tx0, ty0, tx1, ty1, tx2, ty2, 0, 0, 1, 1, fillTintColor, fillTintColor, fillTintColor, pipeline.tintEffect);

src/gameobjects/shape/grid/GridWebGLRenderer.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
8686
var cw = 0;
8787
var ch = 0;
8888

89+
pipeline.setTexture2D();
90+
8991
if (showOutline)
9092
{
9193
// To make room for the grid lines (in case alpha < 1)
@@ -107,7 +109,7 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
107109
{
108110
fillTint = pipeline.fillTint;
109111
fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.fillColor, src.fillAlpha * alpha);
110-
112+
111113
fillTint.TL = fillTintColor;
112114
fillTint.TR = fillTintColor;
113115
fillTint.BL = fillTintColor;
@@ -133,8 +135,6 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
133135
cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB;
134136
ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB;
135137

136-
pipeline.setTexture2D();
137-
138138
pipeline.batchFillRect(
139139
x * cellWidth,
140140
y * cellHeight,
@@ -149,7 +149,7 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
149149
{
150150
fillTint = pipeline.fillTint;
151151
fillTintColor = Utils.getTintAppendFloatAlphaAndSwap(src.altFillColor, src.altFillAlpha * alpha);
152-
152+
153153
fillTint.TL = fillTintColor;
154154
fillTint.TR = fillTintColor;
155155
fillTint.BL = fillTintColor;
@@ -175,8 +175,6 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
175175
cw = (x < gridWidth - 1) ? cellWidthA : cellWidthB;
176176
ch = (y < gridHeight - 1) ? cellHeightA : cellHeightB;
177177

178-
pipeline.setTexture2D();
179-
180178
pipeline.batchFillRect(
181179
x * cellWidth,
182180
y * cellHeight,
@@ -201,17 +199,13 @@ var GridWebGLRenderer = function (renderer, src, interpolationPercentage, camera
201199
{
202200
var x1 = x * cellWidth;
203201

204-
pipeline.setTexture2D();
205-
206202
pipeline.batchLine(x1, 0, x1, height, 1, 1, 1, 0, false);
207203
}
208204

209205
for (y = 1; y < gridHeight; y++)
210206
{
211207
var y1 = y * cellHeight;
212208

213-
pipeline.setTexture2D();
214-
215209
pipeline.batchLine(0, y1, width, y1, 1, 1, 1, 0, false);
216210
}
217211
}

src/gameobjects/shape/isobox/IsoBoxWebGLRenderer.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, came
7979
var x3;
8080
var y3;
8181

82+
pipeline.setTexture2D();
83+
8284
// Top Face
8385

8486
if (src.showTop)
@@ -87,18 +89,16 @@ var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, came
8789

8890
x0 = calcMatrix.getX(-sizeA, -height);
8991
y0 = calcMatrix.getY(-sizeA, -height);
90-
92+
9193
x1 = calcMatrix.getX(0, -sizeB - height);
9294
y1 = calcMatrix.getY(0, -sizeB - height);
93-
95+
9496
x2 = calcMatrix.getX(sizeA, -height);
9597
y2 = calcMatrix.getY(sizeA, -height);
96-
98+
9799
x3 = calcMatrix.getX(0, sizeB - height);
98100
y3 = calcMatrix.getY(0, sizeB - height);
99101

100-
pipeline.setTexture2D();
101-
102102
pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2);
103103
}
104104

@@ -110,18 +110,16 @@ var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, came
110110

111111
x0 = calcMatrix.getX(-sizeA, 0);
112112
y0 = calcMatrix.getY(-sizeA, 0);
113-
113+
114114
x1 = calcMatrix.getX(0, sizeB);
115115
y1 = calcMatrix.getY(0, sizeB);
116-
116+
117117
x2 = calcMatrix.getX(0, sizeB - height);
118118
y2 = calcMatrix.getY(0, sizeB - height);
119-
119+
120120
x3 = calcMatrix.getX(-sizeA, -height);
121121
y3 = calcMatrix.getY(-sizeA, -height);
122122

123-
pipeline.setTexture2D();
124-
125123
pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2);
126124
}
127125

@@ -133,18 +131,16 @@ var IsoBoxWebGLRenderer = function (renderer, src, interpolationPercentage, came
133131

134132
x0 = calcMatrix.getX(sizeA, 0);
135133
y0 = calcMatrix.getY(sizeA, 0);
136-
134+
137135
x1 = calcMatrix.getX(0, sizeB);
138136
y1 = calcMatrix.getY(0, sizeB);
139-
137+
140138
x2 = calcMatrix.getX(0, sizeB - height);
141139
y2 = calcMatrix.getY(0, sizeB - height);
142-
140+
143141
x3 = calcMatrix.getX(sizeA, -height);
144142
y3 = calcMatrix.getY(sizeA, -height);
145143

146-
pipeline.setTexture2D();
147-
148144
pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2);
149145
}
150146
};

src/gameobjects/shape/isotriangle/IsoTriangleWebGLRenderer.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage,
7878
var x2;
7979
var y2;
8080

81+
pipeline.setTexture2D();
82+
8183
// Top Face
8284

8385
if (src.showTop && reversed)
@@ -96,8 +98,6 @@ var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage,
9698
var x3 = calcMatrix.getX(0, sizeB - height);
9799
var y3 = calcMatrix.getY(0, sizeB - height);
98100

99-
pipeline.setTexture2D();
100-
101101
pipeline.batchQuad(x0, y0, x1, y1, x2, y2, x3, y3, 0, 0, 1, 1, tint, tint, tint, tint, 2);
102102
}
103103

@@ -130,8 +130,6 @@ var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage,
130130
y2 = calcMatrix.getY(0, sizeB - height);
131131
}
132132

133-
pipeline.setTexture2D();
134-
135133
pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2);
136134
}
137135

@@ -164,8 +162,6 @@ var IsoTriangleWebGLRenderer = function (renderer, src, interpolationPercentage,
164162
y2 = calcMatrix.getY(0, sizeB - height);
165163
}
166164

167-
pipeline.setTexture2D();
168-
169165
pipeline.batchTri(x0, y0, x1, y1, x2, y2, 0, 0, 1, 1, tint, tint, tint, 2);
170166
}
171167
};

0 commit comments

Comments
 (0)