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/0.6.0-stable
parent
72f74acdbf
commit
d2d9808742
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue