Also move the other avatar based overload out of harms way

avinationmerge
Melanie 2012-08-25 18:32:59 +01:00
parent 5f1021faa6
commit 681066050c
1 changed files with 261 additions and 261 deletions

View File

@ -8670,267 +8670,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return res;
}
public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules)
{
// avatars case
// replies as SL wiki
LSL_List res = new LSL_List();
// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed
SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone??
int idx = 0;
while (idx < rules.Length)
{
int code = (int)rules.GetLSLIntegerItem(idx++);
int remain = rules.Length - idx;
switch (code)
{
case (int)ScriptBaseClass.PRIM_MATERIAL:
res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh));
break;
case (int)ScriptBaseClass.PRIM_PHYSICS:
res.Add(new LSL_Integer(0));
break;
case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
res.Add(new LSL_Integer(0));
break;
case (int)ScriptBaseClass.PRIM_PHANTOM:
res.Add(new LSL_Integer(0));
break;
case (int)ScriptBaseClass.PRIM_POSITION:
Vector3 pos = avatar.OffsetPosition;
Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
pos -= sitOffset;
if( sitPart != null)
pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation();
res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
break;
case (int)ScriptBaseClass.PRIM_SIZE:
// as in llGetAgentSize above
res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight));
break;
case (int)ScriptBaseClass.PRIM_ROTATION:
Quaternion rot = avatar.Rotation;
if (sitPart != null)
{
rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation
}
res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W));
break;
case (int)ScriptBaseClass.PRIM_TYPE:
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX));
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT));
res.Add(new LSL_Vector(0f,1.0f,0f));
res.Add(new LSL_Float(0.0f));
res.Add(new LSL_Vector(0, 0, 0));
res.Add(new LSL_Vector(1.0f,1.0f,0f));
res.Add(new LSL_Vector(0, 0, 0));
break;
case (int)ScriptBaseClass.PRIM_TEXTURE:
if (remain < 1)
return res;
int face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_String(""));
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Float(0.0));
}
}
else
{
if (face >= 0 && face < 21)
{
res.Add(new LSL_String(""));
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Float(0.0));
}
}
break;
case (int)ScriptBaseClass.PRIM_COLOR:
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Float(0));
}
}
else
{
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Float(0));
}
break;
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
}
}
else
{
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
}
break;
case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
}
}
else
{
res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
}
break;
case (int)ScriptBaseClass.PRIM_FLEXIBLE:
res.Add(new LSL_Integer(0));
res.Add(new LSL_Integer(0));// softness
res.Add(new LSL_Float(0.0f)); // gravity
res.Add(new LSL_Float(0.0f)); // friction
res.Add(new LSL_Float(0.0f)); // wind
res.Add(new LSL_Float(0.0f)); // tension
res.Add(new LSL_Vector(0f,0f,0f));
break;
case (int)ScriptBaseClass.PRIM_TEXGEN:
// (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
}
}
else
{
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
}
break;
case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
res.Add(new LSL_Integer(0));
res.Add(new LSL_Vector(0f,0f,0f));
res.Add(new LSL_Float(0f)); // intensity
res.Add(new LSL_Float(0f)); // radius
res.Add(new LSL_Float(0f)); // falloff
break;
case (int)ScriptBaseClass.PRIM_GLOW:
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Float(0f));
}
}
else
{
res.Add(new LSL_Float(0f));
}
break;
case (int)ScriptBaseClass.PRIM_TEXT:
res.Add(new LSL_String(""));
res.Add(new LSL_Vector(0f,0f,0f));
res.Add(new LSL_Float(1.0f));
break;
case (int)ScriptBaseClass.PRIM_NAME:
res.Add(new LSL_String(avatar.Name));
break;
case (int)ScriptBaseClass.PRIM_DESC:
res.Add(new LSL_String(""));
break;
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
Quaternion lrot = avatar.Rotation;
if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
{
lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset
}
res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W));
break;
case (int)ScriptBaseClass.PRIM_POS_LOCAL:
Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part
Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
lpos -= lsitOffset;
if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
{
lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
}
res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
break;
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
return res;
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
LSL_List new_rules = rules.GetSublist(idx, -1);
res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
return res;
}
}
return res;
}
public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules)
{
LSL_List res = new LSL_List();
@ -13152,5 +12891,266 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
return null;
}
public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules)
{
// avatars case
// replies as SL wiki
LSL_List res = new LSL_List();
// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed
SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone??
int idx = 0;
while (idx < rules.Length)
{
int code = (int)rules.GetLSLIntegerItem(idx++);
int remain = rules.Length - idx;
switch (code)
{
case (int)ScriptBaseClass.PRIM_MATERIAL:
res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh));
break;
case (int)ScriptBaseClass.PRIM_PHYSICS:
res.Add(new LSL_Integer(0));
break;
case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
res.Add(new LSL_Integer(0));
break;
case (int)ScriptBaseClass.PRIM_PHANTOM:
res.Add(new LSL_Integer(0));
break;
case (int)ScriptBaseClass.PRIM_POSITION:
Vector3 pos = avatar.OffsetPosition;
Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
pos -= sitOffset;
if( sitPart != null)
pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation();
res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
break;
case (int)ScriptBaseClass.PRIM_SIZE:
// as in llGetAgentSize above
res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight));
break;
case (int)ScriptBaseClass.PRIM_ROTATION:
Quaternion rot = avatar.Rotation;
if (sitPart != null)
{
rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation
}
res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W));
break;
case (int)ScriptBaseClass.PRIM_TYPE:
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX));
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT));
res.Add(new LSL_Vector(0f,1.0f,0f));
res.Add(new LSL_Float(0.0f));
res.Add(new LSL_Vector(0, 0, 0));
res.Add(new LSL_Vector(1.0f,1.0f,0f));
res.Add(new LSL_Vector(0, 0, 0));
break;
case (int)ScriptBaseClass.PRIM_TEXTURE:
if (remain < 1)
return res;
int face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_String(""));
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Float(0.0));
}
}
else
{
if (face >= 0 && face < 21)
{
res.Add(new LSL_String(""));
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Float(0.0));
}
}
break;
case (int)ScriptBaseClass.PRIM_COLOR:
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Float(0));
}
}
else
{
res.Add(new LSL_Vector(0,0,0));
res.Add(new LSL_Float(0));
}
break;
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
}
}
else
{
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
}
break;
case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
}
}
else
{
res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
}
break;
case (int)ScriptBaseClass.PRIM_FLEXIBLE:
res.Add(new LSL_Integer(0));
res.Add(new LSL_Integer(0));// softness
res.Add(new LSL_Float(0.0f)); // gravity
res.Add(new LSL_Float(0.0f)); // friction
res.Add(new LSL_Float(0.0f)); // wind
res.Add(new LSL_Float(0.0f)); // tension
res.Add(new LSL_Vector(0f,0f,0f));
break;
case (int)ScriptBaseClass.PRIM_TEXGEN:
// (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
}
}
else
{
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
}
break;
case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
res.Add(new LSL_Integer(0));
res.Add(new LSL_Vector(0f,0f,0f));
res.Add(new LSL_Float(0f)); // intensity
res.Add(new LSL_Float(0f)); // radius
res.Add(new LSL_Float(0f)); // falloff
break;
case (int)ScriptBaseClass.PRIM_GLOW:
if (remain < 1)
return res;
face = (int)rules.GetLSLIntegerItem(idx++);
if (face == ScriptBaseClass.ALL_SIDES)
{
for (face = 0; face < 21; face++)
{
res.Add(new LSL_Float(0f));
}
}
else
{
res.Add(new LSL_Float(0f));
}
break;
case (int)ScriptBaseClass.PRIM_TEXT:
res.Add(new LSL_String(""));
res.Add(new LSL_Vector(0f,0f,0f));
res.Add(new LSL_Float(1.0f));
break;
case (int)ScriptBaseClass.PRIM_NAME:
res.Add(new LSL_String(avatar.Name));
break;
case (int)ScriptBaseClass.PRIM_DESC:
res.Add(new LSL_String(""));
break;
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
Quaternion lrot = avatar.Rotation;
if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
{
lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset
}
res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W));
break;
case (int)ScriptBaseClass.PRIM_POS_LOCAL:
Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part
Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
lpos -= lsitOffset;
if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
{
lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
}
res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
break;
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
return res;
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
LSL_List new_rules = rules.GetSublist(idx, -1);
res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
return res;
}
}
return res;
}
}
}