diff options
author | UbitUmarov | 2012-04-28 21:36:38 +0100 |
---|---|---|
committer | UbitUmarov | 2012-04-28 21:36:38 +0100 |
commit | dd745f60c201aee7ff48ba81d567e7b38a8f186c (patch) | |
tree | d75ec7775942b912a72bc85d639d6f1dbb206072 /OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |
parent | Oooops don't hover underground but do hover (diff) | |
download | opensim-SC-dd745f60c201aee7ff48ba81d567e7b38a8f186c.zip opensim-SC-dd745f60c201aee7ff48ba81d567e7b38a8f186c.tar.gz opensim-SC-dd745f60c201aee7ff48ba81d567e7b38a8f186c.tar.bz2 opensim-SC-dd745f60c201aee7ff48ba81d567e7b38a8f186c.tar.xz |
fix llGetCenterOfMass ( checked with ubitODE only)
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 33 |
1 files changed, 33 insertions, 0 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. |