diff options
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 118 |
1 files changed, 2 insertions, 116 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 179ecdc..c45fc0f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -4090,123 +4090,9 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); | |||
4090 | } | 4090 | } |
4091 | } | 4091 | } |
4092 | 4092 | ||
4093 | public double GetUpdatePriority(IClientAPI client) | ||
4094 | { | ||
4095 | switch (Scene.UpdatePrioritizationScheme) | ||
4096 | { | ||
4097 | case Scene.UpdatePrioritizationSchemes.Time: | ||
4098 | return GetPriorityByTime(); | ||
4099 | case Scene.UpdatePrioritizationSchemes.Distance: | ||
4100 | return GetPriorityByDistance(client); | ||
4101 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | ||
4102 | return GetPriorityByDistance(client); | ||
4103 | case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: | ||
4104 | return GetPriorityByFrontBack(client); | ||
4105 | default: | ||
4106 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined."); | ||
4107 | } | ||
4108 | } | ||
4109 | |||
4110 | private double GetPriorityByTime() | ||
4111 | { | ||
4112 | return DateTime.Now.ToOADate(); | ||
4113 | } | ||
4114 | |||
4115 | private double GetPriorityByDistance(IClientAPI client) | ||
4116 | { | ||
4117 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
4118 | if (presence != null) | ||
4119 | { | ||
4120 | return GetPriorityByDistance((presence.IsChildAgent) ? | ||
4121 | presence.AbsolutePosition : presence.CameraPosition); | ||
4122 | } | ||
4123 | return double.NaN; | ||
4124 | } | ||
4125 | |||
4126 | private double GetPriorityByFrontBack(IClientAPI client) | ||
4127 | { | ||
4128 | ScenePresence presence = Scene.GetScenePresence(client.AgentId); | ||
4129 | if (presence != null) | ||
4130 | { | ||
4131 | return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis); | ||
4132 | } | ||
4133 | return double.NaN; | ||
4134 | } | ||
4135 | |||
4136 | private double GetPriorityByDistance(Vector3 position) | ||
4137 | { | ||
4138 | return Vector3.Distance(AbsolutePosition, position); | ||
4139 | } | ||
4140 | |||
4141 | private double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis) | ||
4142 | { | ||
4143 | // Distance | ||
4144 | double priority = Vector3.Distance(camPosition, AbsolutePosition); | ||
4145 | |||
4146 | // Plane equation | ||
4147 | float d = -Vector3.Dot(camPosition, camAtAxis); | ||
4148 | float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d; | ||
4149 | if (p < 0.0f) priority *= 2.0f; | ||
4150 | |||
4151 | return priority; | ||
4152 | } | ||
4153 | |||
4154 | private double GetSOGUpdatePriority(SceneObjectGroup sog) | ||
4155 | { | ||
4156 | switch (Scene.UpdatePrioritizationScheme) | ||
4157 | { | ||
4158 | case Scene.UpdatePrioritizationSchemes.Time: | ||
4159 | throw new InvalidOperationException("UpdatePrioritizationScheme for time not supported for reprioritization"); | ||
4160 | case Scene.UpdatePrioritizationSchemes.Distance: | ||
4161 | return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); | ||
4162 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | ||
4163 | return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); | ||
4164 | case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: | ||
4165 | return sog.GetPriorityByFrontBack(CameraPosition, CameraAtAxis); | ||
4166 | default: | ||
4167 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); | ||
4168 | } | ||
4169 | } | ||
4170 | |||
4171 | private double UpdatePriority(UpdatePriorityData data) | ||
4172 | { | ||
4173 | EntityBase entity; | ||
4174 | SceneObjectGroup group; | ||
4175 | |||
4176 | if (Scene.Entities.TryGetValue(data.localID, out entity)) | ||
4177 | { | ||
4178 | group = entity as SceneObjectGroup; | ||
4179 | if (group != null) | ||
4180 | return GetSOGUpdatePriority(group); | ||
4181 | |||
4182 | ScenePresence presence = entity as ScenePresence; | ||
4183 | if (presence == null) | ||
4184 | throw new InvalidOperationException("entity found is neither SceneObjectGroup nor ScenePresence"); | ||
4185 | switch (Scene.UpdatePrioritizationScheme) | ||
4186 | { | ||
4187 | case Scene.UpdatePrioritizationSchemes.Time: | ||
4188 | throw new InvalidOperationException("UpdatePrioritization for time not supported for reprioritization"); | ||
4189 | case Scene.UpdatePrioritizationSchemes.Distance: | ||
4190 | case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance: | ||
4191 | return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition); | ||
4192 | case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack: | ||
4193 | return GetPriorityByFrontBack(CameraPosition, CameraAtAxis); | ||
4194 | default: | ||
4195 | throw new InvalidOperationException("UpdatePrioritizationScheme not defined"); | ||
4196 | } | ||
4197 | } | ||
4198 | else | ||
4199 | { | ||
4200 | group = Scene.GetGroupByPrim(data.localID); | ||
4201 | if (group != null) | ||
4202 | return GetSOGUpdatePriority(group); | ||
4203 | } | ||
4204 | return double.NaN; | ||
4205 | } | ||
4206 | |||
4207 | private void ReprioritizeUpdates() | 4093 | private void ReprioritizeUpdates() |
4208 | { | 4094 | { |
4209 | if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != Scene.UpdatePrioritizationSchemes.Time) | 4095 | if (Scene.IsReprioritizationEnabled && Scene.UpdatePrioritizationScheme != UpdatePrioritizationSchemes.Time) |
4210 | { | 4096 | { |
4211 | lock (m_reprioritization_timer) | 4097 | lock (m_reprioritization_timer) |
4212 | { | 4098 | { |
@@ -4220,7 +4106,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos); | |||
4220 | 4106 | ||
4221 | private void Reprioritize(object sender, ElapsedEventArgs e) | 4107 | private void Reprioritize(object sender, ElapsedEventArgs e) |
4222 | { | 4108 | { |
4223 | m_controllingClient.ReprioritizeUpdates(UpdatePriority); | 4109 | m_controllingClient.ReprioritizeUpdates(); |
4224 | 4110 | ||
4225 | lock (m_reprioritization_timer) | 4111 | lock (m_reprioritization_timer) |
4226 | { | 4112 | { |