Patch from Johan: LibSL updated to the latest revision (1568) and all packets are now

recycled to improve performance and memory usage.
This commit is contained in:
Adam Johnson
2007-12-28 08:51:39 +00:00
parent 8cd72beb86
commit 79496381fc
11 changed files with 308 additions and 242 deletions

View File

@@ -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<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>();
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);
}
}
}
}

View File

@@ -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
// 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);
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
}
}
}

View File

@@ -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; }
}
/// <summary>
///
/// </summary>
@@ -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
/// <param name="client"></param>
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();
}
}
}
}

View File

@@ -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;
}
}
}
}