From e3f01f23afe9ceb3eb46dc95791bf13632c57ea6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 5 Feb 2013 20:09:02 +0000 Subject: Try to fix uploaded mesh rotations - code from Avination code base. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 39 +++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index a534522..6ebe660 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -641,25 +641,40 @@ namespace OpenSim.Region.ClientStack.Linden grp.AddPart(prim); } - // Fix first link number + Vector3 rootPos = positions[0]; + if (grp.Parts.Length > 1) + { + // Fix first link number grp.RootPart.LinkNum++; - Vector3 rootPos = positions[0]; - grp.AbsolutePosition = rootPos; - for (int i = 0; i < positions.Count; i++) - { - Vector3 offset = positions[i] - rootPos; - grp.Parts[i].OffsetPosition = offset; - } + Quaternion rootRotConj = Quaternion.Conjugate(rotations[0]); + Quaternion tmprot; + Vector3 offset; + + // fix children rotations and positions + for (int i = 1; i < rotations.Count; i++) + { + tmprot = rotations[i]; + tmprot = rootRotConj * tmprot; + + grp.Parts[i].RotationOffset = tmprot; - for (int i = 0; i < rotations.Count; i++) + offset = positions[i] - rootPos; + + offset *= rootRotConj; + grp.Parts[i].OffsetPosition = offset; + } + + grp.AbsolutePosition = rootPos; + grp.UpdateGroupRotationR(rotations[0]); + } + else { - if (i != 0) - grp.Parts[i].RotationOffset = rotations[i]; + grp.AbsolutePosition = rootPos; + grp.UpdateGroupRotationR(rotations[0]); } - grp.UpdateGroupRotationR(rotations[0]); data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); } -- cgit v1.1