diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index 52d0f1c8aa..877bfe53f1 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -491,7 +491,7 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); - rootPart.doPhysicsPropertyUpdate(UsePhysics, true); + rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); } rootPart.ScheduleFullUpdate(); diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index cc0f3e15f9..f2eb48661e 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -765,7 +765,7 @@ namespace OpenSim.Region.Environment.Scenes new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); - rootPart.doPhysicsPropertyUpdate(UsePhysics, true); + rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); } MainLog.Instance.Verbose("Loaded " + PrimsFromDB.Count.ToString() + " SceneObject(s)"); } @@ -869,7 +869,7 @@ namespace OpenSim.Region.Environment.Scenes new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), new Quaternion(), UsePhysics); // subscribe to physics events. - rootPart.doPhysicsPropertyUpdate(UsePhysics, true); + rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index cc0b8baf0e..1b55a49024 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -264,6 +264,7 @@ namespace OpenSim.Region.Environment.Scenes reader.ReadStartElement("SceneObjectGroup"); reader.ReadStartElement("RootPart"); m_rootPart = SceneObjectPart.FromXml(reader); + reader.ReadEndElement(); while (reader.Read()) @@ -274,10 +275,13 @@ namespace OpenSim.Region.Environment.Scenes if (reader.Name == "Part") { reader.Read(); - SceneObjectPart Part = SceneObjectPart.FromXml(reader); - Part.LocalID = m_scene.PrimIDAllocate(); - AddPart(Part); - Part.RegionHandle = m_regionHandle; + SceneObjectPart part = SceneObjectPart.FromXml(reader); + part.LocalID = m_scene.PrimIDAllocate(); + AddPart(part); + part.RegionHandle = m_regionHandle; + + part.ApplyPermissions(); + part.ApplyPhysics(); } break; case XmlNodeType.EndElement: @@ -286,8 +290,9 @@ namespace OpenSim.Region.Environment.Scenes } reader.Close(); sr.Close(); - m_rootPart.SetParent(this); - m_parts.Add(m_rootPart.UUID, m_rootPart); + + AddPart( m_rootPart ); + m_rootPart.LocalID = m_scene.PrimIDAllocate(); m_rootPart.ParentID = 0; m_rootPart.RegionHandle = m_regionHandle; @@ -524,7 +529,7 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(dupe.RootPart.RotationOffset.W, dupe.RootPart.RotationOffset.X, dupe.RootPart.RotationOffset.Y, dupe.RootPart.RotationOffset.Z), dupe.RootPart.PhysActor.IsPhysical); - dupe.RootPart.doPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); + dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); } // Now we've made a copy that replaces this one, we need to @@ -906,7 +911,7 @@ namespace OpenSim.Region.Environment.Scenes new Quaternion(linkPart.RotationOffset.W, linkPart.RotationOffset.X, linkPart.RotationOffset.Y, linkPart.RotationOffset.Z), m_rootPart.PhysActor.IsPhysical); - m_rootPart.doPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true); + m_rootPart.DoPhysicsPropertyUpdate(m_rootPart.PhysActor.IsPhysical, true); } @@ -1216,7 +1221,7 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.RotationOffset.Y, m_rootPart.RotationOffset.Z), m_rootPart.PhysActor.IsPhysical); bool UsePhysics = ((m_rootPart.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); - m_rootPart.doPhysicsPropertyUpdate(UsePhysics, true); + m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); } } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index d8e21434fd..e2e97c55ba 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -74,7 +74,6 @@ namespace OpenSim.Region.Environment.Scenes [XmlIgnore] public uint TimeStampTerse = 0; [XmlIgnore] public uint TimeStampLastActivity = 0; // Will be used for AutoReturn - protected SceneObjectGroup m_parentGroup; /// /// Only used internally to schedule client updates @@ -386,6 +385,8 @@ namespace OpenSim.Region.Environment.Scenes get { return OwnerID; } } + // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out. + protected SceneObjectGroup m_parentGroup; public SceneObjectGroup ParentGroup { get { return m_parentGroup; } @@ -533,7 +534,7 @@ namespace OpenSim.Region.Environment.Scenes } bool UsePhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); - doPhysicsPropertyUpdate(UsePhysics, true); + DoPhysicsPropertyUpdate(UsePhysics, true); ScheduleFullUpdate(); } @@ -547,28 +548,33 @@ namespace OpenSim.Region.Environment.Scenes public static SceneObjectPart FromXml(XmlReader xmlReader) { XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart)); - SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader); + SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader); + return newobject; + } - if (!newobject.ParentGroup.m_scene.PermissionsMngr.BypassPermissions) + public void ApplyPhysics() + { + bool UsePhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); + DoPhysicsPropertyUpdate(UsePhysics, true); + } + + public void ApplyPermissions() + { + if (!ParentGroup.m_scene.PermissionsMngr.BypassPermissions) { - newobject.EveryoneMask = newobject.ObjectFlags; - newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; - newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; - newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectCopy; - newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify; - newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove; - newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner; - newobject.EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer; + EveryoneMask = ObjectFlags; + EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOwner; + EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; + EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectCopy; + EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectModify; + EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectMove; + EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectAnyOwner; + EveryoneMask &= ~(uint)LLObject.ObjectFlags.ObjectYouOfficer; } else { - newobject.EveryoneMask = newobject.ObjectFlags; + EveryoneMask = ObjectFlags; } - - bool UsePhysics = ((newobject.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); - newobject.doPhysicsPropertyUpdate(UsePhysics, true); - - return newobject; } /// @@ -719,7 +725,7 @@ namespace OpenSim.Region.Environment.Scenes Array.Copy(Shape.ExtraParams, extraP, extraP.Length); dupe.Shape.ExtraParams = extraP; bool UsePhysics = ((dupe.ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); - dupe.doPhysicsPropertyUpdate(UsePhysics, true); + dupe.DoPhysicsPropertyUpdate(UsePhysics, true); return dupe; } @@ -961,10 +967,10 @@ namespace OpenSim.Region.Environment.Scenes public void UpdatePrimFlags(ushort type, bool inUse, byte[] data) { bool hasPrim = false; - bool UsePhysics = false; + bool usePhysics = false; bool IsTemporary = false; bool IsPhantom = false; - bool CastsShadows = false; + bool castsShadows = false; bool wasUsingPhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0); //bool IsLocked = false; int i = 0; @@ -974,11 +980,11 @@ namespace OpenSim.Region.Environment.Scenes { i += 46; //IsLocked = (data[i++] != 0) ? true : false; - UsePhysics = ((data[i++] != 0) && m_parentGroup.m_scene.m_physicalPrim) ? true : false; + usePhysics = ((data[i++] != 0) && m_parentGroup.m_scene.m_physicalPrim) ? true : false; //System.Console.WriteLine("U" + packet.ToBytes().Length.ToString()); IsTemporary = (data[i++] != 0) ? true : false; IsPhantom = (data[i++] != 0) ? true : false; - CastsShadows = (data[i++] != 0) ? true : false; + castsShadows = (data[i++] != 0) ? true : false; } catch (Exception) { @@ -986,12 +992,12 @@ namespace OpenSim.Region.Environment.Scenes //Silently ignore it - TODO: FIXME Quick } - if (UsePhysics ) + if (usePhysics ) { AddFlag(LLObject.ObjectFlags.Physics); if (!wasUsingPhysics) { - doPhysicsPropertyUpdate(UsePhysics,false); + DoPhysicsPropertyUpdate(usePhysics,false); } } @@ -1000,7 +1006,7 @@ namespace OpenSim.Region.Environment.Scenes RemFlag(LLObject.ObjectFlags.Physics); if (wasUsingPhysics) { - doPhysicsPropertyUpdate(UsePhysics, false); + DoPhysicsPropertyUpdate(usePhysics, false); } } @@ -1030,13 +1036,13 @@ namespace OpenSim.Region.Environment.Scenes AbsolutePosition.Z), new PhysicsVector(Scale.X, Scale.Y, Scale.Z), new Quaternion(RotationOffset.W, RotationOffset.X, - RotationOffset.Y, RotationOffset.Z), UsePhysics); - doPhysicsPropertyUpdate(UsePhysics, true); + RotationOffset.Y, RotationOffset.Z), usePhysics); + DoPhysicsPropertyUpdate(usePhysics, true); } else { - PhysActor.IsPhysical = UsePhysics; - doPhysicsPropertyUpdate(UsePhysics,false); + PhysActor.IsPhysical = usePhysics; + DoPhysicsPropertyUpdate(usePhysics,false); } } @@ -1051,7 +1057,7 @@ namespace OpenSim.Region.Environment.Scenes // System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); ScheduleFullUpdate(); } - public void doPhysicsPropertyUpdate(bool UsePhysics, bool isNew) + public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) { if (PhysActor != null) @@ -1271,13 +1277,20 @@ namespace OpenSim.Region.Environment.Scenes { clientFlags = ObjectFlags; if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanCopyPermission(remoteClient.AgentId, this.ParentGroup.UUID)) - clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy; + { + clientFlags = (clientFlags &= ~(uint) LLObject.ObjectFlags.ObjectCopy); + } + if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanMovePermission(remoteClient.AgentId, this.ParentGroup.UUID)) - clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove; + { + clientFlags = clientFlags &= ~(uint) LLObject.ObjectFlags.ObjectMove; + } clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify; clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.AllowInventoryDrop; clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectTransfer; + + // TODO, FIXME, ERROR : This whole block amounts to moot because of this. clientFlags = EveryoneMask; } } @@ -1372,7 +1385,7 @@ namespace OpenSim.Region.Environment.Scenes { OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", "Physical Object went out of bounds."); RemFlag(LLObject.ObjectFlags.Physics); - doPhysicsPropertyUpdate(false,true); + DoPhysicsPropertyUpdate(false,true); m_parentGroup.m_scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); diff --git a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs index e9c0124c98..40f8b964bc 100644 --- a/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Scenes/SceneXmlLoader.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.Environment.Scenes new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); - rootPart.doPhysicsPropertyUpdate(UsePhysics, true); + rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); } primCount++; @@ -125,7 +125,7 @@ namespace OpenSim.Region.Environment.Scenes new PhysicsVector(rootPart.Scale.X, rootPart.Scale.Y, rootPart.Scale.Z), new Quaternion(rootPart.RotationOffset.W, rootPart.RotationOffset.X, rootPart.RotationOffset.Y, rootPart.RotationOffset.Z), UsePhysics); - rootPart.doPhysicsPropertyUpdate(UsePhysics, true); + rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); } }