Committing a slightly modified version of [LIBOMV-609] to fix prim serialization/deserialization when TextureEntry or DefaultFace data is missing. Thank you echeslack
git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2915 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -1329,6 +1329,7 @@ namespace OpenMetaverse
|
||||
prim["name"] = OSD.FromString("Object");
|
||||
prim["description"] = OSD.FromString(String.Empty);
|
||||
}
|
||||
|
||||
prim["phantom"] = OSD.FromBoolean(((Flags & PrimFlags.Phantom) != 0));
|
||||
prim["physical"] = OSD.FromBoolean(((Flags & PrimFlags.Physics) != 0));
|
||||
prim["position"] = OSD.FromVector3(Position);
|
||||
@@ -1336,11 +1337,13 @@ namespace OpenMetaverse
|
||||
prim["scale"] = OSD.FromVector3(Scale);
|
||||
prim["material"] = OSD.FromInteger((int)PrimData.Material);
|
||||
prim["shadows"] = OSD.FromBoolean(((Flags & PrimFlags.CastShadows) != 0));
|
||||
prim["textures"] = Textures.GetOSD();
|
||||
prim["volume"] = volume;
|
||||
if (ParentID != 0)
|
||||
prim["parentid"] = OSD.FromInteger(ParentID);
|
||||
prim["parentid"] = OSD.FromInteger(ParentID);
|
||||
|
||||
prim["volume"] = volume;
|
||||
|
||||
if (Textures != null)
|
||||
prim["textures"] = Textures.GetOSD();
|
||||
|
||||
if (Light != null)
|
||||
prim["light"] = Light.GetOSD();
|
||||
|
||||
|
||||
@@ -683,7 +683,11 @@ namespace OpenMetaverse
|
||||
{
|
||||
OSDArray array = new OSDArray();
|
||||
|
||||
// Always add default texture
|
||||
// If DefaultTexture is null, assume the whole TextureEntry is empty
|
||||
if (DefaultTexture == null)
|
||||
return array;
|
||||
|
||||
// Otherwise, always add default texture
|
||||
array.Add(DefaultTexture.GetOSD(-1));
|
||||
|
||||
for (int i = 0; i < MAX_FACES; i++)
|
||||
@@ -697,29 +701,30 @@ namespace OpenMetaverse
|
||||
|
||||
public static TextureEntry FromOSD(OSD osd)
|
||||
{
|
||||
OSDArray array = (OSDArray)osd;
|
||||
OSDMap faceSD;
|
||||
|
||||
if (array.Count > 0)
|
||||
if (osd.Type == OSDType.Array)
|
||||
{
|
||||
int faceNumber;
|
||||
faceSD = (OSDMap)array[0];
|
||||
TextureEntryFace defaultFace = TextureEntryFace.FromOSD(faceSD, null, out faceNumber);
|
||||
TextureEntry te = new TextureEntry(defaultFace);
|
||||
OSDArray array = (OSDArray)osd;
|
||||
OSDMap faceSD;
|
||||
|
||||
for (int i = 1; i < array.Count; i++)
|
||||
if (array.Count > 0)
|
||||
{
|
||||
TextureEntryFace tex = TextureEntryFace.FromOSD(array[i], defaultFace, out faceNumber);
|
||||
if (faceNumber >= 0 && faceNumber < te.FaceTextures.Length)
|
||||
te.FaceTextures[faceNumber] = tex;
|
||||
}
|
||||
int faceNumber;
|
||||
faceSD = (OSDMap)array[0];
|
||||
TextureEntryFace defaultFace = TextureEntryFace.FromOSD(faceSD, null, out faceNumber);
|
||||
TextureEntry te = new TextureEntry(defaultFace);
|
||||
|
||||
return te;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("SD contains no elements");
|
||||
for (int i = 1; i < array.Count; i++)
|
||||
{
|
||||
TextureEntryFace tex = TextureEntryFace.FromOSD(array[i], defaultFace, out faceNumber);
|
||||
if (faceNumber >= 0 && faceNumber < te.FaceTextures.Length)
|
||||
te.FaceTextures[faceNumber] = tex;
|
||||
}
|
||||
|
||||
return te;
|
||||
}
|
||||
}
|
||||
|
||||
return new TextureEntry(UUID.Zero);
|
||||
}
|
||||
|
||||
private void FromBytes(byte[] data, int pos, int length)
|
||||
|
||||
Reference in New Issue
Block a user