From d451dddcd0e061cd5aa326cb08d6e24e08817dcc Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 9 Aug 2007 17:54:22 +0000 Subject: Start of replacing the old SceneObject/Primitive classes with the new versions. PLEASE NOTE: that with this revision some prim related features may be broke for a while. (things like linking prims and the parcel prim count.) Also this revision may not work on mono, but that will be fixed soon. --- .../Framework/Communications/Capabilities/Caps.cs | 2 +- .../Environment/Interfaces/IRegionDataStore.cs | 4 +- OpenSim/Region/Environment/LandManagement/Land.cs | 38 +- .../Environment/LandManagement/LandManager.cs | 4 +- OpenSim/Region/Environment/PermissionManager.cs | 6 +- .../Environment/Scenes/AllNewSceneObjectGroup2.cs | 586 ----------------- .../Environment/Scenes/AllNewSceneObjectPart2.cs | 520 --------------- .../Region/Environment/Scenes/Primitive(Old).cs | 719 +++++++++++++++++++++ OpenSim/Region/Environment/Scenes/Primitive.cs | 719 --------------------- .../Environment/Scenes/Scene.PacketHandlers.cs | 184 +++--- OpenSim/Region/Environment/Scenes/Scene.cs | 38 +- OpenSim/Region/Environment/Scenes/SceneEvents.cs | 4 +- .../Region/Environment/Scenes/SceneObject(Old).cs | 315 +++++++++ OpenSim/Region/Environment/Scenes/SceneObject.cs | 315 --------- .../Region/Environment/Scenes/SceneObjectGroup.cs | 647 ++++++++++++++++++ .../Region/Environment/Scenes/SceneObjectPart.cs | 527 +++++++++++++++ .../CSharpEngine/Examples/ExportRegionToLSL.cs | 8 +- .../Scenes/Scripting/ScriptInterpretedAPI.cs | 6 +- .../Region/Examples/SimpleApp/CpuCounterObject.cs | 8 +- .../Region/Examples/SimpleApp/FileSystemObject.cs | 8 +- OpenSim/Region/Examples/SimpleApp/Program.cs | 2 +- .../OpenSim.DataStore.DB4o/DB4oDataStore.cs | 16 +- .../OpenSim.DataStore.NullStorage/NullDataStore.cs | 6 +- 23 files changed, 2375 insertions(+), 2307 deletions(-) delete mode 100644 OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs delete mode 100644 OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs create mode 100644 OpenSim/Region/Environment/Scenes/Primitive(Old).cs delete mode 100644 OpenSim/Region/Environment/Scenes/Primitive.cs create mode 100644 OpenSim/Region/Environment/Scenes/SceneObject(Old).cs delete mode 100644 OpenSim/Region/Environment/Scenes/SceneObject.cs create mode 100644 OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs create mode 100644 OpenSim/Region/Environment/Scenes/SceneObjectPart.cs diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index d56cf6f..82ef08d 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -304,7 +304,7 @@ namespace OpenSim.Region.Capabilities private LLUUID newAssetID; private LLUUID inventoryItemID; private BaseHttpServer httpListener; - private bool SaveAssets = true; + private bool SaveAssets = false; private string m_assetName = ""; /// diff --git a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs index 4148d08..395819d 100644 --- a/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs +++ b/OpenSim/Region/Environment/Interfaces/IRegionDataStore.cs @@ -47,10 +47,10 @@ namespace OpenSim.Region.Interfaces /// The name of the database to store to (may not be applicable) void Initialise(string filename, string dbname); - void StoreObject(SceneObject obj); + void StoreObject(SceneObjectGroup obj); void RemoveObject(LLUUID uuid); - List LoadObjects(); + List LoadObjects(); void StoreTerrain(double[,] terrain); double[,] LoadTerrain(); diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 97f8276..e9f5248 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -16,7 +16,7 @@ namespace OpenSim.Region.Environment.LandManagement { #region Member Variables public LandData landData = new LandData(); - public List primsOverMe = new List(); + public List primsOverMe = new List(); public Scene m_scene; @@ -426,21 +426,21 @@ namespace OpenSim.Region.Environment.LandManagement public void sendForceObjectSelect(int local_id, int request_type, IClientAPI remote_client) { List resultLocalIDs = new List(); - foreach (SceneObject obj in primsOverMe) + foreach (SceneObjectGroup obj in primsOverMe) { - if (obj.rootLocalID > 0) + if (obj.LocalId > 0) { - if (request_type == LandManager.LAND_SELECT_OBJECTS_OWNER && obj.rootPrimitive.OwnerID == this.landData.ownerID) + if (request_type == LandManager.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == this.landData.ownerID) { - resultLocalIDs.Add(obj.rootLocalID); + resultLocalIDs.Add(obj.LocalId); } else if (request_type == LandManager.LAND_SELECT_OBJECTS_GROUP && false) //TODO: change false to group support! { } - else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && obj.rootPrimitive.OwnerID != remote_client.AgentId) + else if (request_type == LandManager.LAND_SELECT_OBJECTS_OTHER && obj.OwnerID != remote_client.AgentId) { - resultLocalIDs.Add(obj.rootLocalID); + resultLocalIDs.Add(obj.LocalId); } } } @@ -486,13 +486,13 @@ namespace OpenSim.Region.Environment.LandManagement public void sendLandObjectOwners(IClientAPI remote_client) { Dictionary ownersAndCount = new Dictionary(); - foreach (SceneObject obj in primsOverMe) + foreach (SceneObjectGroup obj in primsOverMe) { - if (!ownersAndCount.ContainsKey(obj.rootPrimitive.OwnerID)) + if (!ownersAndCount.ContainsKey(obj.OwnerID)) { - ownersAndCount.Add(obj.rootPrimitive.OwnerID, 0); + ownersAndCount.Add(obj.OwnerID, 0); } - ownersAndCount[obj.rootPrimitive.OwnerID] += obj.primCount; + ownersAndCount[obj.OwnerID] += obj.PrimCount; } if (ownersAndCount.Count > 0) { @@ -525,7 +525,7 @@ namespace OpenSim.Region.Environment.LandManagement #endregion #region Object Returning - public void returnObject(SceneObject obj) + public void returnObject(SceneObjectGroup obj) { } public void returnLandObjects(int type, LLUUID owner) @@ -544,12 +544,12 @@ namespace OpenSim.Region.Environment.LandManagement primsOverMe.Clear(); } - public void addPrimToCount(SceneObject obj) + public void addPrimToCount(SceneObjectGroup obj) { - LLUUID prim_owner = obj.rootPrimitive.OwnerID; - int prim_count = obj.primCount; + LLUUID prim_owner = obj.OwnerID; + int prim_count = obj.PrimCount; - if (obj.isSelected) + if (obj.IsSelected) { landData.selectedPrims += prim_count; } @@ -569,12 +569,12 @@ namespace OpenSim.Region.Environment.LandManagement } - public void removePrimFromCount(SceneObject obj) + public void removePrimFromCount(SceneObjectGroup obj) { if (primsOverMe.Contains(obj)) { - LLUUID prim_owner = obj.rootPrimitive.OwnerID; - int prim_count = obj.primCount; + LLUUID prim_owner = obj.OwnerID; + int prim_count = obj.PrimCount; if (prim_owner == landData.ownerID) { diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index f759934..f67b51a 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -552,7 +552,7 @@ namespace OpenSim.Region.Environment.LandManagement this.landPrimCountTainted = true; } - public void addPrimToLandPrimCounts(SceneObject obj) + public void addPrimToLandPrimCounts(SceneObjectGroup obj) { LLVector3 position = obj.Pos; Land landUnderPrim = getLandObject(position.X, position.Y); @@ -562,7 +562,7 @@ namespace OpenSim.Region.Environment.LandManagement } } - public void removePrimFromLandPrimCounts(SceneObject obj) + public void removePrimFromLandPrimCounts(SceneObjectGroup obj) { foreach (Land p in landList.Values) { diff --git a/OpenSim/Region/Environment/PermissionManager.cs b/OpenSim/Region/Environment/PermissionManager.cs index 150a8ed..0758566 100644 --- a/OpenSim/Region/Environment/PermissionManager.cs +++ b/OpenSim/Region/Environment/PermissionManager.cs @@ -53,11 +53,11 @@ namespace OpenSim.Region.Environment bool permission = false; // If it's not an object, we cant edit it. - if (!(m_scene.Entities[obj] is SceneObject)) + if (!(m_scene.Entities[obj] is SceneObjectGroup)) return false; - SceneObject task = (SceneObject)m_scene.Entities[obj]; - LLUUID taskOwner = task.rootPrimitive.OwnerID; + SceneObjectGroup task = (SceneObjectGroup)m_scene.Entities[obj]; + LLUUID taskOwner = null; // Object owners should be able to edit their own content if (user == taskOwner) diff --git a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs deleted file mode 100644 index 86610c0..0000000 --- a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs +++ /dev/null @@ -1,586 +0,0 @@ -using System.Collections.Generic; -using System.Text; -using Axiom.Math; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Physics.Manager; - -namespace OpenSim.Region.Environment.Scenes -{ - // public delegate void PrimCountTaintedDelegate(); - - public class AllNewSceneObjectGroup2 : EntityBase - { - private Encoding enc = Encoding.ASCII; - - protected AllNewSceneObjectPart2 m_rootPart; - protected Dictionary m_parts = new Dictionary(); - - protected ulong m_regionHandle; - - public event PrimCountTaintedDelegate OnPrimCountTainted; - - /// - /// - /// - public int PrimCount - { - get { return 1; } - } - - /// - /// - /// - public LLVector3 GroupCentrePoint - { - get { return new LLVector3(0, 0, 0); } - } - - public override LLVector3 Pos - { - get { return m_rootPart.GroupPosition; } - set - { - lock (this.m_parts) - { - foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) - { - part.GroupPosition = value; - } - } - } - } - - public override uint LocalId - { - get { return m_rootPart.LocalID; } - set { m_rootPart.LocalID = value; } - } - - public override LLUUID UUID - { - get { return m_rootPart.UUID; } - set { m_rootPart.UUID = value; } - } - - /// - /// - /// - public AllNewSceneObjectGroup2() - { - - } - - /// - /// - /// - public AllNewSceneObjectGroup2(byte[] data) - { - - } - - /// - /// - /// - public AllNewSceneObjectGroup2(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) - { - m_regionHandle = regionHandle; - m_scene = scene; - - this.Pos = pos; - LLVector3 rootOffset = new LLVector3(0, 0, 0); - AllNewSceneObjectPart2 newPart = new AllNewSceneObjectPart2(m_regionHandle, this, ownerID, localID, shape, pos, rootOffset); - this.m_parts.Add(newPart.UUID, newPart); - this.SetPartAsRoot(newPart); - } - - - #region Copying - /// - /// - /// - /// - public new AllNewSceneObjectGroup2 Copy() - { - AllNewSceneObjectGroup2 dupe = (AllNewSceneObjectGroup2)this.MemberwiseClone(); - dupe.Pos = new LLVector3(Pos.X, Pos.Y, Pos.Z); - dupe.m_scene = m_scene; - dupe.m_regionHandle = this.m_regionHandle; - - dupe.CopyRootPart(this.m_rootPart); - - foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) - { - if (part.UUID != this.m_rootPart.UUID) - { - dupe.CopyPart(part); - } - } - return dupe; - } - - /// - /// - /// - /// - public void CopyRootPart(AllNewSceneObjectPart2 part) - { - AllNewSceneObjectPart2 newPart = part.Copy(m_scene.PrimIDAllocate()); - this.m_parts.Add(newPart.UUID, newPart); - this.SetPartAsRoot(newPart); - } - - /// - /// - /// - /// - public void CopyPart(AllNewSceneObjectPart2 part) - { - AllNewSceneObjectPart2 newPart = part.Copy(m_scene.PrimIDAllocate()); - this.m_parts.Add(newPart.UUID, newPart); - this.SetPartAsNonRoot(newPart); - } - #endregion - - /// - /// - /// - public override void Update() - { - foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) - { - part.SendScheduledUpdates(); - } - } - - /// - /// - /// - public void ScheduleGroupForFullUpdate() - { - foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) - { - part.ScheduleFullUpdate(); - } - } - - /// - /// - /// - public void ScheduleGroupForTerseUpdate() - { - foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) - { - part.ScheduleTerseUpdate(); - } - } - - /// - /// - /// - public void SendGroupFullUpdate() - { - foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) - { - part.SendFullUpdateToAllClients(); - } - } - - /// - /// - /// - public void SendGroupTerseUpdate() - { - foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) - { - part.SendTerseUpdateToAllClients(); - } - } - - /// - /// - /// - /// - public void LinkToGroup(AllNewSceneObjectGroup2 objectGroup) - { - - } - - /// - /// - /// - /// - /// - private AllNewSceneObjectPart2 GetChildPrim(LLUUID primID) - { - AllNewSceneObjectPart2 childPart = null; - if (this.m_parts.ContainsKey(primID)) - { - childPart = this.m_parts[primID]; - } - return childPart; - } - - /// - /// - /// - /// - /// - private AllNewSceneObjectPart2 GetChildPrim(uint localID) - { - foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) - { - if (part.LocalID == localID) - { - return part; - } - } - return null; - } - - /// - /// Does this group contain the child prim - /// should be able to remove these methods once we have a entity index in scene - /// - /// - /// - public bool HasChildPrim(LLUUID primID) - { - AllNewSceneObjectPart2 childPart = null; - if (this.m_parts.ContainsKey(primID)) - { - childPart = this.m_parts[primID]; - return true; - } - return false; - } - - /// - /// Does this group contain the child prim - /// should be able to remove these methods once we have a entity index in scene - /// - /// - /// - public bool HasChildPrim(uint localID) - { - foreach (AllNewSceneObjectPart2 part in this.m_parts.Values) - { - if (part.LocalID == localID) - { - return true; - } - } - return false; - } - - /// - /// - /// - public void TriggerTainted() - { - if (OnPrimCountTainted != null) - { - this.OnPrimCountTainted(); - } - } - - /// - /// - /// - /// - /// - /// - public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) - { - this.Pos = pos; - this.m_rootPart.SendTerseUpdateToAllClients(); - } - - /// - /// - /// - /// - public void GetProperites(IClientAPI client) - { - ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); - proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; - proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); - proper.ObjectData[0].ItemID = LLUUID.Zero; - proper.ObjectData[0].CreationDate = (ulong)this.m_rootPart.CreationDate; - proper.ObjectData[0].CreatorID = this.m_rootPart.CreatorID; - proper.ObjectData[0].FolderID = LLUUID.Zero; - proper.ObjectData[0].FromTaskID = LLUUID.Zero; - proper.ObjectData[0].GroupID = LLUUID.Zero; - proper.ObjectData[0].InventorySerial = 0; - proper.ObjectData[0].LastOwnerID = this.m_rootPart.LastOwnerID; - proper.ObjectData[0].ObjectID = this.m_uuid; - proper.ObjectData[0].OwnerID = this.m_rootPart.OwnerID; - proper.ObjectData[0].TouchName = enc.GetBytes(this.m_rootPart.TouchName + "\0"); - proper.ObjectData[0].TextureID = new byte[0]; - proper.ObjectData[0].SitName = enc.GetBytes(this.m_rootPart.SitName + "\0"); - proper.ObjectData[0].Name = enc.GetBytes(this.m_rootPart.PartName + "\0"); - proper.ObjectData[0].Description = enc.GetBytes(this.m_rootPart.Description + "\0"); - proper.ObjectData[0].OwnerMask = this.m_rootPart.OwnerMask; - proper.ObjectData[0].NextOwnerMask = this.m_rootPart.NextOwnerMask; - proper.ObjectData[0].GroupMask = this.m_rootPart.GroupMask; - proper.ObjectData[0].EveryoneMask = this.m_rootPart.EveryoneMask; - proper.ObjectData[0].BaseMask = this.m_rootPart.BaseMask; - - client.OutPacket(proper); - } - - /// - /// - /// - /// - /// - public void GetInventory(IClientAPI remoteClient, uint localID) - { - AllNewSceneObjectPart2 part = this.GetChildPrim(localID); - if (part != null) - { - part.GetInventory(remoteClient, localID); - } - } - - /// - /// - /// - /// - /// - /// - /// - public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data) - { - AllNewSceneObjectPart2 part = this.GetChildPrim(localID); - if (part != null) - { - part.UpdateExtraParam(type, inUse, data); - } - } - - /// - /// - /// - /// - /// - public void UpdateTextureEntry(uint localID, byte[] textureEntry) - { - AllNewSceneObjectPart2 part = this.GetChildPrim(localID); - if (part != null) - { - part.UpdateTextureEntry(textureEntry); - } - } - - #region Shape - /// - /// - /// - /// - public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock, uint localID) - { - AllNewSceneObjectPart2 part = this.GetChildPrim(localID); - if (part != null) - { - part.UpdateShape(shapeBlock); - } - } - #endregion - - #region Position - /// - /// - /// - /// - public void UpdateGroupPosition(LLVector3 pos) - { - this.Pos = pos; - } - - /// - /// - /// - /// - /// - public void UpdateSinglePosition(LLVector3 pos, uint localID) - { - AllNewSceneObjectPart2 part = this.GetChildPrim(localID); - if (part != null) - { - if (part.UUID == this.m_rootPart.UUID) - { - this.UpdateRootPosition(pos); - } - else - { - part.UpdateOffSet(pos); - } - } - } - - /// - /// - /// - /// - private void UpdateRootPosition(LLVector3 pos) - { - LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); - LLVector3 oldPos = new LLVector3(this.Pos.X + this.m_rootPart.OffsetPosition.X, this.Pos.Y + this.m_rootPart.OffsetPosition.Y, this.Pos.Z + this.m_rootPart.OffsetPosition.Z); - LLVector3 diff = oldPos - newPos; - Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); - Axiom.Math.Quaternion partRotation = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z); - axDiff = partRotation.Inverse() * axDiff; - diff.X = axDiff.x; - diff.Y = axDiff.y; - diff.Z = axDiff.z; - - foreach (AllNewSceneObjectPart2 obPart in this.m_parts.Values) - { - if (obPart.UUID != this.m_rootPart.UUID) - { - obPart.OffsetPosition = obPart.OffsetPosition + diff; - } - } - this.Pos = newPos; - pos.X = newPos.X; - pos.Y = newPos.Y; - pos.Z = newPos.Z; - } - #endregion - - #region Roation - /// - /// - /// - /// - public void UpdateGroupRotation(LLQuaternion rot) - { - this.m_rootPart.UpdateRotation(rot); - } - - /// - /// - /// - /// - /// - public void UpdateGroupRotation(LLVector3 pos, LLQuaternion rot) - { - this.m_rootPart.UpdateRotation(rot); - this.Pos = pos; - } - - /// - /// - /// - /// - /// - public void UpdateSingleRotation(LLQuaternion rot, uint localID) - { - AllNewSceneObjectPart2 part = this.GetChildPrim(localID); - if (part != null) - { - if (part.UUID == this.m_rootPart.UUID) - { - this.UpdateRootRotation(rot); - } - else - { - part.UpdateRotation(rot); - } - } - } - - /// - /// - /// - /// - private void UpdateRootRotation(LLQuaternion rot) - { - this.m_rootPart.UpdateRotation(rot); - Axiom.Math.Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); - Axiom.Math.Quaternion oldParentRot = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z); - - foreach (AllNewSceneObjectPart2 prim in this.m_parts.Values) - { - if (prim.UUID != this.m_rootPart.UUID) - { - Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z); - axPos = oldParentRot * axPos; - axPos = axRot.Inverse() * axPos; - prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); - Axiom.Math.Quaternion primsRot = new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, prim.RotationOffset.Z); - Axiom.Math.Quaternion newRot = oldParentRot * primsRot; - newRot = axRot.Inverse() * newRot; - prim.RotationOffset = new LLQuaternion(newRot.w, newRot.x, newRot.y, newRot.z); - } - } - } - - #endregion - /// - /// - /// - /// - private void SetPartAsRoot(AllNewSceneObjectPart2 part) - { - this.m_rootPart = part; - //this.m_uuid= part.UUID; - // this.m_localId = part.LocalID; - } - - /// - /// - /// - /// - private void SetPartAsNonRoot(AllNewSceneObjectPart2 part) - { - part.ParentID = this.m_rootPart.LocalID; - } - - /// - /// - /// - /// - public List RequestSceneAvatars() - { - return m_scene.RequestAvatarList(); - } - - /// - /// - /// - /// - /// - internal void SendPartFullUpdate(IClientAPI remoteClient, AllNewSceneObjectPart2 part) - { - if( m_rootPart == part ) - { - part.SendFullUpdateToClient( remoteClient, Pos ); - } - else - { - part.SendFullUpdateToClient( remoteClient ); - } - } - - /// - /// - /// - /// - /// - internal void SendPartTerseUpdate(IClientAPI remoteClient, AllNewSceneObjectPart2 part) - { - if (m_rootPart == part) - { - part.SendTerseUpdateToClient(remoteClient, Pos); - } - else - { - part.SendTerseUpdateToClient(remoteClient); - } - } - } -} diff --git a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs deleted file mode 100644 index c91701a..0000000 --- a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs +++ /dev/null @@ -1,520 +0,0 @@ -using System.Collections.Generic; -using System.Text; -using System; -using Axiom.Math; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; - -namespace OpenSim.Region.Environment.Scenes -{ - - public class AllNewSceneObjectPart2 - { - private const uint FULL_MASK_PERMISSIONS = 2147483647; - - public LLUUID CreatorID; - public LLUUID OwnerID; - public LLUUID GroupID; - public LLUUID LastOwnerID; - public Int32 CreationDate; - public uint ParentID = 0; - - public uint OwnerMask = FULL_MASK_PERMISSIONS; - public uint NextOwnerMask = FULL_MASK_PERMISSIONS; - public uint GroupMask = FULL_MASK_PERMISSIONS; - public uint EveryoneMask = FULL_MASK_PERMISSIONS; - public uint BaseMask = FULL_MASK_PERMISSIONS; - - protected byte[] m_particleSystem = new byte[0]; - - protected AllNewSceneObjectGroup2 m_parentGroup; - - /// - /// Only used internally to schedule client updates - /// - private byte m_updateFlag; - - #region Properties - - protected LLUUID m_uuid; - public LLUUID UUID - { - get { return m_uuid; } - set { value = m_uuid; } - } - - protected uint m_localID; - public uint LocalID - { - get { return m_localID; } - set { m_localID = value; } - } - - protected string m_partName; - public virtual string PartName - { - get { return m_partName; } - set { m_partName = value; } - } - - protected LLObject.ObjectFlags m_flags = (LLObject.ObjectFlags)32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; - public uint ObjectFlags - { - get { return (uint)m_flags; } - set { m_flags = (LLObject.ObjectFlags)value; } - } - - protected LLObject.MaterialType m_material; - public byte Material - { - get { return (byte)m_material; } - set { m_material = (LLObject.MaterialType)value; } - } - - protected ulong m_regionHandle; - public ulong RegionHandle - { - get { return m_regionHandle; } - set { m_regionHandle = value; } - } - - //unkown if this will be kept, added as a way of removing the group position from the group class - protected LLVector3 m_groupPosition; - public LLVector3 GroupPosition - { - get { return m_groupPosition; } - set { m_groupPosition = value; } - } - - protected LLVector3 m_offset; - public LLVector3 OffsetPosition - { - get { return m_offset; } - set { m_offset = value; } - } - - protected LLQuaternion m_rotationOffset; - public LLQuaternion RotationOffset - { - get { return m_rotationOffset; } - set { m_rotationOffset = value; } - } - - protected LLVector3 m_velocity; - /// - public LLVector3 Velocity - { - get { return m_velocity; } - set { m_velocity = value; } - } - - protected LLVector3 m_angularVelocity; - /// - public LLVector3 AngularVelocity - { - get { return m_angularVelocity; } - set { m_angularVelocity = value; } - } - - protected LLVector3 m_acceleration; - /// - public LLVector3 Acceleration - { - get { return m_acceleration; } - set { m_acceleration = value; } - } - - private string m_description = ""; - public string Description - { - get { return this.m_description; } - set { this.m_description = value; } - } - - private string m_text = ""; - public string Text - { - get { return m_text; } - set - { - m_text = value; - ScheduleFullUpdate(); - } - } - - private string m_sitName = ""; - public string SitName - { - get { return m_sitName; } - set { m_sitName = value; } - } - - private string m_touchName = ""; - public string TouchName - { - get { return m_touchName; } - set { m_touchName = value; } - } - - protected PrimitiveBaseShape m_shape; - public PrimitiveBaseShape Shape - { - get { return this.m_shape; } - set { m_shape = value; } - } - - public LLVector3 Scale - { - set { this.m_shape.Scale = value; } - get { return this.m_shape.Scale; } - } - #endregion - - #region Constructors - /// - /// - /// - public AllNewSceneObjectPart2() - { - - } - - /// - /// Create a completely new SceneObjectPart (prim) - /// - /// - /// - /// - /// - /// - /// - public AllNewSceneObjectPart2(ulong regionHandle, AllNewSceneObjectGroup2 parent, LLUUID ownerID, uint localID, PrimitiveBaseShape shape, LLVector3 groupPosition, LLVector3 offsetPosition) - { - this.m_regionHandle = regionHandle; - this.m_parentGroup = parent; - - this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - this.OwnerID = ownerID; - this.CreatorID = this.OwnerID; - this.LastOwnerID = LLUUID.Zero; - this.UUID = LLUUID.Random(); - this.LocalID = (uint)(localID); - this.Shape = shape; - - this.GroupPosition = groupPosition; - this.OffsetPosition = offsetPosition; - this.RotationOffset = LLQuaternion.Identity; - this.Velocity = new LLVector3(0, 0, 0); - this.AngularVelocity = new LLVector3(0, 0, 0); - this.Acceleration = new LLVector3(0, 0, 0); - - //temporary code just so the m_flags field doesn't give a compiler warning - if (m_flags == LLObject.ObjectFlags.AllowInventoryDrop) - { - - } - } - - /// - /// Re/create a SceneObjectPart (prim) - /// - /// - /// - /// - /// - /// - /// - public AllNewSceneObjectPart2(ulong regionHandle, AllNewSceneObjectGroup2 parent, int creationDate, LLUUID ownerID, LLUUID creatorID, LLUUID lastOwnerID, uint localID, PrimitiveBaseShape shape, LLVector3 position, LLQuaternion rotation, uint flags) - { - this.m_regionHandle = regionHandle; - this.m_parentGroup = parent; - - this.CreationDate = creationDate; - this.OwnerID = ownerID; - this.CreatorID = creatorID; - this.LastOwnerID = lastOwnerID; - this.UUID = LLUUID.Random(); - this.LocalID = (uint)(localID); - this.Shape = shape; - - this.OffsetPosition = position; - this.RotationOffset = rotation; - this.ObjectFlags = flags; - } - #endregion - - #region Copying - /// - /// - /// - /// - public AllNewSceneObjectPart2 Copy(uint localID) - { - AllNewSceneObjectPart2 dupe = (AllNewSceneObjectPart2)this.MemberwiseClone(); - dupe.m_shape = m_shape.Copy(); - dupe.m_regionHandle = m_regionHandle; - dupe.UUID = LLUUID.Random(); - dupe.LocalID = localID; - dupe.GroupPosition = new LLVector3(GroupPosition.X, GroupPosition.Y, GroupPosition.Z); - dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z); - dupe.RotationOffset = new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W); - dupe.Velocity = new LLVector3(0, 0, 0); - dupe.Acceleration = new LLVector3(0, 0, 0); - dupe.AngularVelocity = new LLVector3(0, 0, 0); - dupe.ObjectFlags = this.ObjectFlags; - //TODO copy extraparams data and anything else not currently copied - return dupe; - } - #endregion - - #region Update Scheduling - /// - /// - /// - private void ClearUpdateSchedule() - { - m_updateFlag = 0; - } - - /// - /// - /// - public void ScheduleFullUpdate() - { - m_updateFlag = 2; - } - - /// - /// - /// - public void ScheduleTerseUpdate() - { - if (m_updateFlag < 1) - { - m_updateFlag = 1; - } - } - - /// - /// - /// - public void SendScheduledUpdates() - { - if (m_updateFlag == 1) //some change has been made so update the clients - { - SendTerseUpdateToAllClients(); - ClearUpdateSchedule(); - } - else - { - if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes - { - SendFullUpdateToAllClients(); - ClearUpdateSchedule(); - } - } - } - #endregion - - #region Shape - /// - /// - /// - /// - public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) - { - this.m_shape.PathBegin = shapeBlock.PathBegin; - this.m_shape.PathEnd = shapeBlock.PathEnd; - this.m_shape.PathScaleX = shapeBlock.PathScaleX; - this.m_shape.PathScaleY = shapeBlock.PathScaleY; - this.m_shape.PathShearX = shapeBlock.PathShearX; - this.m_shape.PathShearY = shapeBlock.PathShearY; - this.m_shape.PathSkew = shapeBlock.PathSkew; - this.m_shape.ProfileBegin = shapeBlock.ProfileBegin; - this.m_shape.ProfileEnd = shapeBlock.ProfileEnd; - this.m_shape.PathCurve = shapeBlock.PathCurve; - this.m_shape.ProfileCurve = shapeBlock.ProfileCurve; - this.m_shape.ProfileHollow = shapeBlock.ProfileHollow; - this.m_shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; - this.m_shape.PathRevolutions = shapeBlock.PathRevolutions; - this.m_shape.PathTaperX = shapeBlock.PathTaperX; - this.m_shape.PathTaperY = shapeBlock.PathTaperY; - this.m_shape.PathTwist = shapeBlock.PathTwist; - this.m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; - } - #endregion - - #region Inventory - public void GetInventory(IClientAPI client, uint localID) - { - if (localID == this.m_localID) - { - client.SendTaskInventory(this.m_uuid, 0, new byte[0]); - } - } - #endregion - - #region ExtraParams - public void UpdateExtraParam(ushort type, bool inUse, byte[] data) - { - this.m_shape.ExtraParams = new byte[data.Length + 7]; - int i = 0; - uint length = (uint)data.Length; - this.m_shape.ExtraParams[i++] = 1; - this.m_shape.ExtraParams[i++] = (byte)(type % 256); - this.m_shape.ExtraParams[i++] = (byte)((type >> 8) % 256); - - this.m_shape.ExtraParams[i++] = (byte)(length % 256); - this.m_shape.ExtraParams[i++] = (byte)((length >> 8) % 256); - this.m_shape.ExtraParams[i++] = (byte)((length >> 16) % 256); - this.m_shape.ExtraParams[i++] = (byte)((length >> 24) % 256); - Array.Copy(data, 0, this.m_shape.ExtraParams, i, data.Length); - - this.ScheduleFullUpdate(); - } - #endregion - - #region Texture - /// - /// - /// - /// - public void UpdateTextureEntry(byte[] textureEntry) - { - this.m_shape.TextureEntry = textureEntry; - } - #endregion - - #region ParticleSystem - public void AddNewParticleSystem(libsecondlife.Primitive.ParticleSystem pSystem) - { - this.m_particleSystem = pSystem.GetBytes(); - } - #endregion - - #region Position - /// - /// - /// - /// - public void UpdateOffSet(LLVector3 pos) - { - LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); - this.OffsetPosition = newPos; - } - #endregion - - #region rotation - public void UpdateRotation(LLQuaternion rot) - { - this.RotationOffset = new LLQuaternion(rot.X, rot.Y, rot.Z, rot.W); - } - #endregion - - #region Resizing/Scale - /// - /// - /// - /// - public void Resize(LLVector3 scale) - { - this.m_shape.Scale = scale; - } - #endregion - - #region Client Update Methods - /// - /// - /// - public void SendFullUpdateToAllClients() - { - List avatars = this.m_parentGroup.RequestSceneAvatars(); - for (int i = 0; i < avatars.Count; i++) - { - m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this); - } - } - - /// - /// - /// - /// - public void SendFullUpdate(IClientAPI remoteClient) - { - m_parentGroup.SendPartFullUpdate( remoteClient, this ); - } - - /// - /// - /// - /// - public void SendFullUpdateToClient(IClientAPI remoteClient) - { - LLVector3 lPos; - lPos = OffsetPosition; - SendFullUpdateToClient(remoteClient, lPos); - } - - /// - /// - /// - /// - /// - public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) - { - LLQuaternion lRot; - lRot = RotationOffset; - - remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, this.ObjectFlags, m_uuid, OwnerID, - m_text, ParentID, this.m_particleSystem, lRot); - } - - /// - /// - /// - public void SendTerseUpdateToAllClients() - { - List avatars = this.m_parentGroup.RequestSceneAvatars(); - for (int i = 0; i < avatars.Count; i++) - { - m_parentGroup.SendPartTerseUpdate(avatars[i].ControllingClient, this); - } - } - - /// - /// - /// - /// - public void SendTerseUpdate(IClientAPI remoteClient) - { - m_parentGroup.SendPartTerseUpdate(remoteClient, this); - } - - /// - /// - /// - /// - public void SendTerseUpdateToClient(IClientAPI remoteClient) - { - LLVector3 lPos; - lPos = this.OffsetPosition; - LLQuaternion mRot = this.RotationOffset; - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); - } - - /// - /// - /// - /// - /// - public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) - { - LLQuaternion mRot = this.RotationOffset; - remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); - } - #endregion - } -} - diff --git a/OpenSim/Region/Environment/Scenes/Primitive(Old).cs b/OpenSim/Region/Environment/Scenes/Primitive(Old).cs new file mode 100644 index 0000000..64976a8 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/Primitive(Old).cs @@ -0,0 +1,719 @@ +using System; +using System.Collections.Generic; +using System.Xml; +using System.Xml.Serialization; +using Axiom.Math; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Types; + +using InventoryItem = OpenSim.Framework.Inventory.InventoryItem; + +namespace OpenSim.Region.Environment.Scenes +{ + public delegate void PrimCountTaintedDelegate(); + + public class Primitive : EntityBase + { + private const uint FULL_MASK_PERMISSIONS = 2147483647; + + private LLVector3 m_positionLastFrame = new LLVector3(0, 0, 0); + private ulong m_regionHandle; + private byte m_updateFlag; + private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; + + private Dictionary m_inventoryItems; + + private string m_description = ""; + + public LLUUID CreatorID; + public LLUUID OwnerID; + public LLUUID LastOwnerID; + + public Int32 CreationDate; + + public uint ParentID = 0; + + public uint OwnerMask = FULL_MASK_PERMISSIONS; + public uint NextOwnerMask = FULL_MASK_PERMISSIONS; + public uint GroupMask = 0;// FULL_MASK_PERMISSIONS; + public uint EveryoneMask = 0;//FULL_MASK_PERMISSIONS; + public uint BaseMask = 0;//FULL_MASK_PERMISSIONS; + + private PrimitiveBaseShape m_shape; + private byte[] m_particleSystem = new byte[0]; + + public SceneObjectOLD m_RootParent; + public bool m_isRootPrim; + public EntityBase m_Parent; + + public event PrimCountTaintedDelegate OnPrimCountTainted; + + #region Properties + + /// + /// If rootprim, will return world position + /// otherwise will return local offset from rootprim + /// + public override LLVector3 Pos + { + get + { + if (m_isRootPrim) + { + //if we are rootprim then our offset should be zero + return m_pos + m_Parent.Pos; + } + else + { + return m_pos; + } + } + set + { + if (m_isRootPrim) + { + m_Parent.Pos = value; + } + m_pos = value - m_Parent.Pos; + } + } + + public PrimitiveBaseShape Shape + { + get { return m_shape; } + } + + public LLVector3 WorldPos + { + get + { + if (!m_isRootPrim) + { + Primitive parentPrim = (Primitive)m_Parent; + Vector3 offsetPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z); + offsetPos = parentPrim.Rotation * offsetPos; + return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z); + } + else + { + return Pos; + } + } + } + + public string Description + { + get { return m_description; } + set { m_description = value; } + } + + public LLVector3 Scale + { + set { m_shape.Scale = value; } + get { return m_shape.Scale; } + } + + private string m_sitName = ""; + public string SitName + { + get { return m_sitName; } + } + + private string m_touchName = ""; + public string TouchName + { + get { return m_touchName; } + } + + private string m_text = ""; + public string Text + { + get { return m_text; } + set + { + m_text = value; + ScheduleFullUpdate(); + } + } + + #endregion + + #region Constructors + + public Primitive(ulong regionHandle, Scene scene, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, + SceneObjectOLD rootObject, PrimitiveBaseShape shape, LLVector3 pos) + { + m_regionHandle = regionHandle; + m_scene = scene; + m_inventoryItems = new Dictionary(); + m_Parent = parent; + m_isRootPrim = isRoot; + m_RootParent = rootObject; + ClearUpdateSchedule(); + CreateFromShape(ownerID, localID, pos, shape); + + Rotation = Quaternion.Identity; + + m_scene.AcknowledgeNewPrim(this); + + OnPrimCountTainted(); + } + + /// + /// + /// + /// Empty constructor for duplication + public Primitive() + { + } + + #endregion + + #region Destructors + + ~Primitive() + { + if (OnPrimCountTainted != null) + OnPrimCountTainted(); + } + + #endregion + + #region Duplication + + public Primitive Copy(EntityBase parent, SceneObjectOLD rootParent) + { + Primitive dupe = (Primitive)MemberwiseClone(); + + dupe.m_Parent = parent; + dupe.m_RootParent = rootParent; + + // TODO: Copy this properly. + + dupe.m_inventoryItems = m_inventoryItems; + dupe.m_children = new List(); + dupe.m_shape = m_shape.Copy(); + dupe.m_regionHandle = m_regionHandle; + dupe.m_scene = m_scene; + + + uint newLocalID = m_scene.PrimIDAllocate(); + dupe.m_uuid = LLUUID.Random(); + dupe.LocalId = newLocalID; + + if (parent is SceneObjectGroup) + { + dupe.m_isRootPrim = true; + dupe.ParentID = 0; + } + else + { + dupe.m_isRootPrim = false; + dupe.ParentID = ((Primitive)parent).LocalId; + } + + dupe.Scale = new LLVector3(Scale.X, Scale.Y, Scale.Z); + dupe.Rotation = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z); + dupe.m_pos = new LLVector3(m_pos.X, m_pos.Y, m_pos.Z); + + rootParent.AddChildToList(dupe); + m_scene.AcknowledgeNewPrim(dupe); + dupe.TriggerOnPrimCountTainted(); + + + foreach (Primitive prim in m_children) + { + Primitive primClone = prim.Copy(dupe, rootParent); + + dupe.m_children.Add(primClone); + } + + return dupe; + } + + #endregion + + #region Override from EntityBase + + /// + /// + /// + public override void Update() + { + if (m_updateFlag == 1) //some change has been made so update the clients + { + SendTerseUpdateToALLClients(); + ClearUpdateSchedule(); + } + else + { + if (m_updateFlag == 2) // is a new prim just been created/reloaded or has major changes + { + SendFullUpdateToAllClients(); + ClearUpdateSchedule(); + } + } + + foreach (EntityBase child in m_children) + { + child.Update(); + } + } + + private void ClearUpdateSchedule() + { + m_updateFlag = 0; + } + + #endregion + + #region Setup + + /// + /// + /// + /// + /// + /// + public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) + { + CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + OwnerID = ownerID; + CreatorID = OwnerID; + LastOwnerID = LLUUID.Zero; + Pos = pos; + m_uuid = LLUUID.Random(); + m_localId = (uint)(localID); + + m_shape = shape; + + ScheduleFullUpdate(); + } + + private void ScheduleFullUpdate() + { + m_updateFlag = 2; + } + + private void ScheduleTerseUpdate() + { + if (m_updateFlag < 1) + { + m_updateFlag = 1; + } + } + + #endregion + + #region Linking / unlinking + + /// + /// + /// + /// + public void AddNewChildren(SceneObjectOLD linkObject) + { + // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); + //TODO check permissions + + m_children.Add(linkObject.rootPrimitive); + linkObject.rootPrimitive.SetNewParent(this, m_RootParent); + + m_scene.DeleteEntity(linkObject.rootUUID); + linkObject.DeleteAllChildren(); + + OnPrimCountTainted(); + } + + /// + /// + /// + /// + /// + public void SetNewParent(Primitive newParent, SceneObjectOLD rootParent) + { + LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); + m_isRootPrim = false; + m_Parent = newParent; + ParentID = newParent.LocalId; + m_RootParent = rootParent; + m_RootParent.AddChildToList(this); + Pos = oldPos; + Vector3 axPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z); + axPos = m_Parent.Rotation.Inverse() * axPos; + m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); + Quaternion oldRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z); + Rotation = m_Parent.Rotation.Inverse() * Rotation; + ScheduleFullUpdate(); + + + foreach (Primitive child in m_children) + { + child.SetRootParent(rootParent, newParent, oldPos, oldRot); + } + + m_children.Clear(); + + } + + /// + /// + /// + /// + public void SetRootParent(SceneObjectOLD newRoot, Primitive newParent, LLVector3 oldParentPosition, + Quaternion oldParentRotation) + { + LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); + Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z); + axOldPos = oldParentRotation * axOldPos; + oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z); + oldPos += oldParentPosition; + Quaternion oldRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z); + m_isRootPrim = false; + m_Parent = newParent; + ParentID = newParent.LocalId; + newParent.AddToChildrenList(this); + + m_RootParent = newRoot; + m_RootParent.AddChildToList(this); + Pos = oldPos; + Vector3 axPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z); + axPos = m_Parent.Rotation.Inverse() * axPos; + m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); + Rotation = oldParentRotation * Rotation; + Rotation = m_Parent.Rotation.Inverse() * Rotation; + ScheduleFullUpdate(); + foreach (Primitive child in m_children) + { + child.SetRootParent(newRoot, newParent, oldPos, oldRot); + } + + m_children.Clear(); + + } + + /// + /// + /// + /// + public void AddOffsetToChildren(LLVector3 offset) + { + foreach (Primitive prim in m_children) + { + prim.m_pos += offset; + prim.ScheduleTerseUpdate(); + } + OnPrimCountTainted(); + } + + /// + /// + /// + /// + public void AddToChildrenList(Primitive prim) + { + m_children.Add(prim); + } + + #endregion + + #region Resizing/Scale + + /// + /// + /// + /// + public void ResizeGoup(LLVector3 scale) + { + m_shape.Scale = scale; + + ScheduleFullUpdate(); + } + + #endregion + + #region Position + + /// + /// + /// + /// + public void UpdateGroupPosition(LLVector3 pos) + { + LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); + + Pos = newPos; + ScheduleTerseUpdate(); + + OnPrimCountTainted(); + } + + /// + /// + /// + /// + public void UpdateSinglePosition(LLVector3 pos) + { + // Console.WriteLine("updating single prim position"); + if (m_isRootPrim) + { + LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); + LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); + LLVector3 diff = oldPos - newPos; + Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); + axDiff = Rotation.Inverse() * axDiff; + diff.X = axDiff.x; + diff.Y = axDiff.y; + diff.Z = axDiff.z; + Pos = newPos; + + foreach (Primitive prim in m_children) + { + prim.m_pos += diff; + prim.ScheduleTerseUpdate(); + } + ScheduleTerseUpdate(); + } + else + { + LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); + m_pos = newPos; + ScheduleTerseUpdate(); + } + } + + #endregion + + #region Rotation + + /// + /// + /// + /// + public void UpdateGroupRotation(LLQuaternion rot) + { + Rotation = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); + ScheduleTerseUpdate(); + } + + /// + /// + /// + /// + /// + public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) + { + Rotation = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); + Pos = pos; + ScheduleTerseUpdate(); + } + + /// + /// + /// + /// + public void UpdateSingleRotation(LLQuaternion rot) + { + //Console.WriteLine("updating single prim rotation"); + + Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); + Quaternion oldParentRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z); + Rotation = axRot; + foreach (Primitive prim in m_children) + { + Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z); + axPos = oldParentRot * axPos; + axPos = axRot.Inverse() * axPos; + prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); + prim.Rotation = oldParentRot * prim.Rotation; + prim.Rotation = axRot.Inverse() * prim.Rotation; + prim.ScheduleTerseUpdate(); + } + ScheduleTerseUpdate(); + } + + #endregion + + #region Shape + + /// + /// + /// + /// + public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) + { + m_shape.PathBegin = shapeBlock.PathBegin; + m_shape.PathEnd = shapeBlock.PathEnd; + m_shape.PathScaleX = shapeBlock.PathScaleX; + m_shape.PathScaleY = shapeBlock.PathScaleY; + m_shape.PathShearX = shapeBlock.PathShearX; + m_shape.PathShearY = shapeBlock.PathShearY; + m_shape.PathSkew = shapeBlock.PathSkew; + m_shape.ProfileBegin = shapeBlock.ProfileBegin; + m_shape.ProfileEnd = shapeBlock.ProfileEnd; + m_shape.PathCurve = shapeBlock.PathCurve; + m_shape.ProfileCurve = shapeBlock.ProfileCurve; + m_shape.ProfileHollow = shapeBlock.ProfileHollow; + m_shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; + m_shape.PathRevolutions = shapeBlock.PathRevolutions; + m_shape.PathTaperX = shapeBlock.PathTaperX; + m_shape.PathTaperY = shapeBlock.PathTaperY; + m_shape.PathTwist = shapeBlock.PathTwist; + m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; + ScheduleFullUpdate(); + } + + #endregion + + #region Inventory + public void GetInventory(IClientAPI client, uint localID) + { + if (localID == this.m_localId) + { + client.SendTaskInventory(this.m_uuid, 0, new byte[0]); + } + } + #endregion + + public void UpdateExtraParam(ushort type, bool inUse, byte[] data) + { + this.m_shape.ExtraParams = new byte[data.Length + 7]; + int i =0; + uint length = (uint) data.Length; + this.m_shape.ExtraParams[i++] = 1; + this.m_shape.ExtraParams[i++] = (byte)(type % 256); + this.m_shape.ExtraParams[i++] = (byte)((type >> 8) % 256); + + this.m_shape.ExtraParams[i++] = (byte)(length % 256); + this.m_shape.ExtraParams[i++] = (byte)((length >> 8) % 256); + this.m_shape.ExtraParams[i++] = (byte)((length >> 16) % 256); + this.m_shape.ExtraParams[i++] = (byte)((length >> 24) % 256); + Array.Copy(data, 0, this.m_shape.ExtraParams, i, data.Length); + + this.ScheduleFullUpdate(); + } + + #region Texture + + /// + /// + /// + /// + public void UpdateTextureEntry(byte[] textureEntry) + { + m_shape.TextureEntry = textureEntry; + ScheduleFullUpdate(); + } + + #endregion + + public void AddNewParticleSystem(libsecondlife.Primitive.ParticleSystem pSystem) + { + this.m_particleSystem = pSystem.GetBytes(); + ScheduleFullUpdate(); + } + + #region Client Update Methods + + /// + /// + /// + /// + public void SendFullUpdateForAllChildren(IClientAPI remoteClient) + { + + SendFullUpdateToClient(remoteClient); + for (int i = 0; i < m_children.Count; i++) + + { + + if (m_children[i] is Primitive) + { + ((Primitive)m_children[i]).SendFullUpdateForAllChildren(remoteClient); + } + } + } + + /// + /// + /// + /// + public void SendFullUpdateToClient(IClientAPI remoteClient) + { + LLVector3 lPos; + lPos = Pos; + LLQuaternion lRot; + lRot = new LLQuaternion(Rotation.x, Rotation.y, Rotation.z, Rotation.w); + + remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalId, m_shape, lPos, m_flags, m_uuid, OwnerID, + m_text, ParentID, this.m_particleSystem, lRot); + } + + /// + /// + /// + public void SendFullUpdateToAllClients() + { + List avatars = m_scene.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + SendFullUpdateToClient(avatars[i].ControllingClient); + } + } + + /// + /// + /// + /// + public void SendTerseUpdateForAllChildren(IClientAPI remoteClient) + { + + SendTerseUpdateToClient(remoteClient); + for (int i = 0; i < m_children.Count; i++) + { + if (m_children[i] is Primitive) + { + ((Primitive)m_children[i]).SendTerseUpdateForAllChildren(remoteClient); + } + } + } + + /// + /// + /// + /// + public void SendTerseUpdateToClient(IClientAPI RemoteClient) + { + LLVector3 lPos; + Quaternion lRot; + + lPos = Pos; + lRot = Rotation; + + LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); + RemoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalId, lPos, mRot); + } + + /// + /// + /// + public void SendTerseUpdateToALLClients() + { + List avatars = m_scene.RequestAvatarList(); + for (int i = 0; i < avatars.Count; i++) + { + SendTerseUpdateToClient(avatars[i].ControllingClient); + } + } + + #endregion + + public void TriggerOnPrimCountTainted() + { + OnPrimCountTainted(); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs deleted file mode 100644 index 132eabb..0000000 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ /dev/null @@ -1,719 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Xml; -using System.Xml.Serialization; -using Axiom.Math; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Inventory; -using OpenSim.Framework.Types; - -using InventoryItem = OpenSim.Framework.Inventory.InventoryItem; - -namespace OpenSim.Region.Environment.Scenes -{ - public delegate void PrimCountTaintedDelegate(); - - public class Primitive : EntityBase - { - private const uint FULL_MASK_PERMISSIONS = 2147483647; - - private LLVector3 m_positionLastFrame = new LLVector3(0, 0, 0); - private ulong m_regionHandle; - private byte m_updateFlag; - private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; - - private Dictionary m_inventoryItems; - - private string m_description = ""; - - public LLUUID CreatorID; - public LLUUID OwnerID; - public LLUUID LastOwnerID; - - public Int32 CreationDate; - - public uint ParentID = 0; - - public uint OwnerMask = FULL_MASK_PERMISSIONS; - public uint NextOwnerMask = FULL_MASK_PERMISSIONS; - public uint GroupMask = 0;// FULL_MASK_PERMISSIONS; - public uint EveryoneMask = 0;//FULL_MASK_PERMISSIONS; - public uint BaseMask = 0;//FULL_MASK_PERMISSIONS; - - private PrimitiveBaseShape m_shape; - private byte[] m_particleSystem = new byte[0]; - - public SceneObject m_RootParent; - public bool m_isRootPrim; - public EntityBase m_Parent; - - public event PrimCountTaintedDelegate OnPrimCountTainted; - - #region Properties - - /// - /// If rootprim, will return world position - /// otherwise will return local offset from rootprim - /// - public override LLVector3 Pos - { - get - { - if (m_isRootPrim) - { - //if we are rootprim then our offset should be zero - return m_pos + m_Parent.Pos; - } - else - { - return m_pos; - } - } - set - { - if (m_isRootPrim) - { - m_Parent.Pos = value; - } - m_pos = value - m_Parent.Pos; - } - } - - public PrimitiveBaseShape Shape - { - get { return m_shape; } - } - - public LLVector3 WorldPos - { - get - { - if (!m_isRootPrim) - { - Primitive parentPrim = (Primitive)m_Parent; - Vector3 offsetPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z); - offsetPos = parentPrim.Rotation * offsetPos; - return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z); - } - else - { - return Pos; - } - } - } - - public string Description - { - get { return m_description; } - set { m_description = value; } - } - - public LLVector3 Scale - { - set { m_shape.Scale = value; } - get { return m_shape.Scale; } - } - - private string m_sitName = ""; - public string SitName - { - get { return m_sitName; } - } - - private string m_touchName = ""; - public string TouchName - { - get { return m_touchName; } - } - - private string m_text = ""; - public string Text - { - get { return m_text; } - set - { - m_text = value; - ScheduleFullUpdate(); - } - } - - #endregion - - #region Constructors - - public Primitive(ulong regionHandle, Scene scene, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, - SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos) - { - m_regionHandle = regionHandle; - m_scene = scene; - m_inventoryItems = new Dictionary(); - m_Parent = parent; - m_isRootPrim = isRoot; - m_RootParent = rootObject; - ClearUpdateSchedule(); - CreateFromShape(ownerID, localID, pos, shape); - - Rotation = Quaternion.Identity; - - m_scene.AcknowledgeNewPrim(this); - - OnPrimCountTainted(); - } - - /// - /// - /// - /// Empty constructor for duplication - public Primitive() - { - } - - #endregion - - #region Destructors - - ~Primitive() - { - if (OnPrimCountTainted != null) - OnPrimCountTainted(); - } - - #endregion - - #region Duplication - - public Primitive Copy(EntityBase parent, SceneObject rootParent) - { - Primitive dupe = (Primitive)MemberwiseClone(); - - dupe.m_Parent = parent; - dupe.m_RootParent = rootParent; - - // TODO: Copy this properly. - - dupe.m_inventoryItems = m_inventoryItems; - dupe.m_children = new List(); - dupe.m_shape = m_shape.Copy(); - dupe.m_regionHandle = m_regionHandle; - dupe.m_scene = m_scene; - - - uint newLocalID = m_scene.PrimIDAllocate(); - dupe.m_uuid = LLUUID.Random(); - dupe.LocalId = newLocalID; - - if (parent is SceneObject) - { - dupe.m_isRootPrim = true; - dupe.ParentID = 0; - } - else - { - dupe.m_isRootPrim = false; - dupe.ParentID = ((Primitive)parent).LocalId; - } - - dupe.Scale = new LLVector3(Scale.X, Scale.Y, Scale.Z); - dupe.Rotation = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z); - dupe.m_pos = new LLVector3(m_pos.X, m_pos.Y, m_pos.Z); - - rootParent.AddChildToList(dupe); - m_scene.AcknowledgeNewPrim(dupe); - dupe.TriggerOnPrimCountTainted(); - - - foreach (Primitive prim in m_children) - { - Primitive primClone = prim.Copy(dupe, rootParent); - - dupe.m_children.Add(primClone); - } - - return dupe; - } - - #endregion - - #region Override from EntityBase - - /// - /// - /// - public override void Update() - { - if (m_updateFlag == 1) //some change has been made so update the clients - { - SendTerseUpdateToALLClients(); - ClearUpdateSchedule(); - } - else - { - if (m_updateFlag == 2) // is a new prim just been created/reloaded or has major changes - { - SendFullUpdateToAllClients(); - ClearUpdateSchedule(); - } - } - - foreach (EntityBase child in m_children) - { - child.Update(); - } - } - - private void ClearUpdateSchedule() - { - m_updateFlag = 0; - } - - #endregion - - #region Setup - - /// - /// - /// - /// - /// - /// - public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) - { - CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; - OwnerID = ownerID; - CreatorID = OwnerID; - LastOwnerID = LLUUID.Zero; - Pos = pos; - m_uuid = LLUUID.Random(); - m_localId = (uint)(localID); - - m_shape = shape; - - ScheduleFullUpdate(); - } - - private void ScheduleFullUpdate() - { - m_updateFlag = 2; - } - - private void ScheduleTerseUpdate() - { - if (m_updateFlag < 1) - { - m_updateFlag = 1; - } - } - - #endregion - - #region Linking / unlinking - - /// - /// - /// - /// - public void AddNewChildren(SceneObject linkObject) - { - // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); - //TODO check permissions - - m_children.Add(linkObject.rootPrimitive); - linkObject.rootPrimitive.SetNewParent(this, m_RootParent); - - m_scene.DeleteEntity(linkObject.rootUUID); - linkObject.DeleteAllChildren(); - - OnPrimCountTainted(); - } - - /// - /// - /// - /// - /// - public void SetNewParent(Primitive newParent, SceneObject rootParent) - { - LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); - m_isRootPrim = false; - m_Parent = newParent; - ParentID = newParent.LocalId; - m_RootParent = rootParent; - m_RootParent.AddChildToList(this); - Pos = oldPos; - Vector3 axPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z); - axPos = m_Parent.Rotation.Inverse() * axPos; - m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); - Quaternion oldRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z); - Rotation = m_Parent.Rotation.Inverse() * Rotation; - ScheduleFullUpdate(); - - - foreach (Primitive child in m_children) - { - child.SetRootParent(rootParent, newParent, oldPos, oldRot); - } - - m_children.Clear(); - - } - - /// - /// - /// - /// - public void SetRootParent(SceneObject newRoot, Primitive newParent, LLVector3 oldParentPosition, - Quaternion oldParentRotation) - { - LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); - Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z); - axOldPos = oldParentRotation * axOldPos; - oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z); - oldPos += oldParentPosition; - Quaternion oldRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z); - m_isRootPrim = false; - m_Parent = newParent; - ParentID = newParent.LocalId; - newParent.AddToChildrenList(this); - - m_RootParent = newRoot; - m_RootParent.AddChildToList(this); - Pos = oldPos; - Vector3 axPos = new Vector3(m_pos.X, m_pos.Y, m_pos.Z); - axPos = m_Parent.Rotation.Inverse() * axPos; - m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); - Rotation = oldParentRotation * Rotation; - Rotation = m_Parent.Rotation.Inverse() * Rotation; - ScheduleFullUpdate(); - foreach (Primitive child in m_children) - { - child.SetRootParent(newRoot, newParent, oldPos, oldRot); - } - - m_children.Clear(); - - } - - /// - /// - /// - /// - public void AddOffsetToChildren(LLVector3 offset) - { - foreach (Primitive prim in m_children) - { - prim.m_pos += offset; - prim.ScheduleTerseUpdate(); - } - OnPrimCountTainted(); - } - - /// - /// - /// - /// - public void AddToChildrenList(Primitive prim) - { - m_children.Add(prim); - } - - #endregion - - #region Resizing/Scale - - /// - /// - /// - /// - public void ResizeGoup(LLVector3 scale) - { - m_shape.Scale = scale; - - ScheduleFullUpdate(); - } - - #endregion - - #region Position - - /// - /// - /// - /// - public void UpdateGroupPosition(LLVector3 pos) - { - LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); - - Pos = newPos; - ScheduleTerseUpdate(); - - OnPrimCountTainted(); - } - - /// - /// - /// - /// - public void UpdateSinglePosition(LLVector3 pos) - { - // Console.WriteLine("updating single prim position"); - if (m_isRootPrim) - { - LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); - LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); - LLVector3 diff = oldPos - newPos; - Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); - axDiff = Rotation.Inverse() * axDiff; - diff.X = axDiff.x; - diff.Y = axDiff.y; - diff.Z = axDiff.z; - Pos = newPos; - - foreach (Primitive prim in m_children) - { - prim.m_pos += diff; - prim.ScheduleTerseUpdate(); - } - ScheduleTerseUpdate(); - } - else - { - LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); - m_pos = newPos; - ScheduleTerseUpdate(); - } - } - - #endregion - - #region Rotation - - /// - /// - /// - /// - public void UpdateGroupRotation(LLQuaternion rot) - { - Rotation = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); - ScheduleTerseUpdate(); - } - - /// - /// - /// - /// - /// - public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) - { - Rotation = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); - Pos = pos; - ScheduleTerseUpdate(); - } - - /// - /// - /// - /// - public void UpdateSingleRotation(LLQuaternion rot) - { - //Console.WriteLine("updating single prim rotation"); - - Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); - Quaternion oldParentRot = new Quaternion(Rotation.w, Rotation.x, Rotation.y, Rotation.z); - Rotation = axRot; - foreach (Primitive prim in m_children) - { - Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z); - axPos = oldParentRot * axPos; - axPos = axRot.Inverse() * axPos; - prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); - prim.Rotation = oldParentRot * prim.Rotation; - prim.Rotation = axRot.Inverse() * prim.Rotation; - prim.ScheduleTerseUpdate(); - } - ScheduleTerseUpdate(); - } - - #endregion - - #region Shape - - /// - /// - /// - /// - public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) - { - m_shape.PathBegin = shapeBlock.PathBegin; - m_shape.PathEnd = shapeBlock.PathEnd; - m_shape.PathScaleX = shapeBlock.PathScaleX; - m_shape.PathScaleY = shapeBlock.PathScaleY; - m_shape.PathShearX = shapeBlock.PathShearX; - m_shape.PathShearY = shapeBlock.PathShearY; - m_shape.PathSkew = shapeBlock.PathSkew; - m_shape.ProfileBegin = shapeBlock.ProfileBegin; - m_shape.ProfileEnd = shapeBlock.ProfileEnd; - m_shape.PathCurve = shapeBlock.PathCurve; - m_shape.ProfileCurve = shapeBlock.ProfileCurve; - m_shape.ProfileHollow = shapeBlock.ProfileHollow; - m_shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; - m_shape.PathRevolutions = shapeBlock.PathRevolutions; - m_shape.PathTaperX = shapeBlock.PathTaperX; - m_shape.PathTaperY = shapeBlock.PathTaperY; - m_shape.PathTwist = shapeBlock.PathTwist; - m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; - ScheduleFullUpdate(); - } - - #endregion - - #region Inventory - public void GetInventory(IClientAPI client, uint localID) - { - if (localID == this.m_localId) - { - client.SendTaskInventory(this.m_uuid, 0, new byte[0]); - } - } - #endregion - - public void UpdateExtraParam(ushort type, bool inUse, byte[] data) - { - this.m_shape.ExtraParams = new byte[data.Length + 7]; - int i =0; - uint length = (uint) data.Length; - this.m_shape.ExtraParams[i++] = 1; - this.m_shape.ExtraParams[i++] = (byte)(type % 256); - this.m_shape.ExtraParams[i++] = (byte)((type >> 8) % 256); - - this.m_shape.ExtraParams[i++] = (byte)(length % 256); - this.m_shape.ExtraParams[i++] = (byte)((length >> 8) % 256); - this.m_shape.ExtraParams[i++] = (byte)((length >> 16) % 256); - this.m_shape.ExtraParams[i++] = (byte)((length >> 24) % 256); - Array.Copy(data, 0, this.m_shape.ExtraParams, i, data.Length); - - this.ScheduleFullUpdate(); - } - - #region Texture - - /// - /// - /// - /// - public void UpdateTextureEntry(byte[] textureEntry) - { - m_shape.TextureEntry = textureEntry; - ScheduleFullUpdate(); - } - - #endregion - - public void AddNewParticleSystem(libsecondlife.Primitive.ParticleSystem pSystem) - { - this.m_particleSystem = pSystem.GetBytes(); - ScheduleFullUpdate(); - } - - #region Client Update Methods - - /// - /// - /// - /// - public void SendFullUpdateForAllChildren(IClientAPI remoteClient) - { - - SendFullUpdateToClient(remoteClient); - for (int i = 0; i < m_children.Count; i++) - - { - - if (m_children[i] is Primitive) - { - ((Primitive)m_children[i]).SendFullUpdateForAllChildren(remoteClient); - } - } - } - - /// - /// - /// - /// - public void SendFullUpdateToClient(IClientAPI remoteClient) - { - LLVector3 lPos; - lPos = Pos; - LLQuaternion lRot; - lRot = new LLQuaternion(Rotation.x, Rotation.y, Rotation.z, Rotation.w); - - remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalId, m_shape, lPos, m_flags, m_uuid, OwnerID, - m_text, ParentID, this.m_particleSystem, lRot); - } - - /// - /// - /// - public void SendFullUpdateToAllClients() - { - List avatars = m_scene.RequestAvatarList(); - for (int i = 0; i < avatars.Count; i++) - { - SendFullUpdateToClient(avatars[i].ControllingClient); - } - } - - /// - /// - /// - /// - public void SendTerseUpdateForAllChildren(IClientAPI remoteClient) - { - - SendTerseUpdateToClient(remoteClient); - for (int i = 0; i < m_children.Count; i++) - { - if (m_children[i] is Primitive) - { - ((Primitive)m_children[i]).SendTerseUpdateForAllChildren(remoteClient); - } - } - } - - /// - /// - /// - /// - public void SendTerseUpdateToClient(IClientAPI RemoteClient) - { - LLVector3 lPos; - Quaternion lRot; - - lPos = Pos; - lRot = Rotation; - - LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); - RemoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalId, lPos, mRot); - } - - /// - /// - /// - public void SendTerseUpdateToALLClients() - { - List avatars = m_scene.RequestAvatarList(); - for (int i = 0; i < avatars.Count; i++) - { - SendTerseUpdateToClient(avatars[i].ControllingClient); - } - } - - #endregion - - public void TriggerOnPrimCountTainted() - { - OnPrimCountTainted(); - } - } -} \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 2f3ce6e..4300ce4 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -272,14 +272,14 @@ namespace OpenSim.Region.Environment.Scenes /// public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags) { - SceneObject originPrim = null; + SceneObjectGroup originPrim = null; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - if (((SceneObject)ent).rootLocalID == originalPrim) + if (((SceneObjectGroup)ent).LocalId == originalPrim) { - originPrim = (SceneObject)ent; + originPrim = (SceneObjectGroup)ent; break; } } @@ -287,15 +287,16 @@ namespace OpenSim.Region.Environment.Scenes if (originPrim != null) { - SceneObject copy = originPrim.Copy(); + SceneObjectGroup copy = originPrim.Copy(); copy.Pos = copy.Pos + offset; - this.Entities.Add(copy.rootUUID, copy); + this.Entities.Add(copy.UUID, copy); - List avatars = this.RequestAvatarList(); + copy.ScheduleGroupForFullUpdate(); + /* List avatars = this.RequestAvatarList(); for (int i = 0; i < avatars.Count; i++) { - copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); - } + // copy.SendAllChildPrimsToClient(avatars[i].ControllingClient); + }*/ } else @@ -312,40 +313,40 @@ namespace OpenSim.Region.Environment.Scenes /// public void LinkObjects(uint parentPrim, List childPrims) { - SceneObject parenPrim = null; + SceneObjectGroup parenPrim = null; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - if (((SceneObject)ent).rootLocalID == parentPrim) + if (((SceneObjectGroup)ent).LocalId == parentPrim) { - parenPrim = (SceneObject)ent; + parenPrim = (SceneObjectGroup)ent; break; } } } - List children = new List(); + List children = new List(); if (parenPrim != null) { for (int i = 0; i < childPrims.Count; i++) { foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - if (((SceneObject)ent).rootLocalID == childPrims[i]) + if (((SceneObjectGroup)ent).LocalId == childPrims[i]) { - children.Add((SceneObject)ent); + children.Add((SceneObjectGroup)ent); } } } } } - foreach (SceneObject sceneObj in children) + foreach (SceneObjectGroup sceneObj in children) { - parenPrim.AddNewChildPrims(sceneObj); + parenPrim.LinkToGroup(sceneObj); } } @@ -356,15 +357,15 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(primLocalID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + if (hasPrim != false) { - prim.UpdateShape(shapeBlock); + ((SceneObjectGroup)ent).UpdateShape(shapeBlock, primLocalID); break; } } @@ -373,15 +374,15 @@ namespace OpenSim.Region.Environment.Scenes public void UpdateExtraParam(uint primLocalID, ushort type, bool inUse, byte[] data) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(primLocalID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + if (hasPrim != false) { - prim.UpdateExtraParam(type, inUse, data); + ((SceneObjectGroup)ent).UpdateExtraParam(primLocalID, type, inUse, data); break; } } @@ -395,15 +396,16 @@ namespace OpenSim.Region.Environment.Scenes /// public void RequestTaskInventory(IClientAPI remoteClient, uint primLocalID) { - Primitive prim = null; + + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(primLocalID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + if (hasPrim != false) { - prim.GetInventory(remoteClient, primLocalID); + ((SceneObjectGroup)ent).GetPartInventory(remoteClient, primLocalID); break; } } @@ -419,12 +421,12 @@ namespace OpenSim.Region.Environment.Scenes { foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - if (((SceneObject)ent).rootLocalID == primLocalID) + if (((SceneObjectGroup)ent).LocalId == primLocalID) { - ((SceneObject)ent).GetProperites(remoteClient); - ((SceneObject)ent).isSelected = true; + ((SceneObjectGroup)ent).GetProperites(remoteClient); + ((SceneObjectGroup)ent).IsSelected = true; this.LandManager.setPrimsTainted(); break; } @@ -441,11 +443,11 @@ namespace OpenSim.Region.Environment.Scenes { foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - if (((SceneObject)ent).rootLocalID == primLocalID) + if (((SceneObjectGroup)ent).LocalId == primLocalID) { - ((SceneObject)ent).isSelected = false; + ((SceneObjectGroup)ent).IsSelected = false; this.LandManager.setPrimsTainted(); break; } @@ -460,15 +462,15 @@ namespace OpenSim.Region.Environment.Scenes /// public void PrimDescription(uint primLocalID, string description) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(primLocalID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + if (hasPrim != false) { - prim.Description = description; + ((SceneObjectGroup)ent).SetPartDescription(description, primLocalID); break; } } @@ -482,15 +484,15 @@ namespace OpenSim.Region.Environment.Scenes /// public void PrimName(uint primLocalID, string name) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(primLocalID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); + if (hasPrim != false) { - prim.Name = name; + ((SceneObjectGroup)ent).SetPartName(name, primLocalID); break; } } @@ -499,27 +501,19 @@ namespace OpenSim.Region.Environment.Scenes public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(objectID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID); + if (hasPrim != false) { - ((SceneObject)ent).GrapMovement(offset, pos, remoteClient); + ((SceneObjectGroup)ent).GrapMovement(offset, pos, remoteClient); break; } } } - /* - if (this.Entities.ContainsKey(objectID)) - { - if (this.Entities[objectID] is SceneObject) - { - ((SceneObject)this.Entities[objectID]).GrapMovement(offset, pos, remoteClient); - } - }*/ } /// @@ -541,15 +535,16 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(localID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) { - prim.UpdateTextureEntry(texture); + ((SceneObjectGroup)ent).UpdateTextureEntry(localID, texture); + break; } } } @@ -563,15 +558,15 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(localID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) { - prim.UpdateGroupPosition(pos); + ((SceneObjectGroup)ent).UpdateGroupPosition(pos); break; } } @@ -583,9 +578,9 @@ namespace OpenSim.Region.Environment.Scenes Primitive prim = null; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(localID); + //prim = ((SceneObject)ent).HasChildPrim(localID); if (prim != null) { prim.UpdateSinglePosition(pos); @@ -604,15 +599,16 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(localID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) { - prim.UpdateGroupMouseRotation(pos, rot); + ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot); + // prim.UpdateGroupMouseRotation(pos, rot); break; } } @@ -627,15 +623,16 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(localID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) { - prim.UpdateGroupRotation(rot); + ((SceneObjectGroup)ent).UpdateGroupRotation(rot); + //prim.UpdateGroupRotation(rot); break; } } @@ -654,9 +651,9 @@ namespace OpenSim.Region.Environment.Scenes Primitive prim = null; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(localID); + // prim = ((SceneObject)ent).HasChildPrim(localID); if (prim != null) { prim.UpdateSingleRotation(rot); @@ -674,15 +671,16 @@ namespace OpenSim.Region.Environment.Scenes /// public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) { - Primitive prim = null; + bool hasPrim = false; foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - prim = ((SceneObject)ent).HasChildPrim(localID); - if (prim != null) + hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); + if (hasPrim != false) { - prim.ResizeGoup(scale); + ((SceneObjectGroup)ent).Resize(scale, localID); + // prim.ResizeGoup(scale); break; } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 813308b..c2eac60 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.Environment.Scenes { protected Timer m_heartbeatTimer = new Timer(); protected Dictionary Avatars; - protected Dictionary Prims; + protected Dictionary Prims; protected PhysicsScene phyScene; protected float timeStep = 0.1f; private Random Rand = new Random(); @@ -109,7 +109,7 @@ namespace OpenSim.Region.Environment.Scenes get { return m_scriptManager; } } - public Dictionary Objects + public Dictionary Objects { get { return Prims; } } @@ -149,11 +149,11 @@ namespace OpenSim.Region.Environment.Scenes MainLog.Instance.Verbose("Creating new entitities instance"); Entities = new Dictionary(); Avatars = new Dictionary(); - Prims = new Dictionary(); + Prims = new Dictionary(); MainLog.Instance.Verbose("Loading objects from datastore"); - List PrimsFromDB = storageManager.DataStore.LoadObjects(); - foreach (SceneObject prim in PrimsFromDB) + List PrimsFromDB = storageManager.DataStore.LoadObjects(); + foreach (SceneObjectGroup prim in PrimsFromDB) { AddEntity(prim); } @@ -463,10 +463,10 @@ namespace OpenSim.Region.Environment.Scenes public void LoadPrimsFromStorage() { MainLog.Instance.Verbose("World.cs: LoadPrimsFromStorage() - Loading primitives"); - List NewObjectsList = storageManager.DataStore.LoadObjects(); - foreach (SceneObject obj in NewObjectsList) + List NewObjectsList = storageManager.DataStore.LoadObjects(); + foreach (SceneObjectGroup obj in NewObjectsList) { - this.Objects.Add(obj.rootUUID, obj); + this.Objects.Add(obj.UUID, obj); } } @@ -501,7 +501,7 @@ namespace OpenSim.Region.Environment.Scenes /// public void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape) { - SceneObject sceneOb = new SceneObject(this, m_eventManager, ownerID, PrimIDAllocate(), pos, shape); + SceneObjectGroup sceneOb = new SceneObjectGroup(this, this.m_regionHandle, ownerID, PrimIDAllocate(), pos, shape); AddEntity(sceneOb); } @@ -509,28 +509,28 @@ namespace OpenSim.Region.Environment.Scenes { foreach (EntityBase obj in Entities.Values) { - if (obj is SceneObject) + if (obj is SceneObjectGroup) { - if (((SceneObject) obj).LocalId == localID) + if (((SceneObjectGroup) obj).LocalId == localID) { - RemoveEntity((SceneObject) obj); + RemoveEntity((SceneObjectGroup) obj); return; } } } } - public void AddEntity(SceneObject sceneObject) + public void AddEntity(SceneObjectGroup sceneObject) { - Entities.Add(sceneObject.rootUUID, sceneObject); + Entities.Add(sceneObject.UUID, sceneObject); } - public void RemoveEntity(SceneObject sceneObject) + public void RemoveEntity(SceneObjectGroup sceneObject) { - if (Entities.ContainsKey(sceneObject.rootUUID)) + if (Entities.ContainsKey(sceneObject.UUID)) { m_LandManager.removePrimFromLandPrimCounts(sceneObject); - Entities.Remove(sceneObject.rootUUID); + Entities.Remove(sceneObject.UUID); m_LandManager.setPrimsTainted(); } } @@ -779,9 +779,9 @@ namespace OpenSim.Region.Environment.Scenes { foreach (EntityBase ent in Entities.Values) { - if (ent is SceneObject) + if (ent is SceneObjectGroup) { - ((SceneObject) ent).SendAllChildPrimsToClient(client); + // ((SceneObject) ent).SendAllChildPrimsToClient(client); } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index eb1d5b4..1df95cf 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -22,7 +22,7 @@ namespace OpenSim.Region.Environment.Scenes public delegate void OnParcelPrimCountUpdateDelegate(); public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate; - public delegate void OnParcelPrimCountAddDelegate(SceneObject obj); + public delegate void OnParcelPrimCountAddDelegate(SceneObjectGroup obj); public event OnParcelPrimCountAddDelegate OnParcelPrimCountAdd; public delegate void OnScriptConsoleDelegate(string[] args); @@ -74,7 +74,7 @@ namespace OpenSim.Region.Environment.Scenes OnParcelPrimCountUpdate(); } } - public void TriggerParcelPrimCountAdd(SceneObject obj) + public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) { if (OnParcelPrimCountAdd != null) { diff --git a/OpenSim/Region/Environment/Scenes/SceneObject(Old).cs b/OpenSim/Region/Environment/Scenes/SceneObject(Old).cs new file mode 100644 index 0000000..882b72e --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/SceneObject(Old).cs @@ -0,0 +1,315 @@ +/* +* Copyright (c) Contributors, http://www.openmetaverse.org/ +* See CONTRIBUTORS.TXT for a full list of copyright holders. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the OpenSim Project nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Xml; +using System.Xml.Serialization; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Physics.Manager; + +namespace OpenSim.Region.Environment.Scenes +{ + public class SceneObjectOLD : EntityBase + { + private Encoding enc = Encoding.ASCII; + private Dictionary ChildPrimitives = new Dictionary(); //list of all primitive id's that are part of this group + public Primitive rootPrimitive; + protected ulong m_regionHandle; + + private EventManager m_eventManager; + + public bool isSelected = false; + + public LLUUID rootUUID + { + get + { + this.m_uuid = this.rootPrimitive.m_uuid; + return this.m_uuid; + } + } + + public uint rootLocalID + { + get + { + this.m_localId = this.rootPrimitive.LocalId; + return this.LocalId; + } + } + + public int primCount + { + get + { + return this.ChildPrimitives.Count; + } + } + + public Dictionary Children + { + get + { + return this.ChildPrimitives; + } + } + + /// + /// + /// + public SceneObjectOLD(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) + { + m_regionHandle = world.RegionInfo.RegionHandle; + m_scene = world; + m_eventManager = eventManager; + + this.Pos = pos; + this.CreateRootFromShape(ownerID, localID, shape, pos); + + registerEvents(); + } + + /// + /// + /// + /// Need a null constructor for duplication + public SceneObjectOLD() + { + + } + + public void registerEvents() + { + m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); + m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); + } + + public void unregisterEvents() + { + m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup); + m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); + } + + /// + /// Processes backup + /// + /// + public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) + { + // datastore.StoreObject(this); + } + + /// + /// Sends my primitive info to the land manager for it to keep tally of all of the prims! + /// + private void ProcessParcelPrimCountUpdate() + { + + // m_eventManager.TriggerParcelPrimCountAdd(this); + } + + /// + /// + /// + /// + /// + /// + public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos) + { + + // this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_scene, agentID, localID, true, this, this, shape, pos); + this.m_children.Add(rootPrimitive); + + this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); + } + + /// + /// + /// + /// + public void CreateFromBytes(byte[] data) + { + + } + + /// + /// Makes a copy of this SceneObject (and child primitives) + /// + /// A complete copy of the object + public new SceneObjectOLD Copy() + { + SceneObjectOLD dupe = new SceneObjectOLD(); + + dupe.m_scene = this.m_scene; + dupe.m_eventManager = this.m_eventManager; + dupe.m_regionHandle = this.m_regionHandle; + Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe); + dupe.rootPrimitive = newRoot; + + dupe.m_children.Add(dupe.rootPrimitive); + dupe.rootPrimitive.Pos = this.Pos; + dupe.Rotation = this.Rotation; + dupe.LocalId = m_scene.PrimIDAllocate(); + + dupe.registerEvents(); + return dupe; + } + + /// + /// + /// + public void Serialise() + { + + } + + /// + /// + /// + public void DeleteAllChildren() + { + this.m_children.Clear(); + this.ChildPrimitives.Clear(); + this.rootPrimitive = null; + unregisterEvents(); + } + + /// + /// + /// + /// + public void AddNewChildPrims(SceneObjectOLD primObject) + { + this.rootPrimitive.AddNewChildren(primObject); + } + + public void AddChildToList(Primitive prim) + { + if (!this.ChildPrimitives.ContainsKey(prim.m_uuid)) + { + this.ChildPrimitives.Add(prim.m_uuid, prim); + } + } + /// + /// + /// + /// + /// + public Primitive HasChildPrim(LLUUID primID) + { + if (this.ChildPrimitives.ContainsKey(primID)) + { + return this.ChildPrimitives[primID]; + } + + return null; + } + + /// + /// + /// + /// + /// + public Primitive HasChildPrim(uint localID) + { + Primitive returnPrim = null; + foreach (Primitive prim in this.ChildPrimitives.Values) + { + if (prim.LocalId == localID) + { + returnPrim = prim; + break; + } + } + return returnPrim; + } + + public void SendAllChildPrimsToClient(IClientAPI client) + { + this.rootPrimitive.SendFullUpdateForAllChildren(client); + } + + /// + /// + /// + public override void BackUp() + { + + } + + /// + /// + /// + /// + /// + /// + public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) + { + this.rootPrimitive.Pos = pos; + this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient); + } + + /// + /// + /// + /// + public void GetProperites(IClientAPI client) + { + ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); + proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; + proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); + proper.ObjectData[0].ItemID = LLUUID.Zero; + proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate; + proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID; + proper.ObjectData[0].FolderID = LLUUID.Zero; + proper.ObjectData[0].FromTaskID = LLUUID.Zero; + proper.ObjectData[0].GroupID = LLUUID.Zero; + proper.ObjectData[0].InventorySerial = 0; + proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID; + proper.ObjectData[0].ObjectID = this.rootUUID; + proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID; + proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0"); + proper.ObjectData[0].TextureID = new byte[0]; + proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName + "\0"); + proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name + "\0"); + proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description + "\0"); + proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask; + proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask; + proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask; + proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask; + proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask; + + client.OutPacket(proper); + } + + } +} diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs deleted file mode 100644 index 2fae556..0000000 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ /dev/null @@ -1,315 +0,0 @@ -/* -* Copyright (c) Contributors, http://www.openmetaverse.org/ -* See CONTRIBUTORS.TXT for a full list of copyright holders. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the OpenSim Project nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Xml; -using System.Xml.Serialization; -using libsecondlife; -using libsecondlife.Packets; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Types; -using OpenSim.Physics.Manager; - -namespace OpenSim.Region.Environment.Scenes -{ - public class SceneObject : EntityBase - { - private Encoding enc = Encoding.ASCII; - private Dictionary ChildPrimitives = new Dictionary(); //list of all primitive id's that are part of this group - public Primitive rootPrimitive; - protected ulong m_regionHandle; - - private EventManager m_eventManager; - - public bool isSelected = false; - - public LLUUID rootUUID - { - get - { - this.m_uuid = this.rootPrimitive.m_uuid; - return this.m_uuid; - } - } - - public uint rootLocalID - { - get - { - this.m_localId = this.rootPrimitive.LocalId; - return this.LocalId; - } - } - - public int primCount - { - get - { - return this.ChildPrimitives.Count; - } - } - - public Dictionary Children - { - get - { - return this.ChildPrimitives; - } - } - - /// - /// - /// - public SceneObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) - { - m_regionHandle = world.RegionInfo.RegionHandle; - m_scene = world; - m_eventManager = eventManager; - - this.Pos = pos; - this.CreateRootFromShape(ownerID, localID, shape, pos); - - registerEvents(); - } - - /// - /// - /// - /// Need a null constructor for duplication - public SceneObject() - { - - } - - public void registerEvents() - { - m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); - m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); - } - - public void unregisterEvents() - { - m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup); - m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); - } - - /// - /// Processes backup - /// - /// - public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) - { - datastore.StoreObject(this); - } - - /// - /// Sends my primitive info to the land manager for it to keep tally of all of the prims! - /// - private void ProcessParcelPrimCountUpdate() - { - - m_eventManager.TriggerParcelPrimCountAdd(this); - } - - /// - /// - /// - /// - /// - /// - public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos) - { - - this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_scene, agentID, localID, true, this, this, shape, pos); - this.m_children.Add(rootPrimitive); - - this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); - } - - /// - /// - /// - /// - public void CreateFromBytes(byte[] data) - { - - } - - /// - /// Makes a copy of this SceneObject (and child primitives) - /// - /// A complete copy of the object - public new SceneObject Copy() - { - SceneObject dupe = new SceneObject(); - - dupe.m_scene = this.m_scene; - dupe.m_eventManager = this.m_eventManager; - dupe.m_regionHandle = this.m_regionHandle; - Primitive newRoot = this.rootPrimitive.Copy(dupe, dupe); - dupe.rootPrimitive = newRoot; - - dupe.m_children.Add(dupe.rootPrimitive); - dupe.rootPrimitive.Pos = this.Pos; - dupe.Rotation = this.Rotation; - dupe.LocalId = m_scene.PrimIDAllocate(); - - dupe.registerEvents(); - return dupe; - } - - /// - /// - /// - public void Serialise() - { - - } - - /// - /// - /// - public void DeleteAllChildren() - { - this.m_children.Clear(); - this.ChildPrimitives.Clear(); - this.rootPrimitive = null; - unregisterEvents(); - } - - /// - /// - /// - /// - public void AddNewChildPrims(SceneObject primObject) - { - this.rootPrimitive.AddNewChildren(primObject); - } - - public void AddChildToList(Primitive prim) - { - if (!this.ChildPrimitives.ContainsKey(prim.m_uuid)) - { - this.ChildPrimitives.Add(prim.m_uuid, prim); - } - } - /// - /// - /// - /// - /// - public Primitive HasChildPrim(LLUUID primID) - { - if (this.ChildPrimitives.ContainsKey(primID)) - { - return this.ChildPrimitives[primID]; - } - - return null; - } - - /// - /// - /// - /// - /// - public Primitive HasChildPrim(uint localID) - { - Primitive returnPrim = null; - foreach (Primitive prim in this.ChildPrimitives.Values) - { - if (prim.LocalId == localID) - { - returnPrim = prim; - break; - } - } - return returnPrim; - } - - public void SendAllChildPrimsToClient(IClientAPI client) - { - this.rootPrimitive.SendFullUpdateForAllChildren(client); - } - - /// - /// - /// - public override void BackUp() - { - - } - - /// - /// - /// - /// - /// - /// - public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) - { - this.rootPrimitive.Pos = pos; - this.rootPrimitive.SendTerseUpdateForAllChildren(remoteClient); - } - - /// - /// - /// - /// - public void GetProperites(IClientAPI client) - { - ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); - proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; - proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); - proper.ObjectData[0].ItemID = LLUUID.Zero; - proper.ObjectData[0].CreationDate = (ulong)this.rootPrimitive.CreationDate; - proper.ObjectData[0].CreatorID = this.rootPrimitive.CreatorID; - proper.ObjectData[0].FolderID = LLUUID.Zero; - proper.ObjectData[0].FromTaskID = LLUUID.Zero; - proper.ObjectData[0].GroupID = LLUUID.Zero; - proper.ObjectData[0].InventorySerial = 0; - proper.ObjectData[0].LastOwnerID = this.rootPrimitive.LastOwnerID; - proper.ObjectData[0].ObjectID = this.rootUUID; - proper.ObjectData[0].OwnerID = this.rootPrimitive.OwnerID; - proper.ObjectData[0].TouchName = enc.GetBytes(this.rootPrimitive.TouchName + "\0"); - proper.ObjectData[0].TextureID = new byte[0]; - proper.ObjectData[0].SitName = enc.GetBytes(this.rootPrimitive.SitName + "\0"); - proper.ObjectData[0].Name = enc.GetBytes(this.rootPrimitive.Name + "\0"); - proper.ObjectData[0].Description = enc.GetBytes(this.rootPrimitive.Description + "\0"); - proper.ObjectData[0].OwnerMask = this.rootPrimitive.OwnerMask; - proper.ObjectData[0].NextOwnerMask = this.rootPrimitive.NextOwnerMask; - proper.ObjectData[0].GroupMask = this.rootPrimitive.GroupMask; - proper.ObjectData[0].EveryoneMask = this.rootPrimitive.EveryoneMask; - proper.ObjectData[0].BaseMask = this.rootPrimitive.BaseMask; - - client.OutPacket(proper); - } - - } -} diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs new file mode 100644 index 0000000..b7bc229 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -0,0 +1,647 @@ +using System.Collections.Generic; +using System.Text; +using Axiom.Math; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; +using OpenSim.Physics.Manager; + +namespace OpenSim.Region.Environment.Scenes +{ + // public delegate void PrimCountTaintedDelegate(); + + public class SceneObjectGroup : EntityBase + { + private Encoding enc = Encoding.ASCII; + + protected SceneObjectPart m_rootPart; + protected Dictionary m_parts = new Dictionary(); + + protected ulong m_regionHandle; + + public event PrimCountTaintedDelegate OnPrimCountTainted; + + /// + /// + /// + public int PrimCount + { + get { return 1; } + } + + /// + /// + /// + public LLVector3 GroupCentrePoint + { + get { return new LLVector3(0, 0, 0); } + } + + public Dictionary Children + { + get { return this.m_parts; } + set { m_parts = value; } + } + + public override LLVector3 Pos + { + get { return m_rootPart.GroupPosition; } + set + { + lock (this.m_parts) + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + part.GroupPosition = value; + } + } + } + } + + public override uint LocalId + { + get { return m_rootPart.LocalID; } + set { m_rootPart.LocalID = value; } + } + + public override LLUUID UUID + { + get { return m_rootPart.UUID; } + set { m_rootPart.UUID = value; } + } + + public LLUUID OwnerID + { + get { return m_rootPart.OwnerID; } + } + + /// + /// Added because the Parcel code seems to use it + /// but not sure a object should have this + /// as what does it tell us? that some avatar has selected it + /// think really there should be a list (or whatever) in each scenepresence + /// saying what prim(s) that user has selected at any time. + /// + protected bool m_isSelected = false; + public bool IsSelected + { + get{ return m_isSelected;} + set { m_isSelected = value; } + } + + /// + /// + /// + public SceneObjectGroup() + { + + } + + /// + /// + /// + public SceneObjectGroup(byte[] data) + { + + } + + /// + /// + /// + public SceneObjectGroup(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) + { + m_regionHandle = regionHandle; + m_scene = scene; + + this.Pos = pos; + LLVector3 rootOffset = new LLVector3(0, 0, 0); + SceneObjectPart newPart = new SceneObjectPart(m_regionHandle, this, ownerID, localID, shape, pos, rootOffset); + this.m_parts.Add(newPart.UUID, newPart); + this.SetPartAsRoot(newPart); + } + + + #region Copying + /// + /// + /// + /// + public new SceneObjectGroup Copy() + { + SceneObjectGroup dupe = (SceneObjectGroup)this.MemberwiseClone(); + dupe.Pos = new LLVector3(Pos.X, Pos.Y, Pos.Z); + dupe.m_scene = m_scene; + dupe.m_regionHandle = this.m_regionHandle; + + dupe.CopyRootPart(this.m_rootPart); + + foreach (SceneObjectPart part in this.m_parts.Values) + { + if (part.UUID != this.m_rootPart.UUID) + { + dupe.CopyPart(part); + } + } + return dupe; + } + + /// + /// + /// + /// + public void CopyRootPart(SceneObjectPart part) + { + SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate()); + this.m_parts.Add(newPart.UUID, newPart); + this.SetPartAsRoot(newPart); + } + + /// + /// + /// + /// + public void CopyPart(SceneObjectPart part) + { + SceneObjectPart newPart = part.Copy(m_scene.PrimIDAllocate()); + this.m_parts.Add(newPart.UUID, newPart); + this.SetPartAsNonRoot(newPart); + } + #endregion + + /// + /// + /// + public override void Update() + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + part.SendScheduledUpdates(); + } + } + + /// + /// + /// + public void ScheduleGroupForFullUpdate() + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + part.ScheduleFullUpdate(); + } + } + + /// + /// + /// + public void ScheduleGroupForTerseUpdate() + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + part.ScheduleTerseUpdate(); + } + } + + /// + /// + /// + public void SendGroupFullUpdate() + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + part.SendFullUpdateToAllClients(); + } + } + + /// + /// + /// + public void SendGroupTerseUpdate() + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + part.SendTerseUpdateToAllClients(); + } + } + + /// + /// + /// + /// + public void LinkToGroup(SceneObjectGroup objectGroup) + { + + } + + /// + /// + /// + /// + /// + private SceneObjectPart GetChildPrim(LLUUID primID) + { + SceneObjectPart childPart = null; + if (this.m_parts.ContainsKey(primID)) + { + childPart = this.m_parts[primID]; + } + return childPart; + } + + /// + /// + /// + /// + /// + private SceneObjectPart GetChildPrim(uint localID) + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + if (part.LocalID == localID) + { + return part; + } + } + return null; + } + + /// + /// Does this group contain the child prim + /// should be able to remove these methods once we have a entity index in scene + /// + /// + /// + public bool HasChildPrim(LLUUID primID) + { + SceneObjectPart childPart = null; + if (this.m_parts.ContainsKey(primID)) + { + childPart = this.m_parts[primID]; + return true; + } + return false; + } + + /// + /// Does this group contain the child prim + /// should be able to remove these methods once we have a entity index in scene + /// + /// + /// + public bool HasChildPrim(uint localID) + { + foreach (SceneObjectPart part in this.m_parts.Values) + { + if (part.LocalID == localID) + { + return true; + } + } + return false; + } + + /// + /// + /// + public void TriggerTainted() + { + if (OnPrimCountTainted != null) + { + this.OnPrimCountTainted(); + } + } + + /// + /// + /// + /// + /// + /// + public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) + { + this.Pos = pos; + this.m_rootPart.SendTerseUpdateToAllClients(); + } + + /// + /// + /// + /// + public void GetProperites(IClientAPI client) + { + ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); + proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; + proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); + proper.ObjectData[0].ItemID = LLUUID.Zero; + proper.ObjectData[0].CreationDate = (ulong)this.m_rootPart.CreationDate; + proper.ObjectData[0].CreatorID = this.m_rootPart.CreatorID; + proper.ObjectData[0].FolderID = LLUUID.Zero; + proper.ObjectData[0].FromTaskID = LLUUID.Zero; + proper.ObjectData[0].GroupID = LLUUID.Zero; + proper.ObjectData[0].InventorySerial = 0; + proper.ObjectData[0].LastOwnerID = this.m_rootPart.LastOwnerID; + proper.ObjectData[0].ObjectID = this.UUID; + proper.ObjectData[0].OwnerID = this.m_rootPart.OwnerID; + proper.ObjectData[0].TouchName = enc.GetBytes(this.m_rootPart.TouchName + "\0"); + proper.ObjectData[0].TextureID = new byte[0]; + proper.ObjectData[0].SitName = enc.GetBytes(this.m_rootPart.SitName + "\0"); + proper.ObjectData[0].Name = enc.GetBytes(this.m_rootPart.PartName + "\0"); + proper.ObjectData[0].Description = enc.GetBytes(this.m_rootPart.Description + "\0"); + proper.ObjectData[0].OwnerMask = this.m_rootPart.OwnerMask; + proper.ObjectData[0].NextOwnerMask = this.m_rootPart.NextOwnerMask; + proper.ObjectData[0].GroupMask = this.m_rootPart.GroupMask; + proper.ObjectData[0].EveryoneMask = this.m_rootPart.EveryoneMask; + proper.ObjectData[0].BaseMask = this.m_rootPart.BaseMask; + + client.OutPacket(proper); + } + + /// + /// + /// + /// + public void SetPartName(string name, uint localID) + { + SceneObjectPart part = this.GetChildPrim(localID); + if (part != null) + { + part.PartName = name; + } + } + + public void SetPartDescription(string des, uint localID) + { + SceneObjectPart part = this.GetChildPrim(localID); + if (part != null) + { + part.Description = des; + } + } + + /// + /// + /// + /// + /// + public void GetPartInventory(IClientAPI remoteClient, uint localID) + { + SceneObjectPart part = this.GetChildPrim(localID); + if (part != null) + { + part.GetInventory(remoteClient, localID); + } + } + + /// + /// + /// + /// + /// + /// + /// + public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data) + { + SceneObjectPart part = this.GetChildPrim(localID); + if (part != null) + { + part.UpdateExtraParam(type, inUse, data); + } + } + + /// + /// + /// + /// + /// + public void UpdateTextureEntry(uint localID, byte[] textureEntry) + { + SceneObjectPart part = this.GetChildPrim(localID); + if (part != null) + { + part.UpdateTextureEntry(textureEntry); + } + } + + #region Shape + /// + /// + /// + /// + public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock, uint localID) + { + SceneObjectPart part = this.GetChildPrim(localID); + if (part != null) + { + part.UpdateShape(shapeBlock); + } + } + #endregion + + /// + /// + /// + /// + /// + public void Resize(LLVector3 scale, uint localID) + { + SceneObjectPart part = this.GetChildPrim(localID); + if (part != null) + { + part.Resize(scale); + } + } + + #region Position + /// + /// + /// + /// + public void UpdateGroupPosition(LLVector3 pos) + { + this.Pos = pos; + } + + /// + /// + /// + /// + /// + public void UpdateSinglePosition(LLVector3 pos, uint localID) + { + SceneObjectPart part = this.GetChildPrim(localID); + if (part != null) + { + if (part.UUID == this.m_rootPart.UUID) + { + this.UpdateRootPosition(pos); + } + else + { + part.UpdateOffSet(pos); + } + } + } + + /// + /// + /// + /// + private void UpdateRootPosition(LLVector3 pos) + { + LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); + LLVector3 oldPos = new LLVector3(this.Pos.X + this.m_rootPart.OffsetPosition.X, this.Pos.Y + this.m_rootPart.OffsetPosition.Y, this.Pos.Z + this.m_rootPart.OffsetPosition.Z); + LLVector3 diff = oldPos - newPos; + Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); + Axiom.Math.Quaternion partRotation = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z); + axDiff = partRotation.Inverse() * axDiff; + diff.X = axDiff.x; + diff.Y = axDiff.y; + diff.Z = axDiff.z; + + foreach (SceneObjectPart obPart in this.m_parts.Values) + { + if (obPart.UUID != this.m_rootPart.UUID) + { + obPart.OffsetPosition = obPart.OffsetPosition + diff; + } + } + this.Pos = newPos; + pos.X = newPos.X; + pos.Y = newPos.Y; + pos.Z = newPos.Z; + } + #endregion + + #region Roation + /// + /// + /// + /// + public void UpdateGroupRotation(LLQuaternion rot) + { + this.m_rootPart.UpdateRotation(rot); + } + + /// + /// + /// + /// + /// + public void UpdateGroupRotation(LLVector3 pos, LLQuaternion rot) + { + this.m_rootPart.UpdateRotation(rot); + this.Pos = pos; + } + + /// + /// + /// + /// + /// + public void UpdateSingleRotation(LLQuaternion rot, uint localID) + { + SceneObjectPart part = this.GetChildPrim(localID); + if (part != null) + { + if (part.UUID == this.m_rootPart.UUID) + { + this.UpdateRootRotation(rot); + } + else + { + part.UpdateRotation(rot); + } + } + } + + /// + /// + /// + /// + private void UpdateRootRotation(LLQuaternion rot) + { + this.m_rootPart.UpdateRotation(rot); + Axiom.Math.Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z); + Axiom.Math.Quaternion oldParentRot = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z); + + foreach (SceneObjectPart prim in this.m_parts.Values) + { + if (prim.UUID != this.m_rootPart.UUID) + { + Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z); + axPos = oldParentRot * axPos; + axPos = axRot.Inverse() * axPos; + prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z); + Axiom.Math.Quaternion primsRot = new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, prim.RotationOffset.Z); + Axiom.Math.Quaternion newRot = oldParentRot * primsRot; + newRot = axRot.Inverse() * newRot; + prim.RotationOffset = new LLQuaternion(newRot.w, newRot.x, newRot.y, newRot.z); + } + } + } + + #endregion + /// + /// + /// + /// + private void SetPartAsRoot(SceneObjectPart part) + { + this.m_rootPart = part; + //this.m_uuid= part.UUID; + // this.m_localId = part.LocalID; + } + + /// + /// + /// + /// + private void SetPartAsNonRoot(SceneObjectPart part) + { + part.ParentID = this.m_rootPart.LocalID; + } + + /// + /// + /// + /// + public List RequestSceneAvatars() + { + return m_scene.RequestAvatarList(); + } + + /// + /// + /// + /// + /// + internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part) + { + if( m_rootPart == part ) + { + part.SendFullUpdateToClient( remoteClient, Pos ); + } + else + { + part.SendFullUpdateToClient( remoteClient ); + } + } + + /// + /// + /// + /// + /// + internal void SendPartTerseUpdate(IClientAPI remoteClient, SceneObjectPart part) + { + if (m_rootPart == part) + { + part.SendTerseUpdateToClient(remoteClient, Pos); + } + else + { + part.SendTerseUpdateToClient(remoteClient); + } + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs new file mode 100644 index 0000000..d0730d7 --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs @@ -0,0 +1,527 @@ +using System.Collections.Generic; +using System.Text; +using System; +using Axiom.Math; +using libsecondlife; +using libsecondlife.Packets; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Types; + +namespace OpenSim.Region.Environment.Scenes +{ + + public class SceneObjectPart + { + private const uint FULL_MASK_PERMISSIONS = 2147483647; + + public LLUUID CreatorID; + public LLUUID OwnerID; + public LLUUID GroupID; + public LLUUID LastOwnerID; + public Int32 CreationDate; + public uint ParentID = 0; + + public uint OwnerMask = FULL_MASK_PERMISSIONS; + public uint NextOwnerMask = FULL_MASK_PERMISSIONS; + public uint GroupMask = FULL_MASK_PERMISSIONS; + public uint EveryoneMask = FULL_MASK_PERMISSIONS; + public uint BaseMask = FULL_MASK_PERMISSIONS; + + protected byte[] m_particleSystem = new byte[0]; + + protected SceneObjectGroup m_parentGroup; + + /// + /// Only used internally to schedule client updates + /// + private byte m_updateFlag; + + #region Properties + + protected LLUUID m_uuid; + public LLUUID UUID + { + get { return m_uuid; } + set { m_uuid = value ; } + } + + protected uint m_localID; + public uint LocalID + { + get { return m_localID; } + set { m_localID = value; } + } + + protected string m_partName; + public virtual string PartName + { + get { return m_partName; } + set { m_partName = value; } + } + + protected LLObject.ObjectFlags m_flags = (LLObject.ObjectFlags)32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; + public uint ObjectFlags + { + get { return (uint)m_flags; } + set { m_flags = (LLObject.ObjectFlags)value; } + } + + protected LLObject.MaterialType m_material; + public byte Material + { + get { return (byte)m_material; } + set { m_material = (LLObject.MaterialType)value; } + } + + protected ulong m_regionHandle; + public ulong RegionHandle + { + get { return m_regionHandle; } + set { m_regionHandle = value; } + } + + //unkown if this will be kept, added as a way of removing the group position from the group class + protected LLVector3 m_groupPosition; + public LLVector3 GroupPosition + { + get { return m_groupPosition; } + set { m_groupPosition = value; } + } + + protected LLVector3 m_offset; + public LLVector3 OffsetPosition + { + get { return m_offset; } + set { m_offset = value; } + } + + protected LLQuaternion m_rotationOffset; + public LLQuaternion RotationOffset + { + get { return m_rotationOffset; } + set { m_rotationOffset = value; } + } + + protected LLVector3 m_velocity; + /// + public LLVector3 Velocity + { + get { return m_velocity; } + set { m_velocity = value; } + } + + protected LLVector3 m_angularVelocity; + /// + public LLVector3 AngularVelocity + { + get { return m_angularVelocity; } + set { m_angularVelocity = value; } + } + + protected LLVector3 m_acceleration; + /// + public LLVector3 Acceleration + { + get { return m_acceleration; } + set { m_acceleration = value; } + } + + private string m_description = ""; + public string Description + { + get { return this.m_description; } + set { this.m_description = value; } + } + + private string m_text = ""; + public string Text + { + get { return m_text; } + set + { + m_text = value; + ScheduleFullUpdate(); + } + } + + private string m_sitName = ""; + public string SitName + { + get { return m_sitName; } + set { m_sitName = value; } + } + + private string m_touchName = ""; + public string TouchName + { + get { return m_touchName; } + set { m_touchName = value; } + } + + protected PrimitiveBaseShape m_shape; + public PrimitiveBaseShape Shape + { + get { return this.m_shape; } + set { m_shape = value; } + } + + public LLVector3 Scale + { + set { this.m_shape.Scale = value; } + get { return this.m_shape.Scale; } + } + #endregion + + #region Constructors + /// + /// + /// + public SceneObjectPart() + { + + } + + /// + /// Create a completely new SceneObjectPart (prim) + /// + /// + /// + /// + /// + /// + /// + public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, LLUUID ownerID, uint localID, PrimitiveBaseShape shape, LLVector3 groupPosition, LLVector3 offsetPosition) + { + this.m_partName = "Primitive"; + this.m_regionHandle = regionHandle; + this.m_parentGroup = parent; + + this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; + this.OwnerID = ownerID; + this.CreatorID = this.OwnerID; + this.LastOwnerID = LLUUID.Zero; + this.UUID = LLUUID.Random(); + this.LocalID = (uint)(localID); + this.Shape = shape; + + this.GroupPosition = groupPosition; + this.OffsetPosition = offsetPosition; + this.RotationOffset = LLQuaternion.Identity; + this.Velocity = new LLVector3(0, 0, 0); + this.AngularVelocity = new LLVector3(0, 0, 0); + this.Acceleration = new LLVector3(0, 0, 0); + + //temporary code just so the m_flags field doesn't give a compiler warning + if (m_flags == LLObject.ObjectFlags.AllowInventoryDrop) + { + + } + ScheduleFullUpdate(); + } + + /// + /// Re/create a SceneObjectPart (prim) + /// + /// + /// + /// + /// + /// + /// + public SceneObjectPart(ulong regionHandle, SceneObjectGroup parent, int creationDate, LLUUID ownerID, LLUUID creatorID, LLUUID lastOwnerID, uint localID, PrimitiveBaseShape shape, LLVector3 position, LLQuaternion rotation, uint flags) + { + this.m_regionHandle = regionHandle; + this.m_parentGroup = parent; + + this.CreationDate = creationDate; + this.OwnerID = ownerID; + this.CreatorID = creatorID; + this.LastOwnerID = lastOwnerID; + this.UUID = LLUUID.Random(); + this.LocalID = (uint)(localID); + this.Shape = shape; + + this.OffsetPosition = position; + this.RotationOffset = rotation; + this.ObjectFlags = flags; + } + #endregion + + #region Copying + /// + /// + /// + /// + public SceneObjectPart Copy(uint localID) + { + SceneObjectPart dupe = (SceneObjectPart)this.MemberwiseClone(); + dupe.m_shape = m_shape.Copy(); + dupe.m_regionHandle = m_regionHandle; + dupe.UUID = LLUUID.Random(); + dupe.LocalID = localID; + dupe.GroupPosition = new LLVector3(GroupPosition.X, GroupPosition.Y, GroupPosition.Z); + dupe.OffsetPosition = new LLVector3(OffsetPosition.X, OffsetPosition.Y, OffsetPosition.Z); + dupe.RotationOffset = new LLQuaternion(RotationOffset.X, RotationOffset.Y, RotationOffset.Z, RotationOffset.W); + dupe.Velocity = new LLVector3(0, 0, 0); + dupe.Acceleration = new LLVector3(0, 0, 0); + dupe.AngularVelocity = new LLVector3(0, 0, 0); + dupe.ObjectFlags = this.ObjectFlags; + //TODO copy extraparams data and anything else not currently copied + return dupe; + } + #endregion + + #region Update Scheduling + /// + /// + /// + private void ClearUpdateSchedule() + { + m_updateFlag = 0; + } + + /// + /// + /// + public void ScheduleFullUpdate() + { + m_updateFlag = 2; + } + + /// + /// + /// + public void ScheduleTerseUpdate() + { + if (m_updateFlag < 1) + { + m_updateFlag = 1; + } + } + + /// + /// + /// + public void SendScheduledUpdates() + { + if (m_updateFlag == 1) //some change has been made so update the clients + { + SendTerseUpdateToAllClients(); + ClearUpdateSchedule(); + } + else + { + if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes + { + SendFullUpdateToAllClients(); + ClearUpdateSchedule(); + } + } + } + #endregion + + #region Shape + /// + /// + /// + /// + public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) + { + this.m_shape.PathBegin = shapeBlock.PathBegin; + this.m_shape.PathEnd = shapeBlock.PathEnd; + this.m_shape.PathScaleX = shapeBlock.PathScaleX; + this.m_shape.PathScaleY = shapeBlock.PathScaleY; + this.m_shape.PathShearX = shapeBlock.PathShearX; + this.m_shape.PathShearY = shapeBlock.PathShearY; + this.m_shape.PathSkew = shapeBlock.PathSkew; + this.m_shape.ProfileBegin = shapeBlock.ProfileBegin; + this.m_shape.ProfileEnd = shapeBlock.ProfileEnd; + this.m_shape.PathCurve = shapeBlock.PathCurve; + this.m_shape.ProfileCurve = shapeBlock.ProfileCurve; + this.m_shape.ProfileHollow = shapeBlock.ProfileHollow; + this.m_shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; + this.m_shape.PathRevolutions = shapeBlock.PathRevolutions; + this.m_shape.PathTaperX = shapeBlock.PathTaperX; + this.m_shape.PathTaperY = shapeBlock.PathTaperY; + this.m_shape.PathTwist = shapeBlock.PathTwist; + this.m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; + ScheduleFullUpdate(); + } + #endregion + + #region Inventory + public void GetInventory(IClientAPI client, uint localID) + { + if (localID == this.m_localID) + { + client.SendTaskInventory(this.m_uuid, 0, new byte[0]); + } + } + #endregion + + #region ExtraParams + public void UpdateExtraParam(ushort type, bool inUse, byte[] data) + { + this.m_shape.ExtraParams = new byte[data.Length + 7]; + int i = 0; + uint length = (uint)data.Length; + this.m_shape.ExtraParams[i++] = 1; + this.m_shape.ExtraParams[i++] = (byte)(type % 256); + this.m_shape.ExtraParams[i++] = (byte)((type >> 8) % 256); + + this.m_shape.ExtraParams[i++] = (byte)(length % 256); + this.m_shape.ExtraParams[i++] = (byte)((length >> 8) % 256); + this.m_shape.ExtraParams[i++] = (byte)((length >> 16) % 256); + this.m_shape.ExtraParams[i++] = (byte)((length >> 24) % 256); + Array.Copy(data, 0, this.m_shape.ExtraParams, i, data.Length); + + this.ScheduleFullUpdate(); + } + #endregion + + #region Texture + /// + /// + /// + /// + public void UpdateTextureEntry(byte[] textureEntry) + { + this.m_shape.TextureEntry = textureEntry; + ScheduleFullUpdate(); + } + #endregion + + #region ParticleSystem + public void AddNewParticleSystem(libsecondlife.Primitive.ParticleSystem pSystem) + { + this.m_particleSystem = pSystem.GetBytes(); + } + #endregion + + #region Position + /// + /// + /// + /// + public void UpdateOffSet(LLVector3 pos) + { + LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); + this.OffsetPosition = newPos; + ScheduleTerseUpdate(); + } + #endregion + + #region rotation + public void UpdateRotation(LLQuaternion rot) + { + this.RotationOffset = new LLQuaternion(rot.X, rot.Y, rot.Z, rot.W); + ScheduleTerseUpdate(); + } + #endregion + + #region Resizing/Scale + /// + /// + /// + /// + public void Resize(LLVector3 scale) + { + this.m_shape.Scale = scale; + ScheduleFullUpdate(); + } + #endregion + + #region Client Update Methods + /// + /// + /// + public void SendFullUpdateToAllClients() + { + List avatars = this.m_parentGroup.RequestSceneAvatars(); + for (int i = 0; i < avatars.Count; i++) + { + m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this); + } + } + + /// + /// + /// + /// + public void SendFullUpdate(IClientAPI remoteClient) + { + m_parentGroup.SendPartFullUpdate( remoteClient, this ); + } + + /// + /// + /// + /// + public void SendFullUpdateToClient(IClientAPI remoteClient) + { + LLVector3 lPos; + lPos = OffsetPosition; + SendFullUpdateToClient(remoteClient, lPos); + } + + /// + /// + /// + /// + /// + public void SendFullUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) + { + LLQuaternion lRot; + lRot = RotationOffset; + + remoteClient.SendPrimitiveToClient(m_regionHandle, 64096, LocalID, m_shape, lPos, this.ObjectFlags, m_uuid, OwnerID, + m_text, ParentID, this.m_particleSystem, lRot); + } + + /// + /// + /// + public void SendTerseUpdateToAllClients() + { + List avatars = this.m_parentGroup.RequestSceneAvatars(); + for (int i = 0; i < avatars.Count; i++) + { + m_parentGroup.SendPartTerseUpdate(avatars[i].ControllingClient, this); + } + } + + /// + /// + /// + /// + public void SendTerseUpdate(IClientAPI remoteClient) + { + m_parentGroup.SendPartTerseUpdate(remoteClient, this); + } + + /// + /// + /// + /// + public void SendTerseUpdateToClient(IClientAPI remoteClient) + { + LLVector3 lPos; + lPos = this.OffsetPosition; + LLQuaternion mRot = this.RotationOffset; + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); + } + + /// + /// + /// + /// + /// + public void SendTerseUpdateToClient(IClientAPI remoteClient, LLVector3 lPos) + { + LLQuaternion mRot = this.RotationOffset; + remoteClient.SendPrimTerseUpdate(m_regionHandle, 64096, LocalID, lPos, mRot); + } + #endregion + } +} + diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs b/OpenSim/Region/Environment/Scenes/Scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs index d5566b7..97b1ada 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs @@ -26,7 +26,7 @@ namespace OpenSim.Region.Scripting.Examples void ProcessConsoleMsg(string[] args) { - if (args[0].ToLower() == "lslexport") + /*if (args[0].ToLower() == "lslexport") { string sequence = ""; @@ -48,12 +48,12 @@ namespace OpenSim.Region.Scripting.Examples } System.Console.WriteLine(sequence); - } + }*/ } string processPrimitiveToString(OpenSim.Region.Environment.Scenes.Primitive prim) { - string desc = prim.Description; + /*string desc = prim.Description; string name = prim.Name; LLVector3 pos = prim.Pos; LLQuaternion rot = new LLQuaternion(prim.Rotation.x, prim.Rotation.y, prim.Rotation.z, prim.Rotation.w); @@ -65,6 +65,8 @@ namespace OpenSim.Region.Scripting.Examples setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n"; return setPrimParams; + */ + return ""; } } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs b/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs index af8a29f..a5898b7 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs +++ b/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.Scripting /// /// The object our script is supposed to be in /// - public SceneObject Task + public SceneObjectGroup Task { get { return Scene.Objects[ObjectID]; } } @@ -229,8 +229,8 @@ namespace OpenSim.Region.Scripting public void osCreateLink(Key target, int parent) { - if(Scene.Entities[target] is SceneObject) - Task.AddNewChildPrims((SceneObject)Scene.Entities[target]); + if(Scene.Entities[target] is SceneObjectGroup) + Task.LinkToGroup((SceneObjectGroup)Scene.Entities[target]); return; } diff --git a/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs b/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs index 404653d..108fa98 100644 --- a/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs +++ b/OpenSim/Region/Examples/SimpleApp/CpuCounterObject.cs @@ -9,12 +9,12 @@ using System.Diagnostics; namespace SimpleApp { - public class CpuCounterObject : SceneObject + public class CpuCounterObject : SceneObjectGroup { private PerformanceCounter m_counter; - public CpuCounterObject(Scene world, EventManager eventManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) - : base(world, eventManager, ownerID, localID, pos, shape ) + public CpuCounterObject(Scene world, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) + : base(world, regionHandle, ownerID, localID, pos, shape ) { String objectName = "Processor"; String counterName = "% Processor Time"; @@ -27,7 +27,7 @@ namespace SimpleApp { float cpu = m_counter.NextValue() / 40f; LLVector3 size = new LLVector3(cpu, cpu, cpu); - rootPrimitive.ResizeGoup( size ); + //rootPrimitive.ResizeGoup( size ); base.UpdateMovement(); } diff --git a/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs index 83a76e3..920fea7 100644 --- a/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs +++ b/OpenSim/Region/Examples/SimpleApp/FileSystemObject.cs @@ -11,16 +11,16 @@ using Primitive=OpenSim.Region.Environment.Scenes.Primitive; namespace SimpleApp { - public class FileSystemObject : SceneObject + public class FileSystemObject : SceneObjectGroup { public FileSystemObject(Scene world, FileInfo fileInfo, LLVector3 pos) - : base( world, world.EventManager, LLUUID.Zero, world.NextLocalId, pos, BoxShape.Default ) + : base( world, world.RegionInfo.RegionHandle, LLUUID.Zero, world.NextLocalId, pos, BoxShape.Default ) { float size = (float)Math.Pow((double)fileInfo.Length, (double) 1 / 3) / 5; - rootPrimitive.ResizeGoup(new LLVector3(size, size, size)); - rootPrimitive.Text = fileInfo.Name; + // rootPrimitive.ResizeGoup(new LLVector3(size, size, size)); + // rootPrimitive.Text = fileInfo.Name; } public override void Update() diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs index db71578..84c86fd 100644 --- a/OpenSim/Region/Examples/SimpleApp/Program.cs +++ b/OpenSim/Region/Examples/SimpleApp/Program.cs @@ -69,7 +69,7 @@ namespace SimpleApp shape.Scale = new LLVector3(0.5f, 0.5f, 0.5f); LLVector3 pos = new LLVector3(138, 129, 27); - SceneObject sceneObject = new CpuCounterObject(scene, scene.EventManager, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape); + SceneObjectGroup sceneObject = new CpuCounterObject(scene, regionInfo.RegionHandle, LLUUID.Zero, scene.PrimIDAllocate(), pos, shape); scene.AddEntity(sceneObject); MyNpcCharacter m_character = new MyNpcCharacter( scene.EventManager ); diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.DB4o/DB4oDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.DB4o/DB4oDataStore.cs index 06c9069..9c5e4bc 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.DB4o/DB4oDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.DB4o/DB4oDataStore.cs @@ -24,9 +24,9 @@ namespace OpenSim.DataStore.DB4oStorage globalIDSearch = find; } - public bool Match(SceneObject obj) + public bool Match(SceneObjectGroup obj) { - return obj.rootUUID == globalIDSearch; + return obj.UUID == globalIDSearch; } } @@ -43,7 +43,7 @@ namespace OpenSim.DataStore.DB4oStorage return; } - public void StoreObject(SceneObject obj) + public void StoreObject(SceneObjectGroup obj) { db.Set(obj); } @@ -53,21 +53,21 @@ namespace OpenSim.DataStore.DB4oStorage IObjectSet result = db.Query(new SceneObjectQuery(obj)); if (result.Count > 0) { - SceneObject item = (SceneObject)result.Next(); + SceneObjectGroup item = (SceneObjectGroup)result.Next(); db.Delete(item); } } - public List LoadObjects() + public List LoadObjects() { - IObjectSet result = db.Get(typeof(SceneObject)); - List retvals = new List(); + IObjectSet result = db.Get(typeof(SceneObjectGroup)); + List retvals = new List(); MainLog.Instance.Verbose("DATASTORE", "DB4O - LoadObjects found " + result.Count.ToString() + " objects"); foreach (Object obj in result) { - retvals.Add((SceneObject)obj); + retvals.Add((SceneObjectGroup)obj); } return retvals; diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs index fc003e8..643508e 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.NullStorage/NullDataStore.cs @@ -18,7 +18,7 @@ namespace OpenSim.DataStore.NullStorage return; } - public void StoreObject(SceneObject obj) + public void StoreObject(SceneObjectGroup obj) { } @@ -28,9 +28,9 @@ namespace OpenSim.DataStore.NullStorage } - public List LoadObjects() + public List LoadObjects() { - return new List(); + return new List(); } public void StoreTerrain(double[,] ter) -- cgit v1.1