Thank you, salahzar, for a patch that corrects the behavior
of PRIM_TYPE in llGetPrimitiveParams() and improves LSL
conformance in llGetNumberOfSides();
This commit is contained in:
Melanie Thielker
2008-08-25 11:58:55 +00:00
parent c67c56ca94
commit cf7020d73c
2 changed files with 187 additions and 21 deletions

View File

@@ -3370,12 +3370,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// 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,
private void hasCutHollowDimpleProfileCut(int primType,PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
out bool hasDimple, out bool hasProfileCut)
{
hasCut = (shape.PathBegin > 0) || (shape.PathEnd < 1);
if (primType == ScriptBaseClass.PRIM_TYPE_BOX
||
primType == ScriptBaseClass.PRIM_TYPE_CYLINDER
||
primType == ScriptBaseClass.PRIM_TYPE_PRISM)
hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
else
hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);
hasHollow = shape.ProfileHollow > 0;
hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd < 1); // taken from llSetPrimitiveParms
hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
hasProfileCut = hasDimple; // is it the same thing?
}
@@ -3389,9 +3398,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
bool hasDimple;
bool hasProfileCut;
hasCutHollowDimpleProfileCut(m_host.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
int primType = getScriptPrimType(m_host.Shape);
hasCutHollowDimpleProfileCut(primType, m_host.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
switch (getScriptPrimType(m_host.Shape))
switch (primType)
{
case ScriptBaseClass.PRIM_TYPE_BOX:
ret = 6;
@@ -3412,7 +3422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ret = 1;
if (hasCut) ret += 2;
if (hasDimple) ret += 2;
if (hasHollow) ret += 1; // actually lsl adds 4!!!!!! is that a great mistake?
if (hasHollow) ret += 3; // Emulate lsl on secondlife (according to documentation it should have added only +1)
break;
case ScriptBaseClass.PRIM_TYPE_TORUS:
ret = 1;
@@ -6013,15 +6023,88 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
case (int)ScriptBaseClass.PRIM_TYPE:
// TODO--------------
res.Add(new LSL_Types.LSLInteger(0));
// implementing box
PrimitiveBaseShape Shape = m_host.Shape;
int primType = getScriptPrimType(m_host.Shape);
res.Add(new LSL_Types.LSLInteger(primType));
switch (primType)
{
case ScriptBaseClass.PRIM_TYPE_BOX:
case ScriptBaseClass.PRIM_TYPE_CYLINDER:
case ScriptBaseClass.PRIM_TYPE_PRISM:
res.Add(new LSL_Types.LSLInteger(Shape.ProfileCurve));
res.Add(new LSL_Types.Vector3(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
res.Add(new LSL_Types.LSLFloat(Shape.ProfileHollow / 50000.0));
res.Add(new LSL_Types.Vector3(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
res.Add(new LSL_Types.Vector3(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0));
res.Add(new LSL_Types.Vector3(Shape.PathShearX / 100.0, Shape.PathShearY / 100.0, 0));
break;
case ScriptBaseClass.PRIM_TYPE_SPHERE:
res.Add(new LSL_Types.LSLInteger(Shape.ProfileCurve));
res.Add(new LSL_Types.Vector3(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
res.Add(new LSL_Types.LSLFloat(Shape.ProfileHollow / 50000.0));
res.Add(new LSL_Types.Vector3(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
res.Add(new LSL_Types.Vector3(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
break;
case ScriptBaseClass.PRIM_TYPE_SCULPT:
res.Add(Shape.SculptTexture.ToString());
res.Add(new LSL_Types.LSLInteger(Shape.SculptType));
break;
case ScriptBaseClass.PRIM_TYPE_RING:
case ScriptBaseClass.PRIM_TYPE_TUBE:
case ScriptBaseClass.PRIM_TYPE_TORUS:
// holeshape
res.Add(new LSL_Types.LSLInteger(Shape.ProfileCurve));
// cut
res.Add(new LSL_Types.Vector3(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0));
// hollow
res.Add(new LSL_Types.LSLFloat(Shape.ProfileHollow / 50000.0));
// twist
res.Add(new LSL_Types.Vector3(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0));
// vector holesize
res.Add(new LSL_Types.Vector3(1 - (Shape.PathScaleX / 100.0 - 1), 1 - (Shape.PathScaleY / 100.0 - 1), 0));
// vector topshear
res.Add(new LSL_Types.Vector3(Shape.PathShearX / 100.0, Shape.PathShearY / 100.0, 0));
// vector profilecut
res.Add(new LSL_Types.Vector3(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0));
// vector tapera
res.Add(new LSL_Types.Vector3(Shape.PathTaperX / 100.0, Shape.PathTaperY / 100.0, 0));
// float revolutions,
res.Add(new LSL_Types.LSLFloat(Shape.PathRevolutions / 50.0)); // needs fixing :(
// float radiusoffset,
res.Add(new LSL_Types.LSLFloat(Shape.PathRadiusOffset / 100.0));
// float skew
res.Add(new LSL_Types.LSLFloat(Shape.PathSkew / 100.0));
break;
}
break;
case (int)ScriptBaseClass.PRIM_TEXTURE:
if (remain < 1)
return res;
int face=Convert.ToInt32(rules.Data[idx++]);
int face = Convert.ToInt32("" + rules.Data[idx++]);
if (face == -1)
face = 0;