Modified SceneNode::FrustumCull

Now provides an implementation which will test the bounding volume
against the frustum (Basic frustum culling)
Is now const
Disabled face culling on sprites


Former-commit-id: 5cb7a94b38ef8b0ffa5a78f16f5ef65a59ab375d
This commit is contained in:
Lynix
2014-06-05 21:28:17 +02:00
parent bc9c8c6bdb
commit a31ced1d76
10 changed files with 13 additions and 36 deletions

View File

@@ -116,10 +116,11 @@ void NzSprite::SetSize(const NzVector2f& size)
void NzSprite::SetTexture(NzTexture* texture, bool resizeSprite)
{
std::unique_ptr<NzMaterial> material(new NzMaterial);
material->Enable(nzRendererParameter_DepthBuffer, false);
material->SetPersistent(false);
material->Enable(nzRendererParameter_FaceCulling, false);
material->EnableLighting(false);
material->SetDiffuseMap(texture);
material->SetPersistent(false);
SetMaterial(material.get(), resizeSprite);
material.release();
@@ -154,14 +155,6 @@ void NzSprite::SetTextureRect(const NzRectui& rect)
SetTextureCoords(NzRectf(invWidth*rect.x, invHeight*rect.y, invWidth*rect.width, invHeight*rect.height));
}
bool NzSprite::FrustumCull(const NzFrustumf& frustum)
{
if (!m_boundingVolumeUpdated)
UpdateBoundingVolume();
return frustum.Contains(m_boundingVolume);
}
void NzSprite::InvalidateNode()
{
NzSceneNode::InvalidateNode();
@@ -180,7 +173,7 @@ void NzSprite::Unregister()
void NzSprite::UpdateBoundingVolume() const
{
if (m_boundingVolume.IsNull())
m_boundingVolume.Set(-m_size.x*0.5f, -m_size.y*0.5f, 0, m_size.x, m_size.y, 0.f);
m_boundingVolume.Set(-m_size.x*0.5f, -m_size.y*0.5f, 0.f, m_size.x, m_size.y, 0.f);
if (!m_transformMatrixUpdated)
UpdateTransformMatrix();