aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorJohn Hurliman2010-05-21 13:55:36 -0700
committerJohn Hurliman2010-05-21 13:55:36 -0700
commit93ef65c69055157e0b7d51e544abe5a1035f40f0 (patch)
tree0afcfd50591e34f0a5d7efa474f300cf09083f69 /OpenSim/Region/Framework/Scenes/ScenePresence.cs
parentminor: remove LongRunning test designator from TestAddSceneObject() since it ... (diff)
downloadopensim-SC-93ef65c69055157e0b7d51e544abe5a1035f40f0.zip
opensim-SC-93ef65c69055157e0b7d51e544abe5a1035f40f0.tar.gz
opensim-SC-93ef65c69055157e0b7d51e544abe5a1035f40f0.tar.bz2
opensim-SC-93ef65c69055157e0b7d51e544abe5a1035f40f0.tar.xz
* Moving all of the prioritization/reprioritization code into a new file Prioritizer.cs
* Simplified the interest management code to make it easier to add new policies. Prioritization and reprioritization share code paths now * Improved the distance and front back policies to always give your avatar the highest priority
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs118
1 files changed, 2 insertions, 116 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index ee0eb07..2ce1b68 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3777,123 +3777,9 @@ namespace OpenSim.Region.Framework.Scenes
3777 } 3777 }
3778 } 3778 }
3779 3779
3780 public double GetUpdatePriority(IClientAPI client)
3781 {
3782 switch (Scene.UpdatePrioritizationScheme)
3783 {
3784 case Scene.UpdatePrioritizationSchemes.Time:
3785 return GetPriorityByTime();
3786 case Scene.UpdatePrioritizationSchemes.Distance:
3787 return GetPriorityByDistance(client);
3788 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3789 return GetPriorityByDistance(client);
3790 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3791 return GetPriorityByFrontBack(client);
3792 default:
3793 throw new InvalidOperationException("UpdatePrioritizationScheme not defined.");
3794 }
3795 }
3796
3797 private double GetPriorityByTime()
3798 {
3799 return DateTime.Now.ToOADate();
3800 }
3801
3802 private double GetPriorityByDistance(IClientAPI client)
3803 {
3804 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3805 if (presence != null)
3806 {
3807 return GetPriorityByDistance((presence.IsChildAgent) ?
3808 presence.AbsolutePosition : presence.CameraPosition);
3809 }
3810 return double.NaN;
3811 }
3812
3813 private double GetPriorityByFrontBack(IClientAPI client)
3814 {
3815 ScenePresence presence = Scene.GetScenePresence(client.AgentId);
3816 if (presence != null)
3817 {
3818 return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis);
3819 }
3820 return double.NaN;
3821 }
3822
3823 private double GetPriorityByDistance(Vector3 position)
3824 {
3825 return Vector3.Distance(AbsolutePosition, position);
3826 }
3827
3828 private double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis)
3829 {
3830 // Distance
3831 double priority = Vector3.Distance(camPosition, AbsolutePosition);
3832
3833 // Plane equation
3834 float d = -Vector3.Dot(camPosition, camAtAxis);
3835 float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d;
3836 if (p < 0.0f) priority *= 2.0f;
3837
3838 return priority;
3839 }
3840
3841 private double GetSOGUpdatePriority(SceneObjectGroup sog)
3842 {
3843 switch (Scene.UpdatePrioritizationScheme)
3844 {
3845 case Scene.UpdatePrioritizationSchemes.Time:
3846 throw new InvalidOperationException("UpdatePrioritizationScheme for time not supported for reprioritization");
3847 case Scene.UpdatePrioritizationSchemes.Distance:
3848 return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3849 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3850 return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3851 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3852 return sog.GetPriorityByFrontBack(CameraPosition, CameraAtAxis);
3853 default:
3854 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3855 }
3856 }
3857
3858 private double UpdatePriority(UpdatePriorityData data)
3859 {
3860 EntityBase entity;
3861 SceneObjectGroup group;
3862
3863 if (Scene.Entities.TryGetValue(data.localID, out entity))
3864 {
3865 group = entity as SceneObjectGroup;
3866 if (group != null)
3867 return GetSOGUpdatePriority(group);
3868
3869 ScenePresence presence = entity as ScenePresence;
3870 if (presence == null)
3871 throw new InvalidOperationException("entity found is neither SceneObjectGroup nor ScenePresence");
3872 switch (Scene.UpdatePrioritizationScheme)
3873 {
3874 case Scene.UpdatePrioritizationSchemes.Time:
3875 throw new InvalidOperationException("UpdatePrioritization for time not supported for reprioritization");
3876 case Scene.UpdatePrioritizationSchemes.Distance:
3877 case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
3878 return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
3879 case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
3880 return GetPriorityByFrontBack(CameraPosition, CameraAtAxis);
3881 default:
3882 throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
3883 }
3884 }
3885 else
3886 {
3887 group = Scene.GetGroupByPrim(data.localID);
3888 if (group != null)
3889 return GetSOGUpdatePriority(group);
3890 }
3891 return double.NaN;
3892 }
3893
3894 private void ReprioritizeUpdates() 3780 private void ReprioritizeUpdates()
3895 { 3781 {
3896 if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != Scene.UpdatePrioritizationSchemes.Time) 3782 if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time)
3897 { 3783 {
3898 lock (m_reprioritization_timer) 3784 lock (m_reprioritization_timer)
3899 { 3785 {
@@ -3907,7 +3793,7 @@ namespace OpenSim.Region.Framework.Scenes
3907 3793
3908 private void Reprioritize(object sender, ElapsedEventArgs e) 3794 private void Reprioritize(object sender, ElapsedEventArgs e)
3909 { 3795 {
3910 m_controllingClient.ReprioritizeUpdates(UpdatePriority); 3796 m_controllingClient.ReprioritizeUpdates();
3911 3797
3912 lock (m_reprioritization_timer) 3798 lock (m_reprioritization_timer)
3913 { 3799 {