| Anonymous | Login | Signup for a new account | 2013-05-25 13:22 UTC | ![]() |
| Main | My View | View Issues | Change Log | Roadmap | Summary | My Account |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||
| 0006174 | opensim | [REGION] OpenSim Core | public | 2012-08-18 00:23 | 2012-08-18 12:44 | ||||
| Reporter | SignpostMarv | ||||||||
| Assigned To | melanie | ||||||||
| Priority | normal | Severity | tweak | Reproducibility | N/A | ||||
| Status | resolved | Resolution | fixed | ||||||
| Platform | OS | OS Version | |||||||
| Product Version | master (dev code) | ||||||||
| Target Version | Fixed in Version | ||||||||
| Summary | 0006174: Add constructors & operators to LSL types to avoid typecasting | ||||||||
| Description | Following on from a conversation in #opensim-dev, decided to experiment with additional constructors and implicit operators to avoid manual typecasting between LSL and libOMV types | ||||||||
| Tags | No tags attached. | ||||||||
| Git Revision or version number | |||||||||
| Run Mode | Standalone (1 Region) | ||||||||
| Physics Engine | BasicPhysics | ||||||||
| Environment | .NET / Windows64 | ||||||||
| Mono Version | None | ||||||||
| Viewer | |||||||||
| Attached Files | From f15694042c29676ee81c98b50e355ada9d47c718 Mon Sep 17 00:00:00 2001
From: SignpostMarv <github@signpostmarv.name>
Date: Sat, 18 Aug 2012 01:17:01 +0100
Subject: [PATCH] refactoring for Vector3 operator & constructor tweaks
---
.../Shared/Api/Implementation/LSL_Api.cs | 107 +++++++++------------
.../Shared/Api/Implementation/LS_Api.cs | 8 +-
.../Shared/Api/Implementation/MOD_Api.cs | 7 +-
.../Shared/Api/Implementation/OSSL_Api.cs | 22 ++---
.../Api/Implementation/Plugins/SensorRepeat.cs | 9 +-
OpenSim/Region/ScriptEngine/Shared/Helpers.cs | 28 ++----
OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 39 ++++++++
.../Region/ScriptEngine/XEngine/EventManager.cs | 20 ++--
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 +-
9 files changed, 119 insertions(+), 125 deletions(-)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6a2b829..9dd1a78 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1097,9 +1097,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Float llGround(LSL_Vector offset)
{
m_host.AddScriptLPS(1);
- Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x,
- (float)offset.y,
- (float)offset.z);
+ Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
//Get the slope normal. This gives us the equation of the plane tangent to the slope.
LSL_Vector vsn = llGroundNormal(offset);
@@ -1387,7 +1385,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face == ScriptBaseClass.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)
@@ -1974,7 +1972,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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;
}
@@ -2034,13 +2033,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0)
targetPos.z = ground;
SceneObjectGroup parent = part.ParentGroup;
- LSL_Vector real_vec = !adjust ? targetPos : SetPosAdjust(currentPos, targetPos);
- parent.UpdateGroupPosition(new Vector3((float)real_vec.x, (float)real_vec.y, (float)real_vec.z));
+ parent.UpdateGroupPosition(!adjust ? targetPos :
+ SetPosAdjust(currentPos, targetPos));
}
else
{
- LSL_Vector rel_vec = !adjust ? targetPos : SetPosAdjust(currentPos, targetPos);
- part.OffsetPosition = new Vector3((float)rel_vec.x, (float)rel_vec.y, (float)rel_vec.z);
+ part.OffsetPosition = !adjust ? targetPos : SetPosAdjust(
+ currentPos, targetPos);
SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true;
parent.ScheduleGroupForTerseUpdate();
@@ -2084,7 +2083,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// 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)
@@ -2198,7 +2197,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (local != 0)
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)
{
- Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce();
- force.x = tmpForce.X;
- force.y = tmpForce.Y;
- force.z = tmpForce.Z;
+ force = m_host.ParentGroup.RootPart.GetForce();
}
return force;
@@ -2222,8 +2218,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llTarget(LSL_Vector position, double range)
{
m_host.AddScriptLPS(1);
- return m_host.ParentGroup.registerTargetWaypoint(
- new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range);
+ return m_host.ParentGroup.registerTargetWaypoint(position,
+ (float)range);
}
public void llTargetRemove(int number)
@@ -2248,7 +2244,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llMoveToTarget(LSL_Vector target, double tau)
{
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()
@@ -2261,7 +2257,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
//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)
{
v.Normalize();
@@ -2273,13 +2269,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llApplyRotationalImpulse(LSL_Vector force, int local)
{
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)
{
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()
@@ -2830,13 +2826,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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
// 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 (new_group == null)
@@ -2857,10 +2850,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
PhysicsActor pa = new_group.RootPart.PhysActor;
- if (pa != null && pa.IsPhysical && llvel != Vector3.Zero)
+ if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
{
//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)
});
@@ -3381,7 +3374,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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()
@@ -3588,7 +3581,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List<SceneObjectPart> parts = GetLinkParts(linknumber);
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)
@@ -4019,8 +4012,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetText(string text, LSL_Vector color, double alpha)
{
m_host.AddScriptLPS(1);
- Vector3 av3 = Util.Clip(new Vector3((float)color.x, (float)color.y,
- (float)color.z), 0.0f, 1.0f);
+ Vector3 av3 = Util.Clip(color, 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.ScheduleGroupForFullUpdate();
@@ -4217,14 +4209,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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);
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))
{
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);
UUID agentId = new UUID();
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))
{
ScenePresence presence = World.GetScenePresence(agentId);
@@ -4545,7 +4532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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();
@@ -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
//the height of that point on the plane. The resulting vector gives the slope.
- Vector3 vsl = new Vector3();
- vsl.X = (float)vsn.x;
- vsl.Y = (float)vsn.y;
+ Vector3 vsl = vsn;
vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z));
vsl.Normalize();
//Normalization might be overkill here
@@ -6057,9 +6042,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llGroundNormal(LSL_Vector offset)
{
m_host.AddScriptLPS(1);
- Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x,
- (float)offset.y,
- (float)offset.z);
+ Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
// Clamp to valid position
if (pos.X < 0)
pos.X = 0;
@@ -6512,8 +6495,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_host.ParentGroup.IsDeleted)
{
- m_host.ParentGroup.RootPart.SetVehicleVectorParam(param,
- new Vector3((float)vec.x, (float)vec.y, (float)vec.z));
+ m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, vec);
}
}
@@ -6555,7 +6537,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
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.ParentGroup.HasGroupChanged = true;
}
@@ -6659,13 +6641,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetCameraEyeOffset(LSL_Vector offset)
{
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)
{
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)
@@ -6687,7 +6669,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llScriptDanger(LSL_Vector pos)
{
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)
{
return 1;
@@ -7515,7 +7497,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector color=rules.GetVector3Item(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);
break;
@@ -7634,9 +7616,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string primText = rules.GetLSLStringItem(idx++);
LSL_Vector primTextColor = rules.GetVector3Item(idx++);
LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++);
- Vector3 av3 = Util.Clip(new Vector3((float)primTextColor.x,
- (float)primTextColor.y,
- (float)primTextColor.z), 0.0f, 1.0f);
+ Vector3 av3 = Util.Clip(primTextColor, 0.0f, 1.0f);
part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f));
break;
@@ -7691,11 +7671,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part.ParentGroup.RootPart == part)
{
SceneObjectGroup parent = part.ParentGroup;
- parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z));
+ parent.UpdateGroupPosition(currentPosition);
}
else
{
- part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z);
+ part.OffsetPosition = currentPosition;
SceneObjectGroup parent = part.ParentGroup;
parent.HasGroupChanged = true;
parent.ScheduleGroupForTerseUpdate();
@@ -7932,8 +7912,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (part != null)
{
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 upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z);
+ LSL_Vector lower = (new LSL_Vector(halfSize)) * -1.0f;
+ LSL_Vector upper = new LSL_Vector(halfSize);
result.Add(lower);
result.Add(upper);
return result;
@@ -9943,9 +9923,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
if (avatar != null)
{
- avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname,
- new Vector3((float)pos.x, (float)pos.y, (float)pos.z),
- new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
+ avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name,
+ simname, pos, lookAt);
}
ScriptSleep(1000);
}
@@ -11143,8 +11122,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
- Vector3 rayStart = new Vector3((float)start.x, (float)start.y, (float)start.z);
- Vector3 rayEnd = new Vector3((float)end.x, (float)end.y, (float)end.z);
+ Vector3 rayStart = start;
+ Vector3 rayEnd = end;
Vector3 dir = rayEnd - rayStart;
float dist = Vector3.Mag(dir);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 795de80..ceb4660 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -304,7 +304,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
idx++;
iV = rules.GetVector3Item(idx);
- wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ wl.cloudDetailXYDensity = iV;
break;
case (int)ScriptBaseClass.WL_CLOUD_SCALE:
idx++;
@@ -329,7 +329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
idx++;
iV = rules.GetVector3Item(idx);
- wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ wl.cloudXYDensity = iV;
break;
case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
idx++;
@@ -384,7 +384,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
idx++;
iV = rules.GetVector3Item(idx);
- wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ wl.reflectionWaveletScale = iV;
break;
case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
idx++;
@@ -422,7 +422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.WL_WATER_COLOR:
idx++;
iV = rules.GetVector3Item(idx);
- wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
+ wl.waterColor = iV;
break;
case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
idx++;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 7844c75..929948b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -343,8 +343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (type == typeof(OpenMetaverse.Vector3))
{
- LSL_Vector vect = (LSL_Vector)lslparm;
- return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z);
+ return (OpenMetaverse.Vector3)((LSL_Vector)lslparm);
}
}
@@ -372,8 +371,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
else if (plist[i] is LSL_Vector)
{
- LSL_Vector vect = (LSL_Vector)plist[i];
- result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z);
+ result[i] = (OpenMetaverse.Vector3)(
+ (LSL_Vector)plist[i]);
}
else
MODError("unknown LSL list element type");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 859ee93..eff1598 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -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
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
- Util.FireAndForget(
- o => World.RequestTeleportLocation(presence.ControllingClient, regionName,
- new Vector3((float)position.x, (float)position.y, (float)position.z),
- new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
+ Util.FireAndForget(o => World.RequestTeleportLocation(
+ presence.ControllingClient, regionName, position,
+ lookat, (uint)TPFlags.ViaLocation));
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
// before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
- Util.FireAndForget(
- o => World.RequestTeleportLocation(presence.ControllingClient, regionHandle,
- new Vector3((float)position.x, (float)position.y, (float)position.z),
- new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
+ Util.FireAndForget(o => World.RequestTeleportLocation(
+ presence.ControllingClient, regionHandle,
+ position, lookat, (uint)TPFlags.ViaLocation));
ScriptSleep(5000);
@@ -2329,7 +2327,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ownerID = m_host.OwnerID;
UUID x = module.CreateNPC(firstname,
lastname,
- new Vector3((float) position.x, (float) position.y, (float) position.z),
+ position,
ownerID,
senseAsAgent,
World,
@@ -2446,7 +2444,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
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");
m_host.AddScriptLPS(1);
@@ -2461,7 +2459,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!module.CheckPermissions(npcId, m_host.OwnerID))
return;
- Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
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))
return;
- Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
module.MoveToTarget(
new UUID(npc.m_string),
World,
- pos,
+ target,
(options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
(options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0,
(options & ScriptBaseClass.OS_NPC_RUNNING) != 0);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index a626be8..7162226 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -428,9 +428,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
try
{
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, obj_dir);
- double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
+ double dot = LSL_Types.Vector3.Dot(forward_dir, diff);
+ double mag_obj = LSL_Types.Vector3.Mag(diff);
ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
}
catch
@@ -560,8 +559,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
double ang_obj = 0;
try
{
- Vector3 diff = toRegionPos - fromRegionPos;
- LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z);
+ LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(
+ toRegionPos - fromRegionPos);
double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
index 0108f44..5a58f73 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
@@ -160,11 +160,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
else
{
// 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);
- touchUV = new LSL_Types.Vector3(value.UVCoord.X, value.UVCoord.Y, value.UVCoord.Z);
- touchNormal = new LSL_Types.Vector3(value.Normal.X, value.Normal.Y, value.Normal.Z);
- touchBinormal = new LSL_Types.Vector3(value.Binormal.X, value.Binormal.Y, value.Binormal.Z);
- touchPos = new LSL_Types.Vector3(value.Position.X, value.Position.Y, value.Position.Z);
+ touchST = new LSL_Types.Vector3(value.STCoord);
+ touchUV = new LSL_Types.Vector3(value.UVCoord);
+ touchNormal = new LSL_Types.Vector3(value.Normal);
+ touchBinormal = new LSL_Types.Vector3(value.Binormal);
+ touchPos = new LSL_Types.Vector3(value.Position);
touchFace = value.FaceIndex;
}
}
@@ -181,19 +181,13 @@ namespace OpenSim.Region.ScriptEngine.Shared
Name = presence.Firstname + " " + presence.Lastname;
Owner = Key;
- Position = new LSL_Types.Vector3(
- presence.AbsolutePosition.X,
- presence.AbsolutePosition.Y,
- presence.AbsolutePosition.Z);
+ Position = new LSL_Types.Vector3(presence.AbsolutePosition);
Rotation = new LSL_Types.Quaternion(
presence.Rotation.X,
presence.Rotation.Y,
presence.Rotation.Z,
presence.Rotation.W);
- Velocity = new LSL_Types.Vector3(
- presence.Velocity.X,
- presence.Velocity.Y,
- presence.Velocity.Z);
+ Velocity = new LSL_Types.Vector3(presence.Velocity);
if (presence.PresenceType != PresenceType.Npc)
{
@@ -241,16 +235,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
}
}
- Position = new LSL_Types.Vector3(part.AbsolutePosition.X,
- part.AbsolutePosition.Y,
- part.AbsolutePosition.Z);
+ Position = new LSL_Types.Vector3(part.AbsolutePosition);
Quaternion wr = part.ParentGroup.GroupRotation;
Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W);
- Velocity = new LSL_Types.Vector3(part.Velocity.X,
- part.Velocity.Y,
- part.Velocity.Z);
+ Velocity = new LSL_Types.Vector3(part.Velocity);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 562433d..d18efe0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -31,6 +31,11 @@ using System.Globalization;
using System.Text.RegularExpressions;
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
{
[Serializable]
@@ -54,6 +59,20 @@ namespace OpenSim.Region.ScriptEngine.Shared
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)
{
x = X;
@@ -109,6 +128,26 @@ namespace OpenSim.Region.ScriptEngine.Shared
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)
{
return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 5c4174e..a1ad07d 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -152,9 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
det[0] = new DetectParams();
det[0].Key = remoteClient.AgentId;
det[0].Populate(myScriptEngine.World);
- det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
- offsetPos.Y,
- offsetPos.Z);
+ det[0].OffsetPos = offsetPos;
if (originalID == 0)
{
@@ -298,9 +296,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
- d.Position = new LSL_Types.Vector3(detobj.posVector.X,
- detobj.posVector.Y,
- detobj.posVector.Z);
+ d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
@@ -318,9 +314,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
- d.Position = new LSL_Types.Vector3(detobj.posVector.X,
- detobj.posVector.Y,
- detobj.posVector.Z);
+ d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
@@ -337,9 +331,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
- d.Position = new LSL_Types.Vector3(detobj.posVector.X,
- detobj.posVector.Y,
- detobj.posVector.Z);
+ d.Position = detobj.posVector;
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
@@ -381,8 +373,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
myScriptEngine.PostObjectEvent(localID, new EventParams(
"at_target", new object[] {
new LSL_Types.LSLInteger(handle),
- new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z),
- new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) },
+ new LSL_Types.Vector3(targetpos),
+ new LSL_Types.Vector3(atpos) },
new DetectParams[0]));
}
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 1571fb4..a05650a 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -1467,7 +1467,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
else if (p[i] is string)
lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
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)
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)
@@ -1493,7 +1493,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
else if (p[i] is string)
lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
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)
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)
--
1.7.11.msysgit.0
| ||||||||
Notes |
|
|
(0022117) SignpostMarv (reporter) 2012-08-18 00:24 |
I think I've done all the Vector3 refactoring. Will await feedback before continuing to refactor Quaternions. |
|
(0022365) melanie (administrator) 2012-08-18 12:44 |
Again, this patch changes unrelated whitespace. Please refrain from adjusting formatting on code as you come across it. Especially when it's wrong. in our coding style, this is wrong: part.OffsetPosition = !adjust ? targetPos : SetPosAdjust( currentPos, targetPos); we break long lines this way: part.OffsetPosition = !adjust ? targetPos : SetPosAdjust(currentPos, targetPos); Please don't "correct" whitespace to make it be wrong. Please submit whitespace changes in SEPARATE patches containing ONLY whitespace changes. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2012-08-18 00:23 | SignpostMarv | New Issue | |
| 2012-08-18 00:23 | SignpostMarv | File Added: LSL_Type_tweaks-Vector3.patch | |
| 2012-08-18 00:24 | SignpostMarv | Note Added: 0022117 | |
| 2012-08-18 00:24 | SignpostMarv | Status | new => patch included |
| 2012-08-18 11:32 | DMX04 | Issue cloned: 0006177 | |
| 2012-08-18 12:40 | melanie | Status | patch included => resolved |
| 2012-08-18 12:40 | melanie | Resolution | open => fixed |
| 2012-08-18 12:40 | melanie | Assigned To | => melanie |
| 2012-08-18 12:44 | melanie | Note Added: 0022365 | |
| Copyright © 2000 - 2012 MantisBT Group |




