refactoring for Vector3 operator & constructor tweaks

integration
SignpostMarv 2012-08-18 01:17:01 +01:00 committed by Melanie
parent 9d6fe1224a
commit 5d7751da89
9 changed files with 119 additions and 125 deletions

View File

@ -1097,9 +1097,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);
@ -1387,7 +1385,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)
@ -1974,7 +1972,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
bool sameParcel = here.GlobalID == there.GlobalID; bool sameParcel = here.GlobalID == there.GlobalID;
if (!sameParcel && !World.Permissions.CanRezObject(m_host.ParentGroup.PrimCount, m_host.ParentGroup.OwnerID, 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;
} }
@ -2034,13 +2033,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0)
targetPos.z = ground; targetPos.z = ground;
SceneObjectGroup parent = part.ParentGroup; SceneObjectGroup parent = part.ParentGroup;
LSL_Vector real_vec = !adjust ? targetPos : SetPosAdjust(currentPos, targetPos); parent.UpdateGroupPosition(!adjust ? targetPos :
parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z)); SetPosAdjust(currentPos, targetPos));
} }
else else
{ {
LSL_Vector rel_vec = !adjust ? targetPos : SetPosAdjust(currentPos, targetPos); part.OffsetPosition = !adjust ? targetPos : SetPosAdjust(
part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z); currentPos, targetPos);
SceneObjectGroup parent = part.ParentGroup; SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true; parent.HasGroupChanged = true;
parent.ScheduleGroupForTerseUpdate(); parent.ScheduleGroupForTerseUpdate();
@ -2084,7 +2083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// 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.X, pos.Y, pos.Z); return new LSL_Vector(pos);
} }
public void llSetRot(LSL_Rotation rot) public void llSetRot(LSL_Rotation rot)
@ -2198,7 +2197,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);
} }
} }
@ -2210,10 +2209,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;
@ -2222,8 +2218,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)
@ -2248,7 +2244,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()
@ -2261,7 +2257,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();
@ -2273,13 +2269,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.ApplyAngularImpulse(new Vector3((float)force.x, (float)force.y, (float)force.z), local != 0); m_host.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.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0); m_host.SetAngularImpulse(torque, local != 0);
} }
public LSL_Vector llGetTorque() public LSL_Vector llGetTorque()
@ -2830,13 +2826,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)
@ -2857,10 +2850,10 @@ 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)
{ {
//Recoil. //Recoil.
llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); llApplyImpulse(vel * groupmass, 0);
} }
// Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
}); });
@ -3381,7 +3374,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()
@ -3588,7 +3581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List<SceneObjectPart> parts = GetLinkParts(linknumber); List<SceneObjectPart> parts = GetLinkParts(linknumber);
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);
} }
public void llCreateLink(string target, int parent) public void llCreateLink(string target, int parent)
@ -4019,8 +4012,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();
@ -4217,14 +4209,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);
@ -4253,15 +4242,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);
@ -4545,7 +4532,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();
@ -6044,9 +6031,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
@ -6057,9 +6042,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;
@ -6512,8 +6495,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));
} }
} }
@ -6555,7 +6537,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.z = 1; // ZERO_ROTATION = 0,0,0,1 rot.z = 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;
} }
@ -6659,13 +6641,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)
@ -6687,7 +6669,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;
@ -7515,7 +7497,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;
@ -7634,9 +7616,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;
@ -7691,11 +7671,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part.ParentGroup.RootPart == part) if (part.ParentGroup.RootPart == part)
{ {
SceneObjectGroup parent = part.ParentGroup; SceneObjectGroup parent = part.ParentGroup;
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();
@ -7932,8 +7912,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part != null) if (part != null)
{ {
Vector3 halfSize = part.Scale / 2.0f; Vector3 halfSize = part.Scale / 2.0f;
LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f); LSL_Vector lower = (new LSL_Vector(halfSize)) * -1.0f;
LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z); LSL_Vector upper = new LSL_Vector(halfSize);
result.Add(lower); result.Add(lower);
result.Add(upper); result.Add(upper);
return result; return result;
@ -9943,9 +9923,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);
} }
@ -11143,8 +11122,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

@ -773,10 +773,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);
@ -819,10 +818,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);
@ -2329,7 +2327,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,
@ -2446,7 +2444,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);
@ -2461,7 +2459,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);
} }
} }
@ -2481,11 +2478,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

@ -428,9 +428,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
@ -560,8 +559,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

@ -160,11 +160,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;
} }
} }
@ -181,19 +181,13 @@ namespace OpenSim.Region.ScriptEngine.Shared
Name = presence.Firstname + " " + presence.Lastname; Name = presence.Firstname + " " + presence.Lastname;
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);
if (presence.PresenceType != PresenceType.Npc) if (presence.PresenceType != PresenceType.Npc)
{ {
@ -241,16 +235,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

@ -1467,7 +1467,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)
@ -1493,7 +1493,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)