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; int idx = 0;
SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used
bool positionChanged = false;
Vector3 finalPos = Vector3.Zero;
try
{
while (idx < rules.Length) while (idx < rules.Length)
{ {
int code = rules.GetLSLIntegerItem(idx++); int code = rules.GetLSLIntegerItem(idx++);
@ -7949,22 +7954,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector v; LSL_Vector v;
v = rules.GetVector3Item(idx++); 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) if (sitpart == null)
break; break;
@ -7976,33 +7965,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
pos *= Quaternion.Conjugate(rot); // removed sit part rotation pos *= Quaternion.Conjugate(rot); // removed sit part rotation
Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f); Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f);
pos += sitOffset; pos += sitOffset;
av.OffsetPosition = pos; finalPos = pos;
av.SendAvatarDataToAllAgents(); positionChanged = true;
} }
break; break;
case (int)ScriptBaseClass.PRIM_ROTATION: case (int)ScriptBaseClass.PRIM_ROTATION:
{ {
if (remain < 1) if (remain < 1)
return; 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) if (sitpart == null)
break; break;
@ -8021,12 +7995,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if (remain < 1) if (remain < 1)
return; 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) if (sitpart == null)
break; break;
@ -8127,6 +8096,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_LINK_TARGET: 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. 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; return;
if (positionChanged)
{
positionChanged = false;
av.OffsetPosition = finalPos;
av.SendAvatarDataToAllAgents();
}
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
LSL_List new_rules = rules.GetSublist(idx, -1); LSL_List new_rules = rules.GetSublist(idx, -1);
setLinkPrimParams((int)new_linknumber, new_rules); 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) protected void SetPrimParams(SceneObjectPart part, LSL_List rules)
{ {
if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
@ -8166,8 +8154,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return; return;
v=rules.GetVector3Item(idx++); v=rules.GetVector3Item(idx++);
positionChanged = true;
currentPosition = GetSetPosTarget(part, v, currentPosition); currentPosition = GetSetPosTarget(part, v, currentPosition);
positionChanged = true;
break; break;
case (int)ScriptBaseClass.PRIM_SIZE: case (int)ScriptBaseClass.PRIM_SIZE:
@ -8549,13 +8537,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Float gain = rules.GetLSLFloatItem(idx++); LSL_Float gain = rules.GetLSLFloatItem(idx++);
TargetOmega(part, axis, (double)spinrate, (double)gain); TargetOmega(part, axis, (double)spinrate, (double)gain);
break; break;
case (int)ScriptBaseClass.PRIM_LINK_TARGET: 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. 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; return;
// do a pending position change // do a pending position change before jumping to other part/avatar
if (positionChanged) if (positionChanged)
{ {
positionChanged = false;
if (parentgrp == null) if (parentgrp == null)
return; return;
@ -8584,7 +8574,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
finally finally
{ {
/*
if (positionChanged) if (positionChanged)
{ {
if (part.ParentGroup.RootPart == part) if (part.ParentGroup.RootPart == part)
@ -8602,27 +8591,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
parent.ScheduleGroupForTerseUpdate(); 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();
}
} }
} }