aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorJohn Hurliman2009-10-23 02:38:59 -0700
committerJohn Hurliman2009-10-23 02:38:59 -0700
commit62f1a5e36d85b95e8f80bc073ba876873494963a (patch)
tree0afbdc903800f2afd127e45faf6879b49da412af /OpenSim/Region/Framework/Scenes/ScenePresence.cs
parentUncommented the resend log line so the previous commit can be seen in action (diff)
downloadopensim-SC-62f1a5e36d85b95e8f80bc073ba876873494963a.zip
opensim-SC-62f1a5e36d85b95e8f80bc073ba876873494963a.tar.gz
opensim-SC-62f1a5e36d85b95e8f80bc073ba876873494963a.tar.bz2
opensim-SC-62f1a5e36d85b95e8f80bc073ba876873494963a.tar.xz
Implemented a "FrontBack" prioritizer, using distance plus the plane equation to give double weight to prims/avatars in front of you
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 77706ac..a610e42 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -297,6 +297,21 @@ namespace OpenSim.Region.Framework.Scenes
297 get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } 297 get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); }
298 } 298 }
299 299
300 public Vector3 CameraAtAxis
301 {
302 get { return m_CameraAtAxis; }
303 }
304
305 public Vector3 CameraLeftAxis
306 {
307 get { return m_CameraLeftAxis; }
308 }
309
310 public Vector3 CameraUpAxis
311 {
312 get { return m_CameraUpAxis; }
313 }
314
300 public Vector3 Lookat 315 public Vector3 Lookat
301 { 316 {
302 get 317 get
@@ -3867,6 +3882,8 @@ namespace OpenSim.Region.Framework.Scenes
3867 return GetPriorityByDistance(client); 3882 return GetPriorityByDistance(client);
3868 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: 3883 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3869 return GetPriorityByDistance(client); 3884 return GetPriorityByDistance(client);
3885 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3886 return GetPriorityByFrontBack(client);
3870 default: 3887 default:
3871 throw new InvalidOperationException("UpdatePrioritizationScheme not defined."); 3888 throw new InvalidOperationException("UpdatePrioritizationScheme not defined.");
3872 } 3889 }
@@ -3888,11 +3905,34 @@ namespace OpenSim.Region.Framework.Scenes
3888 return double.NaN; 3905 return double.NaN;
3889 } 3906 }
3890 3907
3908 private double GetPriorityByFrontBack(IClientAPI client)
3909 {
3910 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3911 if (presence != null)
3912 {
3913 return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis);
3914 }
3915 return double.NaN;
3916 }
3917
3891 private double GetPriorityByDistance(Vector3 position) 3918 private double GetPriorityByDistance(Vector3 position)
3892 { 3919 {
3893 return Vector3.Distance(AbsolutePosition, position); 3920 return Vector3.Distance(AbsolutePosition, position);
3894 } 3921 }
3895 3922
3923 private double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis)
3924 {
3925 // Distance
3926 double priority = Vector3.Distance(camPosition, AbsolutePosition);
3927
3928 // Plane equation
3929 float d = -Vector3.Dot(camPosition, camAtAxis);
3930 float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d;
3931 if (p < 0.0f) priority *= 2.0f;
3932
3933 return priority;
3934 }
3935
3896 private double GetSOGUpdatePriority(SceneObjectGroup sog) 3936 private double GetSOGUpdatePriority(SceneObjectGroup sog)
3897 { 3937 {
3898 switch (Scene.UpdatePrioritizationScheme) 3938 switch (Scene.UpdatePrioritizationScheme)
@@ -3903,6 +3943,8 @@ namespace OpenSim.Region.Framework.Scenes
3903 return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); 3943 return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3904 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: 3944 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3905 return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); 3945 return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3946 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3947 return sog.GetPriorityByFrontBack(CameraPosition, CameraAtAxis);
3906 default: 3948 default:
3907 throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); 3949 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3908 } 3950 }
@@ -3929,6 +3971,8 @@ namespace OpenSim.Region.Framework.Scenes
3929 case Scene.UpdatePrioritizationSchemes.Distance: 3971 case Scene.UpdatePrioritizationSchemes.Distance:
3930 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: 3972 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3931 return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); 3973 return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3974 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3975 return GetPriorityByFrontBack(CameraPosition, CameraAtAxis);
3932 default: 3976 default:
3933 throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); 3977 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3934 } 3978 }