Merge branch 'master' into mantis5110

Conflicts:
	OpenSim/Region/Framework/Scenes/ScenePresence.cs
viewer-2-initial-appearance
Jonathan Freedman 2010-10-29 23:12:51 -04:00
commit d219317074
42 changed files with 1306 additions and 965 deletions

View File

@ -1472,12 +1472,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
m_log.DebugFormat("[RADMIN] Initializing inventory for {0} from {1}", destination, source);
Scene scene = m_application.SceneManager.CurrentOrFirstScene;
AvatarAppearance avatarAppearance = null;
AvatarData avatar = scene.AvatarService.GetAvatar(source);
if (avatar != null)
avatarAppearance = avatar.ToAvatarAppearance(source);
// If the model has no associated appearance we're done.
AvatarAppearance avatarAppearance = scene.AvatarService.GetAppearance(source);
if (avatarAppearance == null)
return;
@ -1491,8 +1488,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
{
CopyWearablesAndAttachments(destination, source, avatarAppearance);
AvatarData avatarData = new AvatarData(avatarAppearance);
scene.AvatarService.SetAvatar(destination, avatarData);
scene.AvatarService.SetAppearance(destination, avatarAppearance);
}
catch (Exception e)
{
@ -1523,8 +1519,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
}
AvatarData avatarData = new AvatarData(avatarAppearance);
scene.AvatarService.SetAvatar(destination, avatarData);
scene.AvatarService.SetAppearance(destination, avatarAppearance);
}
catch (Exception e)
{
@ -1619,12 +1614,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
}
// Attachments
Dictionary<int, UUID[]> attachments = avatarAppearance.GetAttachmentDictionary();
List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();
foreach (KeyValuePair<int, UUID[]> attachment in attachments)
foreach (AvatarAttachment attachment in attachments)
{
int attachpoint = attachment.Key;
UUID itemID = attachment.Value[0];
int attachpoint = attachment.AttachPoint;
UUID itemID = attachment.ItemID;
if (itemID != UUID.Zero)
{
@ -1908,10 +1903,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (include)
{
// Setup for appearance processing
AvatarData avatarData = scene.AvatarService.GetAvatar(ID);
if (avatarData != null)
avatarAppearance = avatarData.ToAvatarAppearance(ID);
else
avatarAppearance = scene.AvatarService.GetAppearance(ID);
if (avatarAppearance == null)
avatarAppearance = new AvatarAppearance();
AvatarWearable[] wearables = avatarAppearance.Wearables;
@ -2076,8 +2069,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
m_log.DebugFormat("[RADMIN] Outfit {0} load completed", outfitName);
} // foreach outfit
m_log.DebugFormat("[RADMIN] Inventory update complete for {0}", name);
AvatarData avatarData2 = new AvatarData(avatarAppearance);
scene.AvatarService.SetAvatar(ID, avatarData2);
scene.AvatarService.SetAppearance(ID, avatarAppearance);
}
catch (Exception e)
{

View File

@ -27,6 +27,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
using OpenMetaverse;
using OpenSim.Framework;
@ -765,25 +766,19 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
FormatPart(rdata, "UnderShirt", rdata.userAppearance.UnderShirtItem, rdata.userAppearance.UnderShirtAsset);
FormatPart(rdata, "UnderPants", rdata.userAppearance.UnderPantsItem, rdata.userAppearance.UnderPantsAsset);
Hashtable attachments = rdata.userAppearance.GetAttachments();
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting attachments", MsgId);
if (attachments != null)
rdata.writer.WriteStartElement("Attachments");
List<AvatarAttachment> attachments = rdata.userAppearance.GetAttachments();
foreach (AvatarAttachment attach in attachments)
{
Rest.Log.DebugFormat("{0} FormatUserAppearance: Formatting attachments", MsgId);
rdata.writer.WriteStartElement("Attachments");
for (int i = 0; i < attachments.Count; i++)
{
Hashtable attachment = attachments[i] as Hashtable;
rdata.writer.WriteStartElement("Attachment");
rdata.writer.WriteAttributeString("AtPoint", i.ToString());
rdata.writer.WriteAttributeString("Item", (string) attachment["item"]);
rdata.writer.WriteAttributeString("Asset", (string) attachment["asset"]);
rdata.writer.WriteEndElement();
}
rdata.writer.WriteStartElement("Attachment");
rdata.writer.WriteAttributeString("AtPoint", attach.AttachPoint.ToString());
rdata.writer.WriteAttributeString("Item", attach.ItemID.ToString());
rdata.writer.WriteAttributeString("Asset", attach.AssetID.ToString());
rdata.writer.WriteEndElement();
}
rdata.writer.WriteEndElement();
Primitive.TextureEntry texture = rdata.userAppearance.Texture;

View File

@ -596,7 +596,7 @@ namespace OpenSim.Client.MXP.ClientStack
public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
public event DeRezObject OnDeRezObject;
public event Action<IClientAPI> OnRegionHandShakeReply;
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
@ -861,7 +861,7 @@ namespace OpenSim.Client.MXP.ClientStack
OpenSim.Region.Framework.Scenes.Scene scene=(OpenSim.Region.Framework.Scenes.Scene)Scene;
AvatarAppearance appearance;
scene.GetAvatarAppearance(this,out appearance);
OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone());
OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone());
}
public void Stop()

View File

@ -533,9 +533,7 @@ namespace OpenSim.Client.MXP.PacketHandler
agent.InventoryFolder = UUID.Zero;
agent.startpos = new Vector3(0, 0, 0); // TODO Fill in region start position
agent.CapsPath = "http://localhost/";
AvatarData avatar = scene.AvatarService.GetAvatar(account.PrincipalID);
if (avatar != null)
agent.Appearance = avatar.ToAvatarAppearance(account.PrincipalID); //userService.GetUserAppearance(userProfile.ID);
agent.Appearance = scene.AvatarService.GetAppearance(account.PrincipalID);
if (agent.Appearance == null)
{

View File

@ -245,7 +245,7 @@ namespace OpenSim.Client.VWoHTTP.ClientStack
public event TeleportLandmarkRequest OnTeleportLandmarkRequest = delegate { };
public event DeRezObject OnDeRezObject = delegate { };
public event Action<IClientAPI> OnRegionHandShakeReply = delegate { };
public event GenericCall2 OnRequestWearables = delegate { };
public event GenericCall1 OnRequestWearables = delegate { };
public event GenericCall1 OnCompleteMovementToRegion = delegate { };
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate = delegate { };

View File

@ -26,7 +26,9 @@
*/
using System;
using System.Reflection;
using System.Collections.Generic;
using log4net;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@ -38,6 +40,12 @@ namespace OpenSim.Framework
/// </summary>
public class AgentCircuitData
{
// DEBUG ON
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
// DEBUG OFF
/// <summary>
/// Avatar Unique Agent Identifier
/// </summary>
@ -198,15 +206,18 @@ namespace OpenSim.Framework
args["service_session_id"] = OSD.FromString(ServiceSessionID);
args["start_pos"] = OSD.FromString(startpos.ToString());
args["appearance_serial"] = OSD.FromInteger(Appearance.Serial);
args["client_ip"] = OSD.FromString(IPAddress);
args["viewer"] = OSD.FromString(Viewer);
args["channel"] = OSD.FromString(Channel);
args["mac"] = OSD.FromString(Mac);
args["id0"] = OSD.FromString(Id0);
// Eventually this code should be deprecated, use full appearance
// packing in packed_appearance
if (Appearance != null)
{
args["appearance_serial"] = OSD.FromInteger(Appearance.Serial);
//System.Console.WriteLine("XXX Before packing Wearables");
if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
{
@ -221,20 +232,25 @@ namespace OpenSim.Framework
}
//System.Console.WriteLine("XXX Before packing Attachments");
Dictionary<int, UUID[]> attachments = Appearance.GetAttachmentDictionary();
List<AvatarAttachment> attachments = Appearance.GetAttachments();
if ((attachments != null) && (attachments.Count > 0))
{
OSDArray attachs = new OSDArray(attachments.Count);
foreach (KeyValuePair<int, UUID[]> kvp in attachments)
foreach (AvatarAttachment attach in attachments)
{
AttachmentData adata = new AttachmentData(kvp.Key, kvp.Value[0], kvp.Value[1]);
attachs.Add(adata.PackUpdateMessage());
attachs.Add(attach.Pack());
//System.Console.WriteLine("XXX att.pt=" + kvp.Key + "; itemID=" + kvp.Value[0] + "; assetID=" + kvp.Value[1]);
}
args["attachments"] = attachs;
}
}
if (Appearance != null)
{
OSDMap appmap = Appearance.Pack();
args["packed_appearance"] = appmap;
}
if (ServiceURLs != null && ServiceURLs.Count > 0)
{
OSDArray urls = new OSDArray(ServiceURLs.Count * 2);
@ -317,34 +333,57 @@ namespace OpenSim.Framework
if (args["start_pos"] != null)
Vector3.TryParse(args["start_pos"].AsString(), out startpos);
// DEBUG ON
m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}",AgentID,child,startpos.ToString());
// DEBUG OFF
try {
// Unpack various appearance elements
Appearance = new AvatarAppearance(AgentID);
// Eventually this code should be deprecated, use full appearance
// packing in packed_appearance
if (args["appearance_serial"] != null)
Appearance.Serial = args["appearance_serial"].AsInteger();
if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
{
OSDArray wears = (OSDArray)(args["wearables"]);
for (int i = 0; i < wears.Count / 2; i++)
{
Appearance.Wearables[i].ItemID = wears[i*2].AsUUID();
Appearance.Wearables[i].AssetID = wears[(i*2)+1].AsUUID();
AvatarWearable awear = new AvatarWearable(wears[i*2].AsUUID(),wears[(i*2)+1].AsUUID());
Appearance.SetWearable(i,awear);
}
}
}
if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
{
OSDArray attachs = (OSDArray)(args["attachments"]);
AttachmentData[] attachments = new AttachmentData[attachs.Count];
int i = 0;
foreach (OSD o in attachs)
{
if (o.Type == OSDType.Map)
{
attachments[i++] = new AttachmentData((OSDMap)o);
Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
}
}
Appearance.SetAttachments(attachments);
}
if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
{
Appearance.Unpack((OSDMap)args["packed_appearance"]);
// DEBUG ON
m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
// DEBUG OFF
}
// DEBUG ON
else
m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
// DEBUG OFF
} catch (Exception e)
{
m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}",e.Message);
}
ServiceURLs = new Dictionary<string, object>();
if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
{

File diff suppressed because it is too large Load Diff

View File

@ -25,14 +25,54 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using OpenMetaverse;
using OpenSim.Framework;
using OpenMetaverse.StructuredData;
namespace OpenSim.Region.Framework.Interfaces
namespace OpenSim.Framework
{
public interface IAvatarFactory
public class AvatarAttachment
{
bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance);
void UpdateDatabase(UUID userID, AvatarAppearance avatAppearance);
public int AttachPoint;
public UUID ItemID;
public UUID AssetID;
public AvatarAttachment(AvatarAttachment attach)
{
AttachPoint = attach.AttachPoint;
ItemID = attach.ItemID;
AssetID = attach.AssetID;
}
public AvatarAttachment(int point, UUID item, UUID asset)
{
AttachPoint = point;
ItemID = item;
AssetID = asset;
}
public AvatarAttachment(OSDMap args)
{
Unpack(args);
}
public OSDMap Pack()
{
OSDMap attachdata = new OSDMap();
attachdata["point"] = OSD.FromInteger(AttachPoint);
attachdata["item"] = OSD.FromUUID(ItemID);
attachdata["asset"] = OSD.FromUUID(AssetID);
return attachdata;
}
public void Unpack(OSDMap args)
{
if (args["point"] != null)
AttachPoint = args["point"].AsInteger();
ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero;
AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero;
}
}
}

View File

@ -26,14 +26,32 @@
*/
using System;
using System.Runtime.Serialization;
using System.Security.Permissions;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Framework
{
public class AvatarWearable
{
// these are guessed at by the list here -
// http://wiki.secondlife.com/wiki/Avatar_Appearance. We'll
// correct them over time for when were are wrong.
public static readonly int BODY = 0;
public static readonly int SKIN = 1;
public static readonly int HAIR = 2;
public static readonly int EYES = 3;
public static readonly int SHIRT = 4;
public static readonly int PANTS = 5;
public static readonly int SHOES = 6;
public static readonly int SOCKS = 7;
public static readonly int JACKET = 8;
public static readonly int GLOVES = 9;
public static readonly int UNDERSHIRT = 10;
public static readonly int UNDERPANTS = 11;
public static readonly int SKIRT = 12;
public static readonly int MAX_WEARABLES = 13;
public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9");
public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
@ -62,12 +80,32 @@ namespace OpenSim.Framework
ItemID = itemId;
}
public AvatarWearable(OSDMap args)
{
Unpack(args);
}
public OSDMap Pack()
{
OSDMap weardata = new OSDMap();
weardata["item"] = OSD.FromUUID(ItemID);
weardata["asset"] = OSD.FromUUID(AssetID);
return weardata;
}
public void Unpack(OSDMap args)
{
ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero;
AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero;
}
public static AvatarWearable[] DefaultWearables
{
get
{
AvatarWearable[] defaultWearables = new AvatarWearable[13]; //should be 13 of these
for (int i = 0; i < 13; i++)
AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 13 of these
for (int i = 0; i < MAX_WEARABLES; i++)
{
defaultWearables[i] = new AvatarWearable();
}

View File

@ -31,6 +31,7 @@ using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
@ -112,6 +113,8 @@ namespace OpenSim.Framework.Capabilities
private string m_regionName;
private object m_fetchLock = new Object();
private bool m_persistBakedTextures = false;
public bool SSLCaps
{
get { return m_httpListener.UseSSL; }
@ -145,6 +148,15 @@ namespace OpenSim.Framework.Capabilities
m_httpListenPort = httpPort;
m_persistBakedTextures = false;
IConfigSource config = m_Scene.Config;
if (config != null)
{
IConfig sconfig = config.Configs["Startup"];
if (sconfig != null)
m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures",m_persistBakedTextures);
}
if (httpServer != null && httpServer.UseSSL)
{
m_httpListenPort = httpServer.SSLPort;
@ -976,12 +988,14 @@ namespace OpenSim.Framework.Capabilities
public void BakedTextureUploaded(UUID assetID, byte[] data)
{
m_log.DebugFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
// DEBUG ON
m_log.WarnFormat("[CAPS]: Received baked texture {0}", assetID.ToString());
// DEBUG OFF
AssetBase asset;
asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_agentID.ToString());
asset.Data = data;
asset.Temporary = true;
asset.Local = true;
asset.Local = ! m_persistBakedTextures; // Local assets aren't persisted, non-local are
m_assetCache.Store(asset);
}

View File

@ -28,6 +28,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using log4net;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
@ -225,46 +227,6 @@ namespace OpenSim.Framework
}
}
public class AttachmentData
{
public int AttachPoint;
public UUID ItemID;
public UUID AssetID;
public AttachmentData(int point, UUID item, UUID asset)
{
AttachPoint = point;
ItemID = item;
AssetID = asset;
}
public AttachmentData(OSDMap args)
{
UnpackUpdateMessage(args);
}
public OSDMap PackUpdateMessage()
{
OSDMap attachdata = new OSDMap();
attachdata["point"] = OSD.FromInteger(AttachPoint);
attachdata["item"] = OSD.FromUUID(ItemID);
attachdata["asset"] = OSD.FromUUID(AssetID);
return attachdata;
}
public void UnpackUpdateMessage(OSDMap args)
{
if (args["point"] != null)
AttachPoint = args["point"].AsInteger();
if (args["item"] != null)
ItemID = args["item"].AsUUID();
if (args["asset"] != null)
AssetID = args["asset"].AsUUID();
}
}
public class ControllerData
{
public UUID ItemID;
@ -348,11 +310,20 @@ namespace OpenSim.Framework
public UUID GranterID;
// Appearance
public AvatarAppearance Appearance;
// DEBUG ON
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
// DEBUG OFF
/*
public byte[] AgentTextures;
public byte[] VisualParams;
public UUID[] Wearables;
public AttachmentData[] Attachments;
public AvatarAttachment[] Attachments;
*/
// Scripted
public ControllerData[] Controllers;
@ -360,6 +331,10 @@ namespace OpenSim.Framework
public virtual OSDMap Pack()
{
// DEBUG ON
m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Pack data");
// DEBUG OFF
OSDMap args = new OSDMap();
args["message_type"] = OSD.FromString("AgentData");
@ -413,6 +388,9 @@ namespace OpenSim.Framework
args["animations"] = anims;
}
if (Appearance != null)
args["packed_appearance"] = Appearance.Pack();
//if ((AgentTextures != null) && (AgentTextures.Length > 0))
//{
// OSDArray textures = new OSDArray(AgentTextures.Length);
@ -421,30 +399,39 @@ namespace OpenSim.Framework
// args["agent_textures"] = textures;
//}
if ((AgentTextures != null) && (AgentTextures.Length > 0))
args["texture_entry"] = OSD.FromBinary(AgentTextures);
// The code to pack textures, visuals, wearables and attachments
// should be removed; packed appearance contains the full appearance
// This is retained for backward compatibility only
if (Appearance.Texture != null)
{
byte[] rawtextures = Appearance.Texture.GetBytes();
args["texture_entry"] = OSD.FromBinary(rawtextures);
}
if ((VisualParams != null) && (VisualParams.Length > 0))
args["visual_params"] = OSD.FromBinary(VisualParams);
if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0))
args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
// We might not pass this in all cases...
if ((Wearables != null) && (Wearables.Length > 0))
if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
{
OSDArray wears = new OSDArray(Wearables.Length);
foreach (UUID uuid in Wearables)
wears.Add(OSD.FromUUID(uuid));
OSDArray wears = new OSDArray(Appearance.Wearables.Length * 2);
foreach (AvatarWearable awear in Appearance.Wearables)
{
wears.Add(OSD.FromUUID(awear.ItemID));
wears.Add(OSD.FromUUID(awear.AssetID));
}
args["wearables"] = wears;
}
if ((Attachments != null) && (Attachments.Length > 0))
List<AvatarAttachment> attachments = Appearance.GetAttachments();
if ((attachments != null) && (attachments.Count > 0))
{
OSDArray attachs = new OSDArray(Attachments.Length);
foreach (AttachmentData att in Attachments)
attachs.Add(att.PackUpdateMessage());
OSDArray attachs = new OSDArray(attachments.Count);
foreach (AvatarAttachment att in attachments)
attachs.Add(att.Pack());
args["attachments"] = attachs;
}
// End of code to remove
if ((Controllers != null) && (Controllers.Length > 0))
{
@ -469,6 +456,10 @@ namespace OpenSim.Framework
/// <param name="hash"></param>
public virtual void Unpack(OSDMap args)
{
// DEBUG ON
m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Unpack data");
// DEBUG OFF
if (args.ContainsKey("region_id"))
UUID.TryParse(args["region_id"].AsString(), out RegionID);
@ -581,34 +572,53 @@ namespace OpenSim.Framework
// AgentTextures[i++] = o.AsUUID();
//}
Appearance = new AvatarAppearance(AgentID);
// The code to unpack textures, visuals, wearables and attachments
// should be removed; packed appearance contains the full appearance
// This is retained for backward compatibility only
if (args["texture_entry"] != null)
AgentTextures = args["texture_entry"].AsBinary();
{
byte[] rawtextures = args["texture_entry"].AsBinary();
Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures,0,rawtextures.Length);
Appearance.SetTextureEntries(textures);
}
if (args["visual_params"] != null)
VisualParams = args["visual_params"].AsBinary();
Appearance.SetVisualParams(args["visual_params"].AsBinary());
if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
{
OSDArray wears = (OSDArray)(args["wearables"]);
Wearables = new UUID[wears.Count];
int i = 0;
foreach (OSD o in wears)
Wearables[i++] = o.AsUUID();
for (int i = 0; i < wears.Count / 2; i++)
{
AvatarWearable awear = new AvatarWearable(wears[i*2].AsUUID(),wears[(i*2)+1].AsUUID());
Appearance.SetWearable(i,awear);
}
}
if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
{
OSDArray attachs = (OSDArray)(args["attachments"]);
Attachments = new AttachmentData[attachs.Count];
int i = 0;
foreach (OSD o in attachs)
{
if (o.Type == OSDType.Map)
{
Attachments[i++] = new AttachmentData((OSDMap)o);
// We know all of these must end up as attachments so we
// append rather than replace to ensure multiple attachments
// per point continues to work
Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
}
}
}
// end of code to remove
if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
Appearance = new AvatarAppearance(AgentID,(OSDMap)args["packed_appearance"]);
// DEBUG ON
else
m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance");
// DEBUG OFF
if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
{

View File

@ -43,7 +43,7 @@ namespace OpenSim.Framework
public delegate void TextureRequest(Object sender, TextureRequestArgs e);
public delegate void AvatarNowWearing(Object sender, AvatarWearingArgs e);
public delegate void AvatarNowWearing(IClientAPI sender, AvatarWearingArgs e);
public delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im);
@ -65,7 +65,7 @@ namespace OpenSim.Framework
public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);
public delegate void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams);
public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams);
public delegate void StartAnim(IClientAPI remoteClient, UUID animID);
@ -711,7 +711,7 @@ namespace OpenSim.Framework
event TeleportLandmarkRequest OnTeleportLandmarkRequest;
event DeRezObject OnDeRezObject;
event Action<IClientAPI> OnRegionHandShakeReply;
event GenericCall2 OnRequestWearables;
event GenericCall1 OnRequestWearables;
event GenericCall1 OnCompleteMovementToRegion;
event UpdateAgent OnPreAgentUpdate;
event UpdateAgent OnAgentUpdate;

View File

@ -65,9 +65,7 @@ namespace OpenSim.Framework.Tests
SessionId = UUID.Random();
AvAppearance = new AvatarAppearance(AgentId);
AvAppearance.SetDefaultWearables();
VisualParams = new byte[218];
AvAppearance.SetDefaultParams(VisualParams);
//body
VisualParams[(int)AvatarAppearance.VPElement.SHAPE_HEIGHT] = 155;

View File

@ -79,7 +79,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
public event DeRezObject OnDeRezObject;
public event ModifyTerrain OnModifyTerrain;
public event Action<IClientAPI> OnRegionHandShakeReply;
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnRequestWearables;
public event SetAppearance OnSetAppearance;
public event AvatarNowWearing OnAvatarNowWearing;
public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
@ -5647,11 +5647,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
{
GenericCall2 handlerRequestWearables = OnRequestWearables;
GenericCall1 handlerRequestWearables = OnRequestWearables;
if (handlerRequestWearables != null)
{
handlerRequestWearables();
handlerRequestWearables(sender);
}
Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
@ -5694,7 +5694,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (appear.ObjectData.TextureEntry.Length > 1)
te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
handlerSetAppearance(te, visualparams);
handlerSetAppearance(sender, te, visualparams);
}
catch (Exception e)
{

View File

@ -124,13 +124,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// Save avatar attachment information
ScenePresence presence;
if (m_scene.AvatarFactory != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
if (m_scene.AvatarService != null && m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{
m_log.Info(
"[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
+ ", AttachmentPoint: " + AttachmentPt);
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
}
}
}
@ -382,8 +382,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
item = m_scene.InventoryService.GetItem(item);
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
if (m_scene.AvatarFactory != null)
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
if (m_scene.AvatarService != null)
m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
}
}
@ -405,10 +405,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
presence.Appearance.DetachAttachment(itemID);
// Save avatar attachment information
if (m_scene.AvatarFactory != null)
if (m_scene.AvatarService != null)
{
m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + remoteClient.AgentId + ", ItemID: " + itemID);
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
}
}
@ -435,9 +435,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
presence.Appearance.DetachAttachment(itemID);
if (m_scene.AvatarFactory != null)
if (m_scene.AvatarService != null)
{
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
m_scene.AvatarService.SetAppearance(remoteClient.AgentId, presence.Appearance);
}
part.ParentGroup.DetachToGround();

View File

