aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
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
parentMerge branch 'master' into careminster (diff)
parent remove repeated set of group rotation to physics (diff)
downloadopensim-SC_OLD-174fa4a70f2622c65ef8d9488765b71c1fad345e.zip
opensim-SC_OLD-174fa4a70f2622c65ef8d9488765b71c1fad345e.tar.gz
opensim-SC_OLD-174fa4a70f2622c65ef8d9488765b71c1fad345e.tar.bz2
opensim-SC_OLD-174fa4a70f2622c65ef8d9488765b71c1fad345e.tar.xz
Merge branch 'avination'
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs46
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs40
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs35
3 files changed, 113 insertions, 8 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.
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 37b5554..ffb86f3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1865,7 +1865,7 @@ namespace OpenSim.Region.Framework.Scenes
1865 { 1865 {
1866 if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment 1866 if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment
1867 && !(Shape.PathCurve == (byte)Extrusion.Flexible)) 1867 && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1868 AddToPhysics(isPhysical, isPhantom, building, true); 1868 AddToPhysics(isPhysical, isPhantom, building, isPhysical);
1869 else 1869 else
1870 PhysActor = null; // just to be sure 1870 PhysActor = null; // just to be sure
1871 } 1871 }
@@ -2311,7 +2311,7 @@ namespace OpenSim.Region.Framework.Scenes
2311 */ 2311 */
2312 } 2312 }
2313 2313
2314 public float GetMass() 2314 public float GetMass()
2315 { 2315 {
2316 PhysicsActor pa = PhysActor; 2316 PhysicsActor pa = PhysActor;
2317 2317
@@ -2321,6 +2321,40 @@ namespace OpenSim.Region.Framework.Scenes
2321 return 0; 2321 return 0;
2322 } 2322 }
2323 2323
2324 public Vector3 GetCenterOfMass()
2325 {
2326 if (ParentGroup.RootPart == this)
2327 {
2328 if (ParentGroup.IsDeleted)
2329 return AbsolutePosition;
2330 return ParentGroup.GetCenterOfMass();
2331 }
2332
2333 PhysicsActor pa = PhysActor;
2334
2335 if (pa != null)
2336 {
2337 Vector3 tmp = pa.CenterOfMass;
2338 return tmp;
2339 }
2340 else
2341 return AbsolutePosition;
2342 }
2343
2344 public Vector3 GetPartCenterOfMass()
2345 {
2346 PhysicsActor pa = PhysActor;
2347
2348 if (pa != null)
2349 {
2350 Vector3 tmp = pa.CenterOfMass;
2351 return tmp;
2352 }
2353 else
2354 return AbsolutePosition;
2355 }
2356
2357
2324 public Vector3 GetForce() 2358 public Vector3 GetForce()
2325 { 2359 {
2326 return Force; 2360 return Force;
@@ -4804,7 +4838,7 @@ namespace OpenSim.Region.Framework.Scenes
4804 { 4838 {
4805 Velocity = velocity; 4839 Velocity = velocity;
4806 AngularVelocity = rotationalVelocity; 4840 AngularVelocity = rotationalVelocity;
4807 pa.Velocity = velocity; 4841// pa.Velocity = velocity;
4808 pa.RotationalVelocity = rotationalVelocity; 4842 pa.RotationalVelocity = rotationalVelocity;
4809 4843
4810 // if not vehicle and root part apply force and torque 4844 // if not vehicle and root part apply force and torque
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 311ba6a..1e717d9 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1088,6 +1088,41 @@ namespace OpenSim.Region.Framework.Scenes
1088 SendTerseUpdateToAllClients(); 1088 SendTerseUpdateToAllClients();
1089 } 1089 }
1090 1090
1091 public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY)
1092 {
1093 CheckLandingPoint(ref newpos);
1094 AbsolutePosition = newpos;
1095
1096 if (newvel.HasValue)
1097 {
1098 if ((Vector3)newvel == Vector3.Zero)
1099 {
1100 if (PhysicsActor != null)
1101 PhysicsActor.SetMomentum(Vector3.Zero);
1102 m_velocity = Vector3.Zero;
1103 }
1104 else
1105 {
1106 if (PhysicsActor != null)
1107 PhysicsActor.SetMomentum((Vector3)newvel);
1108 m_velocity = (Vector3)newvel;
1109
1110 if (rotateToVelXY)
1111 {
1112 Vector3 lookAt = (Vector3)newvel;
1113 lookAt.Z = 0;
1114 lookAt.Normalize();
1115 ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation);
1116 return;
1117 }
1118 }
1119 }
1120
1121 SendTerseUpdateToAllClients();
1122 }
1123
1124
1125
1091 public void StopFlying() 1126 public void StopFlying()
1092 { 1127 {
1093 ControllingClient.StopFlying(this); 1128 ControllingClient.StopFlying(this);