From d2d9808742c0ffe47fb7aa6464faf1b2dfb216bf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 23 Aug 2008 16:15:17 +0000 Subject: Thank you, salahzar, for a patch that adds llGetNumberOfSides and will also enable LSLconformance on some texture functions as well. Applied the part of the patch in Shared/. The part for Common/ needs to be reworked to remove the reference into Shared/ --- .../Framework/Communications/Capabilities/Caps.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 107 ++++++++++++++++++++- 2 files changed, 106 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Communications/Capabilities/Caps.cs b/OpenSim/Framework/Communications/Capabilities/Caps.cs index 6946561..18ddd9e 100644 --- a/OpenSim/Framework/Communications/Capabilities/Caps.cs +++ b/OpenSim/Framework/Communications/Capabilities/Caps.cs @@ -631,7 +631,7 @@ namespace OpenSim.Framework.Communications.Capabilities } } - //Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); + //System.Console.WriteLine("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type); string assetName = llsdRequest.name; string assetDes = llsdRequest.description; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2428bc4..c461d3d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3330,11 +3330,114 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } + // this function to understand which shape it is (taken from meshmerizer) + // quite useful can be used by meshmerizer to have a centralized point of understanding the shape + // except that it refers to scripting constants + private int getScriptPrimType(PrimitiveBaseShape primShape) + { + + if (primShape.SculptEntry && primShape.SculptType != (byte)0 && primShape.SculptData.Length > 0) + return ScriptBaseClass.PRIM_TYPE_SCULPT; + if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) + { + if (primShape.PathCurve == (byte)Extrusion.Straight) + return ScriptBaseClass.PRIM_TYPE_BOX; + else if (primShape.PathCurve == (byte)Extrusion.Curve1) + return ScriptBaseClass.PRIM_TYPE_TUBE; + } + else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) + { + if (primShape.PathCurve == (byte)Extrusion.Straight) + return ScriptBaseClass.PRIM_TYPE_CYLINDER; + // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits + else if (primShape.PathCurve == (byte)Extrusion.Curve1) + return ScriptBaseClass.PRIM_TYPE_TORUS; + } + else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle) + { + if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte)Extrusion.Curve2) + return ScriptBaseClass.PRIM_TYPE_SPHERE; + } + else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) + { + if (primShape.PathCurve == (byte)Extrusion.Straight) + return ScriptBaseClass.PRIM_TYPE_PRISM; + else if (primShape.PathCurve == (byte)Extrusion.Curve1) + return ScriptBaseClass.PRIM_TYPE_RING; + } + return ScriptBaseClass.PRIM_TYPE_BOX; + + + } + // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces + private void hasCutHollowDimpleProfileCut(PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, + out bool hasDimple, out bool hasProfileCut) + { + hasCut = (shape.PathBegin > 0) || (shape.PathEnd < 1); + hasHollow = shape.ProfileHollow > 0; + hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd < 1); // taken from llSetPrimitiveParms + hasProfileCut = hasDimple; // is it the same thing? + + } + public LSL_Types.LSLInteger llGetNumberOfSides() { m_host.AddScriptLPS(1); - NotImplemented("llGetNumberOfSides"); - return 0; + int ret = 0; + bool hasCut; + bool hasHollow; + bool hasDimple; + bool hasProfileCut; + + hasCutHollowDimpleProfileCut(m_host.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); + + switch (getScriptPrimType(m_host.Shape)) + { + case ScriptBaseClass.PRIM_TYPE_BOX: + ret = 6; + if (hasCut) ret += 2; + if (hasHollow) ret += 1; + break; + case ScriptBaseClass.PRIM_TYPE_CYLINDER: + ret = 3; + if (hasCut) ret += 2; + if (hasHollow) ret += 1; + break; + case ScriptBaseClass.PRIM_TYPE_PRISM: + ret = 5; + if (hasCut) ret += 2; + if (hasHollow) ret += 1; + break; + case ScriptBaseClass.PRIM_TYPE_SPHERE: + ret = 1; + if (hasCut) ret += 2; + if (hasDimple) ret += 2; + if (hasHollow) ret += 1; // actually lsl adds 4!!!!!! is that a great mistake? + break; + case ScriptBaseClass.PRIM_TYPE_TORUS: + ret = 1; + if (hasCut) ret += 2; + if (hasProfileCut) ret += 2; + if (hasHollow) ret += 1; + break; + case ScriptBaseClass.PRIM_TYPE_TUBE: + ret = 4; + if (hasCut) ret += 2; + if (hasProfileCut) ret += 2; + if (hasHollow) ret += 1; + break; + case ScriptBaseClass.PRIM_TYPE_RING: + ret = 3; + if (hasCut) ret += 2; + if (hasProfileCut) ret += 2; + if (hasHollow) ret += 1; + break; + case ScriptBaseClass.PRIM_TYPE_SCULPT: + ret = 1; + break; + } + + return ret; } -- cgit v1.1