@ -32,58 +32,56 @@ using Nini.Config;
using OpenMetaverse;
using OpenSim.Framework;
using System.Threading;
using System.Timers;
using System.Collections.Generic;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{
public class AvatarFactoryModule : IAvatarFactory, IRegionModule
public class AvatarFactoryModule : IRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
private Scene m_scene = null;
private static readonly AvatarAppearance def = new AvatarAppearance();
public bool TryGetAvatarAppearance(UUID avatarId, out AvatarAppearance appearance)
private int m_savetime = 5; // seconds to wait before saving changed appearance
private int m_sendtime = 2; // seconds to wait before sending changed appearance
private int m_checkTime = 500; // milliseconds to wait between checks for appearance updates
private System.Timers.Timer m_updateTimer = new System.Timers.Timer();
private Dictionary<UUID,long> m_savequeue = new Dictionary<UUID,long>();
private Dictionary<UUID,long> m_sendqueue = new Dictionary<UUID,long>();
#region RegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
AvatarData avatar = m_scene.AvatarService.GetAvatar(avatarId);
//if ((profile != null) && (profile.RootFolder != null))
if (avatar != null)
{
appearance = avatar.ToAvatarAppearance(avatarId);
return true;
}
m_log.ErrorFormat("[APPEARANCE]: Appearance not found for {0}, creating default", avatarId);
appearance = CreateDefault(avatarId);
return false;
}
private AvatarAppearance CreateDefault(UUID avatarId)
{
AvatarAppearance appearance = null;
AvatarWearable[] wearables;
byte[] visualParams;
GetDefaultAvatarAppearance(out wearables, out visualParams);
appearance = new AvatarAppearance(avatarId, wearables, visualParams);
return appearance;
}
public void Initialise(Scene scene, IConfigSource source)
{
scene.RegisterModuleInterface<IAvatarFactory>(this);
scene.EventManager.OnNewClient += NewClient;
if (m_scene == null)
if (config != null)
{
m_scene = scene;
IConfig sconfig = config.Configs["Startup"];
if (sconfig != null)
{
m_savetime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime)));
m_sendtime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime)));
}
}
if (m_scene == null)
m_scene = scene;
}
public void PostInitialise()
{
m_updateTimer.Enabled = false;
m_updateTimer.AutoReset = true;
m_updateTimer.Interval = m_checkTime; // 500 milliseconds wait to start async ops
m_updateTimer.Elapsed += new ElapsedEventHandler(HandleAppearanceUpdateTimer);
}
public void Close()
@ -102,6 +100,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
public void NewClient(IClientAPI client)
{
client.OnRequestWearables += SendWearables;
client.OnSetAppearance += SetAppearance;
client.OnAvatarNowWearing += AvatarIsWearing;
}
@ -110,13 +110,263 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// client.OnAvatarNowWearing -= AvatarIsWearing;
}
public void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
#endregion
/// <summary>
/// Set appearance data (textureentry and slider settings) received from the client
/// </summary>
/// <param name="texture"></param>
/// <param name="visualParam"></param>
public void SetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams)
{
// DEBUG ON
m_log.WarnFormat("[AVFACTORY] SetAppearance for {0}",client.AgentId);
// DEBUG OFF
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
{
m_log.WarnFormat("[AVFACTORY] SetAppearance unable to find presence for {0}",client.AgentId);
return;
}
bool changed = false;
// Process the texture entry
if (textureEntry != null)
{
changed = sp.Appearance.SetTextureEntries(textureEntry);
for (int i = 0; i < BAKE_INDICES.Length; i++)
{
int idx = BAKE_INDICES[i];
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
Util.FireAndForget(delegate(object o) { CheckBakedTextureAssets(client,face.TextureID,idx); });
}
}
// Process the visual params, this may change height as well
if (visualParams != null)
{
if (sp.Appearance.SetVisualParams(visualParams))
{
changed = true;
if (sp.Appearance.AvatarHeight > 0)
sp.SetHeight(sp.Appearance.AvatarHeight);
}
}
// If something changed in the appearance then queue an appearance save
if (changed)
QueueAppearanceSave(client.AgentId);
// And always queue up an appearance update to send out
QueueAppearanceSend(client.AgentId);
// Send the appearance back to the avatar
AvatarAppearance avp = sp.Appearance;
sp.ControllingClient.SendAvatarDataImmediate(sp);
sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
}
/// <summary>
/// Checks for the existance of a baked texture asset and
/// requests the viewer rebake if the asset is not found
/// </summary>
/// <param name="client"></param>
/// <param name="textureID"></param>
/// <param name="idx"></param>
private void CheckBakedTextureAssets(IClientAPI client, UUID textureID, int idx)
{
if (m_scene.AssetService.Get(textureID.ToString()) == null)
{
m_log.WarnFormat("[AVFACTORY]: Missing baked texture {0} ({1}) for avatar {2}",
textureID,idx,client.Name);
client.SendRebakeAvatarTextures(textureID);
}
}
#region UpdateAppearanceTimer
public void QueueAppearanceSend(UUID agentid)
{
// DEBUG ON
m_log.WarnFormat("[AVFACTORY] Queue appearance send for {0}",agentid);
// DEBUG OFF
// 100 nanoseconds (ticks) we should wait
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 10000000);
lock (m_sendqueue)
{
m_sendqueue[agentid] = timestamp;
m_updateTimer.Start();
}
}
public void QueueAppearanceSave(UUID agentid)
{
// DEBUG ON
m_log.WarnFormat("[AVFACTORY] Queue appearance save for {0}",agentid);
// DEBUG OFF
// 100 nanoseconds (ticks) we should wait
long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 10000000);
lock (m_savequeue)
{
m_savequeue[agentid] = timestamp;
m_updateTimer.Start();
}
}
private void HandleAppearanceSend(UUID agentid)
{
ScenePresence sp = m_scene.GetScenePresence(agentid);
if (sp == null)
{
m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid);
return;
}
// DEBUG ON
m_log.WarnFormat("[AVFACTORY] Handle appearance send for {0}\n{1}",agentid,sp.Appearance.ToString());
// DEBUG OFF
// Send the appearance to everyone in the scene
sp.SendAppearanceToAllOtherAgents();
// Send the appearance back to the avatar
AvatarAppearance avp = sp.Appearance;
sp.ControllingClient.SendAvatarDataImmediate(sp);
sp.ControllingClient.SendAppearance(avp.Owner,avp.VisualParams,avp.Texture.GetBytes());
/*
// this needs to be fixed, the flag should be on scene presence not the region module
// Start the animations if necessary
if (!m_startAnimationSet)
{
sp.Animator.UpdateMovementAnimations();
m_startAnimationSet = true;
}
*/
}
private void HandleAppearanceSave(UUID agentid)
{
ScenePresence sp = m_scene.GetScenePresence(agentid);
if (sp == null)
{
m_log.WarnFormat("[AVFACTORY] Agent {0} no longer in the scene",agentid);
return;
}
m_scene.AvatarService.SetAppearance(agentid, sp.Appearance);
}
private void HandleAppearanceUpdateTimer(object sender, EventArgs ea)
{
long now = DateTime.Now.Ticks;
lock (m_sendqueue)
{
Dictionary<UUID,long> sends = new Dictionary<UUID,long>(m_sendqueue);
foreach (KeyValuePair<UUID,long> kvp in sends)
{
if (kvp.Value < now)
{
Util.FireAndForget(delegate(object o) { HandleAppearanceSend(kvp.Key); });
m_sendqueue.Remove(kvp.Key);
}
}
}
lock (m_savequeue)
{
Dictionary<UUID,long> saves = new Dictionary<UUID,long>(m_savequeue);
foreach (KeyValuePair<UUID,long> kvp in saves)
{
if (kvp.Value < now)
{
Util.FireAndForget(delegate(object o) { HandleAppearanceSave(kvp.Key); });
m_savequeue.Remove(kvp.Key);
}
}
}
if (m_savequeue.Count == 0 && m_sendqueue.Count == 0)
m_updateTimer.Stop();
}
#endregion
/// <summary>
/// Tell the client for this scene presence what items it should be wearing now
/// </summary>
public void SendWearables(IClientAPI client)
{
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
{
m_log.WarnFormat("[AVFACTORY] SendWearables unable to find presence for {0}",client.AgentId);
return;
}
// DEBUG ON
m_log.WarnFormat("[AVFACTORY]: Received request for wearables of {0}", client.AgentId);
// DEBUG OFF
client.SendWearables(sp.Appearance.Wearables,sp.Appearance.Serial++);
}
/// <summary>
/// Update what the avatar is wearing using an item from their inventory.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void AvatarIsWearing(IClientAPI client, AvatarWearingArgs e)
{
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp == null)
{
m_log.WarnFormat("[AVFACTORY] AvatarIsWearing unable to find presence for {0}",client.AgentId);
return;
}
// DEBUG ON
m_log.WarnFormat("[AVFACTORY]: AvatarIsWearing called for {0}",client.AgentId);
// DEBUG OFF
AvatarAppearance avatAppearance = new AvatarAppearance(sp.Appearance);
//if (!TryGetAvatarAppearance(client.AgentId, out avatAppearance))
//{
// m_log.Warn("[AVFACTORY]: We didn't seem to find the appearance, falling back to ScenePresence");
// avatAppearance = sp.Appearance;
//}
//m_log.DebugFormat("[AVFACTORY]: Received wearables for {0}", client.Name);
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
{
if (wear.Type < AvatarWearable.MAX_WEARABLES)
{
AvatarWearable newWearable = new AvatarWearable(wear.ItemID,UUID.Zero);
avatAppearance.SetWearable(wear.Type, newWearable);
}
}
SetAppearanceAssets(sp.UUID, ref avatAppearance);
m_scene.AvatarService.SetAppearance(client.AgentId, avatAppearance);
sp.Appearance = avatAppearance;
}
private void SetAppearanceAssets(UUID userID, ref AvatarAppearance appearance)
{
IInventoryService invService = m_scene.InventoryService;
if (invService.GetRootFolder(userID) != null)
{
for (int i = 0; i < 13; i++)
for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
{
if (appearance.Wearables[i].ItemID == UUID.Zero)
{
@ -134,84 +384,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
else
{
m_log.ErrorFormat(
"[APPEARANCE]: Can't find inventory item {0} for {1}, setting to default",
"[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default",
appearance.Wearables[i].ItemID, (WearableType)i);
appearance.Wearables[i].AssetID = def.Wearables[i].AssetID;
appearance.Wearables[i].ItemID = UUID.Zero;
appearance.Wearables[i].AssetID = UUID.Zero;
}
}
}
}
else
{
m_log.WarnFormat("[APPEARANCE]: user {0} has no inventory, appearance isn't going to work", userID);
m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID);
}
}
/// <summary>
/// Update what the avatar is wearing using an item from their inventory.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void AvatarIsWearing(Object sender, AvatarWearingArgs e)
{
m_log.DebugFormat("[APPEARANCE]: AvatarIsWearing");
IClientAPI clientView = (IClientAPI)sender;
ScenePresence sp = m_scene.GetScenePresence(clientView.AgentId);
if (sp == null)
{
m_log.Error("[APPEARANCE]: Avatar is child agent, ignoring AvatarIsWearing event");
return;
}
AvatarAppearance avatAppearance = sp.Appearance;
//if (!TryGetAvatarAppearance(clientView.AgentId, out avatAppearance))
//{
// m_log.Warn("[APPEARANCE]: We didn't seem to find the appearance, falling back to ScenePresence");
// avatAppearance = sp.Appearance;
//}
//m_log.DebugFormat("[APPEARANCE]: Received wearables for {0}", clientView.Name);
foreach (AvatarWearingArgs.Wearable wear in e.NowWearing)
{
if (wear.Type < 13)
{
avatAppearance.Wearables[wear.Type].ItemID = wear.ItemID;
}
}
SetAppearanceAssets(sp.UUID, ref avatAppearance);
AvatarData adata = new AvatarData(avatAppearance);
m_scene.AvatarService.SetAvatar(clientView.AgentId, adata);
sp.Appearance = avatAppearance;
}
public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams)
{
visualParams = GetDefaultVisualParams();
wearables = AvatarWearable.DefaultWearables;
}
public void UpdateDatabase(UUID user, AvatarAppearance appearance)
{
//m_log.DebugFormat("[APPEARANCE]: UpdateDatabase");
AvatarData adata = new AvatarData(appearance);
m_scene.AvatarService.SetAvatar(user, adata);
}
private static byte[] GetDefaultVisualParams()
{
byte[] visualParams;
visualParams = new byte[218];
for (int i = 0; i < 218; i++)
{
visualParams[i] = 100;
}
return visualParams;
}
}
}

