Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
avinationmerge
Melanie 2012-08-18 13:57:50 +01:00
commit 5d43e27de2
9 changed files with 119 additions and 124 deletions

View File

@ -1240,9 +1240,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Float llGround(LSL_Vector offset) public LSL_Float llGround(LSL_Vector offset)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x, Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
(float)offset.y,
(float)offset.z);
//Get the slope normal. This gives us the equation of the plane tangent to the slope. //Get the slope normal. This gives us the equation of the plane tangent to the slope.
LSL_Vector vsn = llGroundNormal(offset); LSL_Vector vsn = llGroundNormal(offset);
@ -1578,7 +1576,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face == ScriptBaseClass.ALL_SIDES) if (face == ScriptBaseClass.ALL_SIDES)
face = SceneObjectPart.ALL_SIDES; face = SceneObjectPart.ALL_SIDES;
m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); m_host.SetFaceColor(color, face);
} }
public void SetTexGen(SceneObjectPart part, int face,int style) public void SetTexGen(SceneObjectPart part, int face,int style)
@ -2208,7 +2206,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
bool sameParcel = here.GlobalID == there.GlobalID; bool sameParcel = here.GlobalID == there.GlobalID;
if (!sameParcel && !World.Permissions.CanObjectEntry(m_host.UUID, false, new Vector3((float)pos.x, (float)pos.y, (float)pos.z))) if (!sameParcel && !World.Permissions.CanRezObject(
m_host.ParentGroup.PrimCount, m_host.ParentGroup.OwnerID, pos))
{ {
return 0; return 0;
} }
@ -2267,16 +2266,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part.ParentGroup.RootPart == part) if (part.ParentGroup.RootPart == part)
{ {
SceneObjectGroup parent = part.ParentGroup; SceneObjectGroup parent = part.ParentGroup;
Vector3 dest = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); if (!World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos))
if (!World.Permissions.CanObjectEntry(parent.UUID, false, dest))
return; return;
Util.FireAndForget(delegate(object x) { Util.FireAndForget(delegate(object x) {
parent.UpdateGroupPosition(dest); parent.UpdateGroupPosition((Vector3)toPos);
}); });
} }
else else
{ {
part.OffsetPosition = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); part.OffsetPosition = (Vector3)toPos;
SceneObjectGroup parent = part.ParentGroup; SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true; parent.HasGroupChanged = true;
parent.ScheduleGroupForTerseUpdate(); parent.ScheduleGroupForTerseUpdate();
@ -2314,7 +2312,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
pos = part.AbsolutePosition; pos = part.AbsolutePosition;
} }
return new LSL_Vector(pos.X, pos.Y, pos.Z); // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos);
return new LSL_Vector(pos);
} }
public void llSetRot(LSL_Rotation rot) public void llSetRot(LSL_Rotation rot)
@ -2464,7 +2464,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (local != 0) if (local != 0)
force *= llGetRot(); force *= llGetRot();
m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z)); m_host.ParentGroup.RootPart.SetForce(force);
} }
} }
@ -2476,10 +2476,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_host.ParentGroup.IsDeleted) if (!m_host.ParentGroup.IsDeleted)
{ {
Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce(); force = m_host.ParentGroup.RootPart.GetForce();
force.x = tmpForce.X;
force.y = tmpForce.Y;
force.z = tmpForce.Z;
} }
return force; return force;
@ -2488,8 +2485,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llTarget(LSL_Vector position, double range) public LSL_Integer llTarget(LSL_Vector position, double range)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
return m_host.ParentGroup.registerTargetWaypoint( return m_host.ParentGroup.registerTargetWaypoint(position,
new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range); (float)range);
} }
public void llTargetRemove(int number) public void llTargetRemove(int number)
@ -2514,7 +2511,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llMoveToTarget(LSL_Vector target, double tau) public void llMoveToTarget(LSL_Vector target, double tau)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.MoveToTarget(new Vector3((float)target.x, (float)target.y, (float)target.z), (float)tau); m_host.MoveToTarget(target, (float)tau);
} }
public void llStopMoveToTarget() public void llStopMoveToTarget()
@ -2527,7 +2524,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
//No energy force yet //No energy force yet
Vector3 v = new Vector3((float)force.x, (float)force.y, (float)force.z); Vector3 v = force;
if (v.Length() > 20000.0f) if (v.Length() > 20000.0f)
{ {
v.Normalize(); v.Normalize();
@ -2540,13 +2537,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llApplyRotationalImpulse(LSL_Vector force, int local) public void llApplyRotationalImpulse(LSL_Vector force, int local)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.ParentGroup.RootPart.ApplyAngularImpulse(new Vector3((float)force.x, (float)force.y, (float)force.z), local != 0); m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0);
} }
public void llSetTorque(LSL_Vector torque, int local) public void llSetTorque(LSL_Vector torque, int local)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.ParentGroup.RootPart.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0); m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0);
} }
public LSL_Vector llGetTorque() public LSL_Vector llGetTorque()
@ -3111,13 +3108,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return; return;
} }
Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z);
// need the magnitude later // need the magnitude later
// float velmag = (float)Util.GetMagnitude(llvel); // float velmag = (float)Util.GetMagnitude(llvel);
SceneObjectGroup new_group = World.RezObject(m_host, item, llpos, Rot2Quaternion(rot), llvel, param); SceneObjectGroup new_group = World.RezObject(m_host, item, pos, Rot2Quaternion(rot), vel, param);
// If either of these are null, then there was an unknown error. // If either of these are null, then there was an unknown error.
if (new_group == null) if (new_group == null)
@ -3144,11 +3138,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
PhysicsActor pa = new_group.RootPart.PhysActor; PhysicsActor pa = new_group.RootPart.PhysActor;
if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
{ {
float groupmass = new_group.GetMass(); float groupmass = new_group.GetMass();
llvel *= -groupmass; vel *= -groupmass;
llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); llApplyImpulse(vel, 0);
} }
// Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
return; return;
@ -3706,7 +3700,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain) protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain)
{ {
part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate))); part.UpdateAngularVelocity(axis * spinrate);
} }
public LSL_Integer llGetStartParameter() public LSL_Integer llGetStartParameter()
@ -3916,7 +3910,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
try try
{ {
foreach (SceneObjectPart part in parts) foreach (SceneObjectPart part in parts)
part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); part.SetFaceColor(color, face);
} }
finally finally
{ {
@ -4386,8 +4380,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetText(string text, LSL_Vector color, double alpha) public void llSetText(string text, LSL_Vector color, double alpha)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 av3 = Util.Clip(new Vector3((float)color.x, (float)color.y, Vector3 av3 = Util.Clip(color, 0.0f, 1.0f);
(float)color.z), 0.0f, 1.0f);
m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
//m_host.ParentGroup.HasGroupChanged = true; //m_host.ParentGroup.HasGroupChanged = true;
//m_host.ParentGroup.ScheduleGroupForFullUpdate(); //m_host.ParentGroup.ScheduleGroupForFullUpdate();
@ -4603,14 +4596,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScriptSleep(5000); ScriptSleep(5000);
} }
public void llTeleportAgent(string agent, string destination, LSL_Vector pos, LSL_Vector lookAt) public void llTeleportAgent(string agent, string destination, LSL_Vector targetPos, LSL_Vector targetLookAt)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID agentId = new UUID(); UUID agentId = new UUID();
Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z);
if (UUID.TryParse(agent, out agentId)) if (UUID.TryParse(agent, out agentId))
{ {
ScenePresence presence = World.GetScenePresence(agentId); ScenePresence presence = World.GetScenePresence(agentId);
@ -4639,15 +4629,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector pos, LSL_Vector lookAt) public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector targetPos, LSL_Vector targetLookAt)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID agentId = new UUID(); UUID agentId = new UUID();
ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y); ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y);
Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z);
if (UUID.TryParse(agent, out agentId)) if (UUID.TryParse(agent, out agentId))
{ {
ScenePresence presence = World.GetScenePresence(agentId); ScenePresence presence = World.GetScenePresence(agentId);
@ -4944,7 +4932,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
distance_attenuation = 1f / normalized_units; distance_attenuation = 1f / normalized_units;
} }
Vector3 applied_linear_impulse = new Vector3((float)impulse.x, (float)impulse.y, (float)impulse.z); Vector3 applied_linear_impulse = impulse;
{ {
float impulse_length = applied_linear_impulse.Length(); float impulse_length = applied_linear_impulse.Length();
@ -6505,9 +6493,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//Plug the x,y coordinates of the slope normal into the equation of the plane to get //Plug the x,y coordinates of the slope normal into the equation of the plane to get
//the height of that point on the plane. The resulting vector gives the slope. //the height of that point on the plane. The resulting vector gives the slope.
Vector3 vsl = new Vector3(); Vector3 vsl = vsn;
vsl.X = (float)vsn.x;
vsl.Y = (float)vsn.y;
vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z)); vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z));
vsl.Normalize(); vsl.Normalize();
//Normalization might be overkill here //Normalization might be overkill here
@ -6518,9 +6504,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llGroundNormal(LSL_Vector offset) public LSL_Vector llGroundNormal(LSL_Vector offset)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x, Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
(float)offset.y,
(float)offset.z);
// Clamp to valid position // Clamp to valid position
if (pos.X < 0) if (pos.X < 0)
pos.X = 0; pos.X = 0;
@ -6974,8 +6958,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_host.ParentGroup.IsDeleted) if (!m_host.ParentGroup.IsDeleted)
{ {
m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, vec);
new Vector3((float)vec.x, (float)vec.y, (float)vec.z));
} }
} }
@ -7017,7 +7000,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
rot.s = 1; // ZERO_ROTATION = 0,0,0,1 rot.s = 1; // ZERO_ROTATION = 0,0,0,1
part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); part.SitTargetPosition = offset;
part.SitTargetOrientation = Rot2Quaternion(rot); part.SitTargetOrientation = Rot2Quaternion(rot);
part.ParentGroup.HasGroupChanged = true; part.ParentGroup.HasGroupChanged = true;
} }
@ -7121,13 +7104,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetCameraEyeOffset(LSL_Vector offset) public void llSetCameraEyeOffset(LSL_Vector offset)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.SetCameraEyeOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); m_host.SetCameraEyeOffset(offset);
} }
public void llSetCameraAtOffset(LSL_Vector offset) public void llSetCameraAtOffset(LSL_Vector offset)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
m_host.SetCameraAtOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); m_host.SetCameraAtOffset(offset);
} }
public LSL_String llDumpList2String(LSL_List src, string seperator) public LSL_String llDumpList2String(LSL_List src, string seperator)
@ -7149,7 +7132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llScriptDanger(LSL_Vector pos) public LSL_Integer llScriptDanger(LSL_Vector pos)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)); bool result = World.ScriptDanger(m_host.LocalId, pos);
if (result) if (result)
{ {
return 1; return 1;
@ -8263,7 +8246,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector color=rules.GetVector3Item(idx++); LSL_Vector color=rules.GetVector3Item(idx++);
double alpha=(double)rules.GetLSLFloatItem(idx++); double alpha=(double)rules.GetLSLFloatItem(idx++);
part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); part.SetFaceColor(color, face);
SetAlpha(part, alpha, face); SetAlpha(part, alpha, face);
break; break;
@ -8412,9 +8395,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string primText = rules.GetLSLStringItem(idx++); string primText = rules.GetLSLStringItem(idx++);
LSL_Vector primTextColor = rules.GetVector3Item(idx++); LSL_Vector primTextColor = rules.GetVector3Item(idx++);
LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++);
Vector3 av3 = Util.Clip(new Vector3((float)primTextColor.x, Vector3 av3 = Util.Clip(primTextColor, 0.0f, 1.0f);
(float)primTextColor.y,
(float)primTextColor.z), 0.0f, 1.0f);
part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f));
break; break;
@ -8470,12 +8451,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
SceneObjectGroup parent = part.ParentGroup; SceneObjectGroup parent = part.ParentGroup;
Util.FireAndForget(delegate(object x) { Util.FireAndForget(delegate(object x) {
parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); parent.UpdateGroupPosition(currentPosition);
}); });
} }
else else
{ {
part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); part.OffsetPosition = currentPosition;
SceneObjectGroup parent = part.ParentGroup; SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true; parent.HasGroupChanged = true;
parent.ScheduleGroupForTerseUpdate(); parent.ScheduleGroupForTerseUpdate();
@ -11161,9 +11142,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence avatar = World.GetScenePresence(detectedParams.Key); ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
if (avatar != null) if (avatar != null)
{ {
avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname, avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name,
new Vector3((float)pos.x, (float)pos.y, (float)pos.z), simname, pos, lookAt);
new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
} }
ScriptSleep(1000); ScriptSleep(1000);
@ -12510,8 +12490,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 rayStart = new Vector3((float)start.x, (float)start.y, (float)start.z); Vector3 rayStart = start;
Vector3 rayEnd = new Vector3((float)end.x, (float)end.y, (float)end.z); Vector3 rayEnd = end;
Vector3 dir = rayEnd - rayStart; Vector3 dir = rayEnd - rayStart;
float dist = Vector3.Mag(dir); float dist = Vector3.Mag(dir);

