Replace sit position and rotation code with older, working version

avinationmerge
Melanie 2012-07-15 20:48:47 +02:00
parent ec40c54509
commit a2d19b9703
1 changed files with 28 additions and 26 deletions

View File

@ -8015,31 +8015,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
switch (code) switch (code)
{ {
// a avatar is a child
case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POSITION:
case (int)ScriptBaseClass.PRIM_POS_LOCAL: case (int)ScriptBaseClass.PRIM_POS_LOCAL:
{ {
if (remain < 1) if (remain < 1)
return; return;
LSL_Vector v; LSL_Vector v;
v = rules.GetVector3Item(idx++); v = rules.GetVector3Item(idx++);
if (sitpart == null) SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
if (part == null)
break; break;
Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
if (sitpart != sitpart.ParentGroup.RootPart) if (llGetLinkNumber() > 1)
{ {
pos -= sitpart.OffsetPosition; // remove sit part offset localRot = llGetLocalRot();
Quaternion rot = sitpart.RotationOffset; localPos = llGetLocalPos();
pos *= Quaternion.Conjugate(rot); // removed sit part rotation
} }
Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f * 2.0f);
pos += sitOffset;
finalPos = pos; v -= localPos;
positionChanged = true; v /= localRot;
LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f);
v = v + 2 * sitOffset;
av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
av.SendAvatarDataToAllAgents();
} }
break; break;
@ -8048,24 +8054,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (remain < 1) if (remain < 1)
return; return;
if (sitpart == null) LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
break; LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
LSL_Rotation r = rules.GetQuaternionItem(idx++); if (llGetLinkNumber() > 1)
Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation
// need to replicate SL bug
SceneObjectGroup sitgrp = sitpart.ParentGroup;
if (sitgrp != null && sitgrp.RootPart != sitpart)
{ {
rot = sitgrp.RootPart.RotationOffset * rot; localRot = llGetLocalRot();
localPos = llGetLocalPos();
} }
Quaternion srot = sitpart.RotationOffset; LSL_Rotation r;
rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation r = rules.GetQuaternionItem(idx++);
av.Rotation = rot; r = r * llGetRootRotation() / localRot;
// av.SendAvatarDataToAllAgents(); av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
av.SendTerseUpdateToAllClients(); av.SendAvatarDataToAllAgents();
} }
break; break;