Browse Source

Disallow 1-sample shadow mode when hardware PCF not supported.
Fixed OBB debug drawing.

Lasse Öörni 14 years ago
parent
commit
0c22a1076b
2 changed files with 27 additions and 23 deletions
  1. 23 23
      Engine/Graphics/DebugRenderer.cpp
  2. 4 0
      Engine/Graphics/Renderer.cpp

+ 23 - 23
Engine/Graphics/DebugRenderer.cpp

@@ -108,12 +108,12 @@ void DebugRenderer::AddBoundingBox(const BoundingBox& box, const Color& color, b
     const Vector3& min = box.min_;
     const Vector3& max = box.max_;
     
-    Vector3 v0(max.x_, min.y_, min.z_);
-    Vector3 v1(max.x_, max.y_, min.z_);
-    Vector3 v2(min.x_, max.y_, min.z_);
-    Vector3 v3(min.x_, min.y_, max.z_);
-    Vector3 v4(max.x_, min.y_, max.z_);
-    Vector3 v5(min.x_, max.y_, max.z_);
+    Vector3 v1(max.x_, min.y_, min.z_);
+    Vector3 v2(max.x_, max.y_, min.z_);
+    Vector3 v3(min.x_, max.y_, min.z_);
+    Vector3 v4(min.x_, min.y_, max.z_);
+    Vector3 v5(max.x_, min.y_, max.z_);
+    Vector3 v6(min.x_, max.y_, max.z_);
     
     unsigned uintColor = color.ToUInt();
     
@@ -121,18 +121,18 @@ void DebugRenderer::AddBoundingBox(const BoundingBox& box, const Color& color, b
     if (!depthTest)
         dest = &noDepthLines_;
     
-    dest->Push(DebugLine(min, v0, uintColor));
-    dest->Push(DebugLine(v0, v1, uintColor));
+    dest->Push(DebugLine(min, v1, uintColor));
     dest->Push(DebugLine(v1, v2, uintColor));
-    dest->Push(DebugLine(v2, min, uintColor));
-    dest->Push(DebugLine(v3, v4, uintColor));
-    dest->Push(DebugLine(v4, max, uintColor));
-    dest->Push(DebugLine(max, v5, uintColor));
-    dest->Push(DebugLine(v5, v3, uintColor));
-    dest->Push(DebugLine(min, v3, uintColor));
-    dest->Push(DebugLine(v0, v4, uintColor));
-    dest->Push(DebugLine(v1, max, uintColor));
-    dest->Push(DebugLine(v2, v5, uintColor));
+    dest->Push(DebugLine(v2, v3, uintColor));
+    dest->Push(DebugLine(v3, min, uintColor));
+    dest->Push(DebugLine(v4, v5, uintColor));
+    dest->Push(DebugLine(v5, max, uintColor));
+    dest->Push(DebugLine(max, v6, uintColor));
+    dest->Push(DebugLine(v6, v4, uintColor));
+    dest->Push(DebugLine(min, v4, uintColor));
+    dest->Push(DebugLine(v1, v5, uintColor));
+    dest->Push(DebugLine(v2, max, uintColor));
+    dest->Push(DebugLine(v3, v6, uintColor));
 }
 
 void DebugRenderer::AddBoundingBox(const BoundingBox& box, const Matrix3x4& transform, const Color& color, bool depthTest)
@@ -146,7 +146,7 @@ void DebugRenderer::AddBoundingBox(const BoundingBox& box, const Matrix3x4& tran
     Vector3 v3(transform * Vector3(min.x_, max.y_, min.z_));
     Vector3 v4(transform * Vector3(min.x_, min.y_, max.z_));
     Vector3 v5(transform * Vector3(max.x_, min.y_, max.z_));
-    Vector3 v6(transform * Vector3(max.x_, max.y_, max.z_));
+    Vector3 v6(transform * Vector3(min.x_, max.y_, max.z_));
     Vector3 v7(transform * max);
     
     unsigned uintColor = color.ToUInt();
@@ -160,13 +160,13 @@ void DebugRenderer::AddBoundingBox(const BoundingBox& box, const Matrix3x4& tran
     dest->Push(DebugLine(v2, v3, uintColor));
     dest->Push(DebugLine(v3, v0, uintColor));
     dest->Push(DebugLine(v4, v5, uintColor));
-    dest->Push(DebugLine(v5, v6, uintColor));
-    dest->Push(DebugLine(v6, v7, uintColor));
-    dest->Push(DebugLine(v7, v4, uintColor));
+    dest->Push(DebugLine(v5, v7, uintColor));
+    dest->Push(DebugLine(v7, v6, uintColor));
+    dest->Push(DebugLine(v6, v4, uintColor));
     dest->Push(DebugLine(v0, v4, uintColor));
     dest->Push(DebugLine(v1, v5, uintColor));
-    dest->Push(DebugLine(v2, v6, uintColor));
-    dest->Push(DebugLine(v3, v7, uintColor));
+    dest->Push(DebugLine(v2, v7, uintColor));
+    dest->Push(DebugLine(v3, v6, uintColor));
 }
 
 void DebugRenderer::AddPolyhedron(const Polyhedron& poly, const Color& color, bool depthTest)

+ 4 - 0
Engine/Graphics/Renderer.cpp

@@ -348,6 +348,10 @@ void Renderer::SetShadowQuality(int quality)
         return;
     
     quality &= SHADOWQUALITY_HIGH_24BIT;
+    
+    // If no hardware PCF, do not allow to select one-sample quality
+    if (!graphics_->GetHardwareShadowSupport())
+        quality |= SHADOWQUALITY_HIGH_16BIT;
     if (!graphics_->GetHiresShadowSupport())
         quality &= SHADOWQUALITY_HIGH_16BIT;
     if (graphics_->GetFallback())