* Added some comments to the linkset positioning code

ThreadPoolClientBranch
Teravus Ovares 2008-01-15 14:39:35 +00:00
parent 47c6529523
commit 0a783e4442
1 changed files with 20 additions and 4 deletions

View File

@ -153,6 +153,11 @@ namespace OpenSim.Region.Environment.Scenes
//unkown if this will be kept, added as a way of removing the group position from the group class //unkown if this will be kept, added as a way of removing the group position from the group class
protected LLVector3 m_groupPosition; protected LLVector3 m_groupPosition;
/// <summary>
/// Method for a prim to get it's world position from the group.
/// Remember, the Group Position simply gives the position of the group itself
/// </summary>
/// <returns>A Linked Child Prim objects position in world</returns>
public LLVector3 GetWorldPosition() public LLVector3 GetWorldPosition()
{ {
@ -175,6 +180,10 @@ namespace OpenSim.Region.Environment.Scenes
//return (new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z) + AbsolutePosition); //return (new LLVector3(axiomPos.x, axiomPos.y, axiomPos.z) + AbsolutePosition);
} }
/// <summary>
/// Gets the rotation of this prim offset by the group rotation
/// </summary>
/// <returns></returns>
public LLQuaternion GetWorldRotation() public LLQuaternion GetWorldRotation()
{ {
Quaternion newRot; Quaternion newRot;
@ -211,6 +220,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
get get
{ {
// If this is a linkset, we don't want the physics engine mucking up our group position here.
if (PhysActor != null && ParentID == 0) if (PhysActor != null && ParentID == 0)
{ {
m_groupPosition.X = PhysActor.Position.X; m_groupPosition.X = PhysActor.Position.X;
@ -228,6 +238,7 @@ namespace OpenSim.Region.Environment.Scenes
try try
{ {
// Root prim actually goes at Position
if (ParentID == 0) if (ParentID == 0)
{ {
PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
@ -235,12 +246,16 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
// To move the child prim in respect to the group position and rotation we have to calculate
LLVector3 resultingposition = GetWorldPosition(); LLVector3 resultingposition = GetWorldPosition();
PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z);
LLQuaternion resultingrot = GetWorldRotation(); LLQuaternion resultingrot = GetWorldRotation();
PhysActor.Orientation = new Quaternion(resultingrot.W, resultingrot.X, resultingrot.Y, resultingrot.Z); PhysActor.Orientation = new Quaternion(resultingrot.W, resultingrot.X, resultingrot.Y, resultingrot.Z);
} }
// Tell the physics engines that this prim changed.
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
} }
catch (Exception e) catch (Exception e)
@ -260,7 +275,7 @@ namespace OpenSim.Region.Environment.Scenes
set { m_offsetPosition = value; set { m_offsetPosition = value;
try try
{ {
// Hack to get the child prim to update positions in the physics engine // Hack to get the child prim to update world positions in the physics engine
ParentGroup.ResetChildPrimPhysicsPositions(); ParentGroup.ResetChildPrimPhysicsPositions();
} }
catch (System.NullReferenceException) catch (System.NullReferenceException)
@ -282,6 +297,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
get get
{ {
// We don't want the physics engine mucking up the rotations in a linkset
if (PhysActor != null && ParentID == 0) if (PhysActor != null && ParentID == 0)
{ {
if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0 if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0
@ -303,8 +319,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
try try
{ {
//lock (Scene.SyncRoot) // Root prim gets value directly
//{
if (ParentID == 0) if (ParentID == 0)
{ {
PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z); PhysActor.Orientation = new Quaternion(value.W, value.X, value.Y, value.Z);
@ -312,6 +327,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
// Child prim we have to calculate it's world rotation
LLQuaternion resultingrotation = GetWorldRotation(); LLQuaternion resultingrotation = GetWorldRotation();
PhysActor.Orientation = new Quaternion(resultingrotation.W, resultingrotation.X, resultingrotation.Y, resultingrotation.Z); PhysActor.Orientation = new Quaternion(resultingrotation.W, resultingrotation.X, resultingrotation.Y, resultingrotation.Z);
//MainLog.Instance.Verbose("PART", "RO2:" + PhysActor.Orientation.ToString()); //MainLog.Instance.Verbose("PART", "RO2:" + PhysActor.Orientation.ToString());