Fixed code in handling setting attachedAvatar when its UUID.Zero.

Removed some obselete and debug code.
dsg
Huaiyu (Kitty) Liu 2011-05-19 13:44:15 -07:00
parent 2f7ecf359b
commit ab0630ed81
10 changed files with 49 additions and 177 deletions

View File

@ -567,8 +567,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
{ {
m_log.DebugFormat("[ATTACHMENTS MODULE] Region {5}: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name, m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", Name, avatar.Name,
attachmentpoint, attachOffset, so.RootPart.AttachedPos, m_scene.RegionInfo.RegionName); attachmentpoint, attachOffset, so.RootPart.AttachedPos);
so.DetachFromBackup(); so.DetachFromBackup();

View File

@ -511,10 +511,12 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
m_log.ErrorFormat("{0} Caught exception in UpdatedAvatar handler (TrySetMovementAnimation): {1}", LogHeader(), e.Message); m_log.ErrorFormat("{0} Caught exception in UpdatedAvatar handler (TrySetMovementAnimation): {1}", LogHeader(), e.Message);
} }
/*
string result = String.Format("Avatar \"{0}\" ({1}) ({2}) updated (pos:{3}, vel:{4}, rot:{5}, fly:{6})", string result = String.Format("Avatar \"{0}\" ({1}) ({2}) updated (pos:{3}, vel:{4}, rot:{5}, fly:{6})",
presence.Name, presence.UUID.ToString(), presence.LocalId.ToString(), presence.Name, presence.UUID.ToString(), presence.LocalId.ToString(),
presence.AbsolutePosition.ToString(), presence.Velocity.ToString(), presence.AbsolutePosition.ToString(), presence.Velocity.ToString(),
presence.Rotation.ToString(), presence.PhysicsActor.Flying ? "Y" : "N"); presence.Rotation.ToString(), presence.PhysicsActor.Flying ? "Y" : "N");
* */
// RegionSyncMessage.HandleSuccess(LogHeader(), msg, result); // RegionSyncMessage.HandleSuccess(LogHeader(), msg, result);
return; return;
} }

View File

@ -234,9 +234,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_log.DebugFormat("[REGION SYNC SERVER MODULE] QueuePresenceForUpdate: {0}", presence.UUID.ToString()); //m_log.DebugFormat("[REGION SYNC SERVER MODULE] QueuePresenceForUpdate: {0}", presence.UUID.ToString());
} }
//DSG DEBUG
private Vector3 lastPos;
public void SendUpdates() public void SendUpdates()
{ {
if (!Active || !Synced) if (!Active || !Synced)
@ -300,14 +297,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
presence.lastSentParentID = presence.ParentID; presence.lastSentParentID = presence.ParentID;
} }
//DSG DEBUG
//Vector3 diff = presence.AbsolutePosition - lastPos;
if (Vector3.Distance(presence.AbsolutePosition, lastPos) > 0.1)
{
m_log.DebugFormat("Sending UpdatedAvatar for avatar {0}, with new pos {1}", presence.Name, presence.AbsolutePosition);
lastPos = presence.AbsolutePosition;
}
RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.UpdatedAvatar, OSDParser.SerializeJsonString(data)); RegionSyncMessage rsm = new RegionSyncMessage(RegionSyncMessage.MsgType.UpdatedAvatar, OSDParser.SerializeJsonString(data));
m_server.EnqueuePresenceUpdate(presence.UUID, rsm.ToBytes()); m_server.EnqueuePresenceUpdate(presence.UUID, rsm.ToBytes());

View File

