Streamline and improve llGetMass

avinationmerge
Melanie 2012-09-26 22:30:09 +02:00
parent a70352db17
commit 2998a2df6a
1 changed files with 17 additions and 23 deletions

View File

@ -10599,31 +10599,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID key = new UUID(); UUID key = new UUID();
if (UUID.TryParse(id, out key)) if (UUID.TryParse(id, out key))
{ {
try
{
/*
SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId);
if (obj != null)
return (double)obj.GetMass();
*/
// return total object mass // return total object mass
SceneObjectGroup obj = World.GetGroupByPrim(World.Entities[key].LocalId); SceneObjectPart part = World.GetSceneObjectPart(key);
if (obj != null) if (part != null)
return obj.GetMass(); return part.ParentGroup.GetMass();
// the object is null so the key is for an avatar // the object is null so the key is for an avatar
ScenePresence avatar = World.GetScenePresence(key); ScenePresence avatar = World.GetScenePresence(key);
if (avatar != null) if (avatar != null)
{
if (avatar.IsChildAgent) if (avatar.IsChildAgent)
{
// reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass
// child agents have a mass of 1.0 // child agents have a mass of 1.0
return 1; return 1;
}
else else
{
return (double)avatar.GetMass(); return (double)avatar.GetMass();
} }
catch (KeyNotFoundException)
{
return 0; // The Object/Agent not in the region so just return zero
} }
} }
return 0; return 0;