View File

@ -304,7 +304,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
idx++; idx++;
iV = rules.GetVector3Item(idx); iV = rules.GetVector3Item(idx);
wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); wl.cloudDetailXYDensity = iV;
break; break;
case (int)ScriptBaseClass.WL_CLOUD_SCALE: case (int)ScriptBaseClass.WL_CLOUD_SCALE:
idx++; idx++;
@ -329,7 +329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
idx++; idx++;
iV = rules.GetVector3Item(idx); iV = rules.GetVector3Item(idx);
wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); wl.cloudXYDensity = iV;
break; break;
case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
idx++; idx++;
@ -384,7 +384,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
idx++; idx++;
iV = rules.GetVector3Item(idx); iV = rules.GetVector3Item(idx);
wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); wl.reflectionWaveletScale = iV;
break; break;
case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
idx++; idx++;
@ -422,7 +422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_WATER_COLOR: case (int)ScriptBaseClass.WL_WATER_COLOR:
idx++; idx++;
iV = rules.GetVector3Item(idx); iV = rules.GetVector3Item(idx);
wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); wl.waterColor = iV;
break; break;
case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
idx++; idx++;

View File

@ -343,8 +343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if (type == typeof(OpenMetaverse.Vector3)) if (type == typeof(OpenMetaverse.Vector3))
{ {
LSL_Vector vect = (LSL_Vector)lslparm; return (OpenMetaverse.Vector3)((LSL_Vector)lslparm);
return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z);
} }
} }
@ -372,8 +371,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
else if (plist[i] is LSL_Vector) else if (plist[i] is LSL_Vector)
{ {
LSL_Vector vect = (LSL_Vector)plist[i]; result[i] = (OpenMetaverse.Vector3)(
result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); (LSL_Vector)plist[i]);
} }
else else
MODError("unknown LSL list element type"); MODError("unknown LSL list element type");