@ -196,114 +196,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
get { return m_isSyncRelay; } get { return m_isSyncRelay; }
} }
private Dictionary<SceneObjectPartSyncProperties, string> m_primPropertyBucketMap = new Dictionary<SceneObjectPartSyncProperties, string>();
public Dictionary<SceneObjectPartSyncProperties, string> PrimPropertyBucketMap
{
get { return m_primPropertyBucketMap; }
}
private List<string> m_propertyBucketNames = new List<string>();
public List<string> PropertyBucketDescription
{
get { return m_propertyBucketNames; }
}
public void QueueScenePresenceForTerseUpdate(ScenePresence presence)
{
lock (m_updateScenePresenceLock)
{
m_presenceUpdates[presence.UUID] = presence;
}
}
//SendSceneUpdates put each update into an outgoing queue of each SyncConnector
/// <summary>
/// Send updates to other sync nodes. So far we only handle object updates.
/// </summary>
public void SendSceneUpdates()
{
if (!IsSyncingWithOtherSyncNodes())
{
//no SyncConnector connected. clear update queues and return.
foreach (string bucketName in m_propertyBucketNames)
{
m_primUpdates[bucketName].Clear();
}
return;
}
// Existing value of 1 indicates that updates are currently being sent so skip updates this pass
if (Interlocked.Exchange(ref m_sendingUpdates, 1) == 1)
{
m_log.DebugFormat("[REGION SYNC MODULE] SendUpdates(): An update thread is already running.");
return;
}
Dictionary<string, List<SceneObjectPart>> primUpdates = new Dictionary<string,List<SceneObjectPart>>();
bool updated = false;
//copy the updated SOG list and clear m_primUpdates for immediately future usage
foreach (string bucketName in m_propertyBucketNames)
{
if (m_primUpdates[bucketName].Count > 0)
{
//m_log.DebugFormat(m_primUpdates[bucketName].Count + " to send {0} updated parts in bucket {1}", m_primUpdates[bucketName].Count, bucketName);
lock (m_primUpdateLocks[bucketName])
{
updated = true;
//primUpdates.Add(bucketName, new List<SceneObjectPart>(m_primUpdates[bucketName].Values));
//copy the update list
List<SceneObjectPart> updateList = new List<SceneObjectPart>();
foreach (SceneObjectPart part in m_primUpdates[bucketName].Values)
{
if (!part.ParentGroup.IsDeleted)
{
//m_log.DebugFormat("include {0},{1} in update list", part.Name, part.UUID);
updateList.Add(part);
}
}
primUpdates.Add(bucketName, updateList);
m_primUpdates[bucketName].Clear();
}
}
}
if (updated)
{
long timeStamp = DateTime.Now.Ticks;
// This could be another thread for sending outgoing messages or just have the Queue functions
// create and queue the messages directly into the outgoing server thread.
System.Threading.ThreadPool.QueueUserWorkItem(delegate
{
// Dan's note: Sending the message when it's first queued would yield lower latency but much higher load on the simulator
// as parts may be updated many many times very quickly. Need to implement a higher resolution send in heartbeat
foreach (string bucketName in m_propertyBucketNames)
{
if (primUpdates.ContainsKey(bucketName) && primUpdates[bucketName].Count > 0)
{
//m_log.Debug(LogHeader + " calling update sender for bucket " + bucketName);
m_primUpdatesPerBucketSender[bucketName](bucketName, primUpdates[bucketName]);
primUpdates[bucketName].Clear();
}
}
// Indicate that the current batch of updates has been completed
Interlocked.Exchange(ref m_sendingUpdates, 0);
});
}
else
{
Interlocked.Exchange(ref m_sendingUpdates, 0);
}
}
//The following Sendxxx calls,send out a message immediately, w/o putting it in the SyncConnector's outgoing queue. //The following Sendxxx calls,send out a message immediately, w/o putting it in the SyncConnector's outgoing queue.
//May need some optimization there on the priorities. //May need some optimization there on the priorities.
@ -2654,12 +2546,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//m_log.DebugFormat("{0}: SendPrimPropertyUpdates for {1}, {2}, with updated properties -- {3}", LogHeader, sop.Name, sop.UUID, pString); //m_log.DebugFormat("{0}: SendPrimPropertyUpdates for {1}, {2}, with updated properties -- {3}", LogHeader, sop.Name, sop.UUID, pString);
//DSG DEBUG //DSG DEBUG
/*
if (updatedProperties.Contains(SceneObjectPartSyncProperties.AggregateScriptEvents)) if (updatedProperties.Contains(SceneObjectPartSyncProperties.GroupPosition))
{ {
// m_log.DebugFormat("SendPrimPropertyUpdates -- AggregateScriptEvents: " + sop.AggregateScriptEvents); m_log.DebugFormat("SendPrimPropertyUpdates -- prim {0}: GroupPosition: {1} ", sop.Name, sop.GroupPosition);
} }
if (updatedProperties.Contains(SceneObjectPartSyncProperties.Position))
{
m_log.DebugFormat("SendPrimPropertyUpdates -- prim {0}: Position: {1} ", sop.Name, sop.PhysActor.Position);
}
* */
SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedPrimProperties, OSDParser.SerializeJsonString(syncData)); SymmetricSyncMessage syncMsg = new SymmetricSyncMessage(SymmetricSyncMessage.MsgType.UpdatedPrimProperties, OSDParser.SerializeJsonString(syncData));
SendPrimUpdateToRelevantSyncConnectors(sop.UUID, syncMsg); SendPrimUpdateToRelevantSyncConnectors(sop.UUID, syncMsg);
@ -5553,29 +5449,37 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
if (!part.AttachedAvatar.Equals(attachedAvatar)) if (!part.AttachedAvatar.Equals(attachedAvatar))
{ {
part.AttachedAvatar = attachedAvatar; part.AttachedAvatar = attachedAvatar;
Scene localScene = GetLocalScene(); if (attachedAvatar != UUID.Zero)
ScenePresence avatar = localScene.GetScenePresence(attachedAvatar);
//It is possible that the avatar has not been fully
//created locally when attachment objects are sync'ed.
//So we need to check if the avatar already exists.
//If not, handling of NewAvatar will evetually trigger
//calling of SetParentLocalId.
if (avatar != null)
{ {
if (part.ParentGroup != null) Scene localScene = GetLocalScene();
ScenePresence avatar = localScene.GetScenePresence(attachedAvatar);
//It is possible that the avatar has not been fully
//created locally when attachment objects are sync'ed.
//So we need to check if the avatar already exists.
//If not, handling of NewAvatar will evetually trigger
//calling of SetParentLocalId.
if (avatar != null)
{ {
part.ParentGroup.RootPart.SetParentLocalId(avatar.LocalId); if (part.ParentGroup != null)
} {
else part.ParentGroup.RootPart.SetParentLocalId(avatar.LocalId);
{ }
//If this SOP is not a part of group yet, record the else
//avatar's localID for now. If this SOP is rootpart of {
//the group, then the localID is the right setting; //If this SOP is not a part of group yet, record the
//otherwise, this SOP will be linked to the SOG it belongs //avatar's localID for now. If this SOP is rootpart of
//to later, and that will rewrite the parent localID. //the group, then the localID is the right setting;
part.SetParentLocalId(avatar.LocalId); //otherwise, this SOP will be linked to the SOG it belongs
//to later, and that will rewrite the parent localID.
part.SetParentLocalId(avatar.LocalId);
}
} }
} }
else
{
part.SetParentLocalId(0);
}
} }
break; break;
case SceneObjectPartSyncProperties.AttachedPos: case SceneObjectPartSyncProperties.AttachedPos:

