|
@@ -123,11 +123,14 @@ int SpriteBatch::addg(Geometry *geom, float x, float y, float a, float sx, float
|
|
if ((index == -1 && next >= size) || index < -1 || index >= next)
|
|
if ((index == -1 && next >= size) || index < -1 || index >= next)
|
|
return -1;
|
|
return -1;
|
|
|
|
|
|
- if (geom->getVertexCount() != 4)
|
|
|
|
- throw love::Exception("Can only add quadrilateral geometries to SpriteBatch");
|
|
|
|
|
|
+ size_t vertexcount = geom->getVertexCount();
|
|
|
|
+ if (vertexcount > 4)
|
|
|
|
+ throw love::Exception("Cannot add Geometries with more than 4 vertices to SpriteBatch");
|
|
|
|
|
|
|
|
+ // If the Geometry has 3 vertices, then 2 triangles will be rendered in the
|
|
|
|
+ // SpriteBatch: 0-1-2 and 0-2-0. 0-2-0 will get ignored during rasterization.
|
|
for (size_t i = 0; i < 4; i++)
|
|
for (size_t i = 0; i < 4; i++)
|
|
- sprite[i] = geom->getVertex(i);
|
|
|
|
|
|
+ sprite[i] = geom->getVertex(i % vertexcount);
|
|
|
|
|
|
// Transform.
|
|
// Transform.
|
|
static Matrix t;
|
|
static Matrix t;
|
|
@@ -140,6 +143,10 @@ int SpriteBatch::addg(Geometry *geom, float x, float y, float a, float sx, float
|
|
|
|
|
|
addv(sprite, (index == -1) ? next : index);
|
|
addv(sprite, (index == -1) ? next : index);
|
|
|
|
|
|
|
|
+ // Make sure SpriteBatch colors are enabled if the Geometry has custom colors.
|
|
|
|
+ if (!color && geom->hasVertexColors())
|
|
|
|
+ setColor(Color(255, 255, 255, 255));
|
|
|
|
+
|
|
// Increment counter.
|
|
// Increment counter.
|
|
if (index == -1)
|
|
if (index == -1)
|
|
return next++;
|
|
return next++;
|