fix saving appearence to notecard, so they can work on older regions
parent
85aa77566b
commit
63b0bd7f6b
|
@ -58,7 +58,7 @@ namespace OpenSim.Framework
|
|||
public const int TEXTURE_COUNT_PV7 = 26;
|
||||
public const int BAKES_COUNT_PV7 = 6;
|
||||
public const int MAXWEARABLE_PV7 = 16;
|
||||
public const int MAXWEARABLE_LEGACY = 14;
|
||||
public const int MAXWEARABLE_LEGACY = 15;
|
||||
|
||||
public readonly static byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20, 40, 41, 42, 43, 44 };
|
||||
|
||||
|
@ -739,8 +739,6 @@ namespace OpenSim.Framework
|
|||
return data;
|
||||
|
||||
bool sendPV8 = false;
|
||||
if(ctx != null)
|
||||
sendPV8 = ctx.OutboundVersion >= 0.8;
|
||||
|
||||
// Wearables
|
||||
OSDArray wears;
|
||||
|
@ -749,31 +747,33 @@ namespace OpenSim.Framework
|
|||
count = MAXWEARABLE_LEGACY;
|
||||
else
|
||||
{
|
||||
int wbcount = ctx.WearablesCount;
|
||||
if (wbcount == -1)
|
||||
wbcount = m_wearables.Length;
|
||||
|
||||
count = wbcount;
|
||||
if(count > MAXWEARABLE_PV7)
|
||||
if(ctx.OutboundVersion >= 0.8)
|
||||
{
|
||||
sendPV8 = true;
|
||||
count = m_wearables.Length;
|
||||
}
|
||||
else if (ctx.OutboundVersion >= 0.6)
|
||||
count = MAXWEARABLE_PV7;
|
||||
if(sendPV8)
|
||||
else
|
||||
count = MAXWEARABLE_LEGACY;
|
||||
|
||||
if (sendPV8 && count > MAXWEARABLE_PV7)
|
||||
{
|
||||
wears = new OSDArray(wbcount - MAXWEARABLE_PV7);
|
||||
for (int i = MAXWEARABLE_PV7; i < wbcount; ++i)
|
||||
wears = new OSDArray(count - MAXWEARABLE_PV7);
|
||||
for (int i = MAXWEARABLE_PV7; i < count; ++i)
|
||||
wears.Add(m_wearables[i].Pack());
|
||||
|
||||
data["wrbls8"] = wears;
|
||||
}
|
||||
count = MAXWEARABLE_PV7;
|
||||
}
|
||||
}
|
||||
|
||||
wears = new OSDArray(count);
|
||||
for (int i = 0; i < count; i++)
|
||||
for (int i = 0; i < count; ++i)
|
||||
wears.Add(m_wearables[i].Pack());
|
||||
data["wearables"] = wears;
|
||||
|
||||
// Avatar Textures and preferences hover
|
||||
// Avatar Textures
|
||||
OSDArray textures;
|
||||
if (sendPV8)
|
||||
{
|
||||
|
@ -783,7 +783,7 @@ namespace OpenSim.Framework
|
|||
else
|
||||
{
|
||||
textures = new OSDArray(TEXTURE_COUNT_PV7);
|
||||
for (uint i = 0; i < TEXTURE_COUNT_PV7; i++)
|
||||
for (uint i = 0; i < TEXTURE_COUNT_PV7; ++i)
|
||||
textures.Add(OSD.FromUUID(m_texture.GetFace(i).TextureID));
|
||||
data["textures"] = textures;
|
||||
}
|
||||
|
@ -814,6 +814,64 @@ namespace OpenSim.Framework
|
|||
return data;
|
||||
}
|
||||
|
||||
public OSDMap PackForNotecard()
|
||||
{
|
||||
OSDMap data = new OSDMap();
|
||||
|
||||
data["serial"] = OSD.FromInteger(m_serial);
|
||||
data["height"] = OSD.FromReal(m_avatarHeight);
|
||||
data["aphz"] = OSD.FromReal(AvatarPreferencesHoverZ);
|
||||
|
||||
// old regions may not like missing/empty wears
|
||||
OSDArray wears = new OSDArray(MAXWEARABLE_LEGACY);
|
||||
for (int i = 0; i< MAXWEARABLE_LEGACY; ++i)
|
||||
wears.Add(new OSDArray());
|
||||
data["wearables"] = wears;
|
||||
|
||||
// Avatar Textures
|
||||
OSDArray textures;
|
||||
|
||||
// allow old regions to still see something
|
||||
textures = new OSDArray(TEXTURE_COUNT_PV7);
|
||||
textures.Add(OSD.FromUUID(AppearanceManager.DEFAULT_AVATAR_TEXTURE));
|
||||
for (uint i = 1; i < TEXTURE_COUNT_PV7; ++i)
|
||||
textures.Add(OSD.FromUUID(m_texture.GetFace(i).TextureID));
|
||||
data["textures"] = textures;
|
||||
|
||||
bool needExtra = false;
|
||||
for (int i = BAKES_COUNT_PV7; i < BAKE_INDICES.Length; ++i)
|
||||
{
|
||||
int idx = BAKE_INDICES[i];
|
||||
if (m_texture.FaceTextures[idx] == null)
|
||||
continue;
|
||||
if (m_texture.FaceTextures[idx].TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE ||
|
||||
m_texture.FaceTextures[idx].TextureID == UUID.Zero)
|
||||
continue;
|
||||
needExtra = true;
|
||||
}
|
||||
|
||||
if (needExtra)
|
||||
{
|
||||
byte[] te = m_texture.GetBakesBytes();
|
||||
data["te8"] = OSD.FromBinary(te);
|
||||
}
|
||||
|
||||
// Visual Parameters
|
||||
OSDBinary visualparams = new OSDBinary(m_visualparams);
|
||||
data["visualparams"] = visualparams;
|
||||
|
||||
lock (m_attachments)
|
||||
{
|
||||
// Attachments
|
||||
OSDArray attachs = new OSDArray(m_attachments.Count);
|
||||
foreach (AvatarAttachment attach in GetAttachments())
|
||||
attachs.Add(attach.Pack());
|
||||
data["attachments"] = attachs;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unpack and OSDMap and initialize the appearance
|
||||
/// from it
|
||||
|
@ -855,6 +913,8 @@ namespace OpenSim.Framework
|
|||
if (data.TryGetValue("wearables", out tmpOSD) && (tmpOSD is OSDArray))
|
||||
{
|
||||
OSDArray wears = (OSDArray)tmpOSD;
|
||||
if(wears.Count + wears8Count > 0)
|
||||
{
|
||||
m_wearables = new AvatarWearable[wears.Count + wears8Count];
|
||||
|
||||
for (int i = 0; i < wears.Count; ++i)
|
||||
|
@ -865,12 +925,15 @@ namespace OpenSim.Framework
|
|||
m_wearables[i + wears.Count] = new AvatarWearable((OSDArray)wears8[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables");
|
||||
}
|
||||
|
||||
if (data.TryGetValue("textures", out tmpOSD) && (tmpOSD is OSDArray))
|
||||
if (data.TryGetValue("te8", out tmpOSD))
|
||||
{
|
||||
byte[] teb = tmpOSD.AsBinary();
|
||||
Primitive.TextureEntry te = new Primitive.TextureEntry(teb, 0, teb.Length);
|
||||
m_texture = te;
|
||||
}
|
||||
else if (data.TryGetValue("textures", out tmpOSD) && (tmpOSD is OSDArray))
|
||||
{
|
||||
OSDArray textures = (OSDArray)tmpOSD;
|
||||
for (int i = 0; i < textures.Count && i < TEXTURE_COUNT_PV7; ++i)
|
||||
|
@ -880,12 +943,6 @@ namespace OpenSim.Framework
|
|||
m_texture.CreateFace((uint)i).TextureID = tmpOSD.AsUUID();
|
||||
}
|
||||
}
|
||||
if (data.TryGetValue("te8", out tmpOSD))
|
||||
{
|
||||
byte[] teb = tmpOSD.AsBinary();
|
||||
Primitive.TextureEntry te = new Primitive.TextureEntry(teb, 0, teb.Length);
|
||||
m_texture = te;
|
||||
}
|
||||
|
||||
if (data.TryGetValue("bakedcache", out tmpOSD) && (tmpOSD is OSDArray))
|
||||
{
|
||||
|
@ -970,8 +1027,8 @@ namespace OpenSim.Framework
|
|||
int idx = BAKE_INDICES[i];
|
||||
if (m_texture.FaceTextures[idx] == null)
|
||||
continue;
|
||||
UUID tid = m_texture.FaceTextures[idx].TextureID;
|
||||
if(tid == AppearanceManager.DEFAULT_AVATAR_TEXTURE || tid == UUID.Zero)
|
||||
if (m_texture.FaceTextures[idx].TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE ||
|
||||
m_texture.FaceTextures[idx].TextureID == UUID.Zero)
|
||||
continue;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3456,10 +3456,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return SaveAppearanceToNotecard(m_host.OwnerID, notecard);
|
||||
}
|
||||
|
||||
public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard)
|
||||
public LSL_Key osAgentSaveAppearance(LSL_Key avatarKey, string notecard)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance");
|
||||
|
||||
UUID avatarId;
|
||||
if (!UUID.TryParse(avatarKey, out avatarId))
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
|
||||
return SaveAppearanceToNotecard(avatarId, notecard);
|
||||
}
|
||||
|
||||
|
@ -3470,8 +3474,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
if (appearanceModule != null)
|
||||
{
|
||||
appearanceModule.SaveBakedTextures(sp.UUID);
|
||||
EntityTransferContext ctx = new EntityTransferContext();
|
||||
OSDMap appearancePacked = sp.Appearance.Pack(ctx);
|
||||
OSDMap appearancePacked = sp.Appearance.PackForNotecard();
|
||||
|
||||
TaskInventoryItem item
|
||||
= SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true);
|
||||
|
@ -3494,15 +3497,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return SaveAppearanceToNotecard(sp, notecard);
|
||||
}
|
||||
|
||||
protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard)
|
||||
{
|
||||
UUID avatarId;
|
||||
if (!UUID.TryParse(rawAvatarId, out avatarId))
|
||||
return new LSL_Key(UUID.Zero.ToString());
|
||||
|
||||
return SaveAppearanceToNotecard(avatarId, notecard);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the gender as specified in avatar appearance for a given avatar key
|
||||
/// </summary>
|
||||
|
|
|
@ -451,9 +451,9 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
|||
double scale;
|
||||
double invscale;
|
||||
|
||||
if ((angle + 1f) > 0.05f)
|
||||
if ((angle + 1.0) > 0.0005)
|
||||
{
|
||||
if ((1f - angle) >= 0.05f)
|
||||
if ((1f - angle) >= 0.0005)
|
||||
{
|
||||
// slerp
|
||||
double theta = Math.Acos(angle);
|
||||
|
|
Loading…
Reference in New Issue