//==============================================================================
Error FrustumComponent::update(SceneNode& node, F32, F32, Bool& updated)
{
	m_visible = nullptr;

	updated = false;

	if(m_flags.bitsEnabled(SHAPE_MARKED_FOR_UPDATE))
	{
		updated = true;
		m_pm = m_frustum->calculateProjectionMatrix();
		computeProjectionParams();
	}

	if(m_flags.bitsEnabled(TRANSFORM_MARKED_FOR_UPDATE))
	{
		updated = true;
		m_vm = Mat4(m_frustum->getTransform().getInverse());
	}

	if(updated)
	{
		m_vpm = m_pm * m_vm;
		m_flags.disableBits(
			SHAPE_MARKED_FOR_UPDATE | TRANSFORM_MARKED_FOR_UPDATE);
	}

	return ErrorCode::NONE;
}
Esempio n. 2
0
//==============================================================================
void Renderer::render(SceneGraph& scene, 
	Array<GlCommandBufferHandle, JOB_CHAINS_COUNT>& jobs)
{
	m_scene = &scene;
	Camera& cam = m_scene->getActiveCamera();

	// Calc a few vars
	//
	Timestamp camUpdateTimestamp = cam.FrustumComponent::getTimestamp();
	if(m_projectionParamsUpdateTimestamp 
			< m_scene->getActiveCameraChangeTimestamp()
		|| m_projectionParamsUpdateTimestamp < camUpdateTimestamp
		|| m_projectionParamsUpdateTimestamp == 1)
	{
		ANKI_ASSERT(cam.getCameraType() == Camera::Type::PERSPECTIVE);
		computeProjectionParams(cam.getProjectionMatrix());
		m_projectionParamsUpdateTimestamp = getGlobTimestamp();
	}

	ANKI_COUNTER_START_TIMER(RENDERER_MS_TIME);
	m_ms.run(jobs[0]);
	ANKI_ASSERT(jobs[0].getReferenceCount() == 1);
	jobs[0].flush();
	ANKI_COUNTER_STOP_TIMER_INC(RENDERER_MS_TIME);

	m_tiler.runMinMax(m_ms._getDepthRt());

	ANKI_COUNTER_START_TIMER(RENDERER_IS_TIME);
	m_is.run(jobs[1]);
	ANKI_COUNTER_STOP_TIMER_INC(RENDERER_IS_TIME);

	m_bs.run(jobs[1]);

	ANKI_COUNTER_START_TIMER(RENDERER_PPS_TIME);
	if(m_pps.getEnabled())
	{
		m_pps.run(jobs[1]);
	}
	ANKI_COUNTER_STOP_TIMER_INC(RENDERER_PPS_TIME);

	if(m_dbg.getEnabled())
	{
		m_dbg.run(jobs[1]);
	}

	++m_framesNum;
}