Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor

avinationmerge
Melanie Thielker 2010-08-08 02:04:37 +02:00
commit d2b3d45d76
4 changed files with 636 additions and 617 deletions

View File

@ -317,8 +317,8 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_scriptListens_notAtTarget = false; private bool m_scriptListens_notAtTarget = false;
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
@ -475,16 +475,21 @@ 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);
foreach (ScenePresence av in m_linkedAvatars) }
{ }
Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition; if (!m_dupeInProgress)
av.AbsolutePosition += offset; {
av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition foreach (ScenePresence av in m_linkedAvatars)
av.SendFullUpdateToAllClients(); {
Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition;
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)
@ -1800,88 +1805,96 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="userExposed">True if the duplicate will immediately be in the scene, false otherwise</param> /// <param name="userExposed">True if the duplicate will immediately be in the scene, false otherwise</param>
/// <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>(); {
m_dupeInProgress = true;
// Warning, The following code related to previousAttachmentStatus is needed so that clones of dupe = (SceneObjectGroup)MemberwiseClone();
// attachments do not bordercross while they're being duplicated. This is hacktastic! dupe.m_isBackedUp = false;
// Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! dupe.m_parts = new Dictionary<UUID, SceneObjectPart>();
// 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, // Warning, The following code related to previousAttachmentStatus is needed so that clones of
// then restore it's attachment state // 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!
// This is only necessary when userExposed is false! // 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,
bool previousAttachmentStatus = dupe.RootPart.IsAttachment; // then restore it's attachment state
if (!userExposed) // This is only necessary when userExposed is false!
dupe.RootPart.IsAttachment = true;
bool previousAttachmentStatus = dupe.RootPart.IsAttachment;
dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
if (!userExposed)
if (!userExposed) dupe.RootPart.IsAttachment = true;
{
dupe.RootPart.IsAttachment = previousAttachmentStatus; dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z);
if (!userExposed)
{
dupe.RootPart.IsAttachment = previousAttachmentStatus;
}
dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
if (userExposed)
dupe.m_rootPart.TrimPermissions();
/// may need to create a new Physics actor.
if (dupe.RootPart.PhysActor != null && userExposed)
{
PrimitiveBaseShape pbs = dupe.RootPart.Shape;
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
{
m_dupeInProgress = false;
} }
dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed);
dupe.m_rootPart.LinkNum = m_rootPart.LinkNum;
if (userExposed)
dupe.m_rootPart.TrimPermissions();
/// may need to create a new Physics actor.
if (dupe.RootPart.PhysActor != null && userExposed)
{
PrimitiveBaseShape pbs = dupe.RootPart.Shape;
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();
}
return dupe; return dupe;
} }

View File

@ -718,17 +718,20 @@ namespace OpenSim.Region.Framework.Scenes
// Tell the physics engines that this prim changed. // Tell the physics engines that this prim changed.
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) {
{ List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
if (av.LinkedPrim == m_uuid) 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();
}
}
} }
} }
TriggerScriptChangedEvent(Changed.POSITION); TriggerScriptChangedEvent(Changed.POSITION);

View File

@ -2007,7 +2007,7 @@ namespace OpenSim.Region.Framework.Scenes
if (autopilot) if (autopilot)
{ // its not a scripted sit { // its not a scripted sit
// if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5)
if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 10.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 10.0f) ) if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) )
{ {
autopilot = false; // close enough autopilot = false; // close enough
m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup.
@ -2053,9 +2053,13 @@ namespace OpenSim.Region.Framework.Scenes
//Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset);
//NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child
ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); Quaternion roffset = Quaternion.Identity;
if (SitTargetisSet)
{
roffset = part.RotationOffset;
}
ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * roffset) + part.OffsetPosition), sitOrientation / part.RotationOffset, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook);
m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target
// This calls HandleAgentSit twice, once from here, and the client calls // This calls HandleAgentSit twice, once from here, and the client calls
// HandleAgentSit itself after it gets to the location // HandleAgentSit itself after it gets to the location
// It doesn't get to the location until we've moved them there though // It doesn't get to the location until we've moved them there though
@ -2374,8 +2378,7 @@ namespace OpenSim.Region.Framework.Scenes
m_bodyRot = sitTargetOrient; m_bodyRot = sitTargetOrient;
m_parentPosition = part.AbsolutePosition; m_parentPosition = part.AbsolutePosition;
part.IsOccupied = true; part.IsOccupied = true;
part.ParentGroup.AddAvatar(agentID); part.ParentGroup.AddAvatar(agentID);
Console.WriteLine("Scripted Sit ofset {0}", m_pos);
} }
else else
{ {
@ -2441,7 +2444,7 @@ Console.WriteLine("Scripted Sit ofset {0}", m_pos);
} }
m_linkedPrim = part.UUID; m_linkedPrim = part.UUID;
m_offsetRotation = m_offsetRotation / part.RotationOffset;
Velocity = Vector3.Zero; Velocity = Vector3.Zero;
RemoveFromPhysicalScene(); RemoveFromPhysicalScene();
Animator.TrySetMovementAnimation(sitAnimation); Animator.TrySetMovementAnimation(sitAnimation);

File diff suppressed because it is too large Load Diff