View File

@ -238,7 +238,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
}
(scene as Scene).EventManager.TriggerOnChatToClients(
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully);
}
static private Vector3 CenterOfRegion = new Vector3(128, 128, 30);

View File

@ -143,7 +143,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
if (filePath == ArchiveConstants.CONTROL_FILE_PATH)
{
LoadControlFile(filePath, data);
}
}
else if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
{
if (LoadAsset(filePath, data))
@ -479,11 +479,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
/// <param name="path"></param>
/// <param name="data"></param>
protected void LoadControlFile(string path, byte[] data)
{
{
XDocument doc = XDocument.Parse(Encoding.ASCII.GetString(data));
XElement archiveElement = doc.Element("archive");
int majorVersion = int.Parse(archiveElement.Attribute("major_version").Value);
int minorVersion = int.Parse(archiveElement.Attribute("minor_version").Value);
int minorVersion = int.Parse(archiveElement.Attribute("minor_version").Value);
string version = string.Format("{0}.{1}", majorVersion, minorVersion);
if (majorVersion > MAX_MAJOR_VERSION)
@ -492,7 +492,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
string.Format(
"The IAR you are trying to load has major version number of {0} but this version of OpenSim can only load IARs with major version number {1} and below",
majorVersion, MAX_MAJOR_VERSION));
}
}
m_log.InfoFormat("[INVENTORY ARCHIVER]: Loading IAR with version {0}", version);
}

View File

@ -213,7 +213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
public void Execute()
{
try
{
{
InventoryFolderBase inventoryFolder = null;
InventoryItemBase inventoryItem = null;
InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.PrincipalID);
@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
// Write out control file. This has to be done first so that subsequent loaders will see this file first
// XXX: I know this is a weak way of doing it since external non-OAR aware tar executables will not do this
m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
m_log.InfoFormat("[INVENTORY ARCHIVER]: Added control file to archive.");
m_log.InfoFormat("[INVENTORY ARCHIVER]: Added control file to archive.");
if (inventoryFolder != null)
{

View File

@ -30,6 +30,7 @@ using System.Collections.Generic;
using System.Reflection;
using log4net;
using Nini.Config;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Server.Base;
@ -137,6 +138,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar
#region IAvatarService
public AvatarAppearance GetAppearance(UUID userID)
{
return m_AvatarService.GetAppearance(userID);
}
public bool SetAppearance(UUID userID, AvatarAppearance appearance)
{
return m_AvatarService.SetAppearance(userID,appearance);
}
public AvatarData GetAvatar(UUID userID)
{
return m_AvatarService.GetAvatar(userID);

View File

@ -199,13 +199,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
majorVersion = 1;
minorVersion = 0;
}
}
*/
m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
// if (majorVersion == 1)
// {
// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
// m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
// }
@ -232,6 +232,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
sw.Close();
return s;
}
}
}
}

View File

