Changed t adding the avatar dependent sit offset and not subtracting, so not to break inworld contents. SL ported scripts will show a sit error around 0.1m. Added respective compensation in LSL api to maintain coerence. Fixed several bugs still on SET/GET[link]PrimitiveParams[fast] and llGetObjectDetails()

avinationmerge
UbitUmarov 2012-06-13 04:59:09 +01:00
parent b30c23eba4
commit 7bd274b3d3
2 changed files with 46 additions and 27 deletions

View File

@ -2383,8 +2383,10 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 up = new Vector3((float)x, (float)y, (float)z); Vector3 up = new Vector3((float)x, (float)y, (float)z);
Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f;
// m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT;
m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT;
// m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset;
Rotation = sitTargetOrient; Rotation = sitTargetOrient;
ParentPosition = part.AbsolutePosition; ParentPosition = part.AbsolutePosition;
part.ParentGroup.AddAvatar(UUID); part.ParentGroup.AddAvatar(UUID);

View File

@ -7959,13 +7959,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position
pos -= sitpart.OffsetPosition; // remove sit part offset if (sitpart != sitpart.ParentGroup.RootPart)
{
Quaternion rot = sitpart.RotationOffset; pos -= sitpart.OffsetPosition; // remove sit part offset
pos *= Quaternion.Conjugate(rot); // removed sit part rotation Quaternion rot = sitpart.RotationOffset;
pos *= Quaternion.Conjugate(rot); // removed sit part rotation
// Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); }
// pos += sitOffset; Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f * 2.0f);
pos += sitOffset;
finalPos = pos; finalPos = pos;
positionChanged = true; positionChanged = true;
@ -7990,8 +7991,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
rot = sitgrp.RootPart.RotationOffset * rot; rot = sitgrp.RootPart.RotationOffset * rot;
} }
Quaternion srot = sitpart.GetWorldRotation(); Quaternion srot = sitpart.RotationOffset;
rot = Quaternion.Conjugate(srot) * rot; // removed sit part world rotation rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation
av.Rotation = rot; av.Rotation = rot;
av.SendAvatarDataToAllAgents(); av.SendAvatarDataToAllAgents();
} }
@ -8007,10 +8008,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Rotation r = rules.GetQuaternionItem(idx++); LSL_Rotation r = rules.GetQuaternionItem(idx++);
Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation
if (sitpart != sitpart.ParentGroup.RootPart)
Quaternion srot = sitpart.RotationOffset; {
rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation Quaternion srot = sitpart.RotationOffset;
rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation
}
av.Rotation = rot; av.Rotation = rot;
av.SendAvatarDataToAllAgents(); av.SendAvatarDataToAllAgents();
} }
@ -8956,12 +8958,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POSITION:
// can't use Abs pos to extract offset...
// Vector3 pos = avatar.AbsolutePosition;
Vector3 pos = avatar.OffsetPosition; Vector3 pos = avatar.OffsetPosition;
// Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
// pos -= sitOffset; pos -= sitOffset;
if( sitPart != null) if( sitPart != null)
pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation(); pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation();
@ -9151,7 +9151,8 @@ 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)
if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
{ {
lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset
} }
@ -9160,10 +9161,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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; // pos relative to sit part
// Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f); Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
// lpos -= lsitOffset; lpos -= lsitOffset;
if (sitPart != null) if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
{ {
lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
} }
@ -11819,12 +11820,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ret.Add(new LSL_String("")); ret.Add(new LSL_String(""));
break; break;
case ScriptBaseClass.OBJECT_POS: case ScriptBaseClass.OBJECT_POS:
Vector3 avpos = av.AbsolutePosition; Vector3 avpos;
if (av.ParentID != 0 && av.ParentPart != null)
{
avpos = av.OffsetPosition;
Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f *2.0f);
avpos -= sitOffset;
avpos = av.ParentPart.GetWorldPosition() + avpos * av.ParentPart.GetWorldRotation();
}
else
avpos = av.AbsolutePosition;
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.Rotation;
if(av.ParentID != 0 && av.ParentPart != null) if (av.ParentID != 0 && av.ParentPart != null)
{ {
avrot = av.ParentPart.GetWorldRotation() * avrot; avrot = av.ParentPart.GetWorldRotation() * avrot;
} }
@ -11896,8 +11910,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z)); ret.Add(new LSL_Vector(opos.X, opos.Y, opos.Z));
break; break;
case ScriptBaseClass.OBJECT_ROT: case ScriptBaseClass.OBJECT_ROT:
Quaternion orot = obj.RotationOffset; // Quaternion orot = obj.RotationOffset;
ret.Add(new LSL_Rotation(orot.X, orot.Y, orot.Z, orot.W)); // ret.Add(new LSL_Rotation(orot.X, orot.Y, orot.Z, orot.W));
LSL_Rotation objrot = GetPartRot(obj);
ret.Add(objrot);
break; break;
case ScriptBaseClass.OBJECT_VELOCITY: case ScriptBaseClass.OBJECT_VELOCITY:
Vector3 ovel = obj.Velocity; Vector3 ovel = obj.Velocity;