aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-12-17 00:11:17 +0000
committerJustin Clark-Casey (justincc)2011-12-17 00:11:17 +0000
commit1bf05fbb1f8cc4832d8c8963556d8082181f810a (patch)
tree74cf31834abc9b74390c6fa14866bc4108a9f1d7 /OpenSim/Region/Framework
parentStop generating client flags when we send out full object updates. (diff)
downloadopensim-SC_OLD-1bf05fbb1f8cc4832d8c8963556d8082181f810a.zip
opensim-SC_OLD-1bf05fbb1f8cc4832d8c8963556d8082181f810a.tar.gz
opensim-SC_OLD-1bf05fbb1f8cc4832d8c8963556d8082181f810a.tar.bz2
opensim-SC_OLD-1bf05fbb1f8cc4832d8c8963556d8082181f810a.tar.xz
refactor: simplify methods in Scene.PacketHandlers.cs by using GetGroupByPrim() rather than retrieving GetEntities() and inspecting the entire list
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs209
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs14
2 files changed, 81 insertions, 142 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index 6ba74c7..f9d0e0a 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -116,18 +116,10 @@ namespace OpenSim.Region.Framework.Scenes
116 /// <param name="remoteClient"></param> 116 /// <param name="remoteClient"></param>
117 public void RequestPrim(uint primLocalID, IClientAPI remoteClient) 117 public void RequestPrim(uint primLocalID, IClientAPI remoteClient)
118 { 118 {
119 EntityBase[] entityList = GetEntities(); 119 SceneObjectGroup sog = GetGroupByPrim(primLocalID);
120 foreach (EntityBase ent in entityList) 120
121 { 121 if (sog != null)
122 if (ent is SceneObjectGroup) 122 sog.SendFullUpdateToClient(remoteClient);
123 {
124 if (((SceneObjectGroup)ent).LocalId == primLocalID)
125 {
126 ((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient);
127 return;
128 }
129 }
130 }
131 } 123 }
132 124
133 /// <summary> 125 /// <summary>
@@ -137,47 +129,28 @@ namespace OpenSim.Region.Framework.Scenes
137 /// <param name="remoteClient"></param> 129 /// <param name="remoteClient"></param>
138 public void SelectPrim(uint primLocalID, IClientAPI remoteClient) 130 public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
139 { 131 {
140 EntityBase[] entityList = GetEntities(); 132 SceneObjectPart part = GetSceneObjectPart(primLocalID);
141 foreach (EntityBase ent in entityList) 133
134 if (null == part)
135 return;
136
137 if (part.IsRoot)
142 { 138 {
143 if (ent is SceneObjectGroup) 139 SceneObjectGroup sog = part.ParentGroup;
140 sog.SendPropertiesToClient(remoteClient);
141 sog.IsSelected = true;
142
143 // A prim is only tainted if it's allowed to be edited by the person clicking it.
144 if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)
145 || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId))
144 { 146 {
145 if (((SceneObjectGroup) ent).LocalId == primLocalID) 147 EventManager.TriggerParcelPrimCountTainted();
146 {
147 ((SceneObjectGroup) ent).SendPropertiesToClient(remoteClient);
148 ((SceneObjectGroup) ent).IsSelected = true;
149 // A prim is only tainted if it's allowed to be edited by the person clicking it.
150 if (Permissions.CanEditObject(((SceneObjectGroup)ent).UUID, remoteClient.AgentId)
151 || Permissions.CanMoveObject(((SceneObjectGroup)ent).UUID, remoteClient.AgentId))
152 {
153 EventManager.TriggerParcelPrimCountTainted();
154 }
155 break;
156 }
157 else
158 {
159 // We also need to check the children of this prim as they
160 // can be selected as well and send property information
161 bool foundPrim = false;
162
163 SceneObjectGroup sog = ent as SceneObjectGroup;
164
165 SceneObjectPart[] partList = sog.Parts;
166 foreach (SceneObjectPart part in partList)
167 {
168 if (part.LocalId == primLocalID)
169 {
170 part.SendPropertiesToClient(remoteClient);
171 foundPrim = true;
172 break;
173 }
174 }
175
176 if (foundPrim)
177 break;
178 }
179 } 148 }
180 } 149 }
150 else
151 {
152 part.SendPropertiesToClient(remoteClient);
153 }
181 } 154 }
182 155
183 /// <summary> 156 /// <summary>
@@ -250,121 +223,81 @@ namespace OpenSim.Region.Framework.Scenes
250 223
251 public virtual void ProcessObjectGrab(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) 224 public virtual void ProcessObjectGrab(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
252 { 225 {
253 EntityBase[] EntityList = GetEntities(); 226 SceneObjectPart part = GetSceneObjectPart(localID);
227
228 if (part == null)
229 return;
230
231 SceneObjectGroup obj = part.ParentGroup;
254 232
255 SurfaceTouchEventArgs surfaceArg = null; 233 SurfaceTouchEventArgs surfaceArg = null;
256 if (surfaceArgs != null && surfaceArgs.Count > 0) 234 if (surfaceArgs != null && surfaceArgs.Count > 0)
257 surfaceArg = surfaceArgs[0]; 235 surfaceArg = surfaceArgs[0];
258 236
259 foreach (EntityBase ent in EntityList) 237 // Currently only grab/touch for the single prim
238 // the client handles rez correctly
239 obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
240
241 // If the touched prim handles touches, deliver it
242 // If not, deliver to root prim
243 if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
244 EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
245
246 // Deliver to the root prim if the touched prim doesn't handle touches
247 // or if we're meant to pass on touches anyway. Don't send to root prim
248 // if prim touched is the root prim as we just did it
249 if (((part.ScriptEvents & scriptEvents.touch_start) == 0) ||
250 (part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
260 { 251 {
261 if (ent is SceneObjectGroup) 252 EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
262 {
263 SceneObjectGroup obj = ent as SceneObjectGroup;
264 if (obj != null)
265 {
266 // Is this prim part of the group
267 if (obj.HasChildPrim(localID))
268 {
269 // Currently only grab/touch for the single prim
270 // the client handles rez correctly
271 obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
272
273 SceneObjectPart part = obj.GetChildPart(localID);
274
275 // If the touched prim handles touches, deliver it
276 // If not, deliver to root prim
277 if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
278 EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
279 // Deliver to the root prim if the touched prim doesn't handle touches
280 // or if we're meant to pass on touches anyway. Don't send to root prim
281 // if prim touched is the root prim as we just did it
282 if (((part.ScriptEvents & scriptEvents.touch_start) == 0) ||
283 (part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
284 {
285 EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
286 }
287
288 return;
289 }
290 }
291 }
292 } 253 }
293 } 254 }
294 255
295 public virtual void ProcessObjectGrabUpdate(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) 256 public virtual void ProcessObjectGrabUpdate(
257 UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
296 { 258 {
297 EntityBase[] EntityList = GetEntities(); 259 SceneObjectPart part = GetSceneObjectPart(objectID);
260 if (part == null)
261 return;
262
263 SceneObjectGroup obj = part.ParentGroup;
298 264
299 SurfaceTouchEventArgs surfaceArg = null; 265 SurfaceTouchEventArgs surfaceArg = null;
300 if (surfaceArgs != null && surfaceArgs.Count > 0) 266 if (surfaceArgs != null && surfaceArgs.Count > 0)
301 surfaceArg = surfaceArgs[0]; 267 surfaceArg = surfaceArgs[0];
302 268
303 foreach (EntityBase ent in EntityList) 269 // If the touched prim handles touches, deliver it
270 // If not, deliver to root prim
271 if ((part.ScriptEvents & scriptEvents.touch) != 0)
272 EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
273 // Deliver to the root prim if the touched prim doesn't handle touches
274 // or if we're meant to pass on touches anyway. Don't send to root prim
275 // if prim touched is the root prim as we just did it
276 if (((part.ScriptEvents & scriptEvents.touch) == 0) ||
277 (part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
304 { 278 {
305 if (ent is SceneObjectGroup) 279 EventManager.TriggerObjectGrabbing(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
306 {
307 SceneObjectGroup obj = ent as SceneObjectGroup;
308 if (obj != null)
309 {
310 // Is this prim part of the group
311 if (obj.HasChildPrim(objectID))
312 {
313 SceneObjectPart part = obj.GetChildPart(objectID);
314
315 // If the touched prim handles touches, deliver it
316 // If not, deliver to root prim
317 if ((part.ScriptEvents & scriptEvents.touch) != 0)
318 EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
319 // Deliver to the root prim if the touched prim doesn't handle touches
320 // or if we're meant to pass on touches anyway. Don't send to root prim
321 // if prim touched is the root prim as we just did it
322 if (((part.ScriptEvents & scriptEvents.touch) == 0) ||
323 (part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
324 {
325 EventManager.TriggerObjectGrabbing(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
326 }
327
328 return;
329 }
330 }
331 }
332 } 280 }
333 } 281 }
334 282
335 public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs) 283 public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
336 { 284 {
337 EntityBase[] EntityList = GetEntities(); 285 SceneObjectPart part = GetSceneObjectPart(localID);
286 if (part == null)
287 return;
288
289 SceneObjectGroup obj = part.ParentGroup;
338 290
339 SurfaceTouchEventArgs surfaceArg = null; 291 SurfaceTouchEventArgs surfaceArg = null;
340 if (surfaceArgs != null && surfaceArgs.Count > 0) 292 if (surfaceArgs != null && surfaceArgs.Count > 0)
341 surfaceArg = surfaceArgs[0]; 293 surfaceArg = surfaceArgs[0];
342 294
343 foreach (EntityBase ent in EntityList) 295 // If the touched prim handles touches, deliver it
344 { 296 // If not, deliver to root prim
345 if (ent is SceneObjectGroup) 297 if ((part.ScriptEvents & scriptEvents.touch_end) != 0)
346 { 298 EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg);
347 SceneObjectGroup obj = ent as SceneObjectGroup; 299 else
348 300 EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
349 // Is this prim part of the group
350 if (obj.HasChildPrim(localID))
351 {
352 SceneObjectPart part=obj.GetChildPart(localID);
353 if (part != null)
354 {
355 // If the touched prim handles touches, deliver it
356 // If not, deliver to root prim
357 if ((part.ScriptEvents & scriptEvents.touch_end) != 0)
358 EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg);
359 else
360 EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
361
362 return;
363 }
364 return;
365 }
366 }
367 }
368 } 301 }
369 302
370 public void ProcessAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query) 303 public void ProcessAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 20ef8c9..7bf8c34 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1373,8 +1373,13 @@ namespace OpenSim.Region.Framework.Scenes
1373 1373
1374 #endregion 1374 #endregion
1375 1375
1376 // Send the parts of this SOG to a single client 1376 /// <summary>
1377 // Used when the client initially connects and when client sends RequestPrim packet 1377 /// Send the parts of this SOG to a single client
1378 /// </summary>
1379 /// <remarks>
1380 /// Used when the client initially connects and when client sends RequestPrim packet
1381 /// </remarks>
1382 /// <param name="remoteClient"></param>
1378 public void SendFullUpdateToClient(IClientAPI remoteClient) 1383 public void SendFullUpdateToClient(IClientAPI remoteClient)
1379 { 1384 {
1380 RootPart.SendFullUpdate(remoteClient); 1385 RootPart.SendFullUpdate(remoteClient);
@@ -1678,10 +1683,11 @@ namespace OpenSim.Region.Framework.Scenes
1678 1683
1679 /// <summary> 1684 /// <summary>
1680 /// Reset the UUIDs for all the prims that make up this group. 1685 /// Reset the UUIDs for all the prims that make up this group.
1681 /// 1686 /// </summary>
1687 /// <remarks>
1682 /// This is called by methods which want to add a new group to an existing scene, in order 1688 /// This is called by methods which want to add a new group to an existing scene, in order
1683 /// to ensure that there are no clashes with groups already present. 1689 /// to ensure that there are no clashes with groups already present.
1684 /// </summary> 1690 /// </remarks>
1685 public void ResetIDs() 1691 public void ResetIDs()
1686 { 1692 {
1687 lock (m_parts.SyncRoot) 1693 lock (m_parts.SyncRoot)