View File

@ -782,10 +782,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// We will launch the teleport on a new thread so that when the script threads are terminated // We will launch the teleport on a new thread so that when the script threads are terminated
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
Util.FireAndForget( Util.FireAndForget(o => World.RequestTeleportLocation(
o => World.RequestTeleportLocation(presence.ControllingClient, regionName, presence.ControllingClient, regionName, position,
new Vector3((float)position.x, (float)position.y, (float)position.z), lookat, (uint)TPFlags.ViaLocation));
new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
ScriptSleep(5000); ScriptSleep(5000);
@ -828,10 +827,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// We will launch the teleport on a new thread so that when the script threads are terminated // We will launch the teleport on a new thread so that when the script threads are terminated
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
Util.FireAndForget( Util.FireAndForget(o => World.RequestTeleportLocation(
o => World.RequestTeleportLocation(presence.ControllingClient, regionHandle, presence.ControllingClient, regionHandle,
new Vector3((float)position.x, (float)position.y, (float)position.z), position, lookat, (uint)TPFlags.ViaLocation));
new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
ScriptSleep(5000); ScriptSleep(5000);
@ -2355,7 +2353,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ownerID = m_host.OwnerID; ownerID = m_host.OwnerID;
UUID x = module.CreateNPC(firstname, UUID x = module.CreateNPC(firstname,
lastname, lastname,
new Vector3((float) position.x, (float) position.y, (float) position.z), position,
ownerID, ownerID,
senseAsAgent, senseAsAgent,
World, World,
@ -2478,7 +2476,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Vector(0, 0, 0); return new LSL_Vector(0, 0, 0);
} }
public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos)
{ {
CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
@ -2493,7 +2491,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!module.CheckPermissions(npcId, m_host.OwnerID)) if (!module.CheckPermissions(npcId, m_host.OwnerID))
return; return;
Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
module.MoveToTarget(npcId, World, pos, false, true, false); module.MoveToTarget(npcId, World, pos, false, true, false);
} }
} }
@ -2513,11 +2510,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!module.CheckPermissions(npcId, m_host.OwnerID)) if (!module.CheckPermissions(npcId, m_host.OwnerID))
return; return;
Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
module.MoveToTarget( module.MoveToTarget(
new UUID(npc.m_string), new UUID(npc.m_string),
World, World,
pos, target,
(options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
(options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0, (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0,
(options & ScriptBaseClass.OS_NPC_RUNNING) != 0); (options & ScriptBaseClass.OS_NPC_RUNNING) != 0);

View File

@ -429,9 +429,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
try try
{ {
Vector3 diff = toRegionPos - fromRegionPos; Vector3 diff = toRegionPos - fromRegionPos;
LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); double dot = LSL_Types.Vector3.Dot(forward_dir, diff);
double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); double mag_obj = LSL_Types.Vector3.Mag(diff);
double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
} }
catch catch
@ -564,8 +563,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
double ang_obj = 0; double ang_obj = 0;
try try
{ {
Vector3 diff = toRegionPos - fromRegionPos; LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(
LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); toRegionPos - fromRegionPos);
double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
double mag_obj = LSL_Types.Vector3.Mag(obj_dir); double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));

