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.
parent
39079a62c0
commit
c4a9eae961
|
@ -3956,6 +3956,34 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public Vector3 GetGeometricCenter()
|
||||
{
|
||||
// this is not real geometric center but a average of positions relative to root prim acording to
|
||||
// http://wiki.secondlife.com/wiki/llGetGeometricCenter
|
||||
// ignoring tortured prims details since sl also seems to ignore
|
||||
// so no real use in doing it on physics
|
||||
|
||||
Vector3 gc = Vector3.Zero;
|
||||
|
||||
int nparts = m_parts.Count;
|
||||
if (nparts <= 1)
|
||||
return gc;
|
||||
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
nparts = parts.Length; // just in case it changed
|
||||
if (nparts <= 1)
|
||||
return gc;
|
||||
|
||||
// average all parts positions
|
||||
for (int i = 0; i < nparts; i++)
|
||||
gc += parts[i].GetWorldPosition();
|
||||
gc /= nparts;
|
||||
|
||||
// relative to root:
|
||||
gc -= AbsolutePosition;
|
||||
return gc;
|
||||
}
|
||||
|
||||
public float GetMass()
|
||||
{
|
||||
float retmass = 0f;
|
||||
|
|
|
@ -2260,6 +2260,16 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public Vector3 GetGeometricCenter()
|
||||
{
|
||||
// this is not real geometric center but a average of positions relative to root prim acording to
|
||||
// http://wiki.secondlife.com/wiki/llGetGeometricCenter
|
||||
// ignoring tortured prims details since sl also seems to ignore
|
||||
// so no real use in doing it on physics
|
||||
if (ParentGroup.IsDeleted)
|
||||
return new Vector3(0, 0, 0);
|
||||
|
||||
return ParentGroup.GetGeometricCenter();
|
||||
|
||||
/*
|
||||
PhysicsActor pa = PhysActor;
|
||||
|
||||
if (pa != null)
|
||||
|
@ -2269,6 +2279,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
else
|
||||
return new Vector3(0, 0, 0);
|
||||
*/
|
||||
}
|
||||
|
||||
public float GetMass()
|
||||
|
|
Loading…
Reference in New Issue