aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs40
2 files changed, 70 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index ba353c4..b0f2015 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -4041,6 +4041,39 @@ namespace OpenSim.Region.Framework.Scenes
4041 return retmass; 4041 return retmass;
4042 } 4042 }
4043 4043
4044 // center of mass of full object
4045 public Vector3 GetCenterOfMass()
4046 {
4047 PhysicsActor pa = RootPart.PhysActor;
4048
4049 if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null)
4050 {
4051 // physics knows better about center of mass of physical prims
4052 Vector3 tmp = pa.CenterOfMass;
4053 return tmp;
4054 }
4055
4056 Vector3 Ptot = Vector3.Zero;
4057 float totmass = 0f;
4058 float m;
4059
4060 SceneObjectPart[] parts = m_parts.GetArray();
4061 for (int i = 0; i < parts.Length; i++)
4062 {
4063 m = parts[i].GetMass();
4064 Ptot += parts[i].GetPartCenterOfMass() * m;
4065 totmass += m;
4066 }
4067
4068 if (totmass == 0)
4069 totmass = 0;
4070 else
4071 totmass = 1 / totmass;
4072 Ptot *= totmass;
4073
4074 return Ptot;
4075 }
4076
4044 /// <summary> 4077 /// <summary>
4045 /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that 4078 /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that
4046 /// the physics engine can use it. 4079 /// the physics engine can use it.
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index c9659cb..b198ca7 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 }
@@ -2308,7 +2308,7 @@ namespace OpenSim.Region.Framework.Scenes
2308 */ 2308 */
2309 } 2309 }
2310 2310
2311 public float GetMass() 2311 public float GetMass()
2312 { 2312 {
2313 PhysicsActor pa = PhysActor; 2313 PhysicsActor pa = PhysActor;
2314 2314
@@ -2318,6 +2318,40 @@ namespace OpenSim.Region.Framework.Scenes
2318 return 0; 2318 return 0;
2319 } 2319 }
2320 2320
2321 public Vector3 GetCenterOfMass()
2322 {
2323 if (ParentGroup.RootPart == this)
2324 {
2325 if (ParentGroup.IsDeleted)
2326 return AbsolutePosition;
2327 return ParentGroup.GetCenterOfMass();
2328 }
2329
2330 PhysicsActor pa = PhysActor;
2331
2332 if (pa != null)
2333 {
2334 Vector3 tmp = pa.CenterOfMass;
2335 return tmp;
2336 }
2337 else
2338 return AbsolutePosition;
2339 }
2340
2341 public Vector3 GetPartCenterOfMass()
2342 {
2343 PhysicsActor pa = PhysActor;
2344
2345 if (pa != null)
2346 {
2347 Vector3 tmp = pa.CenterOfMass;
2348 return tmp;
2349 }
2350 else
2351 return AbsolutePosition;
2352 }
2353
2354
2321 public Vector3 GetForce() 2355 public Vector3 GetForce()
2322 { 2356 {
2323 return Force; 2357 return Force;
@@ -4802,7 +4836,7 @@ namespace OpenSim.Region.Framework.Scenes
4802 { 4836 {
4803 Velocity = velocity; 4837 Velocity = velocity;
4804 AngularVelocity = rotationalVelocity; 4838 AngularVelocity = rotationalVelocity;
4805 pa.Velocity = velocity; 4839// pa.Velocity = velocity;
4806 pa.RotationalVelocity = rotationalVelocity; 4840 pa.RotationalVelocity = rotationalVelocity;
4807 4841
4808 // if not vehicle and root part apply force and torque 4842 // if not vehicle and root part apply force and torque