View File

@ -164,11 +164,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
else else
{ {
// Set the values from the touch data provided by the client // Set the values from the touch data provided by the client
touchST = new LSL_Types.Vector3(value.STCoord.X, value.STCoord.Y, value.STCoord.Z); touchST = new LSL_Types.Vector3(value.STCoord);
touchUV = new LSL_Types.Vector3(value.UVCoord.X, value.UVCoord.Y, value.UVCoord.Z); touchUV = new LSL_Types.Vector3(value.UVCoord);
touchNormal = new LSL_Types.Vector3(value.Normal.X, value.Normal.Y, value.Normal.Z); touchNormal = new LSL_Types.Vector3(value.Normal);
touchBinormal = new LSL_Types.Vector3(value.Binormal.X, value.Binormal.Y, value.Binormal.Z); touchBinormal = new LSL_Types.Vector3(value.Binormal);
touchPos = new LSL_Types.Vector3(value.Position.X, value.Position.Y, value.Position.Z); touchPos = new LSL_Types.Vector3(value.Position);
touchFace = value.FaceIndex; touchFace = value.FaceIndex;
} }
} }
@ -189,19 +189,13 @@ namespace OpenSim.Region.ScriptEngine.Shared
Country = account.UserCountry; Country = account.UserCountry;
Owner = Key; Owner = Key;
Position = new LSL_Types.Vector3( Position = new LSL_Types.Vector3(presence.AbsolutePosition);
presence.AbsolutePosition.X,
presence.AbsolutePosition.Y,
presence.AbsolutePosition.Z);
Rotation = new LSL_Types.Quaternion( Rotation = new LSL_Types.Quaternion(
presence.Rotation.X, presence.Rotation.X,
presence.Rotation.Y, presence.Rotation.Y,
presence.Rotation.Z, presence.Rotation.Z,
presence.Rotation.W); presence.Rotation.W);
Velocity = new LSL_Types.Vector3( Velocity = new LSL_Types.Vector3(presence.Velocity);
presence.Velocity.X,
presence.Velocity.Y,
presence.Velocity.Z);
Type = 0x01; // Avatar Type = 0x01; // Avatar
if (presence.PresenceType == PresenceType.Npc) if (presence.PresenceType == PresenceType.Npc)
@ -254,16 +248,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
} }
} }
Position = new LSL_Types.Vector3(part.AbsolutePosition.X, Position = new LSL_Types.Vector3(part.AbsolutePosition);
part.AbsolutePosition.Y,
part.AbsolutePosition.Z);
Quaternion wr = part.ParentGroup.GroupRotation; Quaternion wr = part.ParentGroup.GroupRotation;
Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W);
Velocity = new LSL_Types.Vector3(part.Velocity.X, Velocity = new LSL_Types.Vector3(part.Velocity);
part.Velocity.Y,
part.Velocity.Z);
} }
} }

