protected void SetPrimitiveShapeParams(ISceneChildEntity part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge)
{
ObjectShapePacket.ObjectDataBlock shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist);
shapeBlock.ProfileCurve += fudge;
// profile/path swapped for a torrus, tube, ring
shapeBlock.PathBegin = shapeBlock.ProfileBegin;
shapeBlock.PathEnd = shapeBlock.ProfileEnd;
if (holesize.x < 0.05f)
{
holesize.x = 0.05f;
}
if (holesize.x > 1f)
{
holesize.x = 1f;
}
if (holesize.y < 0.05f)
{
holesize.y = 0.05f;
}
if (holesize.y > 0.5f)
{
holesize.y = 0.5f;
}
float tempFloat = (float)(100.0d * (2.0d - holesize.x));
shapeBlock.PathScaleX = (byte)tempFloat;
tempFloat = (float)(100.0d * (2.0d - holesize.y));
shapeBlock.PathScaleY = (byte)tempFloat;
if (topshear.x < -0.5f)
{
topshear.x = -0.5f;
}
if (topshear.x > 0.5f)
{
topshear.x = 0.5f;
}
if (topshear.y < -0.5f)
{
topshear.y = -0.5f;
}
if (topshear.y > 0.5f)
{
topshear.y = 0.5f;
}
tempFloat = (float)(100.0d * topshear.x);
shapeBlock.PathShearX = (byte)tempFloat;
tempFloat = (float)(100.0d * topshear.y);
shapeBlock.PathShearY = (byte)tempFloat;
if (profilecut.x < 0f)
{
profilecut.x = 0f;
}
if (profilecut.x > 1f)
{
profilecut.x = 1f;
}
if (profilecut.y < 0f)
{
profilecut.y = 0f;
}
if (profilecut.y > 1f)
{
profilecut.y = 1f;
}
if (profilecut.y - profilecut.x < 0.05f)
{
profilecut.x = profilecut.y - 0.05f;
if (profilecut.x < 0.0f)
{
profilecut.x = 0.0f;
profilecut.y = 0.05f;
}
}
shapeBlock.ProfileBegin = (ushort)(50000 * profilecut.x);
shapeBlock.ProfileEnd = (ushort)(50000 * (1 - profilecut.y));
if (taper_a.x < -1f)
{
taper_a.x = -1f;
}
if (taper_a.x > 1f)
{
taper_a.x = 1f;
}
if (taper_a.y < -1f)
{
taper_a.y = -1f;
}
if (taper_a.y > 1f)
{
taper_a.y = 1f;
}
tempFloat = (float)(100.0d * taper_a.x);
shapeBlock.PathTaperX = (sbyte)tempFloat;
tempFloat = (float)(100.0d * taper_a.y);
shapeBlock.PathTaperY = (sbyte)tempFloat;
if (revolutions < 1f)
{
revolutions = 1f;
}
if (revolutions > 4f)
{
revolutions = 4f;
}
tempFloat = 66.66667f * (revolutions - 1.0f);
shapeBlock.PathRevolutions = (byte)tempFloat;
// limits on radiusoffset depend on revolutions and hole size (how?) seems like the maximum range is 0 to 1
if (radiusoffset < 0f)
{
radiusoffset = 0f;
}
if (radiusoffset > 1f)
{
radiusoffset = 1f;
}
tempFloat = 100.0f * radiusoffset;
shapeBlock.PathRadiusOffset = (sbyte)tempFloat;
if (skew < -0.95f)
{
skew = -0.95f;
}
if (skew > 0.95f)
{
skew = 0.95f;
}
tempFloat = 100.0f * skew;
shapeBlock.PathSkew = (sbyte)tempFloat;
part.Shape.SculptEntry = false;
part.UpdateShape(shapeBlock);
}