aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
authorMelanie2012-04-29 01:33:40 +0200
committerMelanie2012-04-29 01:33:40 +0200
commit174fa4a70f2622c65ef8d9488765b71c1fad345e (patch)
tree42e4de081e8ab4f673235471a3b5daf626a8828b /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
parentMerge branch 'master' into careminster (diff)
parent remove repeated set of group rotation to physics (diff)
downloadopensim-SC-174fa4a70f2622c65ef8d9488765b71c1fad345e.zip
opensim-SC-174fa4a70f2622c65ef8d9488765b71c1fad345e.tar.gz
opensim-SC-174fa4a70f2622c65ef8d9488765b71c1fad345e.tar.bz2
opensim-SC-174fa4a70f2622c65ef8d9488765b71c1fad345e.tar.xz
Merge branch 'avination'
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs46
1 files changed, 41 insertions, 5 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 66a6520..b5e1a52 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2671,11 +2671,11 @@ namespace OpenSim.Region.Framework.Scenes
2671 2671
2672 Vector3 axPos = linkPart.OffsetPosition; 2672 Vector3 axPos = linkPart.OffsetPosition;
2673 Quaternion parentRot = m_rootPart.RotationOffset; 2673 Quaternion parentRot = m_rootPart.RotationOffset;
2674 axPos *= Quaternion.Inverse(parentRot); 2674 axPos *= Quaternion.Conjugate(parentRot);
2675 linkPart.OffsetPosition = axPos; 2675 linkPart.OffsetPosition = axPos;
2676 2676
2677 Quaternion oldRot = linkPart.RotationOffset; 2677 Quaternion oldRot = linkPart.RotationOffset;
2678 Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; 2678 Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot;
2679 linkPart.RotationOffset = newRot; 2679 linkPart.RotationOffset = newRot;
2680 2680
2681// linkPart.ParentID = m_rootPart.LocalId; done above 2681// linkPart.ParentID = m_rootPart.LocalId; done above
@@ -2943,12 +2943,12 @@ namespace OpenSim.Region.Framework.Scenes
2943 Quaternion rootRotation = m_rootPart.RotationOffset; 2943 Quaternion rootRotation = m_rootPart.RotationOffset;
2944 2944
2945 Vector3 pos = part.OffsetPosition; 2945 Vector3 pos = part.OffsetPosition;
2946 pos *= Quaternion.Inverse(rootRotation); 2946 pos *= Quaternion.Conjugate(rootRotation);
2947 part.OffsetPosition = pos; 2947 part.OffsetPosition = pos;
2948 2948
2949 parentRot = m_rootPart.RotationOffset; 2949 parentRot = m_rootPart.RotationOffset;
2950 oldRot = part.RotationOffset; 2950 oldRot = part.RotationOffset;
2951 Quaternion newRot = Quaternion.Inverse(parentRot) * worldRot; 2951 Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot;
2952 part.RotationOffset = newRot; 2952 part.RotationOffset = newRot;
2953 2953
2954 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); 2954 part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false);
@@ -3548,13 +3548,16 @@ namespace OpenSim.Region.Framework.Scenes
3548 /// <param name="rot"></param> 3548 /// <param name="rot"></param>
3549 public void UpdateGroupRotationR(Quaternion rot) 3549 public void UpdateGroupRotationR(Quaternion rot)
3550 { 3550 {
3551 m_rootPart.UpdateRotation(rot);
3552
3553/* this is done by rootpart RotationOffset set called by UpdateRotation
3551 PhysicsActor actor = m_rootPart.PhysActor; 3554 PhysicsActor actor = m_rootPart.PhysActor;
3552 if (actor != null) 3555 if (actor != null)
3553 { 3556 {
3554 actor.Orientation = m_rootPart.RotationOffset; 3557 actor.Orientation = m_rootPart.RotationOffset;
3555 m_scene.PhysicsScene.AddPhysicsActorTaint(actor); 3558 m_scene.PhysicsScene.AddPhysicsActorTaint(actor);
3556 } 3559 }
3557 3560*/
3558 HasGroupChanged = true; 3561 HasGroupChanged = true;
3559 ScheduleGroupForTerseUpdate(); 3562 ScheduleGroupForTerseUpdate();
3560 } 3563 }
@@ -4063,6 +4066,39 @@ namespace OpenSim.Region.Framework.Scenes
4063 return retmass; 4066 return retmass;
4064 } 4067 }
4065 4068
4069 // center of mass of full object
4070 public Vector3 GetCenterOfMass()
4071 {
4072 PhysicsActor pa = RootPart.PhysActor;
4073
4074 if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null)
4075 {
4076 // physics knows better about center of mass of physical prims
4077 Vector3 tmp = pa.CenterOfMass;
4078 return tmp;
4079 }
4080
4081 Vector3 Ptot = Vector3.Zero;
4082 float totmass = 0f;
4083 float m;
4084
4085 SceneObjectPart[] parts = m_parts.GetArray();
4086 for (int i = 0; i < parts.Length; i++)
4087 {
4088 m = parts[i].GetMass();
4089 Ptot += parts[i].GetPartCenterOfMass() * m;
4090 totmass += m;
4091 }
4092
4093 if (totmass == 0)
4094 totmass = 0;
4095 else
4096 totmass = 1 / totmass;
4097 Ptot *= totmass;
4098
4099 return Ptot;
4100 }
4101
4066 /// <summary> 4102 /// <summary>
4067 /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that 4103 /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that
4068 /// the physics engine can use it. 4104 /// the physics engine can use it.