View File

@ -31,6 +31,11 @@ using System.Globalization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using OpenSim.Framework; using OpenSim.Framework;
using OpenMetaverse;
using OMV_Vector3 = OpenMetaverse.Vector3;
using OMV_Vector3d = OpenMetaverse.Vector3d;
using OMV_Quaternion = OpenMetaverse.Quaternion;
namespace OpenSim.Region.ScriptEngine.Shared namespace OpenSim.Region.ScriptEngine.Shared
{ {
[Serializable] [Serializable]
@ -54,6 +59,20 @@ namespace OpenSim.Region.ScriptEngine.Shared
z = (float)vector.z; z = (float)vector.z;
} }
public Vector3(OMV_Vector3 vector)
{
x = vector.X;
y = vector.Y;
z = vector.Z;
}
public Vector3(OMV_Vector3d vector)
{
x = vector.X;
y = vector.Y;
z = vector.Z;
}
public Vector3(double X, double Y, double Z) public Vector3(double X, double Y, double Z)
{ {
x = X; x = X;
@ -109,6 +128,26 @@ namespace OpenSim.Region.ScriptEngine.Shared
return new list(new object[] { vec }); return new list(new object[] { vec });
} }
public static implicit operator OMV_Vector3(Vector3 vec)
{
return new OMV_Vector3((float)vec.x, (float)vec.y, (float)vec.z);
}
public static implicit operator Vector3(OMV_Vector3 vec)
{
return new Vector3(vec);
}
public static implicit operator OMV_Vector3d(Vector3 vec)
{
return new OMV_Vector3d(vec.x, vec.y, vec.z);
}
public static implicit operator Vector3(OMV_Vector3d vec)
{
return new Vector3(vec);
}
public static bool operator ==(Vector3 lhs, Vector3 rhs) public static bool operator ==(Vector3 lhs, Vector3 rhs)
{ {
return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z);

View File

@ -152,9 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
det[0] = new DetectParams(); det[0] = new DetectParams();
det[0].Key = remoteClient.AgentId; det[0].Key = remoteClient.AgentId;
det[0].Populate(myScriptEngine.World); det[0].Populate(myScriptEngine.World);
det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X, det[0].OffsetPos = offsetPos;
offsetPos.Y,
offsetPos.Z);
if (originalID == 0) if (originalID == 0)
{ {
@ -298,9 +296,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders) foreach (DetectedObject detobj in col.Colliders)
{ {
DetectParams d = new DetectParams(); DetectParams d = new DetectParams();
d.Position = new LSL_Types.Vector3(detobj.posVector.X, d.Position = detobj.posVector;
detobj.posVector.Y,
detobj.posVector.Z);
d.Populate(myScriptEngine.World); d.Populate(myScriptEngine.World);
det.Add(d); det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams( myScriptEngine.PostObjectEvent(localID, new EventParams(
@ -318,9 +314,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders) foreach (DetectedObject detobj in col.Colliders)
{ {
DetectParams d = new DetectParams(); DetectParams d = new DetectParams();
d.Position = new LSL_Types.Vector3(detobj.posVector.X, d.Position = detobj.posVector;
detobj.posVector.Y,
detobj.posVector.Z);
d.Populate(myScriptEngine.World); d.Populate(myScriptEngine.World);
det.Add(d); det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams( myScriptEngine.PostObjectEvent(localID, new EventParams(
@ -337,9 +331,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders) foreach (DetectedObject detobj in col.Colliders)
{ {
DetectParams d = new DetectParams(); DetectParams d = new DetectParams();
d.Position = new LSL_Types.Vector3(detobj.posVector.X, d.Position = detobj.posVector;
detobj.posVector.Y,
detobj.posVector.Z);
d.Populate(myScriptEngine.World); d.Populate(myScriptEngine.World);
det.Add(d); det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams( myScriptEngine.PostObjectEvent(localID, new EventParams(
@ -381,8 +373,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
myScriptEngine.PostObjectEvent(localID, new EventParams( myScriptEngine.PostObjectEvent(localID, new EventParams(
"at_target", new object[] { "at_target", new object[] {
new LSL_Types.LSLInteger(handle), new LSL_Types.LSLInteger(handle),
new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), new LSL_Types.Vector3(targetpos),
new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }, new LSL_Types.Vector3(atpos) },
new DetectParams[0])); new DetectParams[0]));
} }

View File

@ -1556,7 +1556,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
else if (p[i] is string) else if (p[i] is string)
lsl_p[i] = new LSL_Types.LSLString((string)p[i]); lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
else if (p[i] is Vector3) else if (p[i] is Vector3)
lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]);
else if (p[i] is Quaternion) else if (p[i] is Quaternion)
lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
else if (p[i] is float) else if (p[i] is float)
@ -1582,7 +1582,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
else if (p[i] is string) else if (p[i] is string)
lsl_p[i] = new LSL_Types.LSLString((string)p[i]); lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
else if (p[i] is Vector3) else if (p[i] is Vector3)
lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]);
else if (p[i] is Quaternion) else if (p[i] is Quaternion)
lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
else if (p[i] is float) else if (p[i] is float)