OSDN Git Service

Re-enable more precise distance checking
authorLatif Khalifa <latifer@streamgrid.net>
Mon, 1 Aug 2011 06:28:39 +0000 (06:28 +0000)
committerLatif Khalifa <latifer@streamgrid.net>
Mon, 1 Aug 2011 06:28:39 +0000 (06:28 +0000)
Use actual bounding box for calc
Don't bother with small objects (<5m bounding sphere)

git-svn-id: https://radegast.googlecode.com/svn/trunk@1051 f7a694da-4d33-11de-9ad6-1127a62b9fcd

Radegast/GUI/Rendering/RenderSettings.cs
Radegast/GUI/Rendering/Rendering.cs

index 9e2a548..3c6cd56 100644 (file)
@@ -50,6 +50,6 @@ namespace Radegast.Rendering
         /// <summary>Should we try to optimize by not drawing objects occluded behind other objects</summary>
         public static bool OcclusionCullingEnabled = true;
         /// <summary>Should we try to make sure that large prims that are > our draw distance are in view when we are standing on them</summary>
-        public static bool HeavierDistanceChecking = false;
+        public static bool HeavierDistanceChecking = true;
     }
 }
index 4bbff2b..de7f7a6 100644 (file)
@@ -1314,13 +1314,13 @@ namespace Radegast.Rendering
         /// <returns></returns>\r
         private float FindClosestDistanceSquared(Vector3 calcPos, SceneObject p)\r
         {\r
-            if (!RenderSettings.HeavierDistanceChecking)\r
+            if (p.BoundingVolume == null || p.BoundingVolume.R < 5f || !RenderSettings.HeavierDistanceChecking)\r
                 return Vector3.DistanceSquared(calcPos, p.RenderPosition);\r
 \r
             Vector3 posToCheckFrom = Vector3.Zero;\r
             //Get the bounding boxes for this prim\r
-            Vector3 boundingBoxMin = p.RenderPosition - (p.BasePrim.Scale / 2);\r
-            Vector3 boundingBoxMax = p.RenderPosition + (p.BasePrim.Scale / 2);\r
+            Vector3 boundingBoxMin = p.RenderPosition - p.BoundingVolume.Min * p.BasePrim.Scale;\r
+            Vector3 boundingBoxMax = p.RenderPosition + p.BoundingVolume.Max * p.BasePrim.Scale;\r
             if (calcPos.X > boundingBoxMin.X &&\r
                     calcPos.X < boundingBoxMax.X)\r
             {\r
@@ -3581,7 +3581,7 @@ namespace Radegast.Rendering
         private void cbMisc_CheckedChanged(object sender, EventArgs e)\r
         {\r
             miscEnabled = cbMisc.Checked;\r
-            RenderSettings.OcclusionCullingEnabled = miscEnabled;\r
+            RenderSettings.HeavierDistanceChecking = miscEnabled;\r
         }\r
 \r
         #endregion\r