Example #1
0
void MakeTmapPoly(BSP_TmapPoly &dst, pcs_polygon &src, std::unordered_map<vector3d, int> &norms, std::unordered_map<vector3d, int> &verts, BSP_DefPoints &dpnts)
{
	dst.head.id = 3;
	dst.normal = src.norm;
	dst.nverts = src.verts.size();
	dst.tmap_num = src.texture_id;
	std::vector<vector3d> vertices;
	vertices.reserve(dst.nverts);

	dst.verts.resize(dst.nverts);
	for (int i = 0; i < dst.nverts; i++)
	{
		vertices.push_back(src.verts[i].point);
		dst.verts[i].vertnum = verts[src.verts[i].point];
		dst.verts[i].normnum = norms[src.verts[i].norm];
		dst.verts[i].u = src.verts[i].u;
		dst.verts[i].v = src.verts[i].v;
	}

	// recalculate these just for accracy
	dst.center = dst.MyCenter(vertices);
	dst.radius = dst.MyRadius(dst.center, vertices);


	// last thing
	dst.head.size = dst.MySize();
}