aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
authorRobert Adams2012-07-11 16:07:14 -0700
committerRobert Adams2012-07-11 16:12:38 -0700
commit743437262ed645204d9040e1705a41902860a648 (patch)
tree9e7f572b4460242963a4e313d82ba122ad1d1ae7 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
parentWhere possible, use the system Encoding.ASCII and Encoding.UTF8 rather than c... (diff)
downloadopensim-SC_OLD-743437262ed645204d9040e1705a41902860a648.zip
opensim-SC_OLD-743437262ed645204d9040e1705a41902860a648.tar.gz
opensim-SC_OLD-743437262ed645204d9040e1705a41902860a648.tar.bz2
opensim-SC_OLD-743437262ed645204d9040e1705a41902860a648.tar.xz
Many explanitory comments added to the link and delink code in
SOG and SOP. Should have no functionality changes.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs28
1 files changed, 20 insertions, 8 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b3f11a7..4b2fede 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -693,9 +693,11 @@ namespace OpenSim.Region.Framework.Scenes
693 { 693 {
694 // If this is a linkset, we don't want the physics engine mucking up our group position here. 694 // If this is a linkset, we don't want the physics engine mucking up our group position here.
695 PhysicsActor actor = PhysActor; 695 PhysicsActor actor = PhysActor;
696 // If physical and the root prim of a linkset, the position of the group is what physics thinks.
696 if (actor != null && ParentID == 0) 697 if (actor != null && ParentID == 0)
697 m_groupPosition = actor.Position; 698 m_groupPosition = actor.Position;
698 699
700 // If I'm an attachment, my position is reported as the position of who I'm attached to
699 if (ParentGroup.IsAttachment) 701 if (ParentGroup.IsAttachment)
700 { 702 {
701 ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); 703 ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
@@ -721,7 +723,7 @@ namespace OpenSim.Region.Framework.Scenes
721 } 723 }
722 else 724 else
723 { 725 {
724 // To move the child prim in respect to the group position and rotation we have to calculate 726 // The physics engine always sees all objects (root or linked) in world coordinates.
725 actor.Position = GetWorldPosition(); 727 actor.Position = GetWorldPosition();
726 actor.Orientation = GetWorldRotation(); 728 actor.Orientation = GetWorldRotation();
727 } 729 }
@@ -795,6 +797,8 @@ namespace OpenSim.Region.Framework.Scenes
795 { 797 {
796 // We don't want the physics engine mucking up the rotations in a linkset 798 // We don't want the physics engine mucking up the rotations in a linkset
797 PhysicsActor actor = PhysActor; 799 PhysicsActor actor = PhysActor;
800 // If this is a root of a linkset, the real rotation is what the physics engine thinks.
801 // If not a root prim, the offset rotation is computed by SOG and is relative to the root.
798 if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) 802 if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null)
799 { 803 {
800 if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f 804 if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f
@@ -1980,14 +1984,20 @@ namespace OpenSim.Region.Framework.Scenes
1980 /// <returns>A Linked Child Prim objects position in world</returns> 1984 /// <returns>A Linked Child Prim objects position in world</returns>
1981 public Vector3 GetWorldPosition() 1985 public Vector3 GetWorldPosition()
1982 { 1986 {
1983 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 1987 Vector3 ret;
1984 Vector3 axPos = OffsetPosition; 1988 if (_parentID == 0)
1985 axPos *= parentRot; 1989 // if a root SOP, my position is what it is
1986 Vector3 translationOffsetPosition = axPos; 1990 ret = GroupPosition;
1987 if(_parentID == 0)
1988 return GroupPosition;
1989 else 1991 else
1990 return ParentGroup.AbsolutePosition + translationOffsetPosition; 1992 {
1993 // If a child SOP, my position is relative to the root SOP so take
1994 // my info and add the root's position and rotation to
1995 // get my world position.
1996 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
1997 Vector3 translationOffsetPosition = OffsetPosition * parentRot;
1998 ret = ParentGroup.AbsolutePosition + translationOffsetPosition;
1999 }
2000 return ret;
1991 } 2001 }
1992 2002
1993 /// <summary> 2003 /// <summary>
@@ -2004,6 +2014,8 @@ namespace OpenSim.Region.Framework.Scenes
2004 } 2014 }
2005 else 2015 else
2006 { 2016 {
2017 // A child SOP's rotation is relative to the root SOP's rotation.
2018 // Combine them to get my absolute rotation.
2007 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2019 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
2008 Quaternion oldRot = RotationOffset; 2020 Quaternion oldRot = RotationOffset;
2009 newRot = parentRot * oldRot; 2021 newRot = parentRot * oldRot;