fix the try.. finally in SetPrimitiveParams i did mess and add one for the avatars case, so to optimize a bit 'warp' scripts.

avinationmerge
UbitUmarov 2012-06-12 05:57:28 +01:00
parent 8b5342f613
commit 5784b3eb31
1 changed files with 174 additions and 206 deletions

View File

@ -7932,6 +7932,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
int idx = 0;
SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used
bool positionChanged = false;
Vector3 finalPos = Vector3.Zero;
try
{
while (idx < rules.Length)
{
int code = rules.GetLSLIntegerItem(idx++);
@ -7949,22 +7954,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector v;
v = rules.GetVector3Item(idx++);
/* use the sitpart
SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
if (part == null)
break;
LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
if (llGetLinkNumber() > 1)
{
localRot = llGetLocalRot();
localPos = llGetLocalPos();
}
v -= localPos;
v /= localRot;
*/
if (sitpart == null)
break;
@ -7976,33 +7965,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
pos *= Quaternion.Conjugate(rot); // removed sit part rotation
Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f);
pos += sitOffset;
av.OffsetPosition = pos;
av.SendAvatarDataToAllAgents();
finalPos = pos;
positionChanged = true;
}
break;
case (int)ScriptBaseClass.PRIM_ROTATION:
{
if (remain < 1)
return;
/*
LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
if (llGetLinkNumber() > 1)
{
localRot = llGetLocalRot();
localPos = llGetLocalPos();
}
LSL_Rotation r;
r = rules.GetQuaternionItem(idx++);
r = r * llGetRootRotation() / localRot;
av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
*/
if (sitpart == null)
break;
@ -8021,12 +7995,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (remain < 1)
return;
/*
LSL_Rotation r;
r = rules.GetQuaternionItem(idx++);
av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
av.SendAvatarDataToAllAgents();
*/
if (sitpart == null)
break;
@ -8127,6 +8096,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
return;
if (positionChanged)
{
positionChanged = false;
av.OffsetPosition = finalPos;
av.SendAvatarDataToAllAgents();
}
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
LSL_List new_rules = rules.GetSublist(idx, -1);
setLinkPrimParams((int)new_linknumber, new_rules);
@ -8135,6 +8112,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
finally
{
if (positionChanged)
{
av.OffsetPosition = finalPos;
av.SendAvatarDataToAllAgents();
positionChanged = false;
}
}
}
protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
{
if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
@ -8166,8 +8154,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
v=rules.GetVector3Item(idx++);
positionChanged = true;
currentPosition = GetSetPosTarget(part, v, currentPosition);
positionChanged = true;
break;
case (int)ScriptBaseClass.PRIM_SIZE:
@ -8549,13 +8537,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Float gain = rules.GetLSLFloatItem(idx++);
TargetOmega(part, axis, (double)spinrate, (double)gain);
break;
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
return;
// do a pending position change
// do a pending position change before jumping to other part/avatar
if (positionChanged)
{
positionChanged = false;
if (parentgrp == null)
return;
@ -8584,7 +8574,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
finally
{
/*
if (positionChanged)
{
if (part.ParentGroup.RootPart == part)
@ -8602,27 +8591,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
parent.ScheduleGroupForTerseUpdate();
}
}
*/
}
if (positionChanged)
{
if (parentgrp == null)
return;
if (parentgrp.RootPart == part)
{
Util.FireAndForget(delegate(object x) {
parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z));
});
}
else
{
part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z);
parentgrp.HasGroupChanged = true;
parentgrp.ScheduleGroupForTerseUpdate();
}
}
}