diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 03a419644e..8829582470 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -154,10 +154,36 @@ namespace OpenSim.Framework [XmlIgnore] public Primitive.RenderMaterials RenderMaterials = null; - public bool MeshFlagEntry { - get { return _meshFlagsEntry;} + get { return _meshFlagsEntry; } + } + + public bool AnimeshEnabled + { + get + { + return(_meshFlagsEntry && + (_meshFlags & 0x01) != 0 && + (_sculptType & 0x07) == (int)OpenMetaverse.SculptType.Mesh); + } + set + { + if((_sculptType & 0x07) != (int)OpenMetaverse.SculptType.Mesh) + { + _meshFlagsEntry = false; + _meshFlags = 0; + return; + } + + if (value) + { + _meshFlagsEntry = true; + _meshFlags |= 1; + } + else + _meshFlags &= 0xfe; + } } public byte ProfileCurve @@ -1115,6 +1141,7 @@ namespace OpenSim.Framework if (!inUse) { _meshFlagsEntry = false; + _meshFlags = 0; return; } ReadMeshFlagsData(data, 0); @@ -1324,16 +1351,8 @@ namespace OpenSim.Framework [MethodImpl(MethodImplOptions.AggressiveInlining)] public void ReadMeshFlagsData(byte[] data, int pos) { - if (data.Length - pos >= 4) - { - _meshFlagsEntry = true; - _meshFlags = Utils.BytesToUInt(data, pos); - } - else - { - _meshFlagsEntry = true; - _meshFlags = 0; - } + _meshFlagsEntry = true; + _meshFlags = data.Length - pos >= 4 ? Utils.BytesToUInt(data, pos) : 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6725893b04..9aeaff7425 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8458,10 +8458,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } // Prim type sculpt. - protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) + protected void SetPrimitiveShapeSculptParams(SceneObjectPart part, string map, int type, byte pathcurve) { - if (part is null || part.ParentGroup is null || part.ParentGroup.IsDeleted) + bool partIsMesh = part.Shape.SculptEntry && (part.Shape.SculptType & ScriptBaseClass.PRIM_SCULPT_TYPE_MASK) == ScriptBaseClass.PRIM_SCULPT_TYPE_MESH; + + int base_type = type & ScriptBaseClass.PRIM_SCULPT_TYPE_MASK; + if(base_type == ScriptBaseClass.PRIM_SCULPT_TYPE_MESH) + { + if(!partIsMesh) + return; + + bool animeshEnable = (type & ScriptBaseClass.PRIM_SCULPT_FLAG_ANIMESH) != 0; + if (animeshEnable != part.Shape.AnimeshEnabled) + { + part.Shape.AnimeshEnabled = animeshEnable; + part.ParentGroup.HasGroupChanged = true; + part.TriggerScriptChangedEvent(Changed.SHAPE); + part.ScheduleFullAnimUpdate(); + } return; + } + if (base_type > 5) + return; + + if (partIsMesh) + return; + + type &= ~ScriptBaseClass.PRIM_SCULPT_FLAG_ANIMESH; if (!UUID.TryParse(map, out UUID sculptId)) sculptId = ScriptUtils.GetAssetIdFromItemName(m_host, map, (int)AssetType.Texture); @@ -8469,6 +8492,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (sculptId.IsZero()) return; + part.Shape.SetSculptProperties((byte)type, sculptId); + part.Shape.SculptEntry = true; + ObjectShapePacket.ObjectDataBlock shapeBlock = new() { PathCurve = pathcurve, @@ -8476,20 +8502,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api PathScaleX = 100, PathScaleY = 150 }; - - int flag = type & (ScriptBaseClass.PRIM_SCULPT_FLAG_INVERT | ScriptBaseClass.PRIM_SCULPT_FLAG_MIRROR); - - if (type != (ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER | flag) && - type != (ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE | flag) && - type != (ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE | flag) && - type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) - { - // default - type |= ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; - } - - part.Shape.SetSculptProperties((byte)type, sculptId); - part.Shape.SculptEntry = true; part.UpdateShape(shapeBlock); } @@ -9457,7 +9469,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Error(originFunc, string.Format("Error running rule #{0} -> PRIM_TYPE, PRIM_TYPE_SCULPT: arg #{1} - parameter 4 must be integer", rulesParsed, idx - idxStart - 1)); return new LSL_List(); } - SetPrimitiveShapeParams(part, map, face, (byte)Extrusion.Curve1); + SetPrimitiveShapeSculptParams(part, map, face, (byte)Extrusion.Curve1); break; } @@ -11143,7 +11155,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case ScriptBaseClass.PRIM_TYPE_SCULPT: res.Add(new LSL_String(Shape.SculptTexture.ToString())); - res.Add(new LSL_Integer(Shape.SculptType)); + int stype = Shape.SculptType; + if (Shape.AnimeshEnabled) + stype |= ScriptBaseClass.PRIM_SCULPT_FLAG_ANIMESH; + else + stype &= ScriptBaseClass.PRIM_SCULPT_FLAG_ANIMESH; + res.Add(new LSL_Integer(stype)); break; case ScriptBaseClass.PRIM_TYPE_RING: diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index de89c548c8..5ea728d9de 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -518,6 +518,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int PRIM_SCULPT_TYPE_TORUS = 2; public const int PRIM_SCULPT_TYPE_PLANE = 3; public const int PRIM_SCULPT_TYPE_CYLINDER = 4; + public const int PRIM_SCULPT_TYPE_MESH = 5; + public const int PRIM_SCULPT_FLAG_ANIMESH = 0x20; public const int PRIM_SCULPT_FLAG_INVERT = 0x40; public const int PRIM_SCULPT_FLAG_MIRROR = 0x80; //ApiDesc Auxiliar to clear flags keeping scultp type