mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
try save some zeptogram of CO2
This commit is contained in:
@@ -106,7 +106,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
protected bool throwErrorOnNotImplemented = false;
|
||||
protected float m_ScriptDelayFactor = 1.0f;
|
||||
protected float m_ScriptDistanceFactor = 1.0f;
|
||||
protected float m_Script10mDistance = 10.0f;
|
||||
protected float m_Script10mDistanceSquare = 100.0f;
|
||||
protected float m_MinTimerInterval = 0.5f;
|
||||
protected float m_recoilScaleFactor = 0.0f;
|
||||
protected bool m_AllowGodFunctions;
|
||||
@@ -255,6 +256,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
private int m_saydistance = 20;
|
||||
private int m_shoutdistance = 100;
|
||||
|
||||
bool m_disable_underground_movement = true;
|
||||
|
||||
private string m_lsl_shard = "OpenSim";
|
||||
private string m_lsl_user_agent = string.Empty;
|
||||
|
||||
@@ -417,22 +420,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if (seConfig != null)
|
||||
{
|
||||
m_ScriptDelayFactor =
|
||||
seConfig.GetFloat("ScriptDelayFactor", m_ScriptDelayFactor);
|
||||
m_ScriptDistanceFactor =
|
||||
seConfig.GetFloat("ScriptDistanceLimitFactor", m_ScriptDistanceFactor);
|
||||
m_MinTimerInterval =
|
||||
seConfig.GetFloat("MinTimerInterval", m_MinTimerInterval);
|
||||
m_automaticLinkPermission =
|
||||
seConfig.GetBoolean("AutomaticLinkPermission", m_automaticLinkPermission);
|
||||
m_notecardLineReadCharsMax =
|
||||
seConfig.GetInt("NotecardLineReadCharsMax", m_notecardLineReadCharsMax);
|
||||
float scriptDistanceFactor = seConfig.GetFloat("ScriptDistanceLimitFactor", 1.0f);
|
||||
m_Script10mDistance = 10.0f * scriptDistanceFactor;
|
||||
m_Script10mDistanceSquare = m_Script10mDistance * m_Script10mDistance;
|
||||
|
||||
m_ScriptDelayFactor = seConfig.GetFloat("ScriptDelayFactor", m_ScriptDelayFactor);
|
||||
m_MinTimerInterval = seConfig.GetFloat("MinTimerInterval", m_MinTimerInterval);
|
||||
m_automaticLinkPermission = seConfig.GetBoolean("AutomaticLinkPermission", m_automaticLinkPermission);
|
||||
m_notecardLineReadCharsMax = seConfig.GetInt("NotecardLineReadCharsMax", m_notecardLineReadCharsMax);
|
||||
|
||||
// Rezzing an object with a velocity can create recoil. This feature seems to have been
|
||||
// removed from recent versions of SL. The code computes recoil (vel*mass) and scales
|
||||
// it by this factor. May be zero to turn off recoil all together.
|
||||
m_recoilScaleFactor = seConfig.GetFloat("RecoilScaleFactor", m_recoilScaleFactor);
|
||||
m_AllowGodFunctions = seConfig.GetBoolean("AllowGodFunctions", false);
|
||||
|
||||
m_disable_underground_movement = seConfig.GetBoolean("DisableUndergroundMovement", true);
|
||||
}
|
||||
|
||||
if (m_notecardLineReadCharsMax > 65535)
|
||||
@@ -604,14 +607,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if ((item = GetScriptByName(name)) == UUID.Zero)
|
||||
{
|
||||
Error("llResetOtherScript", "Can't find script '" + name + "'");
|
||||
Error("llResetOtherScript", "Can't find script '" + name + "'");
|
||||
return;
|
||||
}
|
||||
if(item == m_item.ItemID)
|
||||
llResetScript();
|
||||
else
|
||||
{
|
||||
m_ScriptEngine.ResetScript(item);
|
||||
m_ScriptEngine.ResetScript(item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -965,6 +968,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return Math.Sqrt(dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
|
||||
private double VecDistSquare(LSL_Vector a, LSL_Vector b)
|
||||
{
|
||||
double dx = a.x - b.x;
|
||||
double dy = a.y - b.y;
|
||||
double dz = a.z - b.z;
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
public LSL_Float llVecDist(LSL_Vector a, LSL_Vector b)
|
||||
{
|
||||
return VecDist(a, b);
|
||||
@@ -2690,38 +2701,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
SetPos(m_host.ParentGroup.RootPart, pos, false);
|
||||
|
||||
return VecDist(pos, llGetRootPosition()) <= 0.1 ? 1 : 0;
|
||||
return VecDistSquare(pos, llGetRootPosition()) <= 0.01 ? 1 : 0;
|
||||
}
|
||||
|
||||
// Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
|
||||
// note linked setpos is capped "differently"
|
||||
private LSL_Vector SetPosAdjust(LSL_Vector start, LSL_Vector end)
|
||||
{
|
||||
if (llVecDist(start, end) > 10.0f * m_ScriptDistanceFactor)
|
||||
return start + m_ScriptDistanceFactor * 10.0f * llVecNorm(end - start);
|
||||
if (VecDistSquare(start, end) > m_Script10mDistanceSquare)
|
||||
return start + m_Script10mDistance * llVecNorm(end - start);
|
||||
else
|
||||
return end;
|
||||
}
|
||||
|
||||
protected LSL_Vector GetSetPosTarget(SceneObjectPart part, LSL_Vector targetPos, LSL_Vector fromPos, bool adjust)
|
||||
{
|
||||
if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
|
||||
return fromPos;
|
||||
if (part == null)
|
||||
return targetPos;
|
||||
SceneObjectGroup grp = part.ParentGroup;
|
||||
if (grp == null || grp.IsDeleted || grp.inTransit)
|
||||
return targetPos;
|
||||
|
||||
// Capped movemment if distance > 10m (http://wiki.secondlife.com/wiki/LlSetPos)
|
||||
|
||||
|
||||
float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y);
|
||||
bool disable_underground_movement = m_ScriptEngine.Config.GetBoolean("DisableUndergroundMovement", true);
|
||||
|
||||
if (part.ParentGroup.RootPart == part)
|
||||
{
|
||||
if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0)
|
||||
targetPos.z = ground;
|
||||
}
|
||||
if (adjust)
|
||||
return SetPosAdjust(fromPos, targetPos);
|
||||
targetPos = SetPosAdjust(fromPos, targetPos);
|
||||
|
||||
if (m_disable_underground_movement && grp.AttachmentPoint == 0)
|
||||
{
|
||||
if (part.IsRoot)
|
||||
{
|
||||
float ground = World.GetGroundHeight((float)targetPos.x, (float)targetPos.y);
|
||||
if ((targetPos.z < ground))
|
||||
targetPos.z = ground;
|
||||
}
|
||||
}
|
||||
return targetPos;
|
||||
}
|
||||
|
||||
@@ -2733,20 +2745,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
/// <param name="adjust">if TRUE, will cap the distance to 10m.</param>
|
||||
protected void SetPos(SceneObjectPart part, LSL_Vector targetPos, bool adjust)
|
||||
{
|
||||
if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted || part.ParentGroup.inTransit)
|
||||
if (part == null)
|
||||
return;
|
||||
|
||||
|
||||
SceneObjectGroup grp = part.ParentGroup;
|
||||
if (grp == null || grp.IsDeleted || grp.inTransit)
|
||||
return;
|
||||
|
||||
LSL_Vector currentPos = GetPartLocalPos(part);
|
||||
LSL_Vector toPos = GetSetPosTarget(part, targetPos, currentPos, adjust);
|
||||
|
||||
|
||||
if (part.ParentGroup.RootPart == part)
|
||||
if (part.IsRoot)
|
||||
{
|
||||
SceneObjectGroup parent = part.ParentGroup;
|
||||
if (!parent.IsAttachment && !World.Permissions.CanObjectEntry(parent, false, (Vector3)toPos))
|
||||
if (!grp.IsAttachment && !World.Permissions.CanObjectEntry(grp, false, (Vector3)toPos))
|
||||
return;
|
||||
parent.UpdateGroupPosition((Vector3)toPos);
|
||||
grp.UpdateGroupPosition((Vector3)toPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2770,23 +2783,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
protected LSL_Vector GetPartLocalPos(SceneObjectPart part)
|
||||
{
|
||||
|
||||
Vector3 pos;
|
||||
|
||||
if (!part.IsRoot)
|
||||
{
|
||||
pos = part.OffsetPosition;
|
||||
}
|
||||
else
|
||||
if (part.IsRoot)
|
||||
{
|
||||
if (part.ParentGroup.IsAttachment)
|
||||
pos = part.AttachedPos;
|
||||
else
|
||||
pos = part.AbsolutePosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = part.OffsetPosition;
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos);
|
||||
|
||||
//m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos);
|
||||
return new LSL_Vector(pos);
|
||||
}
|
||||
|
||||
@@ -3521,9 +3531,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (string.IsNullOrEmpty(inventory) || Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s))
|
||||
return;
|
||||
|
||||
float dist = (float)llVecDist(llGetPos(), pos);
|
||||
|
||||
if (dist > m_ScriptDistanceFactor * 10.0f)
|
||||
if (VecDistSquare(llGetPos(), pos) > m_Script10mDistanceSquare)
|
||||
return;
|
||||
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory);
|
||||
@@ -3542,7 +3550,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
Util.FireAndForget(x =>
|
||||
{
|
||||
|
||||
Quaternion wrot = rot;
|
||||
wrot.Normalize();
|
||||
List<SceneObjectGroup> new_groups = World.RezObject(m_host, item, pos, wrot, vel, param, atRoot);
|
||||
|
||||
Reference in New Issue
Block a user