From e8e9a0fb43be02315ab46373f054bd3f7ed6f57d Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Tue, 8 Feb 2011 15:33:54 -0800 Subject: [PATCH] Enabled all synchronized properties to be updated by calling through SetXXX() to set values. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 2 +- .../Framework/Scenes/SceneObjectGroup.cs | 150 ++++++++++++++++-- .../Framework/Scenes/SceneObjectPart.cs | 100 +++++++++--- 4 files changed, 222 insertions(+), 32 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9341c577e0..282491b153 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -795,7 +795,7 @@ namespace OpenSim.Region.Framework.Scenes //Set the property values as in the incoming copy of the object group SceneObjectGroup localGroup = root.ParentGroup; - localGroup.UpdateObjectProperties(linkedGroup); + localGroup.UpdateObjectGroupBySync(linkedGroup); //debug /* diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index d698e9eb42..d75cad2931 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -2299,7 +2299,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - localAfterGroup.UpdateObjectProperties(incomingAfterDelinkGroupsDictionary[localAfterGroup.UUID]); + localAfterGroup.UpdateObjectGroupBySync(incomingAfterDelinkGroupsDictionary[localAfterGroup.UUID]); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 236a17f1d6..74ac1f2171 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -294,6 +294,11 @@ namespace OpenSim.Region.Framework.Scenes get { return m_rootPart.GroupPosition; } set { + SetAbsolutePosition(value); + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + parts[i].UpdateBucketSyncInfo("GroupPosition"); + /* Vector3 val = value; //REGION SYNC touched @@ -328,6 +333,39 @@ namespace OpenSim.Region.Framework.Scenes //m_rootPart.GroupPosition.Z); //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); //} + * */ + } + } + public void SetAbsolutePosition(Vector3 value) + { + Vector3 val = value; + + //REGION SYNC touched + + //if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) + // || m_scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || m_scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) + // && !IsAttachmentCheckFull()) + if (m_scene.IsBorderCrossing(LocX, LocY, val) && !IsAttachmentCheckFull() && (!m_scene.LoadingPrims)) + { + m_scene.CrossPrimGroupIntoNewRegion(val, this, true); + } + //end REGION SYNC touched + if (RootPart.GetStatusSandbox()) + { + if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) + { + RootPart.ScriptSetPhysicsStatus(false); + Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), + ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); + return; + } + } + + SceneObjectPart[] parts = m_parts.GetArray(); + for (int i = 0; i < parts.Length; i++) + { + //parts[i].GroupPosition = val; + parts[i].SetGroupPosition(val); } } @@ -465,6 +503,20 @@ namespace OpenSim.Region.Framework.Scenes #region Constructors + //SYMMETRIC SYNC + public SceneObjectGroup(SceneObjectPart part, bool newGroupBySync) + { + if (!newGroupBySync) + { + SetRootPart(part); + } + else + { + SetRootPartBySync(part); + } + + } + /// /// Constructor /// @@ -3728,7 +3780,8 @@ namespace OpenSim.Region.Framework.Scenes if (part.LinkNum > linkPart.LinkNum) { //part.LinkNum--; - part.SetLinkNum(part.LinkNum--); + int linkNum = part.LinkNum - 1; + part.SetLinkNum(linkNum); } } } @@ -3761,7 +3814,9 @@ namespace OpenSim.Region.Framework.Scenes linkPart.SetOffsetPosition(new Vector3(0, 0, 0)); linkPart.SetRotationOffset(worldRot); - SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); + //SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); + bool newGroupBySync = true; + SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart, newGroupBySync); m_scene.AddNewSceneObjectBySync(objectGroup, true); @@ -3777,7 +3832,23 @@ namespace OpenSim.Region.Framework.Scenes return objectGroup; } + /// + /// Set a part to act as the root part for this scene object, in which SetLinkNum() is called instead of "LinkNum=". + /// + /// + public void SetRootPartBySync(SceneObjectPart part) + { + if (part == null) + throw new ArgumentNullException("Cannot give SceneObjectGroup a null root SceneObjectPart"); + part.SetParent(this); + m_rootPart = part; + if (!IsAttachment) + part.ParentID = 0; + part.SetLinkNum(0); + + m_parts.Add(m_rootPart.UUID, m_rootPart); + } public void ScheduleGroupForFullUpdate_SyncInfoUnchanged() { @@ -3806,21 +3877,27 @@ namespace OpenSim.Region.Framework.Scenes Vector3 oldGroupPosition = linkPart.GroupPosition; Quaternion oldRootRotation = linkPart.RotationOffset; - linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; - linkPart.GroupPosition = AbsolutePosition; + //linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; + //linkPart.GroupPosition = AbsolutePosition; + linkPart.SetOffsetPosition(linkPart.GroupPosition - AbsolutePosition); + linkPart.SetGroupPosition(AbsolutePosition); Vector3 axPos = linkPart.OffsetPosition; Quaternion parentRot = m_rootPart.RotationOffset; axPos *= Quaternion.Inverse(parentRot); - linkPart.OffsetPosition = axPos; + //linkPart.OffsetPosition = axPos; + linkPart.SetOffsetPosition(axPos); Quaternion oldRot = linkPart.RotationOffset; Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; - linkPart.RotationOffset = newRot; + //linkPart.RotationOffset = newRot; + linkPart.SetRotationOffset(newRot); + //ParentID is only valid locally, so remote value is ignored and no syncinfo will be modified linkPart.ParentID = m_rootPart.LocalId; if (m_rootPart.LinkNum == 0) - m_rootPart.LinkNum = 1; + //m_rootPart.LinkNum = 1; + m_rootPart.SetLinkNum(1); lock (m_parts.SyncRoot) { @@ -3836,11 +3913,13 @@ namespace OpenSim.Region.Framework.Scenes if (part.LinkNum != 1) { // Don't update root prim link number - part.LinkNum += objectGroup.PrimCount; + //part.LinkNum += objectGroup.PrimCount; + part.SetLinkNum(objectGroup.PrimCount); } } - linkPart.LinkNum = 2; + //linkPart.LinkNum = 2; + linkPart.SetLinkNum(2); linkPart.SetParent(this); linkPart.CreateSelected = true; @@ -3859,7 +3938,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = ogParts[i]; if (part.UUID != objectGroup.m_rootPart.UUID) - LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); + LinkNonRootPartBySync(part, oldGroupPosition, oldRootRotation, linkNum++); part.ClearUndoState(); } } @@ -3877,10 +3956,59 @@ namespace OpenSim.Region.Framework.Scenes // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and // unmoved prims! - ResetChildPrimPhysicsPositions(); + //ResetChildPrimPhysicsPositions(); + //EntityBase sogBase = (EntityBase)this; + //sogBase.AbsolutePosition = AbsolutePosition; + SetAbsolutePosition(AbsolutePosition); } + private void LinkNonRootPartBySync(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum) + { + Quaternion parentRot = oldGroupRotation; + Quaternion oldRot = part.RotationOffset; + Quaternion worldRot = parentRot * oldRot; + + parentRot = oldGroupRotation; + + Vector3 axPos = part.OffsetPosition; + + axPos *= parentRot; + //part.OffsetPosition = axPos; + //part.GroupPosition = oldGroupPosition + part.OffsetPosition; + //part.OffsetPosition = Vector3.Zero; + //part.RotationOffset = worldRot; + part.SetOffsetPosition(axPos); + part.SetGroupPosition(oldGroupPosition + part.OffsetPosition); + part.SetOffsetPosition(Vector3.Zero); + part.SetRotationOffset(worldRot); + + part.SetParent(this); + part.ParentID = m_rootPart.LocalId; + + m_parts.Add(part.UUID, part); + + //part.LinkNum = linkNum; + part.SetLinkNum(linkNum); + + //part.OffsetPosition = part.GroupPosition - AbsolutePosition; + part.SetOffsetPosition(part.GroupPosition - AbsolutePosition); + + Quaternion rootRotation = m_rootPart.RotationOffset; + + Vector3 pos = part.OffsetPosition; + pos *= Quaternion.Inverse(rootRotation); + //part.OffsetPosition = pos; + part.SetOffsetPosition(pos); + + parentRot = m_rootPart.RotationOffset; + oldRot = part.RotationOffset; + Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; + //part.RotationOffset = newRot; + part.SetRotationOffset(newRot); + } + + /* public void SyncInfoUpdate() { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index d8fc82b281..4edfdf93c7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -335,7 +335,24 @@ namespace OpenSim.Region.Framework.Scenes public bool IgnoreUndoUpdate = false; - public PrimFlags LocalFlags; + //SYMMETRIC SYNC + //public PrimFlags LocalFlags; + private PrimFlags m_localFlags; + public PrimFlags LocalFlags + { + get { return m_localFlags; } + set + { + SetLocalFlags(value); + UpdateBucketSyncInfo("LocalFlags"); + } + } + public void SetLocalFlags(PrimFlags value) + { + m_localFlags = value; + } + + private float m_damage = -1.0f; private byte[] m_TextureAnimation; private byte m_clickAction; @@ -675,7 +692,9 @@ namespace OpenSim.Region.Framework.Scenes { get { return m_name; } set - { + { + SetName(value); + UpdateBucketSyncInfo("Name"); /* m_name = value; if (PhysActor != null) @@ -1239,7 +1258,8 @@ namespace OpenSim.Region.Framework.Scenes set { SetAcceleration(value); - //UpdateBucketSyncInfo("Acceleration"); + + UpdateBucketSyncInfo("Acceleration"); //m_acceleration = value; } } @@ -1255,7 +1275,7 @@ namespace OpenSim.Region.Framework.Scenes set { SetDescription(value); - //UpdateBucketSyncInfo("Description"); + UpdateBucketSyncInfo("Description"); /* m_description = value; PhysicsActor actor = PhysActor; @@ -1286,7 +1306,7 @@ namespace OpenSim.Region.Framework.Scenes set { SetColor(value); - //UpdateBucketSyncInfo("Color"); + UpdateBucketSyncInfo("Color"); //m_color = value; /* ScheduleFullUpdate() need not be called b/c after @@ -1315,7 +1335,7 @@ namespace OpenSim.Region.Framework.Scenes set { SetText(value, false); - //UpdateBucketSyncInfo("Text"); + UpdateBucketSyncInfo("Text"); //m_text = value; } } @@ -1333,7 +1353,7 @@ namespace OpenSim.Region.Framework.Scenes set { SetSitName(value); - //UpdateBucketSyncInfo("SitName"); + UpdateBucketSyncInfo("SitName"); //m_sitName = value; } } @@ -1381,7 +1401,7 @@ namespace OpenSim.Region.Framework.Scenes set { SetClickAction(value); - //UpdateBucketSyncInfo("ClickAction"); + UpdateBucketSyncInfo("ClickAction"); //m_clickAction = value; } } @@ -1579,6 +1599,11 @@ namespace OpenSim.Region.Framework.Scenes //m_sitTargetPosition = value; } } + //SYMMETRIC SYNC + public void SetSitTargetPositionLL(Vector3 value) + { + m_sitTargetPosition = value; + } public Quaternion SitTargetOrientationLL { @@ -1599,6 +1624,11 @@ namespace OpenSim.Region.Framework.Scenes //m_sitTargetOrientation = new Quaternion(value.X, value.Y, value.Z, value.W); } } + //SYMMETRIC SYNC + public void SetSitTargetOrientationLL(Quaternion value) + { + m_sitTargetOrientation = value; + } public bool Stopped { @@ -5673,8 +5703,8 @@ namespace OpenSim.Region.Framework.Scenes "RotationOffset", "Velocity", "AngularVelocity", - //"Acceleration", - "SOP_Acceleration", //SOP and PA read/write their own local copies of acceleration, so we distinguish the copies + "Acceleration", //This is the property maintained in SOP. SOP and PA read/write their own local copies of acceleration, so we distinguish the copies + //"SOP_Acceleration", //SOP and PA read/write their own local copies of acceleration, so we distinguish the copies "Description", "Color", "Text", @@ -5997,21 +6027,53 @@ namespace OpenSim.Region.Framework.Scenes SetPassTouches(updatedPart.PassTouches); //RegionHandle skipped SetScriptAccessPin(updatedPart.ScriptAccessPin); - - //SetAcceleration(updatedPart.Acceleration); - //SetDescription(updatedPart.Description); - //SetColor(updatedPart.Color); - //SetText(updatedPart.Text); - //SetSitName(updatedPart.SitName); - + SetAcceleration(updatedPart.Acceleration); + SetDescription(updatedPart.Description); + SetColor(updatedPart.Color); + SetText(updatedPart.Text); + SetSitName(updatedPart.SitName); SetTouchName(updatedPart.TouchName); SetLinkNum(updatedPart.LinkNum); - //SetClickAction(updatedPart.ClickAction); - + SetClickAction(updatedPart.ClickAction); SetShape(updatedPart.Shape); + //UpdateFlag skipped: It's a flag meanful locally, especially in scheduling updates to viewers. + //Only in one place will it cause updating some "last" variables (see SendScheduledUpdates). + SetSitTargetOrientation(updatedPart.SitTargetOrientation); + SetSitTargetPosition(updatedPart.SitTargetPosition); + SetSitTargetPositionLL(updatedPart.SitTargetPositionLL); + SetSitTargetOrientationLL(updatedPart.SitTargetOrientationLL); + //ParentID skipped, the value is assigned locally and only meaningful locally (LinkObjects and LinkObjectsBySync will set it appropriately)\ + SetCreationDate(updatedPart.CreationDate); + SetCategory(updatedPart.Category); + SetSalePrice(updatedPart.SalePrice); + SetObjectSaleType(updatedPart.ObjectSaleType); + SetOwnershipCost(updatedPart.OwnershipCost); + SetGroupID(updatedPart.GroupID); + SetOwnerID(updatedPart.OwnerID); + SetLastOwnerID(updatedPart.LastOwnerID); + SetBaseMask(updatedPart.BaseMask); + SetOwnerMask(updatedPart.OwnerMask); + SetGroupMask(updatedPart.GroupMask); + SetEveryoneMask(updatedPart.EveryoneMask); + SetNextOwnerMask(updatedPart.NextOwnerMask); + SetFlags(updatedPart.Flags); + //Treat CollisionSound in a different way, so that if any property needs to be changed due to aggregateScriptEvents(), timestamp can be updated after + //the current copying-property-values-from-remote-sync-message is done. + bool collisionSoundUpdated = UpdateCollisionSound(updatedPart.CollisionSound); + SetCollisionSoundVolume(updatedPart.CollisionSoundVolume); + SetMediaUrl(updatedPart.MediaUrl); + SetTextureAnimation(updatedPart.TextureAnimation); + SetParticleSystem(updatedPart.ParticleSystem); + m_bucketSyncInfoList[bucketName].LastUpdateTimeStamp = updatedPart.BucketSyncInfoList[bucketName].LastUpdateTimeStamp; m_bucketSyncInfoList[bucketName].LastUpdateActorID = updatedPart.BucketSyncInfoList[bucketName].LastUpdateActorID; + + if (collisionSoundUpdated) + { + //If the local actor is Script Engine, it will catch this evnet and trigger aggregateScriptEvents() + m_parentGroup.Scene.EventManager.TriggerAggregateScriptEvents(this); + } } }