fix get/set parameters on avatars
parent
89655b0baa
commit
dc752e8d82
|
@ -10133,7 +10133,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
SceneObjectPart parentPart = sp.ParentPart;
|
SceneObjectPart parentPart = sp.ParentPart;
|
||||||
|
|
||||||
if (parentPart != null)
|
if (parentPart != null)
|
||||||
sp.Rotation = m_host.GetWorldRotation() * inRot;
|
sp.Rotation = m_host.GetWorldRotation() * inRot;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -13466,14 +13466,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
case ScriptBaseClass.OBJECT_POS:
|
case ScriptBaseClass.OBJECT_POS:
|
||||||
Vector3 avpos;
|
Vector3 avpos;
|
||||||
|
|
||||||
if (av.ParentID != 0 && av.ParentPart != null)
|
if (av.ParentID != 0 && av.ParentPart != null &&
|
||||||
|
av.ParentPart.ParentGroup != null && av.ParentPart.ParentGroup.RootPart != null )
|
||||||
{
|
{
|
||||||
avpos = av.OffsetPosition;
|
avpos = av.OffsetPosition;
|
||||||
|
|
||||||
Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f);
|
Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f);
|
||||||
avpos -= sitOffset;
|
avpos -= sitOffset;
|
||||||
|
SceneObjectPart sitRoot = av.ParentPart.ParentGroup.RootPart;
|
||||||
avpos = av.ParentPart.GetWorldPosition() + avpos * av.ParentPart.GetWorldRotation();
|
avpos = sitRoot.GetWorldPosition() + avpos * sitRoot.GetWorldRotation();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
avpos = av.AbsolutePosition;
|
avpos = av.AbsolutePosition;
|
||||||
|
@ -13481,12 +13482,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z));
|
ret.Add(new LSL_Vector((double)avpos.X, (double)avpos.Y, (double)avpos.Z));
|
||||||
break;
|
break;
|
||||||
case ScriptBaseClass.OBJECT_ROT:
|
case ScriptBaseClass.OBJECT_ROT:
|
||||||
Quaternion avrot = av.Rotation;
|
Quaternion avrot = av.GetWorldRotation();
|
||||||
if (av.ParentID != 0 && av.ParentPart != null)
|
ret.Add(new LSL_Rotation(avrot));
|
||||||
{
|
|
||||||
avrot = av.ParentPart.GetWorldRotation() * avrot;
|
|
||||||
}
|
|
||||||
ret.Add(new LSL_Rotation((double)avrot.X, (double)avrot.Y, (double)avrot.Z, (double)avrot.W));
|
|
||||||
break;
|
break;
|
||||||
case ScriptBaseClass.OBJECT_VELOCITY:
|
case ScriptBaseClass.OBJECT_VELOCITY:
|
||||||
Vector3 avvel = av.GetWorldVelocity();
|
Vector3 avvel = av.GetWorldVelocity();
|
||||||
|
@ -15695,14 +15692,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed)
|
protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed)
|
||||||
{
|
{
|
||||||
//This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
|
//This is a special version of SetPrimParams to deal with avatars which are sitting on the linkset.
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
int idxStart = 0;
|
int idxStart = 0;
|
||||||
|
|
||||||
bool positionChanged = false;
|
bool positionChanged = false;
|
||||||
Vector3 finalPos = Vector3.Zero;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (idx < rules.Length)
|
while (idx < rules.Length)
|
||||||
|
@ -15729,13 +15724,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
v = v + 2 * sitOffset;
|
v = v + 2 * sitOffset;
|
||||||
|
|
||||||
av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
|
av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
|
||||||
av.SendAvatarDataToAllAgents();
|
positionChanged = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (int)ScriptBaseClass.PRIM_ROTATION:
|
||||||
|
{
|
||||||
|
if (remain < 1)
|
||||||
|
return new LSL_List();
|
||||||
|
|
||||||
|
Quaternion r;
|
||||||
|
r = rules.GetQuaternionItem(idx++);
|
||||||
|
|
||||||
|
av.Rotation = m_host.GetWorldRotation() * r;
|
||||||
|
positionChanged = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
|
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
|
||||||
case (int)ScriptBaseClass.PRIM_ROTATION:
|
|
||||||
{
|
{
|
||||||
if (remain < 1)
|
if (remain < 1)
|
||||||
return new LSL_List();
|
return new LSL_List();
|
||||||
|
@ -15743,8 +15749,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
LSL_Rotation r;
|
LSL_Rotation r;
|
||||||
r = rules.GetQuaternionItem(idx++);
|
r = rules.GetQuaternionItem(idx++);
|
||||||
|
|
||||||
av.Rotation = r * llGetRootRotation();
|
av.Rotation = r;
|
||||||
av.SendAvatarDataToAllAgents();
|
positionChanged = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -15848,12 +15854,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (positionChanged)
|
if (positionChanged)
|
||||||
{
|
|
||||||
av.OffsetPosition = finalPos;
|
|
||||||
// av.SendAvatarDataToAllAgents();
|
|
||||||
av.SendTerseUpdateToAllClients();
|
av.SendTerseUpdateToAllClients();
|
||||||
positionChanged = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new LSL_List();
|
return new LSL_List();
|
||||||
}
|
}
|
||||||
|
@ -15891,11 +15892,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (int)ScriptBaseClass.PRIM_POSITION:
|
case (int)ScriptBaseClass.PRIM_POSITION:
|
||||||
|
Vector3 pos;
|
||||||
|
|
||||||
Vector3 pos = avatar.OffsetPosition;
|
if (sitPart.ParentGroup.RootPart != null)
|
||||||
|
{
|
||||||
|
pos = avatar.OffsetPosition;
|
||||||
|
|
||||||
Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
|
Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
|
||||||
pos -= sitOffset;
|
pos -= sitOffset;
|
||||||
|
|
||||||
|
SceneObjectPart sitroot = sitPart.ParentGroup.RootPart;
|
||||||
|
pos = sitroot.AbsolutePosition + pos * sitroot.GetWorldRotation();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
pos = avatar.AbsolutePosition;
|
||||||
|
|
||||||
res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
|
res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
|
||||||
break;
|
break;
|
||||||
|
@ -15907,9 +15917,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (int)ScriptBaseClass.PRIM_ROTATION:
|
case (int)ScriptBaseClass.PRIM_ROTATION:
|
||||||
LSL_Rotation rot = new LSL_Rotation(avatar.Rotation.X, avatar.Rotation.Y, avatar.Rotation.Z, avatar.Rotation.W) / llGetRootRotation();
|
res.Add(new LSL_Rotation(avatar.GetWorldRotation()));
|
||||||
|
|
||||||
res.Add(rot);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (int)ScriptBaseClass.PRIM_TYPE:
|
case (int)ScriptBaseClass.PRIM_TYPE:
|
||||||
|
@ -16079,23 +16087,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
|
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
|
||||||
Quaternion lrot = avatar.Rotation;
|
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));
|
res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (int)ScriptBaseClass.PRIM_POS_LOCAL:
|
case (int)ScriptBaseClass.PRIM_POS_LOCAL:
|
||||||
Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part
|
Vector3 lpos = avatar.OffsetPosition;
|
||||||
Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
|
Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
|
||||||
lpos -= lsitOffset;
|
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));
|
res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue