Example #1
0
void _findBoundaries(Vector& low, Vector& high, const BasicMesh& from)
{
	assert(sizeof(Vector) == 3*sizeof(*(from.getVertices())));
	low.x = low.y = low.z = std::numeric_limits<float>::max();
	high.x = high.y = high.z = -std::numeric_limits<float>::max(); // numeric::min is actually minimal *positive* value

	const Vector* vertex = reinterpret_cast<const Vector*>(from.getVertices());

	for(int i = 0; i < from.getVerticesCount(); ++i)
	{
		if(low.x > vertex->x) low.x = vertex->x;
		if(low.y > vertex->y) low.y = vertex->y;
		if(low.z > vertex->z) low.z = vertex->z;

		if(high.x < vertex->x) high.x = vertex->x;
		if(high.y < vertex->y) high.y = vertex->y;
		if(high.z < vertex->z) high.z = vertex->z;

		++vertex;
	}
}