Streamline and improve llGetMass
parent
a70352db17
commit
2998a2df6a
|
@ -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
|
// return total object mass
|
||||||
{
|
SceneObjectPart part = World.GetSceneObjectPart(key);
|
||||||
/*
|
if (part != null)
|
||||||
SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId);
|
return part.ParentGroup.GetMass();
|
||||||
if (obj != null)
|
|
||||||
return (double)obj.GetMass();
|
|
||||||
*/
|
|
||||||
// return total object mass
|
|
||||||
SceneObjectGroup obj = World.GetGroupByPrim(World.Entities[key].LocalId);
|
|
||||||
if (obj != null)
|
|
||||||
return obj.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)
|
|
||||||
// reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass
|
|
||||||
// child agents have a mass of 1.0
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return (double)avatar.GetMass();
|
|
||||||
}
|
|
||||||
catch (KeyNotFoundException)
|
|
||||||
{
|
{
|
||||||
return 0; // The Object/Agent not in the region so just return zero
|
if (avatar.IsChildAgent)
|
||||||
|
{
|
||||||
|
// reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass
|
||||||
|
// child agents have a mass of 1.0
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (double)avatar.GetMass();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue