From f5195a453c265891858fbdcbed02dd768e7cb80f Mon Sep 17 00:00:00 2001 From: dan miller Date: Tue, 30 Oct 2007 23:38:56 +0000 Subject: Tevarus' patch for object flags & implemented Phantom edits --- OpenSim/Region/Environment/Scenes/EntityBase.cs | 2 +- .../Environment/Scenes/Scene.PacketHandlers.cs | 16 ++++ OpenSim/Region/Environment/Scenes/Scene.cs | 1 + .../Region/Environment/Scenes/SceneObjectGroup.cs | 9 ++ .../Region/Environment/Scenes/SceneObjectPart.cs | 106 ++++++++++++++++++++- 5 files changed, 129 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Scenes/EntityBase.cs b/OpenSim/Region/Environment/Scenes/EntityBase.cs index b8bae57..d0cbcf6 100644 --- a/OpenSim/Region/Environment/Scenes/EntityBase.cs +++ b/OpenSim/Region/Environment/Scenes/EntityBase.cs @@ -36,7 +36,7 @@ namespace OpenSim.Region.Environment.Scenes { protected List m_children; - protected Scene m_scene; + public Scene m_scene; public LLUUID m_uuid; diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 69bd310..73954d0 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -327,6 +327,22 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) { + bool hasprim = false; + foreach (EntityBase ent in Entities.Values) + { + if (ent is SceneObjectGroup) + { + hasprim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasprim != false) + { + + ((SceneObjectGroup)ent).UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); + + } + } + } + + //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString()); } /// diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index db4d230..0a2a5a3 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -817,6 +817,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnObjectName += PrimName; client.OnLinkObjects += LinkObjects; client.OnObjectDuplicate += DuplicateObject; + client.OnUpdatePrimFlags += UpdatePrimFlags; client.OnParcelPropertiesRequest += new ParcelPropertiesRequest(m_LandManager.handleParcelPropertiesRequest); client.OnParcelDivideRequest += new ParcelDivideRequest(m_LandManager.handleParcelDivideRequest); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 4d439b2..2f86d2f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -910,6 +910,15 @@ namespace OpenSim.Region.Environment.Scenes /// /// /// + /// + public void UpdatePrimFlags(uint localID, ushort type, bool inUse, byte[] data) + { + SceneObjectPart part = GetChildPart(localID); + if (part != null) + { + part.UpdatePrimFlags(type, inUse, data); + } + } public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data) { SceneObjectPart part = GetChildPart(localID); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 387f573..f0d6916 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -308,9 +308,9 @@ namespace OpenSim.Region.Environment.Scenes m_flags = 0; m_flags |= LLObject.ObjectFlags.ObjectModify | LLObject.ObjectFlags.ObjectCopy | - LLObject.ObjectFlags.ObjectYouOwner | - LLObject.ObjectFlags.Touch | - LLObject.ObjectFlags.ObjectMove | + LLObject.ObjectFlags.ObjectYouOwner | + LLObject.ObjectFlags.Touch | + LLObject.ObjectFlags.ObjectMove | LLObject.ObjectFlags.AllowInventoryDrop | LLObject.ObjectFlags.ObjectTransfer | LLObject.ObjectFlags.ObjectOwnerModify; @@ -441,6 +441,30 @@ namespace OpenSim.Region.Environment.Scenes TimeStampFull = (uint) Util.UnixTimeSinceEpoch(); m_updateFlag = 2; } + public void AddFlag(LLObject.ObjectFlags flag) + { + LLObject.ObjectFlags prevflag = m_flags; + //uint objflags = m_flags; + if ((this.ObjectFlags & (uint)flag) == 0) + { + //Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString()); + m_flags |= flag; + } + uint currflag = (uint)m_flags; + //System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); + //ScheduleFullUpdate(); + } + public void RemFlag(LLObject.ObjectFlags flag) + { + LLObject.ObjectFlags prevflag = m_flags; + if ((this.ObjectFlags & (uint) flag) != 0) + { + //Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString()); + m_flags &= ~flag; + } + //System.Console.WriteLine("prev: " + prevflag.ToString() + " curr: " + m_flags.ToString()); + //ScheduleFullUpdate(); + } /// /// @@ -610,6 +634,80 @@ namespace OpenSim.Region.Environment.Scenes #endregion #region ExtraParams + public void UpdatePrimFlags(ushort type, bool inUse, byte[] data) + { + bool hasPrim = false; + bool UsePhysics = false; + bool IsTemporary = false; + bool IsPhantom = false; + bool CastsShadows = false; + //bool IsLocked = false; + int i = 0; + + + try + { + i += 46; + //IsLocked = (data[i++] != 0) ? true : false; + UsePhysics = (data[i++] != 0) ? 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; + } + catch (System.Exception e) + { + System.Console.WriteLine("Ignoring invalid Packet:"); + //Silently ignore it - TODO: FIXME Quick + } + + if (IsPhantom) + { + AddFlag(LLObject.ObjectFlags.Phantom); + if(this.PhysActor != null) { + this.m_parentGroup.m_scene.PhysScene.RemovePrim(this.PhysActor); /// that's not wholesome. Had to make m_scene public + this.PhysActor = null; + } + } + else + { + RemFlag(LLObject.ObjectFlags.Phantom); + if (this.PhysActor == null) + { + this.PhysActor = this.m_parentGroup.m_scene.PhysScene.AddPrimShape( + this.Name, + this.Shape, + new PhysicsVector(this.AbsolutePosition.X, this.AbsolutePosition.Y, + this.AbsolutePosition.Z), + new PhysicsVector(this.Scale.X, this.Scale.Y, this.Scale.Z), + new Quaternion(this.RotationOffset.W, this.RotationOffset.X, + this.RotationOffset.Y, this.RotationOffset.Z)); + } + } + + if (UsePhysics) + { + AddFlag(LLObject.ObjectFlags.Physics); + + } + else + { + RemFlag(LLObject.ObjectFlags.Physics); + } + if (IsTemporary) + { + AddFlag(LLObject.ObjectFlags.TemporaryOnRez); + } + else + { + RemFlag(LLObject.ObjectFlags.TemporaryOnRez); + } +// System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); + ScheduleFullUpdate(); + + + + } public void UpdateExtraParam(ushort type, bool inUse, byte[] data) { @@ -922,4 +1020,4 @@ namespace OpenSim.Region.Environment.Scenes } } } -} \ No newline at end of file +} -- cgit v1.1