Fix a rather nasty issue where the Backup() process causes objects and avatars sitting on them to be pushed to the corner of the sim.
parent
8d3a73d126
commit
19ab4c9508
|
@ -318,7 +318,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
private bool m_scriptListens_atRotTarget = false;
|
private bool m_scriptListens_atRotTarget = false;
|
||||||
private bool m_scriptListens_notAtRotTarget = false;
|
private bool m_scriptListens_notAtRotTarget = false;
|
||||||
|
public bool m_dupeInProgress = false;
|
||||||
internal Dictionary<UUID, string> m_savedScriptState = null;
|
internal Dictionary<UUID, string> m_savedScriptState = null;
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
@ -476,15 +476,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
part.IgnoreUndoUpdate = false;
|
part.IgnoreUndoUpdate = false;
|
||||||
part.StoreUndoState(UndoType.STATE_GROUP_POSITION);
|
part.StoreUndoState(UndoType.STATE_GROUP_POSITION);
|
||||||
part.GroupPosition = val;
|
part.GroupPosition = val;
|
||||||
part.TriggerScriptChangedEvent(Changed.POSITION);
|
if (!m_dupeInProgress)
|
||||||
|
{
|
||||||
|
part.TriggerScriptChangedEvent(Changed.POSITION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (!m_dupeInProgress)
|
||||||
foreach (ScenePresence av in m_linkedAvatars)
|
|
||||||
{
|
{
|
||||||
Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition;
|
foreach (ScenePresence av in m_linkedAvatars)
|
||||||
av.AbsolutePosition += offset;
|
{
|
||||||
av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition
|
Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition;
|
||||||
av.SendFullUpdateToAllClients();
|
av.AbsolutePosition += offset;
|
||||||
|
av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition
|
||||||
|
av.SendFullUpdateToAllClients();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (m_rootPart.PhysActor != null)
|
//if (m_rootPart.PhysActor != null)
|
||||||
|
@ -1801,87 +1806,95 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public SceneObjectGroup Copy(bool userExposed)
|
public SceneObjectGroup Copy(bool userExposed)
|
||||||
{
|
{
|
||||||
SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone();
|
SceneObjectGroup dupe;
|
||||||
dupe.m_isBackedUp = false;
|
try
|
||||||
dupe.m_parts = new Dictionary<UUID, SceneObjectPart>();
|
|
||||||
|
|
||||||
// Warning, The following code related to previousAttachmentStatus is needed so that clones of
|
|
||||||
// attachments do not bordercross while they're being duplicated. This is hacktastic!
|
|
||||||
// Normally, setting AbsolutePosition will bordercross a prim if it's outside the region!
|
|
||||||
// unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state
|
|
||||||
// (which should be false anyway) set it as an Attachment and then set it's Absolute Position,
|
|
||||||
// then restore it's attachment state
|
|
||||||
|
|
||||||
// This is only necessary when userExposed is false!
|
|
||||||
|
|
||||||
bool previousAttachmentStatus = dupe.RootPart.IsAttachment;
|
|
||||||
|
|
||||||
if (!userExposed)
|
|
||||||
dupe.RootPart.IsAttachment = true;
|
|
||||||
|
|
||||||
dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
|
|
||||||
|
|
||||||
if (!userExposed)
|
|
||||||
{
|
{
|
||||||
dupe.RootPart.IsAttachment = previousAttachmentStatus;
|
m_dupeInProgress = true;
|
||||||
}
|
dupe = (SceneObjectGroup)MemberwiseClone();
|
||||||
|
dupe.m_isBackedUp = false;
|
||||||
|
dupe.m_parts = new Dictionary<UUID, SceneObjectPart>();
|
||||||
|
|
||||||
dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
|
// Warning, The following code related to previousAttachmentStatus is needed so that clones of
|
||||||
dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
|
// attachments do not bordercross while they're being duplicated. This is hacktastic!
|
||||||
|
// Normally, setting AbsolutePosition will bordercross a prim if it's outside the region!
|
||||||
|
// unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state
|
||||||
|
// (which should be false anyway) set it as an Attachment and then set it's Absolute Position,
|
||||||
|
// then restore it's attachment state
|
||||||
|
|
||||||
if (userExposed)
|
// This is only necessary when userExposed is false!
|
||||||
dupe.m_rootPart.TrimPermissions();
|
|
||||||
|
|
||||||
/// may need to create a new Physics actor.
|
bool previousAttachmentStatus = dupe.RootPart.IsAttachment;
|
||||||
if (dupe.RootPart.PhysActor != null && userExposed)
|
|
||||||
{
|
|
||||||
PrimitiveBaseShape pbs = dupe.RootPart.Shape;
|
|
||||||
|
|
||||||
dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape(
|
if (!userExposed)
|
||||||
dupe.RootPart.Name,
|
dupe.RootPart.IsAttachment = true;
|
||||||
pbs,
|
|
||||||
dupe.RootPart.AbsolutePosition,
|
|
||||||
dupe.RootPart.Scale,
|
|
||||||
dupe.RootPart.RotationOffset,
|
|
||||||
dupe.RootPart.PhysActor.IsPhysical);
|
|
||||||
|
|
||||||
dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId;
|
dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
|
||||||
dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<SceneObjectPart> partList;
|
if (!userExposed)
|
||||||
|
|
||||||
lockPartsForRead(true);
|
|
||||||
|
|
||||||
partList = new List<SceneObjectPart>(m_parts.Values);
|
|
||||||
|
|
||||||
lockPartsForRead(false);
|
|
||||||
|
|
||||||
partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2)
|
|
||||||
{
|
{
|
||||||
return p1.LinkNum.CompareTo(p2.LinkNum);
|
dupe.RootPart.IsAttachment = previousAttachmentStatus;
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
foreach (SceneObjectPart part in partList)
|
dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
|
||||||
{
|
dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
|
||||||
if (part.UUID != m_rootPart.UUID)
|
|
||||||
|
if (userExposed)
|
||||||
|
dupe.m_rootPart.TrimPermissions();
|
||||||
|
|
||||||
|
/// may need to create a new Physics actor.
|
||||||
|
if (dupe.RootPart.PhysActor != null && userExposed)
|
||||||
{
|
{
|
||||||
SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed);
|
PrimitiveBaseShape pbs = dupe.RootPart.Shape;
|
||||||
|
|
||||||
newPart.LinkNum = part.LinkNum;
|
dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape(
|
||||||
|
dupe.RootPart.Name,
|
||||||
|
pbs,
|
||||||
|
dupe.RootPart.AbsolutePosition,
|
||||||
|
dupe.RootPart.Scale,
|
||||||
|
dupe.RootPart.RotationOffset,
|
||||||
|
dupe.RootPart.PhysActor.IsPhysical);
|
||||||
|
|
||||||
|
dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId;
|
||||||
|
dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SceneObjectPart> partList;
|
||||||
|
|
||||||
|
lockPartsForRead(true);
|
||||||
|
|
||||||
|
partList = new List<SceneObjectPart>(m_parts.Values);
|
||||||
|
|
||||||
|
lockPartsForRead(false);
|
||||||
|
|
||||||
|
partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2)
|
||||||
|
{
|
||||||
|
return p1.LinkNum.CompareTo(p2.LinkNum);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach (SceneObjectPart part in partList)
|
||||||
|
{
|
||||||
|
if (part.UUID != m_rootPart.UUID)
|
||||||
|
{
|
||||||
|
SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed);
|
||||||
|
|
||||||
|
newPart.LinkNum = part.LinkNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userExposed)
|
||||||
|
{
|
||||||
|
dupe.UpdateParentIDs();
|
||||||
|
dupe.HasGroupChanged = true;
|
||||||
|
dupe.AttachToBackup();
|
||||||
|
|
||||||
|
ScheduleGroupForFullUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
if (userExposed)
|
|
||||||
{
|
{
|
||||||
dupe.UpdateParentIDs();
|
m_dupeInProgress = false;
|
||||||
dupe.HasGroupChanged = true;
|
|
||||||
dupe.AttachToBackup();
|
|
||||||
|
|
||||||
ScheduleGroupForFullUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dupe;
|
return dupe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -720,14 +720,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
|
if (!m_parentGroup.m_dupeInProgress)
|
||||||
foreach (ScenePresence av in avs)
|
|
||||||
{
|
{
|
||||||
if (av.LinkedPrim == m_uuid)
|
List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
|
||||||
|
foreach (ScenePresence av in avs)
|
||||||
{
|
{
|
||||||
Vector3 offset = (m_offsetPosition - oldpos);
|
if (av.LinkedPrim == m_uuid)
|
||||||
av.OffsetPosition += offset;
|
{
|
||||||
av.SendFullUpdateToAllClients();
|
Vector3 offset = (m_offsetPosition - oldpos);
|
||||||
|
av.OffsetPosition += offset;
|
||||||
|
av.SendFullUpdateToAllClients();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue