Commits

Alex Szpakowski committed ff82a75

The Vertex struct is now recognized as POD by C++, also fixed the name to be consistent with other love structs

  • Participants
  • Parent commits 0eac995

Comments (0)

Files changed (24)

src/common/Matrix.cpp

 // | e2 e6 e10 e14 |
 // | e3 e7 e11 e15 |
 
-void Matrix::transform(vertex *dst, const vertex *src, int size) const
+void Matrix::transform(Vertex *dst, const Vertex *src, int size) const
 {
 	for (int i = 0; i<size; i++)
 	{

src/common/Matrix.h

 	 * @param src The source vertices.
 	 * @param size The number of vertices.
 	 **/
-	void transform(vertex *dst, const vertex *src, int size) const;
+	void transform(Vertex *dst, const Vertex *src, int size) const;
 
 private:
 

src/common/math.h

 namespace love
 {
 
-struct vertex
+struct Vertex
 {
-	vertex()
-		: r(255), g(255), b(255), a(255)
-		, x(0), y(0)
-		, s(0), t(0)
-	{}
-
-	vertex(float x, float y,
-	       float s, float t)
-		: r(255), g(255), b(255), a(255)
-		, x(x), y(y)
-		, s(s), t(t)
-	{}
-
-	vertex(float x, float y,
-	       float s, float t,
-	       unsigned char r, unsigned char g, unsigned char b, unsigned char a)
-		: r(r), g(g), b(b), a(a)
-		, x(x), y(y)
-		, s(s), t(t)
-	{}
-
-	unsigned char r, g, b, a;
 	float x, y;
 	float s, t;
+	unsigned char r, g, b, a;
 };
 
 struct Triangle
 {
-	Triangle(const vertex &x, const vertex &y, const vertex &z)
+	Triangle(const Vertex &x, const Vertex &y, const Vertex &z)
 		: a(x), b(y), c(z)
 	{}
-	vertex a, b, c;
+	Vertex a, b, c;
 };
 
 inline int next_p2(int x)

src/modules/graphics/Geometry.cpp

 namespace graphics
 {
 
-Geometry::Geometry(const std::vector<vertex> &polygon, const std::vector<uint16> &elements, Geometry::DrawMode mode)
+Geometry::Geometry(const std::vector<Vertex> &polygon, const std::vector<uint16> &elements, Geometry::DrawMode mode)
 	: vertexArray(NULL)
 	, vertexCount(polygon.size())
 	, elementArray(NULL)
 			throw love::Exception("Invalid vertex map value");
 	}
 
-	vertexArray = new vertex[vertexCount];
-	memcpy(vertexArray, &polygon[0], vertexCount * sizeof(vertex));
+	vertexArray = new Vertex[vertexCount];
+	memcpy(vertexArray, &polygon[0], vertexCount * sizeof(Vertex));
 
 	if (elementCount > 0)
 	{
 	, vertexColors(false)
 	, drawMode(DRAW_MODE_FAN)
 {
-	vertexArray = new vertex[4];
 	float s0 = x/sw, s1 = (x+w)/sw, t0 = y/sh, t1 = (y+h)/sh;
-	vertexArray[0] = vertex(0,0, s0,t0);
-	vertexArray[1] = vertex(w,0, s1,t0);
-	vertexArray[2] = vertex(w,h, s1,t1);
-	vertexArray[3] = vertex(0,h, s0,t1);
+
+	Vertex verts[4] = {
+		{0,0, s0,t0, 255, 255, 255, 255},
+		{w,0, s1,t0, 255, 255, 255, 255},
+		{w,h, s1,t1, 255, 255, 255, 255},
+		{0,h, s0,t1, 255, 255, 255, 255}
+	};
+
+	vertexArray = new Vertex[4];
+
+	for (int i = 0; i < 4; i++)
+		vertexArray[i] = verts[i];
 }
 
 Geometry::Geometry(const Geometry &other)
 	, vertexColors(other.vertexColors)
 	, drawMode(other.drawMode)
 {
-	vertexArray = new vertex[vertexCount];
-	memcpy(vertexArray, other.vertexArray, vertexCount * sizeof(vertex));
+	vertexArray = new Vertex[vertexCount];
+	memcpy(vertexArray, other.vertexArray, vertexCount * sizeof(Vertex));
 
 	if (elementCount > 0)
 	{
 	delete[] elementArray;
 }
 
-const vertex &Geometry::getVertex(size_t i) const
+const Vertex &Geometry::getVertex(size_t i) const
 {
 	if (i >= vertexCount)
 		throw Exception("Invalid vertex index");
 	return vertexArray[i];
 }
 
-void Geometry::setVertex(size_t i, const vertex &v)
+void Geometry::setVertex(size_t i, const Vertex &v)
 {
 	if (i >= vertexCount)
 		throw Exception("Invalid vertex index");

src/modules/graphics/Geometry.h

 	/**
 	 * Creates a new geometry object from a std::vector<vertex>.
 	 **/
-	Geometry(const std::vector<vertex> &polygon, const std::vector<uint16> &elements, DrawMode mode = DRAW_MODE_FAN);
+	Geometry(const std::vector<Vertex> &polygon, const std::vector<uint16> &elements, DrawMode mode = DRAW_MODE_FAN);
 
 	/**
 	 * Creates a new geometry from (texture) quad information.
 	Geometry &operator=(const Geometry &other);
 	virtual ~Geometry();
 
-	const vertex &getVertex(size_t i) const;
-	void setVertex(size_t i, const vertex &v);
+	const Vertex &getVertex(size_t i) const;
+	void setVertex(size_t i, const Vertex &v);
 
 	/**
 	 * Returns a pointer to the vertex array.
 	 **/
-	inline const vertex *getVertexArray() const
+	inline const Vertex *getVertexArray() const
 	{
 		return vertexArray;
 	}
 
 private:
 
-	vertex *vertexArray;
+	Vertex *vertexArray;
 	size_t vertexCount;
 
 	uint16 *elementArray;

src/modules/graphics/opengl/Canvas.cpp

 
 	// flip texture coordinates vertically
 	size_t vcount = geom->getVertexCount();
-	const vertex *w = geom->getVertexArray();
-	vertex *v = new vertex[vcount];
+	const Vertex *w = geom->getVertexArray();
+	Vertex *v = new Vertex[vcount];
 	for (size_t i = 0; i < vcount; ++i)
 	{
 		v[i] = w[i];
 	if (geom->hasVertexColors())
 	{
 		glEnableClientState(GL_COLOR_ARRAY);
-		glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *)&v->r);
+		glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), (GLvoid *)&v->r);
 	}
 
 	GLenum glmode;
 	return height;
 }
 
-void Canvas::drawv(const Matrix &t, const vertex *v, GLsizei count, GLenum mode, const uint16 *e, GLsizei ecount) const
+void Canvas::drawv(const Matrix &t, const Vertex *v, GLsizei count, GLenum mode, const uint16 *e, GLsizei ecount) const
 {
 	glPushMatrix();
 
 	//      defined in the geometry to draw itself.
 	//      if the drawing method below is changed to use something other than
 	//      glDrawArrays(), drawg() needs to be updated accordingly!
-	glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&v[0].x);
-	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&v[0].s);
+	glVertexPointer(2, GL_FLOAT, sizeof(Vertex), (GLvoid *)&v[0].x);
+	glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (GLvoid *)&v[0].s);
 
 	if (e != 0 && ecount > 0)
 		glDrawElements(mode, ecount, GL_UNSIGNED_SHORT, (GLvoid *) e);