View File

@ -57,41 +57,15 @@ namespace OpenSim.Region.Framework.Interfaces
//DSGActorTypes DSGActorType { get; set; } //DSGActorTypes DSGActorType { get; set; }
bool IsSyncRelay { get; } bool IsSyncRelay { get; }
/// <summary>
/// The mapping of a property (identified by its name) to the index of a bucket.
/// </summary>
Dictionary<SceneObjectPartSyncProperties, string> PrimPropertyBucketMap { get; }
/// <summary>
/// The text description of the properties in each bucket, e.g. "General", "Physics"
/// </summary>
List<string> PropertyBucketDescription { get; }
//Enqueue updates for scene-objects and scene-presences
//Legacy interface, used in Bucket-sync
//void QueueSceneObjectPartForUpdate(SceneObjectPart part);
void QueueScenePresenceForTerseUpdate(ScenePresence presence);
//void ProcessAndEnqueuePrimUpdatesBySync(SceneObjectPart part, List<SceneObjectPartSyncProperties> updatedProperties);
void ProcessAndEnqueuePrimUpdatesByLocal(SceneObjectPart part, List<SceneObjectPartSyncProperties> updatedProperties); void ProcessAndEnqueuePrimUpdatesByLocal(SceneObjectPart part, List<SceneObjectPartSyncProperties> updatedProperties);
void SyncOutPrimUpdates(); void SyncOutPrimUpdates();
//Legacy calls in Bucket sync'ing
//The folloiwng calls deal with object updates, and will insert each update into an outgoing queue of each SyncConnector
//void SendSceneUpdates();
//void SendNewObject(SceneObjectGroup sog);
//void SendDeleteObject(SceneObjectGroup sog, bool softDelete);
//void SendLinkObject(SceneObjectGroup linkedGroup, SceneObjectPart root, List<SceneObjectPart> children);
//void SendDeLinkObject(List<SceneObjectPart> prims, List<SceneObjectGroup> beforeDelinkGroups, List<SceneObjectGroup> afterDelinkGroups);
//New functions for per property sync'ing //New functions for per property sync'ing
void SyncNewObject(SceneObjectGroup sog); void SyncNewObject(SceneObjectGroup sog);
void SyncDeleteObject(SceneObjectGroup sog, bool softDelete); void SyncDeleteObject(SceneObjectGroup sog, bool softDelete);
void SyncLinkObject(SceneObjectGroup linkedGroup, SceneObjectPart root, List<SceneObjectPart> children); void SyncLinkObject(SceneObjectGroup linkedGroup, SceneObjectPart root, List<SceneObjectPart> children);
void SyncDeLinkObject(List<SceneObjectPart> prims, List<SceneObjectGroup> beforeDelinkGroups, List<SceneObjectGroup> afterDelinkGroups); void SyncDeLinkObject(List<SceneObjectPart> prims, List<SceneObjectGroup> beforeDelinkGroups, List<SceneObjectGroup> afterDelinkGroups);
//In RegionSyncModule's implementation,
//The following calls send out a message immediately, w/o putting it in the SyncConnector's outgoing queue.
//May need some optimization there on the priorities.
void SendTerrainUpdates(long updateTimeStamp, string lastUpdateActorID); void SendTerrainUpdates(long updateTimeStamp, string lastUpdateActorID);
//For propogating scene events to other actors //For propogating scene events to other actors
void PublishSceneEvent(EventManager.EventNames ev, Object[] evArgs); void PublishSceneEvent(EventManager.EventNames ev, Object[] evArgs);
@ -101,7 +75,7 @@ namespace OpenSim.Region.Framework.Interfaces
//void QueuePresenceForTerseUpdate(ScenePresence presence) //void QueuePresenceForTerseUpdate(ScenePresence presence)
//void SendAvatarUpdates(); //void SendAvatarUpdates();
//Debug purpose, mainly for LSL scripts //Debug purpose, mainly for debugging properties updated by LSL scripts
void Debug(String debugMsg); void Debug(String debugMsg);
} }

