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,205 +7932,193 @@ 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
while (idx < rules.Length) bool positionChanged = false;
Vector3 finalPos = Vector3.Zero;
try
{ {
int code = rules.GetLSLIntegerItem(idx++); while (idx < rules.Length)
int remain = rules.Length - idx;
switch (code)
{ {
int code = rules.GetLSLIntegerItem(idx++);
int remain = rules.Length - idx;
switch (code)
{
// a avatar is a child // a avatar is a child
case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POSITION:
case (int)ScriptBaseClass.PRIM_POS_LOCAL: case (int)ScriptBaseClass.PRIM_POS_LOCAL:
{
if (remain < 1)
return;
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(); if (remain < 1)
localPos = llGetLocalPos(); return;
LSL_Vector v;
v = rules.GetVector3Item(idx++);
if (sitpart == null)
break;
Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position
pos -= sitpart.OffsetPosition; // remove sit part offset
Quaternion rot = sitpart.RotationOffset;
pos *= Quaternion.Conjugate(rot); // removed sit part rotation
Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f);
pos += sitOffset;
finalPos = pos;
positionChanged = true;
} }
break;
v -= localPos; case (int)ScriptBaseClass.PRIM_ROTATION:
v /= localRot;
*/
if (sitpart == null)
break;
Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position
pos -= sitpart.OffsetPosition; // remove sit part offset
Quaternion rot = sitpart.RotationOffset;
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();
}
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(); if (remain < 1)
localPos = llGetLocalPos(); return;
if (sitpart == null)
break;
LSL_Rotation r = rules.GetQuaternionItem(idx++);
Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation
Quaternion srot = sitpart.GetWorldRotation();
rot *= Quaternion.Conjugate(srot); // removed sit part world rotation
av.Rotation = rot;
av.SendAvatarDataToAllAgents();
} }
break;
LSL_Rotation r; case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
r = rules.GetQuaternionItem(idx++); {
r = r * llGetRootRotation() / localRot; if (remain < 1)
av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); return;
*/
if (sitpart == null)
break;
LSL_Rotation r = rules.GetQuaternionItem(idx++); if (sitpart == null)
Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation break;
Quaternion srot = sitpart.GetWorldRotation();
rot *= Quaternion.Conjugate(srot); // removed sit part world rotation
av.Rotation = rot; LSL_Rotation r = rules.GetQuaternionItem(idx++);
av.SendAvatarDataToAllAgents(); Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation
}
break;
case (int)ScriptBaseClass.PRIM_ROT_LOCAL: Quaternion srot = sitpart.RotationOffset;
{ rot *= Quaternion.Conjugate(srot); // remove sit part offset rotation
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;
LSL_Rotation r = rules.GetQuaternionItem(idx++); av.Rotation = rot;
Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation av.SendAvatarDataToAllAgents();
}
Quaternion srot = sitpart.RotationOffset; break;
rot *= Quaternion.Conjugate(srot); // remove sit part offset rotation
av.Rotation = rot;
av.SendAvatarDataToAllAgents();
}
break;
// parse rest doing nothing but number of parameters error check // parse rest doing nothing but number of parameters error check
case (int)ScriptBaseClass.PRIM_SIZE: case (int)ScriptBaseClass.PRIM_SIZE:
case (int)ScriptBaseClass.PRIM_MATERIAL: case (int)ScriptBaseClass.PRIM_MATERIAL:
case (int)ScriptBaseClass.PRIM_PHANTOM: case (int)ScriptBaseClass.PRIM_PHANTOM:
case (int)ScriptBaseClass.PRIM_PHYSICS: case (int)ScriptBaseClass.PRIM_PHYSICS:
case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
case (int)ScriptBaseClass.PRIM_NAME: case (int)ScriptBaseClass.PRIM_NAME:
case (int)ScriptBaseClass.PRIM_DESC: case (int)ScriptBaseClass.PRIM_DESC:
if (remain < 1) if (remain < 1)
return;
idx++;
break;
case (int)ScriptBaseClass.PRIM_GLOW:
case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
case (int)ScriptBaseClass.PRIM_TEXGEN:
if (remain < 2)
return;
idx += 2;
break;
case (int)ScriptBaseClass.PRIM_TYPE:
if (remain < 3)
return;
code = (int)rules.GetLSLIntegerItem(idx++);
remain = rules.Length - idx;
switch (code)
{
case (int)ScriptBaseClass.PRIM_TYPE_BOX:
case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
if (remain < 6)
return;
idx += 6;
break;
case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
if (remain < 5)
return;
idx += 5;
break;
case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
case (int)ScriptBaseClass.PRIM_TYPE_RING:
if (remain < 11)
return;
idx += 11;
break;
case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
if (remain < 2)
return;
idx += 2;
break;
}
break;
case (int)ScriptBaseClass.PRIM_COLOR:
case (int)ScriptBaseClass.PRIM_TEXT:
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
case (int)ScriptBaseClass.PRIM_OMEGA:
if (remain < 3)
return;
idx += 3;
break;
case (int)ScriptBaseClass.PRIM_TEXTURE:
case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
if (remain < 5)
return;
idx += 5;
break;
case (int)ScriptBaseClass.PRIM_FLEXIBLE:
if (remain < 7)
return;
idx += 7;
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;
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);
return; return;
idx++; }
break; }
}
case (int)ScriptBaseClass.PRIM_GLOW: finally
case (int)ScriptBaseClass.PRIM_FULLBRIGHT: {
case (int)ScriptBaseClass.PRIM_TEXGEN: if (positionChanged)
if (remain < 2) {
return; av.OffsetPosition = finalPos;
idx += 2; av.SendAvatarDataToAllAgents();
break; positionChanged = false;
case (int)ScriptBaseClass.PRIM_TYPE:
if (remain < 3)
return;
code = (int)rules.GetLSLIntegerItem(idx++);
remain = rules.Length - idx;
switch (code)
{
case (int)ScriptBaseClass.PRIM_TYPE_BOX:
case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
if (remain < 6)
return;
idx += 6;
break;
case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
if (remain < 5)
return;
idx += 5;
break;
case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
case (int)ScriptBaseClass.PRIM_TYPE_RING:
if (remain < 11)
return;
idx += 11;
break;
case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
if (remain < 2)
return;
idx += 2;
break;
}
break;
case (int)ScriptBaseClass.PRIM_COLOR:
case (int)ScriptBaseClass.PRIM_TEXT:
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
case (int)ScriptBaseClass.PRIM_OMEGA:
if (remain < 3)
return;
idx += 3;
break;
case (int)ScriptBaseClass.PRIM_TEXTURE:
case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
if (remain < 5)
return;
idx += 5;
break;
case (int)ScriptBaseClass.PRIM_FLEXIBLE:
if (remain < 7)
return;
idx += 7;
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;
LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
LSL_List new_rules = rules.GetSublist(idx, -1);
setLinkPrimParams((int)new_linknumber, new_rules);
return;
} }
} }
} }
@ -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();
}
} }
} }