Browse Source

Use camera's frustum for Renderer2D culling always. Closes #1191.

Lasse Öörni 9 years ago
parent
commit
8c839265f0
2 changed files with 4 additions and 15 deletions
  1. 2 12
      Source/Urho3D/Urho2D/Renderer2D.cpp
  2. 2 3
      Source/Urho3D/Urho2D/Renderer2D.h

+ 2 - 12
Source/Urho3D/Urho2D/Renderer2D.cpp

@@ -63,7 +63,6 @@ Renderer2D::Renderer2D(Context* context) :
     Drawable(context, DRAWABLE_GEOMETRY),
     material_(new Material(context)),
     indexBuffer_(new IndexBuffer(context_)),
-    frustum_(0),
     viewMask_(DEFAULT_VIEWMASK)
 {
     material_->SetName("Urho2D");
@@ -273,10 +272,7 @@ bool Renderer2D::CheckVisibility(Drawable2D* drawable) const
         return false;
 
     const BoundingBox& box = drawable->GetWorldBoundingBox();
-    if (frustum_)
-        return frustum_->IsInsideFast(box) != OUTSIDE;
-
-    return frustumBoundingBox_.IsInsideFast(box) != OUTSIDE;
+    return frustum_.IsInsideFast(box) != OUTSIDE;
 }
 
 void Renderer2D::OnWorldBoundingBoxUpdate()
@@ -336,13 +332,7 @@ void Renderer2D::HandleBeginViewUpdate(StringHash eventType, VariantMap& eventDa
     URHO3D_PROFILE(UpdateRenderer2D);
 
     Camera* camera = static_cast<Camera*>(eventData[P_CAMERA].GetPtr());
-    frustum_ = &camera->GetFrustum();
-    if (camera->IsOrthographic() && camera->GetNode()->GetWorldDirection() == Vector3::FORWARD)
-    {
-        // Define bounding box with min and max points
-        frustumBoundingBox_.Define(frustum_->vertices_[2], frustum_->vertices_[4]);
-        frustum_ = 0;
-    }
+    frustum_ = camera->GetFrustum();
     viewMask_ = camera->GetViewMask();
 
     // Check visibility

+ 2 - 3
Source/Urho3D/Urho2D/Renderer2D.h

@@ -23,6 +23,7 @@
 #pragma once
 
 #include "../Graphics/Drawable.h"
+#include "../Math/Frustum.h"
 
 namespace Urho3D
 {
@@ -123,9 +124,7 @@ private:
     /// View batch info.
     HashMap<Camera*, ViewBatchInfo2D> viewBatchInfos_;
     /// Frustum for current frame.
-    const Frustum* frustum_;
-    /// Frustum bounding box for current frame.
-    BoundingBox frustumBoundingBox_;
+    Frustum frustum_;
     /// View mask of current camera for visibility checking.
     unsigned viewMask_;
     /// Cached materials.