From 743437262ed645204d9040e1705a41902860a648 Mon Sep 17 00:00:00 2001
From: Robert Adams
Date: Wed, 11 Jul 2012 16:07:14 -0700
Subject: Many explanitory comments added to the link and delink code in SOG
and SOP. Should have no functionality changes.
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 28 +++++++++++++++-------
1 file changed, 20 insertions(+), 8 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
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
{
// 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
/// A Linked Child Prim objects position in world
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;
}
///
@@ -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;
--
cgit v1.1