aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Scenes/Primitive.cs78
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs1
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObject.cs2
3 files changed, 70 insertions, 11 deletions
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
46 public EntityBase m_Parent; 46 public EntityBase m_Parent;
47 47
48 #region Properties 48 #region Properties
49 public override LLVector3 Pos 49 /// <summary>
50 /// If rootprim will return world position
51 /// otherwise will return local offset from rootprim
52 /// </summary>
53 public override LLVector3 Pos
50 { 54 {
51 get 55 get
52 { 56 {
53 if (isRootPrim) 57 if (isRootPrim)
54 { 58 {
59 //if we are rootprim then our offset should be zero
55 return this.m_pos + m_Parent.Pos; 60 return this.m_pos + m_Parent.Pos;
56 } 61 }
57 else 62 else
@@ -77,7 +82,9 @@ namespace OpenSim.Region.Environment.Scenes
77 if (!this.isRootPrim) 82 if (!this.isRootPrim)
78 { 83 {
79 Primitive parentPrim = (Primitive)this.m_Parent; 84 Primitive parentPrim = (Primitive)this.m_Parent;
80 return this.m_pos + parentPrim.WorldPos; 85 Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z);
86 offsetPos = parentPrim.rotation * offsetPos;
87 return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z);
81 } 88 }
82 else 89 else
83 { 90 {
@@ -112,6 +119,17 @@ namespace OpenSim.Region.Environment.Scenes
112 #endregion 119 #endregion
113 120
114 #region Constructors 121 #region Constructors
122 /// <summary>
123 ///
124 /// </summary>
125 /// <param name="regionHandle"></param>
126 /// <param name="world"></param>
127 /// <param name="addPacket"></param>
128 /// <param name="ownerID"></param>
129 /// <param name="localID"></param>
130 /// <param name="isRoot"></param>
131 /// <param name="parent"></param>
132 /// <param name="rootObject"></param>
115 public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject) 133 public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject)
116 { 134 {
117 m_regionHandle = regionHandle; 135 m_regionHandle = regionHandle;
@@ -227,12 +245,13 @@ namespace OpenSim.Region.Environment.Scenes
227 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); 245 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
228 axPos = this.m_Parent.rotation.Inverse() * axPos; 246 axPos = this.m_Parent.rotation.Inverse() * axPos;
229 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 247 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
230 this.rotation = this.rotation * this.m_Parent.rotation.Inverse(); 248 Axiom.Math.Quaternion oldRot = new Quaternion(this.rotation.w, this.rotation.x, this.rotation.y, this.rotation.z);
249 this.rotation = this.m_Parent.rotation.Inverse() * this.rotation;
231 this.updateFlag = 1; 250 this.updateFlag = 1;
232 251
233 foreach (Primitive child in children) 252 foreach (Primitive child in children)
234 { 253 {
235 child.SetRootParent(rootParent, newParent, oldPos); 254 child.SetRootParent(rootParent, newParent, oldPos, oldRot);
236 } 255 }
237 children.Clear(); 256 children.Clear();
238 257
@@ -243,10 +262,14 @@ namespace OpenSim.Region.Environment.Scenes
243 /// 262 ///
244 /// </summary> 263 /// </summary>
245 /// <param name="newRoot"></param> 264 /// <param name="newRoot"></param>
246 public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition) 265 public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation)
247 { 266 {
248 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); 267 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
268 Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z);
269 axOldPos = oldParentRotation * axOldPos;
270 oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z);
249 oldPos += oldParentPosition; 271 oldPos += oldParentPosition;
272 Axiom.Math.Quaternion oldRot = new Quaternion(this.rotation.w, this.rotation.x, this.rotation.y, this.rotation.z);
250 this.isRootPrim = false; 273 this.isRootPrim = false;
251 this.m_Parent = newParent; 274 this.m_Parent = newParent;
252 this.ParentID = newParent.LocalId; 275 this.ParentID = newParent.LocalId;
@@ -257,15 +280,20 @@ namespace OpenSim.Region.Environment.Scenes
257 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); 280 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
258 axPos = this.m_Parent.rotation.Inverse() * axPos; 281 axPos = this.m_Parent.rotation.Inverse() * axPos;
259 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 282 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
260 this.rotation = this.rotation * this.m_Parent.rotation.Inverse(); 283 this.rotation = oldParentRotation * this.rotation;
284 this.rotation = this.m_Parent.rotation.Inverse()* this.rotation ;
261 this.updateFlag = 1; 285 this.updateFlag = 1;
262 foreach (Primitive child in children) 286 foreach (Primitive child in children)
263 { 287 {
264 child.SetRootParent(newRoot, newParent, oldPos); 288 child.SetRootParent(newRoot, newParent, oldPos, oldRot);
265 } 289 }
266 children.Clear(); 290 children.Clear();
267 } 291 }
268 292
293 /// <summary>
294 ///
295 /// </summary>
296 /// <param name="offset"></param>
269 public void AddOffsetToChildren(LLVector3 offset) 297 public void AddOffsetToChildren(LLVector3 offset)
270 { 298 {
271 foreach (Primitive prim in this.children) 299 foreach (Primitive prim in this.children)
@@ -275,6 +303,10 @@ namespace OpenSim.Region.Environment.Scenes
275 } 303 }
276 } 304 }
277 305
306 /// <summary>
307 ///
308 /// </summary>
309 /// <param name="prim"></param>
278 public void AddToChildrenList(Primitive prim) 310 public void AddToChildrenList(Primitive prim)
279 { 311 {
280 this.children.Add(prim); 312 this.children.Add(prim);
@@ -282,6 +314,10 @@ namespace OpenSim.Region.Environment.Scenes
282 #endregion 314 #endregion
283 315
284 #region Resizing/Scale 316 #region Resizing/Scale
317 /// <summary>
318 ///
319 /// </summary>
320 /// <param name="scale"></param>
285 public void ResizeGoup(LLVector3 scale) 321 public void ResizeGoup(LLVector3 scale)
286 { 322 {
287 LLVector3 offset = (scale - this.m_Shape.Scale); 323 LLVector3 offset = (scale - this.m_Shape.Scale);
@@ -317,9 +353,13 @@ namespace OpenSim.Region.Environment.Scenes
317 this.updateFlag = 2; 353 this.updateFlag = 2;
318 } 354 }
319 355
356 /// <summary>
357 ///
358 /// </summary>
359 /// <param name="pos"></param>
320 public void UpdateSinglePosition(LLVector3 pos) 360 public void UpdateSinglePosition(LLVector3 pos)
321 { 361 {
322 //Console.WriteLine("updating single prim position"); 362 // Console.WriteLine("updating single prim position");
323 if (this.isRootPrim) 363 if (this.isRootPrim)
324 { 364 {
325 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); 365 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
@@ -350,14 +390,23 @@ namespace OpenSim.Region.Environment.Scenes
350 #endregion 390 #endregion
351 391
352 #region Rotation 392 #region Rotation
393 /// <summary>
394 ///
395 /// </summary>
396 /// <param name="rot"></param>
353 public void UpdateRotation(LLQuaternion rot) 397 public void UpdateRotation(LLQuaternion rot)
354 { 398 {
355 this.rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); 399 this.rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
356 this.updateFlag = 2; 400 this.updateFlag = 2;
357 } 401 }
358 402
403 /// <summary>
404 ///
405 /// </summary>
406 /// <param name="rot"></param>
359 public void UpdateSingleRotation(LLQuaternion rot) 407 public void UpdateSingleRotation(LLQuaternion rot)
360 { 408 {
409 //Console.WriteLine("updating single prim rotation");
361 Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); 410 Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
362 Axiom.Math.Quaternion oldParentRot = new Quaternion(this.rotation.w, this.rotation.x, this.rotation.y, this.rotation.z); 411 Axiom.Math.Quaternion oldParentRot = new Quaternion(this.rotation.w, this.rotation.x, this.rotation.y, this.rotation.z);
363 this.rotation = axRot; 412 this.rotation = axRot;
@@ -367,13 +416,18 @@ namespace OpenSim.Region.Environment.Scenes
367 axPos = oldParentRot * axPos; 416 axPos = oldParentRot * axPos;
368 axPos = axRot.Inverse() * axPos; 417 axPos = axRot.Inverse() * axPos;
369 prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 418 prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
370 prim.rotation = prim.rotation * oldParentRot; 419 prim.rotation = oldParentRot * prim.rotation ;
371 prim.rotation = prim.rotation * axRot.Inverse(); 420 prim.rotation = axRot.Inverse()* prim.rotation;
372 prim.updateFlag = 2; 421 prim.updateFlag = 2;
373 } 422 }
374 this.updateFlag = 2; 423 this.updateFlag = 2;
375 } 424 }
376 425
426 /// <summary>
427 ///
428 /// </summary>
429 /// <param name="pos"></param>
430 /// <param name="rot"></param>
377 public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) 431 public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot)
378 { 432 {
379 this.rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); 433 this.rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
@@ -384,6 +438,10 @@ namespace OpenSim.Region.Environment.Scenes
384 #endregion 438 #endregion
385 439
386 #region Shape 440 #region Shape
441 /// <summary>
442 ///
443 /// </summary>
444 /// <param name="shapeBlock"></param>
387 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) 445 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock)
388 { 446 {
389 this.m_Shape.PathBegin = shapeBlock.PathBegin; 447 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
454 /// <param name="remoteClient"></param> 454 /// <param name="remoteClient"></param>
455 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) 455 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
456 { 456 {
457 //Console.WriteLine("trying to update single prim rotation");
457 Primitive prim = null; 458 Primitive prim = null;
458 foreach (EntityBase ent in Entities.Values) 459 foreach (EntityBase ent in Entities.Values)
459 { 460 {
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
45 private bool physicsEnabled = false; 45 private bool physicsEnabled = false;
46 private PhysicsScene m_PhysScene; 46 private PhysicsScene m_PhysScene;
47 private PhysicsActor m_PhysActor; 47 private PhysicsActor m_PhysActor;
48 48
49 public LLUUID rootUUID 49 public LLUUID rootUUID
50 { 50 {
51 get 51 get