View File

@ -3700,6 +3700,11 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.RemoveScenePresence(agentID); m_sceneGraph.RemoveScenePresence(agentID);
m_clientManager.Remove(agentID); m_clientManager.Remove(agentID);
//DSG
// We need to keep track of this state in case this group is still queued for sync'ing.
avatar.IsDeleted = true;
//end of DSG
try try
{ {
avatar.Close(); avatar.Close();

View File

@ -434,7 +434,7 @@ namespace OpenSim.Region.Framework.Scenes
//sceneObject.ScheduleGroupForFullUpdate(); //sceneObject.ScheduleGroupForFullUpdate();
sceneObject.ScheduleGroupForFullUpdate(null); sceneObject.ScheduleGroupForFullUpdate(null);
//DSG SYNC: sending NewObject event, and sending it before calling ScheduleGroupForFullUpdate //DSG SYNC: sending NewObject event,
if (m_parentScene.RegionSyncModule != null && triggerSyncNewObject) if (m_parentScene.RegionSyncModule != null && triggerSyncNewObject)
{ {
m_parentScene.RegionSyncModule.SyncNewObject(sceneObject); m_parentScene.RegionSyncModule.SyncNewObject(sceneObject);

View File

@ -983,7 +983,8 @@ namespace OpenSim.Region.Framework.Scenes
AttachToBackup(); AttachToBackup();
m_scene.EventManager.TriggerParcelPrimCountTainted(); m_scene.EventManager.TriggerParcelPrimCountTainted();
//m_rootPart.ScheduleFullUpdate(); //m_rootPart.ScheduleFullUpdate();
m_rootPart.ScheduleFullUpdate(new List<SceneObjectPartSyncProperties>() { SceneObjectPartSyncProperties.GroupPosition, SceneObjectPartSyncProperties.AttachmentPoint}); //Physics properties, such as Position, OffsetPosition, etc, should be tainted in ApplyPhysics() m_rootPart.ScheduleFullUpdate(new List<SceneObjectPartSyncProperties>() { SceneObjectPartSyncProperties.GroupPosition, SceneObjectPartSyncProperties.AttachmentPoint,
SceneObjectPartSyncProperties.AttachedAvatar, SceneObjectPartSyncProperties.Flags}); //Physics properties, such as Position, OffsetPosition, etc, should be tainted in ApplyPhysics()
m_rootPart.ClearUndoState(); m_rootPart.ClearUndoState();
} }

View File

@ -773,7 +773,7 @@ namespace OpenSim.Region.Framework.Scenes
if (IsAttachment) if (IsAttachment)
{ {
if (m_parentGroup != null) //need to check this, it would be null while deserialization -- IsAttachment is now serialized if (m_parentGroup != null)
{ {
ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar);
if (sp != null) if (sp != null)

View File

@ -2938,9 +2938,6 @@ namespace OpenSim.Region.Framework.Scenes
} }
else if (neighbor > 0) else if (neighbor > 0)
{ {
//DSG DEBUG
m_log.DebugFormat("{0} now at pos {1}, calling CrossToNewRegion", Name);
if (!CrossToNewRegion()) if (!CrossToNewRegion())
{ {
if (m_requestedSitTargetUUID == UUID.Zero) if (m_requestedSitTargetUUID == UUID.Zero)