@ -44,10 +44,8 @@ namespace OpenSim.Region.CoreModules
/// it is not based on ~06:00 == Sun Rise. Rather it is based on 00:00 being sun-rise.
/// </summary>
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
//
// Global Constants used to determine where in the sky the sun is
//
@ -108,26 +106,25 @@ namespace OpenSim.Region.CoreModules
private Scene m_scene = null;
// Calculated Once in the lifetime of a region
private long TicksToEpoch; // Elapsed time for 1/1/1970
private uint SecondsPerSunCycle; // Length of a virtual day in RW seconds
private uint SecondsPerYear; // Length of a virtual year in RW seconds
private double SunSpeed; // Rate of passage in radians/second
private double SeasonSpeed; // Rate of change for seasonal effects
// private double HoursToRadians; // Rate of change for seasonal effects
private long TicksUTCOffset = 0; // seconds offset from UTC
private long TicksToEpoch; // Elapsed time for 1/1/1970
private uint SecondsPerSunCycle; // Length of a virtual day in RW seconds
private uint SecondsPerYear; // Length of a virtual year in RW seconds
private double SunSpeed; // Rate of passage in radians/second
private double SeasonSpeed; // Rate of change for seasonal effects
// private double HoursToRadians; // Rate of change for seasonal effects
private long TicksUTCOffset = 0; // seconds offset from UTC
// Calculated every update
private float OrbitalPosition; // Orbital placement at a point in time
private double HorizonShift; // Axis offset to skew day and night
private double TotalDistanceTravelled; // Distance since beginning of time (in radians)
private double SeasonalOffset; // Seaonal variation of tilt
private float Magnitude; // Normal tilt
// private double VWTimeRatio; // VW time as a ratio of real time
private float OrbitalPosition; // Orbital placement at a point in time
private double HorizonShift; // Axis offset to skew day and night
private double TotalDistanceTravelled; // Distance since beginning of time (in radians)
private double SeasonalOffset; // Seaonal variation of tilt
private float Magnitude; // Normal tilt
// private double VWTimeRatio; // VW time as a ratio of real time
// Working values
private Vector3 Position = Vector3.Zero;
private Vector3 Velocity = Vector3.Zero;
private Quaternion Tilt = new Quaternion(1.0f, 0.0f, 0.0f, 0.0f);
private Quaternion Tilt = new Quaternion(1.0f, 0.0f, 0.0f, 0.0f);
// Used to fix the sun in the sky so it doesn't move based on current time
private bool m_SunFixed = false;
@ -135,8 +132,6 @@ namespace OpenSim.Region.CoreModules
private const int TICKS_PER_SECOND = 10000000;
// Current time in elapsed seconds since Jan 1st 1970
private ulong CurrentTime
{
@ -149,8 +144,6 @@ namespace OpenSim.Region.CoreModules
// Time in seconds since UTC to use to calculate sun position.
ulong PosTime = 0;
/// <summary>
/// Calculate the sun's orbital position and its velocity.
/// </summary>
@ -202,7 +195,6 @@ namespace OpenSim.Region.CoreModules
PosTime += (ulong)(((CurDayPercentage - 0.5) / .5) * NightSeconds);
}
}
}
TotalDistanceTravelled = SunSpeed * PosTime; // distance measured in radians
@ -251,7 +243,6 @@ namespace OpenSim.Region.CoreModules
Velocity.X = 0;
Velocity.Y = 0;
Velocity.Z = 0;
}
else
{
@ -271,9 +262,7 @@ namespace OpenSim.Region.CoreModules
private float GetCurrentTimeAsLindenSunHour()
{
if (m_SunFixed)
{
return m_SunFixedHour + 6;
}
return GetCurrentSunHour() + 6.0f;
}
@ -297,8 +286,6 @@ namespace OpenSim.Region.CoreModules
m_scene.AddCommand(this, String.Format("sun {0}", kvp.Key), String.Format("{0} - {1}", kvp.Key, kvp.Value), "", HandleSunConsoleCommand);
}
TimeZone local = TimeZone.CurrentTimeZone;
TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks;
m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset);
@ -325,13 +312,11 @@ namespace OpenSim.Region.CoreModules
// must hard code to ~.5 to match sun position in LL based viewers
m_HorizonShift = config.Configs["Sun"].GetDouble("day_night_offset", d_day_night);
// Scales the sun hours 0...12 vs 12...24, essentially makes daylight hours longer/shorter vs nighttime hours
m_DayTimeSunHourScale = config.Configs["Sun"].GetDouble("day_time_sun_hour_scale", d_DayTimeSunHourScale);
// Update frequency in frames
m_UpdateInterval = config.Configs["Sun"].GetInt("update_interval", d_frame_mod);
}
catch (Exception e)
{
@ -391,10 +376,8 @@ namespace OpenSim.Region.CoreModules
}
scene.RegisterModuleInterface<ISunModule>(this);
}
public void PostInitialise()
{
}
@ -402,7 +385,7 @@ namespace OpenSim.Region.CoreModules
public void Close()
{
ready = false;
// Remove our hooks
m_scene.EventManager.OnFrame -= SunUpdate;
m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
@ -419,6 +402,7 @@ namespace OpenSim.Region.CoreModules
{
get { return false; }
}
#endregion
#region EventManager Events
@ -446,9 +430,7 @@ namespace OpenSim.Region.CoreModules
public void SunUpdate()
{
if (((m_frame++ % m_UpdateInterval) != 0) || !ready || m_SunFixed || !receivedEstateToolsSunUpdate)
{
return;
}
GenSunPos(); // Generate shared values once
@ -467,7 +449,7 @@ namespace OpenSim.Region.CoreModules
}
/// <summary>
///
///
/// </summary>
/// <param name="regionHandle"></param>
/// <param name="FixedTime">Is the sun's position fixed?</param>
@ -484,7 +466,6 @@ namespace OpenSim.Region.CoreModules
while (FixedSunHour < 0)
FixedSunHour += 24;
m_SunFixedHour = FixedSunHour;
m_SunFixed = FixedSun;
@ -499,14 +480,12 @@ namespace OpenSim.Region.CoreModules
// When sun settings are updated, we should update all clients with new settings.
SunUpdateToAllClients();
m_log.DebugFormat("[SUN]: PosTime : {0}", PosTime.ToString());
}
}
#endregion
private void SunUpdateToAllClients()
{
m_scene.ForEachScenePresence(delegate(ScenePresence sp)
@ -553,7 +532,6 @@ namespace OpenSim.Region.CoreModules
{
float ticksleftover = CurrentTime % SecondsPerSunCycle;
return (24.0f * (ticksleftover / SecondsPerSunCycle));
}
@ -666,7 +644,6 @@ namespace OpenSim.Region.CoreModules
// When sun settings are updated, we should update all clients with new settings.
SunUpdateToAllClients();
}
return Output;

View File

@ -82,7 +82,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event DeRezObject OnDeRezObject;
public event Action<IClientAPI> OnRegionHandShakeReply;
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;

View File

@ -296,7 +296,7 @@ namespace OpenSim.Region.Framework.Scenes
/// ChatToClientsEvent is triggered via ChatModule (or
/// substitutes thereof) when a chat message is actually sent to clients. Clients will only be sent a
/// received chat message if they satisfy various conditions (within audible range, etc.)
/// </summary>
/// </summary>
public delegate void ChatToClientsEvent(
UUID senderID, HashSet<UUID> receiverIDs,
string message, ChatTypeEnum type, Vector3 fromPos, string fromName,
@ -1636,8 +1636,8 @@ namespace OpenSim.Region.Framework.Scenes
e.Message, e.StackTrace);
}
}
}
}
}
}
public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat)
{

View File

@ -119,7 +119,6 @@ namespace OpenSim.Region.Framework.Scenes
protected IXMLRPC m_xmlrpcModule;
protected IWorldComm m_worldCommModule;
protected IAvatarFactory m_AvatarFactory;
protected IConfigSource m_config;
protected IRegionSerialiserModule m_serialiser;
protected IDialogModule m_dialogModule;
@ -399,11 +398,6 @@ namespace OpenSim.Region.Framework.Scenes
public IAttachmentsModule AttachmentsModule { get; set; }
public IAvatarFactory AvatarFactory
{
get { return m_AvatarFactory; }
}
public ICapabilitiesModule CapsModule
{
get { return m_capsModule; }
@ -1159,7 +1153,6 @@ namespace OpenSim.Region.Framework.Scenes
m_xmlrpcModule = RequestModuleInterface<IXMLRPC>();
m_worldCommModule = RequestModuleInterface<IWorldComm>();
XferManager = RequestModuleInterface<IXfer>();
m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
AttachmentsModule = RequestModuleInterface<IAttachmentsModule>();
m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
m_dialogModule = RequestModuleInterface<IDialogModule>();
@ -3278,7 +3271,6 @@ namespace OpenSim.Region.Framework.Scenes
m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
}
/// <summary>
/// Do the work necessary to initiate a new user connection for a particular scene.
/// At the moment, this consists of setting up the caps infrastructure
@ -3290,6 +3282,23 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns>True if the region accepts this agent. False if it does not. False will
/// also return a reason.</returns>
public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason)
{
return NewUserConnection(agent, teleportFlags, out reason, true);
}
/// <summary>
/// Do the work necessary to initiate a new user connection for a particular scene.
/// At the moment, this consists of setting up the caps infrastructure
/// The return bool should allow for connections to be refused, but as not all calling paths
/// take proper notice of it let, we allowed banned users in still.
/// </summary>
/// <param name="agent">CircuitData of the agent who is connecting</param>
/// <param name="reason">Outputs the reason for the false response on this string</param>
/// <param name="requirePresenceLookup">True for normal presence. False for NPC
/// or other applications where a full grid/Hypergrid presence may not be required.</param>
/// <returns>True if the region accepts this agent. False if it does not. False will
/// also return a reason.</returns>
public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason, bool requirePresenceLookup)
{
bool vialogin = ((teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0 ||
(teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0);
@ -3339,16 +3348,18 @@ namespace OpenSim.Region.Framework.Scenes
if (sp == null) // We don't have an [child] agent here already
{
try
if (requirePresenceLookup)
{
if (!VerifyUserPresence(agent, out reason))
try
{
if (!VerifyUserPresence(agent, out reason))
return false;
}
catch (Exception e)
{
m_log.ErrorFormat("[CONNECTION BEGIN]: Exception verifying presence " + e.ToString());
return false;
}
catch (Exception e)
{
m_log.ErrorFormat("[CONNECTION BEGIN]: Exception verifying presence " + e.ToString());
return false;
}
}
try

View File

@ -406,11 +406,14 @@ namespace OpenSim.Region.Framework.Scenes
public bool DeleteSceneObject(UUID uuid, bool resultOfObjectLinked)
{
EntityBase entity;
if (!Entities.TryGetValue(uuid, out entity) && entity is SceneObjectGroup)
if (!Entities.TryGetValue(uuid, out entity) || (!(entity is SceneObjectGroup)))
return false;
SceneObjectGroup grp = (SceneObjectGroup)entity;
if (entity == null)
return false;
if (!resultOfObjectLinked)
{
m_numPrim -= grp.PrimCount;

View File

@ -75,7 +75,6 @@ namespace OpenSim.Region.Framework.Scenes
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
// private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes();
private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags));
private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f);
@ -137,8 +136,6 @@ namespace OpenSim.Region.Framework.Scenes
private SendCourseLocationsMethod m_sendCourseLocationsMethod;
private bool m_startAnimationSet;
//private Vector3 m_requestedSitOffset = new Vector3();
private Vector3 m_LastFinitePos;
@ -713,13 +710,14 @@ namespace OpenSim.Region.Framework.Scenes
SetDirectionVectors();
}
/*
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, byte[] visualParams,
AvatarWearable[] wearables)
: this(client, world, reginfo)
{
m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
}
*/
public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
: this(client, world, reginfo)
{
@ -733,8 +731,6 @@ namespace OpenSim.Region.Framework.Scenes
public void RegisterToEvents()
{
m_controllingClient.OnRequestWearables += SendWearables;
m_controllingClient.OnSetAppearance += SetAppearance;
m_controllingClient.OnCompleteMovementToRegion += CompleteMovement;
//m_controllingClient.OnCompleteMovementToRegion += SendInitialData;
m_controllingClient.OnAgentUpdate += HandleAgentUpdate;
@ -1068,7 +1064,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary>
/// Sets avatar height in the phyiscs plugin
/// </summary>
internal void SetHeight(float height)
public void SetHeight(float height)
{
m_avHeight = height;
if (PhysicsActor != null && !IsChildAgent)
@ -1133,7 +1129,6 @@ namespace OpenSim.Region.Framework.Scenes
if (friendsModule != null)
friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
}
}
/// <summary>
@ -2392,9 +2387,12 @@ namespace OpenSim.Region.Framework.Scenes
if (m_appearance.Texture == null)
return;
Vector3 pos = m_pos;
pos.Z += m_appearance.HipOffset;
if (IsChildAgent)
{
m_log.WarnFormat("[SCENEPRESENCE] A child agent is attempting to send out avatar data");
return;
}
remoteAvatar.m_controllingClient.SendAvatarDataImmediate(this);
m_scene.StatsReporter.AddAgentUpdates(1);
}
@ -2437,6 +2435,12 @@ namespace OpenSim.Region.Framework.Scenes
m_perfMonMS = Util.EnvironmentTickCount();
// only send update from root agents to other clients; children are only "listening posts"
if (IsChildAgent)
{
m_log.Warn("[SCENEPRESENCE] attempt to send update from a childagent");
return;
}
int count = 0;
m_scene.ForEachScenePresence(delegate(ScenePresence sp)
{
@ -2460,29 +2464,20 @@ namespace OpenSim.Region.Framework.Scenes
// the inventory arrives
// m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance);
Vector3 pos = m_pos;
pos.Z += m_appearance.HipOffset;
m_controllingClient.SendAvatarDataImmediate(this);
m_controllingClient.SendAppearance(m_appearance.Owner,m_appearance.VisualParams,m_appearance.Texture.GetBytes());
SendInitialFullUpdateToAllClients();
}
/// <summary>
/// Tell the client for this scene presence what items it should be wearing now
/// </summary>
public void SendWearables()
{
m_log.DebugFormat("[SCENE]: Received request for wearables of {0}", Name);
ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
}
/// <summary>
///
/// </summary>
public void SendAppearanceToAllOtherAgents()
{
// DEBUG ON
m_log.WarnFormat("[SP] Send appearance from {0} to all other agents",m_uuid);
// DEBUG OFF
m_perfMonMS = Util.EnvironmentTickCount();
m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
@ -2502,87 +2497,13 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="avatar"></param>
public void SendAppearanceToOtherAgent(ScenePresence avatar)
{
// DEBUG ON
m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
// DEBUG OFF
avatar.ControllingClient.SendAppearance(
m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
}
/// <summary>
/// Set appearance data (textureentry and slider settings) received from the client
/// </summary>
/// <param name="texture"></param>
/// <param name="visualParam"></param>
public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams)
{
if (m_physicsActor != null)
{
if (!IsChildAgent)
{
// This may seem like it's redundant, remove the avatar from the physics scene
// just to add it back again, but it saves us from having to update
// 3 variables 10 times a second.
bool flyingTemp = m_physicsActor.Flying;
RemoveFromPhysicalScene();
//m_scene.PhysicsScene.RemoveAvatar(m_physicsActor);
//PhysicsActor = null;
AddToPhysicalScene(flyingTemp);
}
}
#region Bake Cache Check
if (textureEntry != null)
{
for (int i = 0; i < BAKE_INDICES.Length; i++)
{
int j = BAKE_INDICES[i];
Primitive.TextureEntryFace face = textureEntry.FaceTextures[j];
if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE)
{
if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
{
m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + j + ") for avatar " + this.Name);
this.ControllingClient.SendRebakeAvatarTextures(face.TextureID);
}
}
}
}
#endregion Bake Cache Check
m_appearance.SetAppearance(textureEntry, visualParams);
if (m_appearance.AvatarHeight > 0)
SetHeight(m_appearance.AvatarHeight);
// This is not needed, because only the transient data changed
//AvatarData adata = new AvatarData(m_appearance);
//m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
SendAppearanceToAllOtherAgents();
if (!m_startAnimationSet)
{
Animator.UpdateMovementAnimations();
m_startAnimationSet = true;
}
Vector3 pos = m_pos;
pos.Z += m_appearance.HipOffset;
m_controllingClient.SendAvatarDataImmediate(this);
}
public void SetWearable(int wearableId, AvatarWearable wearable)
{
m_appearance.SetWearable(wearableId, wearable);
AvatarData adata = new AvatarData(m_appearance);
m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
}
// Because appearance setting is in a module, we actually need
// to give it access to our appearance directly, otherwise we
// get a synchronization issue.
@ -3017,6 +2938,9 @@ namespace OpenSim.Region.Framework.Scenes
cAgent.AlwaysRun = m_setAlwaysRun;
cAgent.Appearance = new AvatarAppearance(m_appearance);
/*
try
{
// We might not pass the Wearables in all cases...
@ -3056,14 +2980,14 @@ namespace OpenSim.Region.Framework.Scenes
{
//m_log.DebugFormat("[SCENE PRESENCE]: attachments {0}", attPoints.Count);
int i = 0;
AttachmentData[] attachs = new AttachmentData[attPoints.Count];
AvatarAttachment[] attachs = new AvatarAttachment[attPoints.Count];
foreach (int point in attPoints)
{
attachs[i++] = new AttachmentData(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
attachs[i++] = new AvatarAttachment(point, m_appearance.GetAttachedItem(point), m_appearance.GetAttachedAsset(point));
}
cAgent.Attachments = attachs;
}
*/
lock (scriptedcontrols)
{
ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
@ -3090,6 +3014,9 @@ namespace OpenSim.Region.Framework.Scenes
public void CopyFrom(AgentData cAgent)
{
// DEBUG ON
m_log.ErrorFormat("[SCENEPRESENCE] CALLING COPYFROM");
// DEBUG OFF
m_originRegionID = cAgent.RegionID;
m_callbackURI = cAgent.CallbackURI;
@ -3115,6 +3042,9 @@ namespace OpenSim.Region.Framework.Scenes
m_godLevel = cAgent.GodLevel;
m_setAlwaysRun = cAgent.AlwaysRun;
m_appearance = new AvatarAppearance(cAgent.Appearance);
/*
uint i = 0;
try
{
@ -3127,15 +3057,17 @@ namespace OpenSim.Region.Framework.Scenes
UUID assetId = cAgent.Wearables[n + 1];
wears[i++] = new AvatarWearable(itemId, assetId);
}
m_appearance.Wearables = wears;
Primitive.TextureEntry te;
// m_appearance.Wearables = wears;
Primitive.TextureEntry textures = null;
if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1)
te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length);
else
te = AvatarAppearance.GetDefaultTexture();
if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT))
cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams();
m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone());
textures = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length);
byte[] visuals = null;
if ((cAgent.VisualParams != null) && (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT))
visuals = (byte[])cAgent.VisualParams.Clone();
m_appearance = new AvatarAppearance(cAgent.AgentID,wears,textures,visuals);
}
catch (Exception e)
{
@ -3148,14 +3080,14 @@ namespace OpenSim.Region.Framework.Scenes
if (cAgent.Attachments != null)
{
m_appearance.ClearAttachments();
foreach (AttachmentData att in cAgent.Attachments)
foreach (AvatarAttachment att in cAgent.Attachments)
{
m_appearance.SetAttachment(att.AttachPoint, att.ItemID, att.AssetID);
}
}
}
catch { }
*/
try
{
lock (scriptedcontrols)
@ -3724,15 +3656,16 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
List<int> attPoints = m_appearance.GetAttachedPoints();
foreach (int p in attPoints)
List<AvatarAttachment> attachments = m_appearance.GetAttachments();
foreach (AvatarAttachment attach in attachments)
{
if (m_isDeleted)
return;
UUID itemID = m_appearance.GetAttachedItem(p);
int p = attach.AttachPoint;
UUID itemID = attach.ItemID;
//UUID assetID = m_appearance.GetAttachedAsset(p);
//UUID assetID = attach.AssetID;
// For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
// But they're not used anyway, the item is being looked up for now, so let's proceed.
//if (UUID.Zero == assetID)

View File

@ -804,7 +804,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
private static void ProcessShpTextureEntry(PrimitiveBaseShape shp, XmlTextReader reader)
{
byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry"));
shp.Textures = new Primitive.TextureEntry(teData, 0, teData.Length);
shp.Textures = new Primitive.TextureEntry(teData, 0, teData.Length);
}
private static void ProcessShpExtraParams(PrimitiveBaseShape shp, XmlTextReader reader)

View File

@ -676,7 +676,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
public event DeRezObject OnDeRezObject;
public event Action<IClientAPI> OnRegionHandShakeReply;
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;
@ -899,7 +899,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
Scene scene = (Scene)Scene;
AvatarAppearance appearance;
scene.GetAvatarAppearance(this, out appearance);
OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone());
OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone());
}
public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)

View File

@ -220,7 +220,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
groupID, groupMembers.Count);
foreach (GroupMembersData member in groupMembers)
{
{
if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID))
{
// Don't deliver messages to people who have dropped this session
@ -266,7 +266,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
void OnClientLogin(IClientAPI client)
{
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name);
if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: OnInstantMessage registered for {0}", client.Name);
}
private void OnNewClient(IClientAPI client)

View File

@ -32,7 +32,7 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
class ExtensionHandler : IExtension
class ExtensionHandler : IExtension
{
private readonly Dictionary<Type, object> m_instances;

View File

@ -50,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>();
private readonly Dictionary<Type,object> m_extensions = new Dictionary<Type, object>();
@ -77,7 +77,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
m_log.Info("[MRM] Enabling MRM Module");
m_scene = scene;
// when hidden, we don't listen for client initiated script events
// only making the MRM engine available for region modules
if (!source.Configs["MRM"].GetBoolean("Hidden", false))
@ -85,7 +85,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
scene.EventManager.OnRezScript += EventManager_OnRezScript;
scene.EventManager.OnStopScript += EventManager_OnStopScript;
}
scene.EventManager.OnFrame += EventManager_OnFrame;
scene.RegisterModuleInterface<IMRMModule>(this);
@ -291,7 +291,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public void InitializeMRM(MRMBase mmb, uint localID, UUID itemID)
{
m_log.Info("[MRM] Created MRM Instance");
IWorld world;
@ -304,7 +303,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public void PostInitialise()
{
}
public void Close()
@ -350,7 +348,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
if (!Directory.Exists(tmp))
Directory.CreateDirectory(tmp);
m_log.Info("MRM 2");
try
@ -396,8 +393,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
parameters.IncludeDebugInformation = true;
string rootPath =
Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
List<string> libraries = new List<string>();
string[] lines = Script.Split(new string[] {"\n"}, StringSplitOptions.RemoveEmptyEntries);

View File

@ -29,6 +29,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Security;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
@ -81,16 +82,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
get {
List<IAvatarAttachment> attachments = new List<IAvatarAttachment>();
Hashtable internalAttachments = GetSP().Appearance.GetAttachments();
if (internalAttachments != null)
List<AvatarAttachment> internalAttachments = GetSP().Appearance.GetAttachments();
foreach (AvatarAttachment attach in internalAttachments)
{
foreach (DictionaryEntry element in internalAttachments)
{
Hashtable attachInfo = (Hashtable)element.Value;
attachments.Add(new SPAvatarAttachment(m_rootScene, this, (int) element.Key,
new UUID((string) attachInfo["item"]),
new UUID((string) attachInfo["asset"]), m_security));
}
attachments.Add(new SPAvatarAttachment(m_rootScene, this, attach.AttachPoint,
new UUID(attach.ItemID),
new UUID(attach.AssetID), m_security));
}
return attachments.ToArray();

View File

@ -188,7 +188,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public event DeRezObject OnDeRezObject;
public event Action<IClientAPI> OnRegionHandShakeReply;
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;

View File

@ -64,15 +64,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
if (m_appearanceCache.ContainsKey(target))
return m_appearanceCache[target];
AvatarData adata = scene.AvatarService.GetAvatar(target);
if (adata != null)
AvatarAppearance appearance = scene.AvatarService.GetAppearance(target);
if (appearance != null)
{
AvatarAppearance x = adata.ToAvatarAppearance(target);
m_appearanceCache.Add(target, x);
return x;
m_appearanceCache.Add(target, appearance);
return appearance;
}
return new AvatarAppearance();
}
@ -169,7 +167,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
{
AvatarAppearance x = GetAppearance(p_cloneAppearanceFrom, p_scene);
sp.SetAppearance(x.Texture, (byte[])x.VisualParams.Clone());
sp.Appearance.SetTextureEntries(x.Texture);
sp.Appearance.SetVisualParams((byte[])x.VisualParams.Clone());
sp.SendAppearanceToAllOtherAgents();
}
m_avatars.Add(npcAvatar.AgentId, npcAvatar);

View File

@ -51,6 +51,20 @@ namespace OpenSim.Services.AvatarService
m_log.Debug("[AVATAR SERVICE]: Starting avatar service");
}
// Get|SetAppearance should preserve existing semantics
// until AvatarData can be removed completely
public AvatarAppearance GetAppearance(UUID principalID)
{
AvatarData avatar = GetAvatar(principalID);
return avatar.ToAvatarAppearance(principalID);
}
public bool SetAppearance(UUID principalID, AvatarAppearance appearance)
{
AvatarData avatar = new AvatarData(appearance);
return SetAvatar(principalID,avatar);
}
public AvatarData GetAvatar(UUID principalID)
{
AvatarBaseData[] av = m_Database.Get("PrincipalID", principalID.ToString());

View File

@ -87,6 +87,18 @@ namespace OpenSim.Services.Connectors
#region IAvatarService
public AvatarAppearance GetAppearance(UUID userID)
{
AvatarData avatar = GetAvatar(userID);
return avatar.ToAvatarAppearance(userID);
}
public bool SetAppearance(UUID userID, AvatarAppearance appearance)
{
AvatarData avatar = new AvatarData(appearance);
return SetAvatar(userID,avatar);
}
public AvatarData GetAvatar(UUID userID)
{
Dictionary<string, object> sendData = new Dictionary<string, object>();

View File

@ -28,6 +28,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
// DEBUG ON
using System.Diagnostics;
// DEBUG OFF
using System.Reflection;
using log4net;
using Mono.Addins;
@ -106,6 +109,80 @@ namespace OpenSim.Services.Connectors.SimianGrid
#region IAvatarService
// <summary>
// Retrieves the LLPackedAppearance field from user data and unpacks
// it into an AvatarAppearance structure
// </summary>
// <param name="userID"></param>
public AvatarAppearance GetAppearance(UUID userID)
{
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "GetUser" },
{ "UserID", userID.ToString() }
};
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
if (response["Success"].AsBoolean())
{
OSDMap map = null;
try { map = OSDParser.DeserializeJson(response["LLPackedAppearance"].AsString()) as OSDMap; }
catch { }
if (map != null)
{
AvatarAppearance appearance = new AvatarAppearance(map);
// DEBUG ON
m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR] retrieved appearance for {0}:\n{1}",userID,appearance.ToString());
// DEBUG OFF
return appearance;
}
m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to decode appearance for {0}",userID);
return null;
}
m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to get appearance for {0}: {1}",
userID,response["Message"].AsString());
return null;
}
// <summary>
// </summary>
// <param name=""></param>
public bool SetAppearance(UUID userID, AvatarAppearance appearance)
{
OSDMap map = appearance.Pack();
if (map == null)
{
m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to encode appearance for {0}",userID);
return false;
}
// DEBUG ON
m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR] save appearance for {0}",userID);
// DEBUG OFF
NameValueCollection requestArgs = new NameValueCollection
{
{ "RequestMethod", "AddUserData" },
{ "UserID", userID.ToString() },
{ "LLPackedAppearance", OSDParser.SerializeJsonString(map) }
};
OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs);
bool success = response["Success"].AsBoolean();
if (! success)
m_log.WarnFormat("[SIMIAN AVATAR CONNECTOR]: Failed to save appearance for {0}: {1}",
userID,response["Message"].AsString());
return success;
}
// <summary>
// </summary>
// <param name=""></param>
public AvatarData GetAvatar(UUID userID)
{
NameValueCollection requestArgs = new NameValueCollection
@ -154,7 +231,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
foreach (KeyValuePair<string, OSD> kvp in map)
avatar.Data[kvp.Key] = kvp.Value.AsString();
}
return avatar;
}
else
@ -173,6 +250,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
return null;
}
// <summary>
// </summary>
// <param name=""></param>
public bool SetAvatar(UUID userID, AvatarData avatar)
{
m_log.Debug("[SIMIAN AVATAR CONNECTOR]: SetAvatar called for " + userID);

View File

@ -37,6 +37,21 @@ namespace OpenSim.Services.Interfaces
{
public interface IAvatarService
{
/// <summary>
/// Called by the login service
/// </summary>
/// <param name="userID"></param>
/// <returns></returns>
AvatarAppearance GetAppearance(UUID userID);
/// <summary>
/// Called by everyone who can change the avatar data (so, regions)
/// </summary>
/// <param name="userID"></param>
/// <param name="appearance"></param>
/// <returns></returns>
bool SetAppearance(UUID userID, AvatarAppearance appearance);
/// <summary>
/// Called by the login service
/// </summary>
@ -163,17 +178,11 @@ namespace OpenSim.Services.Interfaces
Data["UnderShirtAsset"] = appearance.UnderShirtAsset.ToString();
// Attachments
Hashtable attachs = appearance.GetAttachments();
if (attachs != null)
foreach (DictionaryEntry dentry in attachs)
{
if (dentry.Value != null)
{
Hashtable tab = (Hashtable)dentry.Value;
if (tab.ContainsKey("item") && tab["item"] != null)
Data["_ap_" + dentry.Key] = tab["item"].ToString();
}
}
List<AvatarAttachment> attachments = appearance.GetAttachments();
foreach (AvatarAttachment attach in attachments)
{
Data["_ap_" + attach.AttachPoint] = attach.ItemID.ToString();
}
}
public AvatarAppearance ToAvatarAppearance(UUID owner)
@ -217,23 +226,26 @@ namespace OpenSim.Services.Interfaces
foreach (KeyValuePair<string, string> _kvp in Data)
if (_kvp.Key.StartsWith("_ap_"))
attchs[_kvp.Key] = _kvp.Value;
Hashtable aaAttachs = new Hashtable();
foreach (KeyValuePair<string, string> _kvp in attchs)
{
string pointStr = _kvp.Key.Substring(4);
int point = 0;
if (!Int32.TryParse(pointStr, out point))
continue;
Hashtable tmp = new Hashtable();
UUID uuid = UUID.Zero;
UUID.TryParse(_kvp.Value, out uuid);
tmp["item"] = uuid;
tmp["asset"] = UUID.Zero.ToString();
aaAttachs[point] = tmp;
appearance.SetAttachment(point,uuid,UUID.Zero);
}
appearance.SetAttachments(aaAttachs);
}
catch { }
catch
{
// We really should report something here, returning null
// will at least break the wrapper
return null;
}
return appearance;
}

