
#include "vertexlist.h"


#define CLASS_NAME VertexList
#define CLASS_TYPE Vertex
#define CLASS_TYPE_PTR Vertex*

#define SIMPLE_COPY
#define CHUNK_SIZE 1024


#include "dynarray.C"


int VertexList::AugmentBound(real min_max[2][3], int first) {

	if (Size() < 1)
		return 0;

	int i = 0;

	if (first) {
		real x, y, z;
		(*this)[0].Point().Vec4FastGet3(x, y, z);
		min_max[0][0] = min_max[1][0] = x;
		min_max[0][1] = min_max[1][1] = y;
		min_max[0][2] = min_max[1][2] = z;
		i = 1;
	}

	for (; i<Size(); i++)
		(*this)[i].Point().AugmentBound(min_max);

	return 1;
}


void VertexList::ApplyTransform(const JLmatrix &M) {

	for (int i=0; i<Size(); i++)
		(*this)[i] *= M;

	// If there are any triangle lists that use these vertices,
	// you better recalculate their normals!
}


void VertexList::HomogeneousDivide() {

	for (int i=0; i<Size(); i++)
		(*this)[i].DivideByW();

	// If there are any triangle lists that use these vertices,
	// you better recalculate their normals!
}


real VertexList::Top(JLmatrix*, JLmatrix*) {

	real t = -1E30;

	for (int i=0; i<Size(); i++) {
		real y = (*this)[i].Point().y();
		if (y > t)
			t = y;
	}

	return t;
}



#undef SIMPLE_COPY
#undef CHUNK_SIZE

#undef CLASS_NAME
#undef CLASS_TYPE
#undef CLASS_TYPE_PTR