src/modules/graphics/opengl/Canvas.h

 
 	TextureType texture_type;
 
-	vertex vertices[4];
+	Vertex vertices[4];
 
 	GLenum status;
 
 	std::vector<Canvas *> attachedCanvases;
 
 	void setupGrab();
-	void drawv(const Matrix &t, const vertex *v, GLsizei count = 4, GLenum mode = GL_QUADS, const uint16 *e = 0, GLsizei ecount = 0) const;
+	void drawv(const Matrix &t, const Vertex *v, GLsizei count = 4, GLenum mode = GL_QUADS, const uint16 *e = 0, GLsizei ecount = 0) const;
 
 	static StringMap<TextureType, TYPE_MAX_ENUM>::Entry textureTypeEntries[];
 	static StringMap<TextureType, TYPE_MAX_ENUM> textureTypes;

src/modules/graphics/opengl/Font.cpp

 	g->texture = 0;
 	g->spacing = gd->getAdvance();
 
-	memset(g->vertices, 0, sizeof(vertex) * 4);
+	memset(g->vertices, 0, sizeof(GlyphVertex) * 4);
 
 	// don't waste space for empty glyphs. also fixes a division by zero bug with ati drivers
 	if (w > 0 && h > 0)
 
 		g->texture = t;
 
-		const vertex verts[4] = {
-			vertex(0, 0, float(textureX)/float(textureWidth),   float(textureY)/float(textureHeight)),
-			vertex(w, 0, float(textureX+w)/float(textureWidth), float(textureY)/float(textureHeight)),
-			vertex(w, h, float(textureX+w)/float(textureWidth), float(textureY+h)/float(textureHeight)),
-			vertex(0, h, float(textureX)/float(textureWidth),   float(textureY+h)/float(textureHeight)),
+		const GlyphVertex verts[4] = {
+			{0, 0, float(textureX)/float(textureWidth),   float(textureY)/float(textureHeight)},
+			{w, 0, float(textureX+w)/float(textureWidth), float(textureY)/float(textureHeight)},
+			{w, h, float(textureX+w)/float(textureWidth), float(textureY+h)/float(textureHeight)},
+			{0, h, float(textureX)/float(textureWidth),   float(textureY+h)/float(textureHeight)},
 		};
 
 		// copy vertex data to the glyph and set proper bearing
 	std::vector<GlyphArrayDrawInfo> glyphinfolist;
 
 	// Pre-allocate space for the maximum possible number of vertices.
-	std::vector<vertex> glyphverts;
+	std::vector<GlyphVertex> glyphverts;
 	glyphverts.reserve(text.length() * 4);
 
 	int vertexcount = 0;
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
-	glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&glyphverts[0].x);
-	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&glyphverts[0].s);
+	glVertexPointer(2, GL_FLOAT, sizeof(GlyphVertex), (GLvoid *)&glyphverts[0].x);
+	glTexCoordPointer(2, GL_FLOAT, sizeof(GlyphVertex), (GLvoid *)&glyphverts[0].s);
 
 	// We need to draw a new vertex array for every section of the string which
 	// uses a different texture than the previous section.

