From 79496381fc68cbd30ff5a95d1f05fcb18c6b1a93 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 28 Dec 2007 08:51:39 +0000 Subject: Patch from Johan: LibSL updated to the latest revision (1568) and all packets are now recycled to improve performance and memory usage. --- .../Environment/Scenes/Scene.PacketHandlers.cs | 8 ++- OpenSim/Region/Environment/Scenes/Scene.cs | 71 +++++++++++----------- .../Region/Environment/Scenes/SceneObjectGroup.cs | 13 ++-- .../Region/Environment/Scenes/SimStatsReporter.cs | 6 +- 4 files changed, 53 insertions(+), 45 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 999b70f..647fbf4 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -29,6 +29,8 @@ using System.Collections.Generic; using libsecondlife; using libsecondlife.Packets; using OpenSim.Framework; +using OpenSim.Framework.UserManagement; +using OpenSim.Framework.Console; namespace OpenSim.Region.Environment.Scenes { @@ -164,7 +166,9 @@ namespace OpenSim.Region.Environment.Scenes List AvatarResponses = new List(); AvatarResponses = CommsManager.GenerateAgentPickerRequestResponse(RequestID, query); - AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket(); + AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); + // TODO: don't create new blocks if recycling an old packet + AvatarPickerReplyPacket.DataBlock[] searchData = new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); @@ -192,4 +196,4 @@ namespace OpenSim.Region.Environment.Scenes client.SendAvatarPickerReply(replyPacket); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index d8c5255..4657264 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -474,7 +474,7 @@ namespace OpenSim.Region.Environment.Scenes if (!avatar.IsChildAgent) avatar.ControllingClient.Kick("The simulator is going down."); - avatar.ControllingClient.OutPacket(new DisableSimulatorPacket(), + avatar.ControllingClient.OutPacket(PacketPool.Instance.GetPacket(libsecondlife.Packets.PacketType.DisableSimulator), ThrottleOutPacketType.Task); }); @@ -1016,43 +1016,42 @@ namespace OpenSim.Region.Environment.Scenes // It's wrong many times though. LLVector3 pos = GetNewRezLocation(RayStart, RayEnd, RayTargetID, rot, bypassRaycast, RayEndIsIntersection); + + + if (PermissionsMngr.CanRezObject(ownerID, pos)) { - // rez ON the ground, not IN the ground - pos.Z += 0.25F; - - AddNewPrim(ownerID, pos, rot, shape); - } - } - public virtual void AddNewPrim(LLUUID ownerID, LLVector3 pos, LLQuaternion rot, PrimitiveBaseShape shape) - { - SceneObjectGroup sceneOb = - new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape); - - AddEntity(sceneOb); - SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); - // if grass or tree, make phantom - //rootPart.ApplySanePermissions(); - if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255) || (rootPart.Shape.PCode == 111)) - { - rootPart.AddFlag(LLObject.ObjectFlags.Phantom); - //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; - } - // if not phantom, add to physics - bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); - if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) - { - rootPart.PhysActor = - PhysicsScene.AddPrimShape( - rootPart.Name, - rootPart.Shape, - new PhysicsVector(pos.X, pos.Y, pos.Z), - new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), - new Quaternion(), UsePhysics); - // subscribe to physics events. - rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); + // rez ON the ground, not IN the ground + pos.Z += 0.25F; + + + SceneObjectGroup sceneOb = + new SceneObjectGroup(this, m_regionHandle, ownerID, PrimIDAllocate(), pos, rot, shape); + AddEntity(sceneOb); + SceneObjectPart rootPart = sceneOb.GetChildPart(sceneOb.UUID); + // if grass or tree, make phantom + //rootPart.ApplySanePermissions(); + if ((rootPart.Shape.PCode == 95) || (rootPart.Shape.PCode == 255) || (rootPart.Shape.PCode == 111)) + { + rootPart.AddFlag(LLObject.ObjectFlags.Phantom); + //rootPart.ObjectFlags += (uint)LLObject.ObjectFlags.Phantom; + } + // if not phantom, add to physics + bool UsePhysics = (((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) > 0) && m_physicalPrim); + if ((rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Phantom) == 0) + { + rootPart.PhysActor = + PhysicsScene.AddPrimShape( + rootPart.Name, + rootPart.Shape, + new PhysicsVector(pos.X, pos.Y, pos.Z), + new PhysicsVector(shape.Scale.X, shape.Scale.Y, shape.Scale.Z), + new Quaternion(), UsePhysics); + // subscribe to physics events. + rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); + } } } @@ -1499,7 +1498,7 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.removeUserCount(true); } // Tell a single agent to disconnect from the region. - DisableSimulatorPacket disable = new DisableSimulatorPacket(); + libsecondlife.Packets.DisableSimulatorPacket disable = (libsecondlife.Packets.DisableSimulatorPacket) PacketPool.Instance.GetPacket(libsecondlife.Packets.PacketType.DisableSimulator); presence.ControllingClient.OutPacket(disable, ThrottleOutPacketType.Task); } } @@ -2246,4 +2245,4 @@ namespace OpenSim.Region.Environment.Scenes #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 5b74c9b..94b6797 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -74,13 +74,11 @@ namespace OpenSim.Region.Environment.Scenes { get { return m_rootPart.RotationOffset; } } - public LLUUID GroupID { get { return m_rootPart.GroupID; } set { m_rootPart.GroupID = value; } } - /// /// /// @@ -638,7 +636,9 @@ namespace OpenSim.Region.Environment.Scenes public void ServiceObjectPropertiesFamilyRequest(IClientAPI remoteClient, LLUUID AgentID, uint RequestFlags) { //RootPart.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, RequestFlags); - ObjectPropertiesFamilyPacket objPropFamilyPack = new ObjectPropertiesFamilyPacket(); + ObjectPropertiesFamilyPacket objPropFamilyPack = (ObjectPropertiesFamilyPacket) PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily); + // TODO: don't create new blocks if recycling an old packet + ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = new ObjectPropertiesFamilyPacket.ObjectDataBlock(); objPropDB.RequestFlags = RequestFlags; objPropDB.ObjectID = RootPart.UUID; @@ -1045,7 +1045,9 @@ namespace OpenSim.Region.Environment.Scenes /// public void GetProperites(IClientAPI client) { - ObjectPropertiesPacket proper = new ObjectPropertiesPacket(); + ObjectPropertiesPacket proper = (ObjectPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ObjectProperties); + // TODO: don't create new blocks if recycling an old packet + proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1]; proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock(); proper.ObjectData[0].ItemID = LLUUID.Zero; @@ -1297,6 +1299,7 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.PhysActor.IsPhysical); bool UsePhysics = ((m_rootPart.ObjectFlags & (uint) LLObject.ObjectFlags.Physics) != 0); m_rootPart.DoPhysicsPropertyUpdate(UsePhysics, true); + } } @@ -1737,4 +1740,4 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.ApplyPhysics(); } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs index b183c04..5033965 100644 --- a/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Environment/Scenes/SimStatsReporter.cs @@ -83,7 +83,9 @@ namespace OpenSim.Region.Environment.Scenes private void statsHeartBeat(object sender, EventArgs e) { m_report.Enabled = false; - SimStatsPacket statpack = new SimStatsPacket(); + SimStatsPacket statpack = (SimStatsPacket) PacketPool.Instance.GetPacket(PacketType.SimStats); + // TODO: don't create new blocks if recycling an old packet + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[11]; statpack.Region = new SimStatsPacket.RegionBlock(); statpack.Region.RegionX = ReportingRegion.RegionLocX; @@ -241,4 +243,4 @@ namespace OpenSim.Region.Environment.Scenes m_unAckedBytes += numBytes; } } -} \ No newline at end of file +} -- cgit v1.1