refactor: simplify methods in Scene.PacketHandlers.cs by using GetGroupByPrim() rather than retrieving GetEntities() and inspecting the entire list
parent
4de98ca4c8
commit
7d426debd3
|
@ -116,18 +116,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="remoteClient"></param>
|
/// <param name="remoteClient"></param>
|
||||||
public void RequestPrim(uint primLocalID, IClientAPI remoteClient)
|
public void RequestPrim(uint primLocalID, IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
EntityBase[] entityList = GetEntities();
|
SceneObjectGroup sog = GetGroupByPrim(primLocalID);
|
||||||
foreach (EntityBase ent in entityList)
|
|
||||||
{
|
if (sog != null)
|
||||||
if (ent is SceneObjectGroup)
|
sog.SendFullUpdateToClient(remoteClient);
|
||||||
{
|
|
||||||
if (((SceneObjectGroup)ent).LocalId == primLocalID)
|
|
||||||
{
|
|
||||||
((SceneObjectGroup)ent).SendFullUpdateToClient(remoteClient);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -137,47 +129,28 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="remoteClient"></param>
|
/// <param name="remoteClient"></param>
|
||||||
public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
|
public void SelectPrim(uint primLocalID, IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
EntityBase[] entityList = GetEntities();
|
SceneObjectPart part = GetSceneObjectPart(primLocalID);
|
||||||
foreach (EntityBase ent in entityList)
|
|
||||||
|
if (null == part)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (part.IsRoot)
|
||||||
{
|
{
|
||||||
if (ent is SceneObjectGroup)
|
SceneObjectGroup sog = part.ParentGroup;
|
||||||
|
sog.SendPropertiesToClient(remoteClient);
|
||||||
|
sog.IsSelected = true;
|
||||||
|
|
||||||
|
// A prim is only tainted if it's allowed to be edited by the person clicking it.
|
||||||
|
if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)
|
||||||
|
|| Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId))
|
||||||
{
|
{
|
||||||
if (((SceneObjectGroup) ent).LocalId == primLocalID)
|
EventManager.TriggerParcelPrimCountTainted();
|
||||||
{
|
|
||||||
((SceneObjectGroup) ent).SendPropertiesToClient(remoteClient);
|
|
||||||
((SceneObjectGroup) ent).IsSelected = true;
|
|
||||||
// A prim is only tainted if it's allowed to be edited by the person clicking it.
|
|
||||||
if (Permissions.CanEditObject(((SceneObjectGroup)ent).UUID, remoteClient.AgentId)
|
|
||||||
|| Permissions.CanMoveObject(((SceneObjectGroup)ent).UUID, remoteClient.AgentId))
|
|
||||||
{
|
|
||||||
EventManager.TriggerParcelPrimCountTainted();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We also need to check the children of this prim as they
|
|
||||||
// can be selected as well and send property information
|
|
||||||
bool foundPrim = false;
|
|
||||||
|
|
||||||
SceneObjectGroup sog = ent as SceneObjectGroup;
|
|
||||||
|
|
||||||
SceneObjectPart[] partList = sog.Parts;
|
|
||||||
foreach (SceneObjectPart part in partList)
|
|
||||||
{
|
|
||||||
if (part.LocalId == primLocalID)
|
|
||||||
{
|
|
||||||
part.SendPropertiesToClient(remoteClient);
|
|
||||||
foundPrim = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (foundPrim)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
part.SendPropertiesToClient(remoteClient);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -250,121 +223,81 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public virtual void ProcessObjectGrab(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
|
public virtual void ProcessObjectGrab(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
|
||||||
{
|
{
|
||||||
EntityBase[] EntityList = GetEntities();
|
SceneObjectPart part = GetSceneObjectPart(localID);
|
||||||
|
|
||||||
|
if (part == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SceneObjectGroup obj = part.ParentGroup;
|
||||||
|
|
||||||
SurfaceTouchEventArgs surfaceArg = null;
|
SurfaceTouchEventArgs surfaceArg = null;
|
||||||
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
||||||
surfaceArg = surfaceArgs[0];
|
surfaceArg = surfaceArgs[0];
|
||||||
|
|
||||||
foreach (EntityBase ent in EntityList)
|
// Currently only grab/touch for the single prim
|
||||||
|
// the client handles rez correctly
|
||||||
|
obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
|
||||||
|
|
||||||
|
// If the touched prim handles touches, deliver it
|
||||||
|
// If not, deliver to root prim
|
||||||
|
if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
|
||||||
|
EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
|
||||||
|
|
||||||
|
// Deliver to the root prim if the touched prim doesn't handle touches
|
||||||
|
// or if we're meant to pass on touches anyway. Don't send to root prim
|
||||||
|
// if prim touched is the root prim as we just did it
|
||||||
|
if (((part.ScriptEvents & scriptEvents.touch_start) == 0) ||
|
||||||
|
(part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
|
||||||
{
|
{
|
||||||
if (ent is SceneObjectGroup)
|
EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
|
||||||
{
|
|
||||||
SceneObjectGroup obj = ent as SceneObjectGroup;
|
|
||||||
if (obj != null)
|
|
||||||
{
|
|
||||||
// Is this prim part of the group
|
|
||||||
if (obj.HasChildPrim(localID))
|
|
||||||
{
|
|
||||||
// Currently only grab/touch for the single prim
|
|
||||||
// the client handles rez correctly
|
|
||||||
obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
|
|
||||||
|
|
||||||
SceneObjectPart part = obj.GetChildPart(localID);
|
|
||||||
|
|
||||||
// If the touched prim handles touches, deliver it
|
|
||||||
// If not, deliver to root prim
|
|
||||||
if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
|
|
||||||
EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
|
|
||||||
// Deliver to the root prim if the touched prim doesn't handle touches
|
|
||||||
// or if we're meant to pass on touches anyway. Don't send to root prim
|
|
||||||
// if prim touched is the root prim as we just did it
|
|
||||||
if (((part.ScriptEvents & scriptEvents.touch_start) == 0) ||
|
|
||||||
(part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
|
|
||||||
{
|
|
||||||
EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ProcessObjectGrabUpdate(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
|
public virtual void ProcessObjectGrabUpdate(
|
||||||
|
UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
|
||||||
{
|
{
|
||||||
EntityBase[] EntityList = GetEntities();
|
SceneObjectPart part = GetSceneObjectPart(objectID);
|
||||||
|
if (part == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SceneObjectGroup obj = part.ParentGroup;
|
||||||
|
|
||||||
SurfaceTouchEventArgs surfaceArg = null;
|
SurfaceTouchEventArgs surfaceArg = null;
|
||||||
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
||||||
surfaceArg = surfaceArgs[0];
|
surfaceArg = surfaceArgs[0];
|
||||||
|
|
||||||
foreach (EntityBase ent in EntityList)
|
// If the touched prim handles touches, deliver it
|
||||||
|
// If not, deliver to root prim
|
||||||
|
if ((part.ScriptEvents & scriptEvents.touch) != 0)
|
||||||
|
EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
|
||||||
|
// Deliver to the root prim if the touched prim doesn't handle touches
|
||||||
|
// or if we're meant to pass on touches anyway. Don't send to root prim
|
||||||
|
// if prim touched is the root prim as we just did it
|
||||||
|
if (((part.ScriptEvents & scriptEvents.touch) == 0) ||
|
||||||
|
(part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
|
||||||
{
|
{
|
||||||
if (ent is SceneObjectGroup)
|
EventManager.TriggerObjectGrabbing(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
|
||||||
{
|
|
||||||
SceneObjectGroup obj = ent as SceneObjectGroup;
|
|
||||||
if (obj != null)
|
|
||||||
{
|
|
||||||
// Is this prim part of the group
|
|
||||||
if (obj.HasChildPrim(objectID))
|
|
||||||
{
|
|
||||||
SceneObjectPart part = obj.GetChildPart(objectID);
|
|
||||||
|
|
||||||
// If the touched prim handles touches, deliver it
|
|
||||||
// If not, deliver to root prim
|
|
||||||
if ((part.ScriptEvents & scriptEvents.touch) != 0)
|
|
||||||
EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
|
|
||||||
// Deliver to the root prim if the touched prim doesn't handle touches
|
|
||||||
// or if we're meant to pass on touches anyway. Don't send to root prim
|
|
||||||
// if prim touched is the root prim as we just did it
|
|
||||||
if (((part.ScriptEvents & scriptEvents.touch) == 0) ||
|
|
||||||
(part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
|
|
||||||
{
|
|
||||||
EventManager.TriggerObjectGrabbing(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
|
public virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
|
||||||
{
|
{
|
||||||
EntityBase[] EntityList = GetEntities();
|
SceneObjectPart part = GetSceneObjectPart(localID);
|
||||||
|
if (part == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SceneObjectGroup obj = part.ParentGroup;
|
||||||
|
|
||||||
SurfaceTouchEventArgs surfaceArg = null;
|
SurfaceTouchEventArgs surfaceArg = null;
|
||||||
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
||||||
surfaceArg = surfaceArgs[0];
|
surfaceArg = surfaceArgs[0];
|
||||||
|
|
||||||
foreach (EntityBase ent in EntityList)
|
// If the touched prim handles touches, deliver it
|
||||||
{
|
// If not, deliver to root prim
|
||||||
if (ent is SceneObjectGroup)
|
if ((part.ScriptEvents & scriptEvents.touch_end) != 0)
|
||||||
{
|
EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg);
|
||||||
SceneObjectGroup obj = ent as SceneObjectGroup;
|
else
|
||||||
|
EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
|
||||||
// Is this prim part of the group
|
|
||||||
if (obj.HasChildPrim(localID))
|
|
||||||
{
|
|
||||||
SceneObjectPart part=obj.GetChildPart(localID);
|
|
||||||
if (part != null)
|
|
||||||
{
|
|
||||||
// If the touched prim handles touches, deliver it
|
|
||||||
// If not, deliver to root prim
|
|
||||||
if ((part.ScriptEvents & scriptEvents.touch_end) != 0)
|
|
||||||
EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg);
|
|
||||||
else
|
|
||||||
EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
|
public void ProcessAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
|
||||||
|
|
|
@ -1388,6 +1388,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Send the parts of this SOG to a single client
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Used when the client initially connects and when client sends RequestPrim packet
|
||||||
|
/// </remarks>
|
||||||
|
/// <param name="remoteClient"></param>
|
||||||
public void SendFullUpdateToClient(IClientAPI remoteClient)
|
public void SendFullUpdateToClient(IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
RootPart.SendFullUpdate(remoteClient);
|
RootPart.SendFullUpdate(remoteClient);
|
||||||
|
@ -1691,10 +1698,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the UUIDs for all the prims that make up this group.
|
/// Reset the UUIDs for all the prims that make up this group.
|
||||||
///
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
/// This is called by methods which want to add a new group to an existing scene, in order
|
/// This is called by methods which want to add a new group to an existing scene, in order
|
||||||
/// to ensure that there are no clashes with groups already present.
|
/// to ensure that there are no clashes with groups already present.
|
||||||
/// </summary>
|
/// </remarks>
|
||||||
public void ResetIDs()
|
public void ResetIDs()
|
||||||
{
|
{
|
||||||
lock (m_parts.SyncRoot)
|
lock (m_parts.SyncRoot)
|
||||||
|
|
Loading…
Reference in New Issue