src/modules/graphics/opengl/Font.h

 		FONT_UNKNOWN
 	};
 
+	struct GlyphVertex
+	{
+		float x, y;
+		float s, t;
+	};
+
 	struct Glyph
 	{
 		GLuint texture;
 		int spacing;
-		vertex vertices[4];
+		GlyphVertex vertices[4];
 	};
 
 	// used to determine when to change textures in the vertex array generated when printing text

src/modules/graphics/opengl/Graphics.cpp

 	return image;
 }
 
-Geometry *Graphics::newGeometry(const std::vector<vertex> &vertices, const std::vector<uint16> &vertexmap, Geometry::DrawMode mode)
+Geometry *Graphics::newGeometry(const std::vector<Vertex> &vertices, const std::vector<uint16> &vertexmap, Geometry::DrawMode mode)
 {
 	return new Geometry(vertices, vertexmap, mode);
 }

src/modules/graphics/opengl/Graphics.h

 	/**
 	 * Creates a Geometry object.
 	 **/
-	Geometry *newGeometry(const std::vector<vertex> &vertices, const std::vector<uint16> &vertexmap, Geometry::DrawMode mode);
+	Geometry *newGeometry(const std::vector<Vertex> &vertices, const std::vector<uint16> &vertexmap, Geometry::DrawMode mode);
 
 	/**
 	 * Creates a quadliteral Geometry object.

src/modules/graphics/opengl/Image.cpp

 	return height;
 }
 
-const vertex *Image::getVertices() const
+const Vertex *Image::getVertices() const
 {
 	return vertices;
 }
 	static Matrix t;
 	t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
 
-	const vertex *v = geom->getVertexArray();
+	const Vertex *v = geom->getVertexArray();
 	size_t vertcount = geom->getVertexCount();
 
 	// Padded NPOT images require texture coordinate scaling with Geometry.
 	if (geom->hasVertexColors())
 	{
 		glEnableClientState(GL_COLOR_ARRAY);
-		glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *) &v[0].r);
+		glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), (GLvoid *) &v[0].r);
 	}
 
 	GLenum glmode;
 
 void Image::preload()
 {
-	memset(vertices, 255, sizeof(vertex)*4);
+	memset(vertices, 255, sizeof(Vertex)*4);
 
 	vertices[0].x = 0;
 	vertices[0].y = 0;
 	return love::Vector(vertices[2].s, vertices[2].t);
 }
 
-vertex *Image::scaleNPOT(const love::vertex *v, size_t count) const
+Vertex *Image::scaleNPOT(const love::Vertex *v, size_t count) const
 {
-	vertex *newverts = new vertex[count];
+	Vertex *newverts = new Vertex[count];
 	love::Vector scale = getTexCoordScale();
 
 	for (size_t i = 0; i < count; i++)
 	return newverts;
 }
 
-void Image::drawv(const Matrix &t, const vertex *v, GLsizei count, GLenum mode, const uint16 *e, GLsizei ecount) const
+void Image::drawv(const Matrix &t, const Vertex *v, GLsizei count, GLenum mode, const uint16 *e, GLsizei ecount) const
 {
 	bind();
 
 	//      defined in the geometry to draw itself.
 	//      if the drawing method below is changed to use something other than
 	//      glDrawArrays(), drawg() needs to be updated accordingly!
-	glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&v[0].x);
-	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&v[0].s);
+	glVertexPointer(2, GL_FLOAT, sizeof(Vertex), (GLvoid *)&v[0].x);
+	glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (GLvoid *)&v[0].s);
 
 	if (e != 0 && ecount > 0)
 		glDrawElements(mode, ecount, GL_UNSIGNED_SHORT, (GLvoid *) e);

src/modules/graphics/opengl/Image.h

 	float getWidth() const;
 	float getHeight() const;
 
-	const vertex *getVertices() const;
+	const Vertex *getVertices() const;
 
 	love::image::ImageData *getImageData() const;
 	love::image::CompressedData *getCompressedData() const;
 
 private:
 
-	vertex *scaleNPOT(const vertex *v, size_t count) const;
+	Vertex *scaleNPOT(const Vertex *v, size_t count) const;
 	void uploadDefaultTexture();
 
-	void drawv(const Matrix &t, const vertex *v, GLsizei count = 4, GLenum mode = GL_QUADS, const uint16 *e = 0, GLsizei ecount = 0) const;
+	void drawv(const Matrix &t, const Vertex *v, GLsizei count = 4, GLenum mode = GL_QUADS, const uint16 *e = 0, GLsizei ecount = 0) const;
 
 	friend class Shader;
 	GLuint getTextureName() const
 	GLuint texture;
 
 	// The source vertices of the image.
-	vertex vertices[4];
+	Vertex vertices[4];
 
 	// Mipmap texture LOD bias (sharpness) value.
 	float mipmapSharpness;

src/modules/graphics/opengl/OpenGL.h

 // STL
 #include <vector>
 
+// The last argument to AttribPointer takes a buffer offset casted to a pointer.
+#define BUFFER_OFFSET(i) ((char *) NULL + (i))
+
 namespace love
 {
 namespace graphics

src/modules/graphics/opengl/ParticleSystem.cpp

 	try
 	{
 		pFree = pMem = new particle[size];
-		particleVerts = new love::vertex[size * 4];
+		particleVerts = new love::Vertex[size * 4];
 		maxParticles = (uint32) size;
 	}
 	catch (std::bad_alloc &)
 	t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
 	glMultMatrixf((const GLfloat *)t.getElements());
 
-	const vertex *imageVerts = image->getVertices();
-	vertex *pVerts = particleVerts;
+	const Vertex *imageVerts = image->getVertices();
+	Vertex *pVerts = particleVerts;
 	particle *p = pHead;
 
 	// set the vertex data for each particle (transformation, texcoords, color)
 	glEnableClientState(GL_VERTEX_ARRAY);
 	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 
-	glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *) &particleVerts[0].r);
-	glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *) &particleVerts[0].x);
-	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *) &particleVerts[0].s);
+	glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), (GLvoid *) &particleVerts[0].r);
+	glVertexPointer(2, GL_FLOAT, sizeof(Vertex), (GLvoid *) &particleVerts[0].x);
+	glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (GLvoid *) &particleVerts[0].s);
 
 	glDrawArrays(GL_QUADS, 0, pCount * 4);
 

src/modules/graphics/opengl/ParticleSystem.h

 	particle *pTail;
 
 	// array of transformed vertex data for all particles, for drawing
-	vertex * particleVerts;
+	Vertex *particleVerts;
 
 	// The image to be drawn.
 	Image *image;

src/modules/graphics/opengl/SpriteBatch.cpp

 #include "modules/graphics/Geometry.h"
 #include "VertexBuffer.h"
 
-// stdlib
+// C++
 #include <algorithm>
 
+// C
+#include <stddef.h>
+
 namespace love
 {
 namespace graphics
 		break;
 	}
 
-	const size_t vertex_size = sizeof(vertex) * 4 * size;
+	const size_t vertex_size = sizeof(Vertex) * 4 * size;
 
 	try
 	{
 		return -1;
 
 	// Needed for colors.
-	memcpy(sprite, image->getVertices(), sizeof(vertex)*4);
+	memcpy(sprite, image->getVertices(), sizeof(Vertex)*4);
 
 	// Transform.
 	static Matrix t;
 	// Map (lock) the old VertexBuffer to get a pointer to its data.
 	void *old_data = lock();
 
-	size_t vertex_size = sizeof(vertex) * 4 * newsize;
+	size_t vertex_size = sizeof(Vertex) * 4 * newsize;
 
 	VertexBuffer *new_array_buf = 0;
 	VertexIndex *new_element_buf = 0;
 	}
 
 	// Copy as much of the old data into the new VertexBuffer as can fit.
-	memcpy(new_data, old_data, sizeof(vertex) * 4 * std::min(newsize, size));
+	memcpy(new_data, old_data, sizeof(Vertex) * 4 * std::min(newsize, size));
 
 	// We don't need to unmap the old VertexBuffer since we're deleting it.
 	delete array_buf;
 
 void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const
 {
-	const int color_offset = 0;
-	const int vertex_offset = sizeof(unsigned char) * 4;
-	const int texel_offset = sizeof(unsigned char) * 4 + sizeof(float) * 2;
+	const size_t vertex_offset = offsetof(Vertex, x);
+	const size_t texel_offset = offsetof(Vertex, s);
+	const size_t color_offset = offsetof(Vertex, r);
 
 	if (next == 0)
 		return;
 	if (color)
 	{
 		glEnableClientState(GL_COLOR_ARRAY);
-		glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), array_buf->getPointer(color_offset));
+		glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), array_buf->getPointer(color_offset));
 	}
 
 	glEnableClientState(GL_VERTEX_ARRAY);
-	glVertexPointer(2, GL_FLOAT, sizeof(vertex), array_buf->getPointer(vertex_offset));
+	glVertexPointer(2, GL_FLOAT, sizeof(Vertex), array_buf->getPointer(vertex_offset));
 
 	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-	glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), array_buf->getPointer(texel_offset));
+	glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), array_buf->getPointer(texel_offset));
 
 	glDrawElements(GL_TRIANGLES, element_buf->getIndexCount(next), element_buf->getType(), element_buf->getPointer(0));
 
 	glPopMatrix();
 }
 
-void SpriteBatch::scaleNPOT(vertex *v, size_t count)
+void SpriteBatch::scaleNPOT(Vertex *v, size_t count)
 {
 	if (Image::hasNpot())
 		return;
 	}
 }
 
-void SpriteBatch::addv(const vertex *v, int index)
+void SpriteBatch::addv(const Vertex *v, int index)
 {
-	static const int sprite_size = 4 * sizeof(vertex); // bytecount
+	static const int sprite_size = 4 * sizeof(Vertex); // bytecount
 	VertexBuffer::Bind bind(*array_buf);
 	array_buf->fill(index * sprite_size, sprite_size, v);
 }
 
-void SpriteBatch::setColorv(vertex *v, const Color &color)
+void SpriteBatch::setColorv(Vertex *v, const Color &color)
 {
 	for (size_t i = 0; i < 4; ++i)
 	{

src/modules/graphics/opengl/SpriteBatch.h

 
 private:
 
-	void scaleNPOT(vertex *v, size_t count);
+	void scaleNPOT(Vertex *v, size_t count);
 
-	void addv(const vertex *v, int index);
+	void addv(const Vertex *v, int index);
 
 	/**
 	 * Set the color for vertices.
 	 *          of size 4.
 	 * @param color The color to assign to each vertex.
 	 */
