From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001 From: onefang Date: Sun, 19 May 2019 21:24:15 +1000 Subject: Dump OpenSim 0.9.0.1 into it's own branch. --- OpenSim/Framework/PrimitiveBaseShape.cs | 153 +++++++++++++++++++++++++++----- 1 file changed, 131 insertions(+), 22 deletions(-) (limited to 'OpenSim/Framework/PrimitiveBaseShape.cs') diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index c8a5376..6e7a038 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -238,8 +238,8 @@ namespace OpenSim.Framework SculptTexture = prim.Sculpt.SculptTexture; SculptType = (byte)prim.Sculpt.Type; } - else - { + else + { SculptType = (byte)OpenMetaverse.SculptType.None; } } @@ -328,6 +328,72 @@ namespace OpenSim.Framework return shape; } + public static PrimitiveBaseShape CreateMesh(int numberOfFaces, UUID meshAssetID) + { + PrimitiveBaseShape shape = new PrimitiveBaseShape(); + + shape._pathScaleX = 100; + shape._pathScaleY = 100; + + if(numberOfFaces <= 0) // oops ? + numberOfFaces = 1; + + switch(numberOfFaces) + { + case 1: // torus + shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; + shape.PathCurve = (byte)Extrusion.Curve1; + shape._pathScaleY = 150; + break; + + case 2: // torus with hollow (a sl viewer whould see 4 faces on a hollow sphere) + shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; + shape.PathCurve = (byte)Extrusion.Curve1; + shape.ProfileHollow = 27500; + shape._pathScaleY = 150; + break; + + case 3: // cylinder + shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; + shape.PathCurve = (byte)Extrusion.Straight; + break; + + case 4: // cylinder with hollow + shape.ProfileCurve = (byte)ProfileShape.Circle | (byte)HollowShape.Triangle; + shape.PathCurve = (byte)Extrusion.Straight; + shape.ProfileHollow = 27500; + break; + + case 5: // prism + shape.ProfileCurve = (byte)ProfileShape.EquilateralTriangle | (byte)HollowShape.Triangle; + shape.PathCurve = (byte)Extrusion.Straight; + break; + + case 6: // box + shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle; + shape.PathCurve = (byte)Extrusion.Straight; + break; + + case 7: // box with hollow + shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle; + shape.PathCurve = (byte)Extrusion.Straight; + shape.ProfileHollow = 27500; + break; + + default: // 8 faces box with cut + shape.ProfileCurve = (byte)ProfileShape.Square | (byte)HollowShape.Triangle; + shape.PathCurve = (byte)Extrusion.Straight; + shape.ProfileBegin = 9375; + break; + } + + shape.SculptEntry = true; + shape.SculptType = (byte)OpenMetaverse.SculptType.Mesh; + shape.SculptTexture = meshAssetID; + + return shape; + } + public void SetScale(float side) { _scale = new Vector3(side, side, side); @@ -728,7 +794,12 @@ namespace OpenSim.Framework return _lightColorR; } set { - _lightColorR = value; + if (value < 0) + _lightColorR = 0; + else if (value > 1.0f) + _lightColorR = 1.0f; + else + _lightColorR = value; } } @@ -737,7 +808,12 @@ namespace OpenSim.Framework return _lightColorG; } set { - _lightColorG = value; + if (value < 0) + _lightColorG = 0; + else if (value > 1.0f) + _lightColorG = 1.0f; + else + _lightColorG = value; } } @@ -746,7 +822,12 @@ namespace OpenSim.Framework return _lightColorB; } set { - _lightColorB = value; + if (value < 0) + _lightColorB = 0; + else if (value > 1.0f) + _lightColorB = 1.0f; + else + _lightColorB = value; } } @@ -755,7 +836,12 @@ namespace OpenSim.Framework return _lightColorA; } set { - _lightColorA = value; + if (value < 0) + _lightColorA = 0; + else if (value > 1.0f) + _lightColorA = 1.0f; + else + _lightColorA = value; } } @@ -869,6 +955,11 @@ namespace OpenSim.Framework public ulong GetMeshKey(Vector3 size, float lod) { + return GetMeshKey(size, lod, false); + } + + public ulong GetMeshKey(Vector3 size, float lod, bool convex) + { ulong hash = 5381; hash = djb2(hash, this.PathCurve); @@ -914,6 +1005,9 @@ namespace OpenSim.Framework hash = djb2(hash, scaleBytes[i]); } + if(convex) + hash = djb2(hash, 0xa5); + return hash; } @@ -1417,7 +1511,7 @@ namespace OpenSim.Framework prim.Textures = this.Textures; prim.Properties = new Primitive.ObjectProperties(); - prim.Properties.Name = "Primitive"; + prim.Properties.Name = "Object"; prim.Properties.Description = ""; prim.Properties.CreatorID = UUID.Zero; prim.Properties.GroupID = UUID.Zero; @@ -1488,35 +1582,50 @@ namespace OpenSim.Framework { MediaList ml = new MediaList(); ml.ReadXml(rawXml); + if(ml.Count == 0) + return null; return ml; } public void ReadXml(string rawXml) { - using (StringReader sr = new StringReader(rawXml)) + try { - using (XmlTextReader xtr = new XmlTextReader(sr)) + using (StringReader sr = new StringReader(rawXml)) { - xtr.MoveToContent(); + using (XmlTextReader xtr = new XmlTextReader(sr)) + { + xtr.ProhibitDtd = true; - string type = xtr.GetAttribute("type"); - //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type); + xtr.MoveToContent(); - if (type != MEDIA_TEXTURE_TYPE) - return; + string type = xtr.GetAttribute("type"); + //m_log.DebugFormat("[MOAP]: Loaded media texture entry with type {0}", type); - xtr.ReadStartElement("OSMedia"); + if (type != MEDIA_TEXTURE_TYPE) + return; - OSDArray osdMeArray = (OSDArray)OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); - foreach (OSD osdMe in osdMeArray) - { - MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); - Add(me); - } + xtr.ReadStartElement("OSMedia"); + OSD osdp = OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); + if(osdp == null || !(osdp is OSDArray)) + return; - xtr.ReadEndElement(); + OSDArray osdMeArray = osdp as OSDArray; + if(osdMeArray.Count == 0) + return; + + foreach (OSD osdMe in osdMeArray) + { + MediaEntry me = (osdMe is OSDMap ? MediaEntry.FromOSD(osdMe) : new MediaEntry()); + Add(me); + } + } } } + catch + { + m_log.Debug("PrimitiveBaseShape] error decoding MOAP xml" ); + } } public void ReadXml(XmlReader reader) -- cgit v1.1