void RenderList::RemoveExcessObjects(const Frustum& frustum)
{
	auto mark_objects_for_removal = [&](std::vector<RenderList_Object>& list)
	{
		//First iterate over each object in the list and mark it for removal (this can easily be parallised as it does not need any synchronisation)
		const int size = (int)list.size();

#pragma omp parallel for
		for (int i = 0; i < size; ++i)
		{
			Object* obj = list[i].target_obj;

			if (!frustum.InsideFrustum(obj->GetWorldTransform().GetPositionVector(), obj->GetBoundingRadius()))
			{
				obj->GetFrustumCullFlags() &= ~m_BitMask;
			}
		}

		//Next iterate over the list - removing any objects that are no longer inside the frustum
		int n_removed = 0;
		for (int i = 0; i < size; ++i)
		{
			if (! (list[i].target_obj->GetFrustumCullFlags() & m_BitMask) )
			{
				n_removed++;
			}
			else if (n_removed > 0)
			{
				list[i - n_removed] = list[i];
			}
		}

		if (n_removed > 0)
			list._Pop_back_n(n_removed);

	};

	mark_objects_for_removal(m_vRenderListOpaque);

	if (m_SupportsTransparancy)
		mark_objects_for_removal(m_vRenderListTransparent);
}