-	void setColorv(vertex *v, const Color &color);
+	void setColorv(Vertex *v, const Color &color);
 
 	Image *image;
 
 	// The next free element.
 	int next;
 
-	vertex sprite[4];
+	Vertex sprite[4];
 
 	// Current color. This color, if present, will be applied to the next
 	// added geometry.

src/modules/graphics/opengl/VertexBuffer.cpp

 
 const void *VBO::getPointer(size_t offset) const
 {
-	return reinterpret_cast<const void *>(offset);
+	return BUFFER_OFFSET(offset);
 }
 
 bool VBO::loadVolatile()

src/modules/graphics/opengl/wrap_Geometry.cpp

 	size_t i = size_t(luaL_checkinteger(L, 2));
 
 	EXCEPT_GUARD(
-		const vertex &v = geom->getVertex(i-1);
+		const Vertex &v = geom->getVertex(i-1);
 		lua_pushnumber(L, v.x);
 		lua_pushnumber(L, v.y);
 		lua_pushnumber(L, v.s);
 	Geometry *geom = luax_checkgeometry(L, 1);
 	size_t i = size_t(luaL_checkinteger(L, 2));
 
-	vertex v;
+	Vertex v;
 
 	if (lua_istable(L, 3))
 	{

src/modules/graphics/opengl/wrap_Graphics.cpp

 
 	bool hasvertexcolors = false;
 
-	std::vector<vertex> vertices;
+	std::vector<Vertex> vertices;
 	vertices.reserve(vertexcount);
 
 	for (size_t i = 0; i < vertexcount; ++i)
 	{
-		vertex v;
+		Vertex v;
 
 		if (is_table)
 		{

src/modules/math/MathModule.cpp

 
 using std::list;
 using std::vector;
-using love::vertex;
+using love::Vertex;
 
 namespace
 {
 	// check if an angle is oriented counter clockwise
-	inline bool is_oriented_ccw(const vertex &a, const vertex &b, const vertex &c)
+	inline bool is_oriented_ccw(const Vertex &a, const Vertex &b, const Vertex &c)
 	{
 		// return det(b-a, c-a) >= 0
 		return ((b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)) >= 0;
 	}
 
 	// check if a and b are on the same side of the line c->d
-	bool on_same_side(const vertex &a, const vertex &b, const vertex &c, const vertex &d)
+	bool on_same_side(const Vertex &a, const Vertex &b, const Vertex &c, const Vertex &d)
 	{
 		float px = d.x - c.x, py = d.y - c.y;
 		// return det(p, a-c) * det(p, b-c) >= 0
 	}
 
 	// checks is p is contained in the triangle abc
-	inline bool point_in_triangle(const vertex &p, const vertex &a, const vertex &b, const vertex &c)
+	inline bool point_in_triangle(const Vertex &p, const Vertex &a, const Vertex &b, const Vertex &c)
 	{
 		return on_same_side(p,a, b,c) && on_same_side(p,b, a,c) && on_same_side(p,c, a,b);
 	}
 
 	// checks if any vertex in `vertices' is in the triangle abc.
-	bool any_point_in_triangle(const list<const vertex *> &vertices, const vertex &a, const vertex &b, const vertex &c)
+	bool any_point_in_triangle(const list<const Vertex *> &vertices, const Vertex &a, const Vertex &b, const Vertex &c)
 	{
-		list<const vertex *>::const_iterator it, end = vertices.end();
+		list<const Vertex *>::const_iterator it, end = vertices.end();
 		for (it = vertices.begin(); it != end; ++it)
 		{
-			const vertex *p = *it;
+			const Vertex *p = *it;
 			if ((p != &a) && (p != &b) && (p != &c) && point_in_triangle(*p, a,b,c)) // oh god...
 				return true;
 		}
 		return false;
 	}
 
-	inline bool is_ear(const vertex &a, const vertex &b, const vertex &c, const list<const vertex *> &vertices)
+	inline bool is_ear(const Vertex &a, const Vertex &b, const Vertex &c, const list<const Vertex *> &vertices)
 	{
 		return is_oriented_ccw(a,b,c) && !any_point_in_triangle(vertices, a,b,c);
 	}
 	return new BezierCurve(points);
 }
 
-vector<Triangle> Math::triangulate(const vector<vertex> &polygon)
+vector<Triangle> Math::triangulate(const vector<Vertex> &polygon)
 {
 	if (polygon.size() < 3)
 		throw love::Exception("Not a ploygon");
 	size_t idx_lm = 0;
 	for (size_t i = 0; i < polygon.size(); ++i)
 	{
-		const vertex &lm = polygon[idx_lm], &p = polygon[i];
+		const Vertex &lm = polygon[idx_lm], &p = polygon[i];
 		if (p.x < lm.x || (p.x == lm.x && p.y < lm.y))
 			idx_lm = i;
 		next_idx[i] = i+1;
 		next_idx.swap(prev_idx);
 
 	// collect list of concave polygons
-	list<const vertex *> concave_vertices;
+	list<const Vertex *> concave_vertices;
 	for (size_t i = 0; i < polygon.size(); ++i)
 	{
 		if (!is_oriented_ccw(polygon[prev_idx[i]], polygon[i], polygon[next_idx[i]]))
 	{
 		next = next_idx[current];
 		prev = prev_idx[current];
-		const vertex &a = polygon[prev], &b = polygon[current], &c = polygon[next];
+		const Vertex &a = polygon[prev], &b = polygon[current], &c = polygon[next];
 		if (is_ear(a,b,c, concave_vertices))
 		{
 			triangles.push_back(Triangle(a,b,c));
 	return triangles;
 }
 
-bool Math::isConvex(const std::vector<vertex> &polygon)
+bool Math::isConvex(const std::vector<Vertex> &polygon)
 {
 	if (polygon.size() < 3)
 		return false;

src/modules/math/MathModule.h

 	 * @param polygon Polygon to triangulate. Must not intersect itself.
 	 * @return List of triangles the polygon is composed of.
 	 **/
-	std::vector<Triangle> triangulate(const std::vector<vertex> &polygon);
+	std::vector<Triangle> triangulate(const std::vector<Vertex> &polygon);
 
 	/**
 	 * Checks whether a polygon is convex.
 	 * @param polygon Polygon to test.
 	 * @return True if the polygon is convex, false otherwise.
 	 **/
-	bool isConvex(const std::vector<vertex> &polygon);
+	bool isConvex(const std::vector<Vertex> &polygon);
 
 	/**
 	 * Calculate Simplex noise for the specified coordinate(s).

src/modules/math/wrap_Math.cpp

 
 int w_triangulate(lua_State *L)
 {
-	std::vector<vertex> vertices;
+	std::vector<Vertex> vertices;
 	if (lua_istable(L, 1))
 	{
 		size_t top = lua_objlen(L, 1);
 			lua_rawgeti(L, 1, i);
 			lua_rawgeti(L, 1, i+1);
 
-			vertex v;
+			Vertex v;
 			v.x = luaL_checknumber(L, -2);
 			v.y = luaL_checknumber(L, -1);
 			vertices.push_back(v);
 		vertices.reserve(top / 2);
 		for (size_t i = 1; i <= top; i += 2)
 		{
-			vertex v;
+			Vertex v;
 			v.x = luaL_checknumber(L, i);
 			v.y = luaL_checknumber(L, i+1);
 			vertices.push_back(v);
 
 int w_isConvex(lua_State *L)
 {
-	std::vector<vertex> vertices;
+	std::vector<Vertex> vertices;
 	if (lua_istable(L, 1))
 	{
 		size_t top = lua_objlen(L, 1);
 			lua_rawgeti(L, 1, i);
 			lua_rawgeti(L, 1, i+1);
 
-			vertex v;
+			Vertex v;
 			v.x = luaL_checknumber(L, -2);
 			v.y = luaL_checknumber(L, -1);
 			vertices.push_back(v);
 		vertices.reserve(top / 2);
 		for (size_t i = 1; i <= top; i += 2)
 		{
-			vertex v;
+			Vertex v;
 			v.x = luaL_checknumber(L, i);
 			v.y = luaL_checknumber(L, i+1);
 			vertices.push_back(v);