Account for rotation in frustum culling algorithm 66/57366/2
authorPaul Wisbey <p.wisbey@samsung.com>
Tue, 19 Jan 2016 11:54:59 +0000 (11:54 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Tue, 19 Jan 2016 13:12:17 +0000 (13:12 +0000)
Change-Id: I523a4ff53376d5cf035d0a797da00dc99f946d97

dali/internal/update/manager/prepare-render-instructions.cpp

index 56b42d6..71ed9f1 100644 (file)
@@ -75,14 +75,29 @@ inline void AddRendererToRenderList( BufferIndex updateBufferIndex,
   const Matrix& worldMatrix = renderable.mNode->GetWorldMatrix( updateBufferIndex );
   if ( cull && renderable.mRenderer->GetMaterial().GetShader()->GeometryHintEnabled( Dali::ShaderEffect::HINT_DOESNT_MODIFY_GEOMETRY ) )
   {
-    const Vector3& position = worldMatrix.GetTranslation3();
     const Vector3& scale = renderable.mNode->GetWorldScale( updateBufferIndex );
     const Vector3& halfSize = renderable.mNode->GetSize( updateBufferIndex ) * scale * 0.5f;
     float radius( halfSize.Length() );
 
-    inside = (radius > Math::MACHINE_EPSILON_1000) &&
-             (cameraAttachment.CheckAABBInFrustum( updateBufferIndex, position, halfSize) );
+    if( radius > Math::MACHINE_EPSILON_1000 )
+    {
+      const Vector3& position = worldMatrix.GetTranslation3();
+      const Quaternion& rotation = renderable.mNode->GetWorldOrientation( updateBufferIndex );
+      bool axisAligned = rotation.IsIdentity();
 
+      if( axisAligned )
+      {
+        inside = cameraAttachment.CheckAABBInFrustum( updateBufferIndex, position, halfSize );
+      }
+      else
+      {
+        inside = cameraAttachment.CheckSphereInFrustum( updateBufferIndex, position, halfSize.Length() );
+      }
+    }
+    else
+    {
+      inside = false;
+    }
   }
 
   if ( inside )