Try to fix uploaded mesh rotations - code from Avination code base.

0.7.5-pf-bulletsim
Melanie 2013-02-05 20:09:02 +00:00 committed by Justin Clark-Casey (justincc)
parent f28a592310
commit e3f01f23af
1 changed files with 28 additions and 13 deletions

View File

@ -641,25 +641,40 @@ namespace OpenSim.Region.ClientStack.Linden
grp.AddPart(prim); grp.AddPart(prim);
} }
// Fix first link number Vector3 rootPos = positions[0];
if (grp.Parts.Length > 1) if (grp.Parts.Length > 1)
{
// Fix first link number
grp.RootPart.LinkNum++; grp.RootPart.LinkNum++;
Vector3 rootPos = positions[0]; Quaternion rootRotConj = Quaternion.Conjugate(rotations[0]);
grp.AbsolutePosition = rootPos; Quaternion tmprot;
for (int i = 0; i < positions.Count; i++) Vector3 offset;
// fix children rotations and positions
for (int i = 1; i < rotations.Count; i++)
{ {
Vector3 offset = positions[i] - rootPos; tmprot = rotations[i];
tmprot = rootRotConj * tmprot;
grp.Parts[i].RotationOffset = tmprot;
offset = positions[i] - rootPos;
offset *= rootRotConj;
grp.Parts[i].OffsetPosition = offset; grp.Parts[i].OffsetPosition = offset;
} }
for (int i = 0; i < rotations.Count; i++) grp.AbsolutePosition = rootPos;
grp.UpdateGroupRotationR(rotations[0]);
}
else
{ {
if (i != 0) grp.AbsolutePosition = rootPos;
grp.Parts[i].RotationOffset = rotations[i]; grp.UpdateGroupRotationR(rotations[0]);
} }
grp.UpdateGroupRotationR(rotations[0]);
data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp));
} }