Many explanitory comments added to the link and delink code in

SOG and SOP. Should have no functionality changes.
This commit is contained in:
Robert Adams
2012-07-11 16:07:14 -07:00
parent 916e3bf886
commit 743437262e
2 changed files with 96 additions and 26 deletions

View File

@@ -693,9 +693,11 @@ namespace OpenSim.Region.Framework.Scenes
{
// If this is a linkset, we don't want the physics engine mucking up our group position here.
PhysicsActor actor = PhysActor;
// If physical and the root prim of a linkset, the position of the group is what physics thinks.
if (actor != null && ParentID == 0)
m_groupPosition = actor.Position;
// If I'm an attachment, my position is reported as the position of who I'm attached to
if (ParentGroup.IsAttachment)
{
ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
@@ -721,7 +723,7 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
// To move the child prim in respect to the group position and rotation we have to calculate
// The physics engine always sees all objects (root or linked) in world coordinates.
actor.Position = GetWorldPosition();
actor.Orientation = GetWorldRotation();
}
@@ -795,6 +797,8 @@ namespace OpenSim.Region.Framework.Scenes
{
// We don't want the physics engine mucking up the rotations in a linkset
PhysicsActor actor = PhysActor;
// If this is a root of a linkset, the real rotation is what the physics engine thinks.
// If not a root prim, the offset rotation is computed by SOG and is relative to the root.
if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null)
{
if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f
@@ -1980,14 +1984,20 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns>A Linked Child Prim objects position in world</returns>
public Vector3 GetWorldPosition()
{
Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
Vector3 axPos = OffsetPosition;
axPos *= parentRot;
Vector3 translationOffsetPosition = axPos;
if(_parentID == 0)
return GroupPosition;
Vector3 ret;
if (_parentID == 0)
// if a root SOP, my position is what it is
ret = GroupPosition;
else
return ParentGroup.AbsolutePosition + translationOffsetPosition;
{
// If a child SOP, my position is relative to the root SOP so take
// my info and add the root's position and rotation to
// get my world position.
Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
Vector3 translationOffsetPosition = OffsetPosition * parentRot;
ret = ParentGroup.AbsolutePosition + translationOffsetPosition;
}
return ret;
}
/// <summary>
@@ -2004,6 +2014,8 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
// A child SOP's rotation is relative to the root SOP's rotation.
// Combine them to get my absolute rotation.
Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
Quaternion oldRot = RotationOffset;
newRot = parentRot * oldRot;