aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2012-04-09 23:33:42 +0100
committerUbitUmarov2012-04-09 23:33:42 +0100
commitc4a9eae961030280473f6df77e59cb53865535b6 (patch)
tree0c067ce26208b6e578f9ab40f0f5d77b9f25b9a8 /OpenSim/Region
parentchODE and ubitODE always return prim mass (they where returning object mass o... (diff)
downloadopensim-SC-c4a9eae961030280473f6df77e59cb53865535b6.zip
opensim-SC-c4a9eae961030280473f6df77e59cb53865535b6.tar.gz
opensim-SC-c4a9eae961030280473f6df77e59cb53865535b6.tar.bz2
opensim-SC-c4a9eae961030280473f6df77e59cb53865535b6.tar.xz
make llGetGeometricCenter() work as in current SL. Now this is not real geom center but a average of positions relative to root prim ignoring prims details, so no need to use physics engine.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs30
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs29
2 files changed, 49 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 107d9b6..3fd1f5e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3955,7 +3955,35 @@ namespace OpenSim.Region.Framework.Scenes
3955 } 3955 }
3956 } 3956 }
3957 } 3957 }
3958 3958
3959 public Vector3 GetGeometricCenter()
3960 {
3961 // this is not real geometric center but a average of positions relative to root prim acording to
3962 // http://wiki.secondlife.com/wiki/llGetGeometricCenter
3963 // ignoring tortured prims details since sl also seems to ignore
3964 // so no real use in doing it on physics
3965
3966 Vector3 gc = Vector3.Zero;
3967
3968 int nparts = m_parts.Count;
3969 if (nparts <= 1)
3970 return gc;
3971
3972 SceneObjectPart[] parts = m_parts.GetArray();
3973 nparts = parts.Length; // just in case it changed
3974 if (nparts <= 1)
3975 return gc;
3976
3977 // average all parts positions
3978 for (int i = 0; i < nparts; i++)
3979 gc += parts[i].GetWorldPosition();
3980 gc /= nparts;
3981
3982 // relative to root:
3983 gc -= AbsolutePosition;
3984 return gc;
3985 }
3986
3959 public float GetMass() 3987 public float GetMass()
3960 { 3988 {
3961 float retmass = 0f; 3989 float retmass = 0f;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index d419710..511ab19 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2260,18 +2260,29 @@ namespace OpenSim.Region.Framework.Scenes
2260 2260
2261 public Vector3 GetGeometricCenter() 2261 public Vector3 GetGeometricCenter()
2262 { 2262 {
2263 PhysicsActor pa = PhysActor; 2263 // this is not real geometric center but a average of positions relative to root prim acording to
2264 2264 // http://wiki.secondlife.com/wiki/llGetGeometricCenter
2265 if (pa != null) 2265 // ignoring tortured prims details since sl also seems to ignore
2266 { 2266 // so no real use in doing it on physics
2267 Vector3 vtmp = pa.CenterOfMass; 2267 if (ParentGroup.IsDeleted)
2268 return vtmp;
2269 }
2270 else
2271 return new Vector3(0, 0, 0); 2268 return new Vector3(0, 0, 0);
2269
2270 return ParentGroup.GetGeometricCenter();
2271
2272 /*
2273 PhysicsActor pa = PhysActor;
2274
2275 if (pa != null)
2276 {
2277 Vector3 vtmp = pa.CenterOfMass;
2278 return vtmp;
2279 }
2280 else
2281 return new Vector3(0, 0, 0);
2282 */
2272 } 2283 }
2273 2284
2274 public float GetMass() 2285 public float GetMass()
2275 { 2286 {
2276 PhysicsActor pa = PhysActor; 2287 PhysicsActor pa = PhysActor;
2277 2288