Disallow concave shapes as geometry.

This commit is contained in:
vrld
2013-05-12 13:01:05 +02:00
parent d454be7025
commit e9d0204cdc
6 changed files with 40 additions and 71 deletions
+2 -2
View File
@@ -592,7 +592,7 @@ void Canvas::drawg(love::graphics::Geometry *geom, float x, float y, float angle
t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
// flip texture coordinates vertically
size_t vcount = geom->getVertexArraySize();
size_t vcount = geom->getVertexCount();
const vertex *w = geom->getVertexArray();
vertex *v = new vertex[vcount];
for (size_t i = 0; i < vcount; ++i)
@@ -608,7 +608,7 @@ void Canvas::drawg(love::graphics::Geometry *geom, float x, float y, float angle
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *)&v->r);
}
drawv(t, v, vcount, GL_TRIANGLES);
drawv(t, v, vcount, GL_TRIANGLE_FAN);
if (geom->hasVertexColors())
{
+1 -1
View File
@@ -115,7 +115,7 @@ void Image::drawg(love::graphics::Geometry *geom, float x, float y, float angle,
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *) &v[0].r);
}
drawv(t, v, geom->getVertexArraySize(), GL_TRIANGLES);
drawv(t, v, geom->getVertexCount(), GL_TRIANGLE_FAN);
if (geom->hasVertexColors())
{
+1 -1
View File
@@ -123,7 +123,7 @@ int SpriteBatch::addg(Geometry *geom, float x, float y, float a, float sx, float
if ((index == -1 && next >= size) || index < -1 || index >= next)
return -1;
if (geom->getNumVertices() != 4)
if (geom->getVertexCount() != 4)
throw love::Exception("Can only add quadliteral geometries to SpriteBatch");
for (size_t i = 0; i < 4; i++)
@@ -38,7 +38,7 @@ Geometry *luax_checkgeometry(lua_State *L, int idx)
int w_Geometry_getVertexCount(lua_State *L)
{
Geometry *geom = luax_checkgeometry(L, 1);
lua_pushinteger(L, geom->getNumVertices());
lua_pushinteger(L, geom->getVertexCount());
return 1;
}