From 70d8731aa2b50f4ef615e0623c02ac1da0067366 Mon Sep 17 00:00:00 2001
From: MW
Date: Thu, 5 Jul 2007 19:19:39 +0000
Subject: Fixed rotation editing of individual prims in a group. I think
positioning and rotations should now be correct (for both groups and on
editing individuals of a group). Resizing still needs work.
---
OpenSim/Region/Environment/Scenes/Primitive.cs | 78 +++++++++++++++++++---
.../Environment/Scenes/Scene.PacketHandlers.cs | 1 +
OpenSim/Region/Environment/Scenes/SceneObject.cs | 2 +-
3 files changed, 70 insertions(+), 11 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs
index 24dc115..9d01618 100644
--- a/OpenSim/Region/Environment/Scenes/Primitive.cs
+++ b/OpenSim/Region/Environment/Scenes/Primitive.cs
@@ -46,12 +46,17 @@ namespace OpenSim.Region.Environment.Scenes
public EntityBase m_Parent;
#region Properties
- public override LLVector3 Pos
+ ///
+ /// If rootprim will return world position
+ /// otherwise will return local offset from rootprim
+ ///
+ public override LLVector3 Pos
{
get
{
if (isRootPrim)
{
+ //if we are rootprim then our offset should be zero
return this.m_pos + m_Parent.Pos;
}
else
@@ -77,7 +82,9 @@ namespace OpenSim.Region.Environment.Scenes
if (!this.isRootPrim)
{
Primitive parentPrim = (Primitive)this.m_Parent;
- return this.m_pos + parentPrim.WorldPos;
+ Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z);
+ offsetPos = parentPrim.rotation * offsetPos;
+ return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z);
}
else
{
@@ -112,6 +119,17 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Constructors
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject)
{
m_regionHandle = regionHandle;
@@ -227,12 +245,13 @@ namespace OpenSim.Region.Environment.Scenes
Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
axPos = this.m_Parent.rotation.Inverse() * axPos;
this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
- this.rotation = this.rotation * this.m_Parent.rotation.Inverse();
+ Axiom.Math.Quaternion oldRot = new Quaternion(this.rotation.w, this.rotation.x, this.rotation.y, this.rotation.z);
+ this.rotation = this.m_Parent.rotation.Inverse() * this.rotation;
this.updateFlag = 1;
foreach (Primitive child in children)
{
- child.SetRootParent(rootParent, newParent, oldPos);
+ child.SetRootParent(rootParent, newParent, oldPos, oldRot);
}
children.Clear();
@@ -243,10 +262,14 @@ namespace OpenSim.Region.Environment.Scenes
///
///
///
- public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition)
+ public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation)
{
LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
+ Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z);
+ axOldPos = oldParentRotation * axOldPos;
+ oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z);
oldPos += oldParentPosition;
+ Axiom.Math.Quaternion oldRot = new Quaternion(this.rotation.w, this.rotation.x, this.rotation.y, this.rotation.z);
this.isRootPrim = false;
this.m_Parent = newParent;
this.ParentID = newParent.LocalId;
@@ -257,15 +280,20 @@ namespace OpenSim.Region.Environment.Scenes
Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
axPos = this.m_Parent.rotation.Inverse() * axPos;
this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
- this.rotation = this.rotation * this.m_Parent.rotation.Inverse();
+ this.rotation = oldParentRotation * this.rotation;
+ this.rotation = this.m_Parent.rotation.Inverse()* this.rotation ;
this.updateFlag = 1;
foreach (Primitive child in children)
{
- child.SetRootParent(newRoot, newParent, oldPos);
+ child.SetRootParent(newRoot, newParent, oldPos, oldRot);
}
children.Clear();
}
+ ///
+ ///
+ ///
+ ///
public void AddOffsetToChildren(LLVector3 offset)
{
foreach (Primitive prim in this.children)
@@ -275,6 +303,10 @@ namespace OpenSim.Region.Environment.Scenes
}
}
+ ///
+ ///
+ ///
+ ///
public void AddToChildrenList(Primitive prim)
{
this.children.Add(prim);
@@ -282,6 +314,10 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Resizing/Scale
+ ///
+ ///
+ ///
+ ///
public void ResizeGoup(LLVector3 scale)
{
LLVector3 offset = (scale - this.m_Shape.Scale);
@@ -317,9 +353,13 @@ namespace OpenSim.Region.Environment.Scenes
this.updateFlag = 2;
}
+ ///
+ ///
+ ///
+ ///
public void UpdateSinglePosition(LLVector3 pos)
{
- //Console.WriteLine("updating single prim position");
+ // Console.WriteLine("updating single prim position");
if (this.isRootPrim)
{
LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
@@ -350,14 +390,23 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Rotation
+ ///
+ ///
+ ///
+ ///
public void UpdateRotation(LLQuaternion rot)
{
this.rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
this.updateFlag = 2;
}
+ ///
+ ///
+ ///
+ ///
public void UpdateSingleRotation(LLQuaternion rot)
{
+ //Console.WriteLine("updating single prim rotation");
Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
Axiom.Math.Quaternion oldParentRot = new Quaternion(this.rotation.w, this.rotation.x, this.rotation.y, this.rotation.z);
this.rotation = axRot;
@@ -367,13 +416,18 @@ namespace OpenSim.Region.Environment.Scenes
axPos = oldParentRot * axPos;
axPos = axRot.Inverse() * axPos;
prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
- prim.rotation = prim.rotation * oldParentRot;
- prim.rotation = prim.rotation * axRot.Inverse();
+ prim.rotation = oldParentRot * prim.rotation ;
+ prim.rotation = axRot.Inverse()* prim.rotation;
prim.updateFlag = 2;
}
this.updateFlag = 2;
}
+ ///
+ ///
+ ///
+ ///
+ ///
public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot)
{
this.rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
@@ -384,6 +438,10 @@ namespace OpenSim.Region.Environment.Scenes
#endregion
#region Shape
+ ///
+ ///
+ ///
+ ///
public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock)
{
this.m_Shape.PathBegin = shapeBlock.PathBegin;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index b3d9d15..bcef137 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -454,6 +454,7 @@ namespace OpenSim.Region.Environment.Scenes
///
public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
{
+ //Console.WriteLine("trying to update single prim rotation");
Primitive prim = null;
foreach (EntityBase ent in Entities.Values)
{
diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs
index 00d7c63..452502b 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObject.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Region.Environment.Scenes
private bool physicsEnabled = false;
private PhysicsScene m_PhysScene;
private PhysicsActor m_PhysActor;
-
+
public LLUUID rootUUID
{
get
--
cgit v1.1