View File

@ -330,10 +330,10 @@ namespace OpenSim.Services.LLLoginService
//
// Get the avatar
//
AvatarData avatar = null;
AvatarAppearance avatar = null;
if (m_AvatarService != null)
{
avatar = m_AvatarService.GetAvatar(account.PrincipalID);
avatar = m_AvatarService.GetAppearance(account.PrincipalID);
}
//
@ -602,7 +602,7 @@ namespace OpenSim.Services.LLLoginService
}
}
protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarData avatar,
protected AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarAppearance avatar,
UUID session, UUID secureSession, Vector3 position, string currentWhere, string viewer, string channel, string mac, string id0,
IPEndPoint clientIP, out string where, out string reason, out GridRegion dest)
{
@ -696,14 +696,14 @@ namespace OpenSim.Services.LLLoginService
}
private AgentCircuitData MakeAgent(GridRegion region, UserAccount account,
AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position,
AvatarAppearance avatar, UUID session, UUID secureSession, uint circuit, Vector3 position,
string ipaddress, string viewer, string channel, string mac, string id0)
{
AgentCircuitData aCircuit = new AgentCircuitData();
aCircuit.AgentID = account.PrincipalID;
if (avatar != null)
aCircuit.Appearance = avatar.ToAvatarAppearance(account.PrincipalID);
aCircuit.Appearance = new AvatarAppearance(avatar);
else
aCircuit.Appearance = new AvatarAppearance(account.PrincipalID);

View File

@ -94,7 +94,7 @@ namespace OpenSim.Tests.Common.Mock
public event DeRezObject OnDeRezObject;
public event Action<IClientAPI> OnRegionHandShakeReply;
public event GenericCall2 OnRequestWearables;
public event GenericCall1 OnRequestWearables;
public event GenericCall1 OnCompleteMovementToRegion;
public event UpdateAgent OnPreAgentUpdate;
public event UpdateAgent OnAgentUpdate;

View File

@ -255,6 +255,20 @@
; OpenJPEG if false
; UseCSJ2K = true
; Persist avatar baked textures
; Persisting baked textures can speed up login and region border
; crossings especially with large numbers of users, though it
; will store potentially large numbers of textures in your asset
; database
PersistBakedTextures = false
; Control the delay before appearance is sent to other avatars and
; saved in the avatar service. Attempts to limit the impact caused
; by the very chatty dialog that sets appearance when an avatar
; logs in or teleports into a region; values are in seconds
DelayBeforeAppearanceSave = 5
DelayBeforeAppearanceSend = 2
[SMTP]
enabled=false