/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


		#include "core/simple_list_renderable.h"
		#include "log/log.h"

		using namespace GS;
		using namespace GS::Core;


//------------------------------------------------------------------------------
void				SimpleCullingSystem::AddRenderable(Renderable *r)
{	renderable_list.Add(r);	}
void				SimpleCullingSystem::DeleteRenderable(Renderable *r)
{	renderable_list.Remove(r);	}
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
void				SimpleCullingSystem::ComputeRenderableMinMax(MinMax &mm)
{
	if	(!renderable_list.GetCount())
		return;

	renderable_list[0]->ComputeRenderableMinMax(mm);

	MinMax l_mm;
	for	(uint n = 1; n < renderable_list.GetCount(); ++n)
	{
		renderable_list[n]->ComputeRenderableMinMax(l_mm);
		mm.Grow(l_mm);
	}
}
uint				SimpleCullingSystem::GetRenderablePrimitiveList(const Camera &view, const Camera &default_view, Stack <Render::Primitive *> &list, Context ctx, bool cull)
{
	uint tested_primitive = 0;
	ArrayListForeachPtr(Renderable *, renderable, renderable_list)
		if	(renderable->IsRenderable())
			tested_primitive += renderable->GetRenderablePrimitiveList(view, default_view, list, ctx, cull);

	return tested_primitive;
}
//------------------------------------------------------------------------------
