Merge branch 'master' into httptests

This commit is contained in:
UbitUmarov
2016-11-07 11:36:43 +00:00
11 changed files with 210 additions and 119 deletions

View File

@@ -113,7 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected float m_MinTimerInterval = 0.5f;
protected float m_recoilScaleFactor = 0.0f;
protected DateTime m_timer = DateTime.Now;
protected double m_timer = Util.GetTimeStampMS();
protected bool m_waitingForScriptAnswer = false;
protected bool m_automaticLinkPermission = false;
protected IMessageTransferModule m_TransferModule = null;
@@ -662,15 +662,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
List<SceneObjectPart> ret = new List<SceneObjectPart>();
if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
return ret;
ret.Add(part);
switch (linkType)
{
case ScriptBaseClass.LINK_SET:
return new List<SceneObjectPart>(part.ParentGroup.Parts);
case ScriptBaseClass.LINK_ROOT:
ret = new List<SceneObjectPart>();
case ScriptBaseClass.LINK_ROOT:
ret.Add(part.ParentGroup.RootPart);
return ret;
@@ -690,16 +688,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return ret;
case ScriptBaseClass.LINK_THIS:
ret.Add(part);
return ret;
default:
if (linkType < 0)
return new List<SceneObjectPart>();
return ret;
SceneObjectPart target = part.ParentGroup.GetLinkNumPart(linkType);
if (target == null)
return new List<SceneObjectPart>();
ret = new List<SceneObjectPart>();
return ret;
ret.Add(target);
return ret;
}
@@ -3050,22 +3048,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Float llGetTime()
{
m_host.AddScriptLPS(1);
TimeSpan ScriptTime = DateTime.Now - m_timer;
return (double)(ScriptTime.TotalMilliseconds / 1000);
double ScriptTime = Util.GetTimeStampMS() - m_timer;
return (ScriptTime / 1000.0);
}
public void llResetTime()
{
m_host.AddScriptLPS(1);
m_timer = DateTime.Now;
m_timer = Util.GetTimeStampMS();
}
public LSL_Float llGetAndResetTime()
{
m_host.AddScriptLPS(1);
TimeSpan ScriptTime = DateTime.Now - m_timer;
m_timer = DateTime.Now;
return (double)(ScriptTime.TotalMilliseconds / 1000);
double now = Util.GetTimeStampMS();
double ScriptTime = now - m_timer;
m_timer = now;
return (ScriptTime / 1000.0);
}
public void llSound(string sound, double volume, int queue, int loop)
@@ -10086,6 +10085,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
part.UpdateSlice((float)slice.x, (float)slice.y);
break;
case ScriptBaseClass.PRIM_SIT_TARGET:
if (remain < 3)
return new LSL_List();
int active;
try
{
active = rules.GetLSLIntegerItem(idx++);
}
catch(InvalidCastException)
{
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SIT_TARGET: arg #{1} - parameter 1 must be integer", rulesParsed, idx - idxStart - 1));
return new LSL_List();
}
LSL_Vector offset;
try
{
offset = rules.GetVector3Item(idx++);
}
catch(InvalidCastException)
{
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SIT_TARGET: arg #{1} - parameter 2 must be vector", rulesParsed, idx - idxStart - 1));
return new LSL_List();
}
LSL_Rotation sitrot;
try
{
sitrot = rules.GetQuaternionItem(idx++);
}
catch(InvalidCastException)
{
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SIT_TARGET: arg #{1} - parameter 3 must be rotation", rulesParsed, idx - idxStart - 1));
return new LSL_List();
}
// not SL compatible since we don't have a independent flag to control active target but use the values of offset and rotation
if(active == 1)
{
if(offset.x == 0 && offset.y == 0 && offset.z == 0 && sitrot.s == 1.0)
offset.z = 1e-5f; // hack
SitTarget(part,offset,sitrot);
}
else if(active == 0)
SitTarget(part, Vector3.Zero , Quaternion.Identity);
break;
case ScriptBaseClass.PRIM_LINK_TARGET:
if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
return new LSL_List();
@@ -11182,7 +11228,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
res.Add(new LSL_Float(spin));
res.Add(new LSL_Float(gain));
break;
case (int)ScriptBaseClass.PRIM_SIT_TARGET:
if(part.IsSitTargetSet)
{
res.Add(new LSL_Integer(1));
res.Add(new LSL_Vector(part.SitTargetPosition));
res.Add(new LSL_Rotation(part.SitTargetOrientation));
}
else
{
res.Add(new LSL_Integer(0));
res.Add(new LSL_Vector(Vector3.Zero));
res.Add(new LSL_Rotation(Quaternion.Identity));
}
break;
case (int)ScriptBaseClass.PRIM_LINK_TARGET:
// TODO: Should be issuing a runtime script warning in this case.
@@ -14155,18 +14216,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return false;
}
private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd)
private ContactResult[] AvatarIntersection(Vector3 rayStart, Vector3 rayEnd, bool skipPhys)
{
List<ContactResult> contacts = new List<ContactResult>();
Vector3 ab = rayEnd - rayStart;
float ablen = ab.Length();
World.ForEachScenePresence(delegate(ScenePresence sp)
{
Vector3 ac = sp.AbsolutePosition - rayStart;
// Vector3 bc = sp.AbsolutePosition - rayEnd;
if(skipPhys && sp.PhysicsActor != null)
return;
double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd));
Vector3 ac = sp.AbsolutePosition - rayStart;
double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / ablen);
if (d > 1.5)
return;
@@ -14455,7 +14519,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
Vector3 rayEnd = end;
Vector3 dir = rayEnd - rayStart;
float dist = Vector3.Mag(dir);
float dist = dir.Length();
int count = 1;
bool detectPhantom = false;
@@ -14484,7 +14548,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL);
bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
if (World.SupportsRayCastFiltered())
{
if (dist == 0)
@@ -14493,8 +14556,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
RayFilterFlags rayfilter = RayFilterFlags.BackFaceCull;
if (checkTerrain)
rayfilter |= RayFilterFlags.land;
// if (checkAgents)
// rayfilter |= RayFilterFlags.agent;
if (checkAgents)
rayfilter |= RayFilterFlags.agent;
if (checkPhysical)
rayfilter |= RayFilterFlags.physical;
if (checkNonPhysical)
@@ -14520,16 +14583,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (physresults == null)
{
list.Add(new LSL_Integer(-3)); // timeout error
return list;
// list.Add(new LSL_Integer(-3)); // timeout error
// return list;
results = new List<ContactResult>();
}
results = (List<ContactResult>)physresults;
else
results = (List<ContactResult>)physresults;
// for now physics doesn't detect sitted avatars so do it outside physics
if (checkAgents)
{
ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd);
ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, true);
foreach (ContactResult r in agentHits)
results.Add(r);
}
@@ -14545,12 +14609,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
foreach (ContactResult r in objectHits)
results.Add(r);
}
// Double check this because of current ODE distance problems
if (checkTerrain && dist > 60)
{
bool skipGroundCheck = false;
foreach (ContactResult c in results)
{
if (c.ConsumerID == 0) // Physics gave us a ground collision
skipGroundCheck = true;
}
if (!skipGroundCheck)
{
float tmp = dir.X * dir.X + dir.Y * dir.Y;
if(tmp > 2500)
{
ContactResult? groundContact = GroundIntersection(rayStart, rayEnd);
if (groundContact != null)
results.Add((ContactResult)groundContact);
}
}
}
}
else
{
if (checkAgents)
{
ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd);
ContactResult[] agentHits = AvatarIntersection(rayStart, rayEnd, false);
foreach (ContactResult r in agentHits)
results.Add(r);
}
@@ -14565,20 +14651,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
results.Add(objectHits[iter]);
}
}
}
// Double check this
if (checkTerrain)
{
bool skipGroundCheck = false;
foreach (ContactResult c in results)
{
if (c.ConsumerID == 0) // Physics gave us a ground collision
skipGroundCheck = true;
}
if (!skipGroundCheck)
if (checkTerrain)
{
ContactResult? groundContact = GroundIntersection(rayStart, rayEnd);
if (groundContact != null)
@@ -14590,7 +14664,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
return a.Depth.CompareTo(b.Depth);
});
int values = 0;
SceneObjectGroup thisgrp = m_host.ParentGroup;
@@ -14644,7 +14718,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
list.Add(new LSL_Integer(values));
return list;
}
@@ -15919,6 +15992,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_TEXT:
case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
case (int)ScriptBaseClass.PRIM_OMEGA:
case (int)ScriptBaseClass.PRIM_SIT_TARGET:
if (remain < 3)
return new LSL_List();
idx += 3;

View File

@@ -365,8 +365,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// </summary>
protected object ConvertFromLSL(object lslparm, Type type, string fname)
{
if(lslparm.GetType() == type)
return lslparm;
// ---------- String ----------
if (lslparm is LSL_String)
else if (lslparm is LSL_String)
{
if (type == typeof(string))
return (string)(LSL_String)lslparm;

View File

@@ -254,6 +254,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int ATTACH_HUD_BOTTOM_RIGHT = 38;
public const int ATTACH_NECK = 39;
public const int ATTACH_AVATAR_CENTER = 40;
public const int ATTACH_LHAND_RING1 = 41;
public const int ATTACH_RHAND_RING1 = 42;
public const int ATTACH_TAIL_BASE = 43;
public const int ATTACH_TAIL_TIP = 44;
public const int ATTACH_LWING = 45;
public const int ATTACH_RWING = 46;
public const int ATTACH_FACE_JAW = 47;
public const int ATTACH_FACE_LEAR = 48;
public const int ATTACH_FACE_REAR = 49;
public const int ATTACH_FACE_LEYE = 50;
public const int ATTACH_FACE_REYE = 51;
public const int ATTACH_FACE_TONGUE = 52;
public const int ATTACH_GROIN = 53;
public const int ATTACH_HIND_LFOOT = 54;
public const int ATTACH_HIND_RFOOT = 55;
#region osMessageAttachments constants
@@ -336,11 +351,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int ROTATE = 32;
public const int SCALE = 64;
public const int ALL_SIDES = -1;
// LINK flags
public const int LINK_SET = -1;
public const int LINK_ROOT = 1;
public const int LINK_ALL_OTHERS = -2;
public const int LINK_ALL_CHILDREN = -3;
public const int LINK_THIS = -4;
public const int CHANGED_INVENTORY = 1;
public const int CHANGED_COLOR = 2;
public const int CHANGED_SHAPE = 4;
@@ -356,6 +374,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int CHANGED_MEDIA = 2048;
public const int CHANGED_ANIMATION = 16384;
public const int CHANGED_POSITION = 32768;
public const int TYPE_INVALID = 0;
public const int TYPE_INTEGER = 1;
public const int TYPE_FLOAT = 2;
@@ -389,6 +408,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int CONTENT_TYPE_FORM = 7; //application/x-www-form-urlencoded
public const int CONTENT_TYPE_RSS = 8; //application/rss+xml
//parameters comand flags
public const int PRIM_MATERIAL = 2;
public const int PRIM_PHYSICS = 3;
public const int PRIM_TEMP_ON_REZ = 4;
@@ -397,19 +417,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int PRIM_SIZE = 7;
public const int PRIM_ROTATION = 8;
public const int PRIM_TYPE = 9;
// gap 10-16
public const int PRIM_TEXTURE = 17;
public const int PRIM_COLOR = 18;
public const int PRIM_BUMP_SHINY = 19;
public const int PRIM_FULLBRIGHT = 20;
public const int PRIM_FLEXIBLE = 21;
public const int PRIM_TEXGEN = 22;
public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake
public const int PRIM_POINT_LIGHT = 23; // Huh?
public const int PRIM_CAST_SHADOWS = 24; // Not implemented, here for completeness sake
public const int PRIM_GLOW = 25;
public const int PRIM_TEXT = 26;
public const int PRIM_NAME = 27;
public const int PRIM_DESC = 28;
public const int PRIM_ROT_LOCAL = 29;
public const int PRIM_PHYSICS_SHAPE_TYPE = 30;
public const int PRIM_PHYSICS_MATERIAL = 31; // apparently not on SL wiki
public const int PRIM_OMEGA = 32;
public const int PRIM_POS_LOCAL = 33;
public const int PRIM_LINK_TARGET = 34;
@@ -417,6 +440,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int PRIM_SPECULAR = 36;
public const int PRIM_NORMAL = 37;
public const int PRIM_ALPHA_MODE = 38;
public const int PRIM_ALLOW_UNSIT = 39; // experiences related. unsupported
public const int PRIM_SCRIPTED_SIT_ONLY = 40; // experiences related. unsupported
public const int PRIM_SIT_TARGET = 41;
// parameters
public const int PRIM_TEXGEN_DEFAULT = 0;
public const int PRIM_TEXGEN_PLANAR = 1;
@@ -473,6 +502,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int PRIM_SCULPT_FLAG_INVERT = 64;
public const int PRIM_SCULPT_FLAG_MIRROR = 128;
public const int PRIM_PHYSICS_SHAPE_PRIM = 0;
public const int PRIM_PHYSICS_SHAPE_NONE = 1;
public const int PRIM_PHYSICS_SHAPE_CONVEX = 2;
public const int PROFILE_NONE = 0;
public const int PROFILE_SCRIPT_MEMORY = 1;
@@ -701,12 +734,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int PRIM_MEDIA_PERM_GROUP = 2;
public const int PRIM_MEDIA_PERM_ANYONE = 4;
public const int PRIM_PHYSICS_SHAPE_TYPE = 30;
public const int PRIM_PHYSICS_SHAPE_PRIM = 0;
public const int PRIM_PHYSICS_SHAPE_CONVEX = 2;
public const int PRIM_PHYSICS_SHAPE_NONE = 1;
public const int PRIM_PHYSICS_MATERIAL = 31;
public const int DENSITY = 1;
public const int FRICTION = 2;
public const int RESTITUTION = 4;

View File

@@ -704,12 +704,16 @@ namespace OpenSim.Region.ScriptEngine.Shared
{
if (Data[itemIndex] is LSL_Types.Quaternion)
{
return (LSL_Types.Quaternion)Data[itemIndex];
LSL_Types.Quaternion q = (LSL_Types.Quaternion)Data[itemIndex];
q.Normalize();
return q;
}
else if(Data[itemIndex] is OpenMetaverse.Quaternion)
{
return new LSL_Types.Quaternion(
LSL_Types.Quaternion q = new LSL_Types.Quaternion(
(OpenMetaverse.Quaternion)Data[itemIndex]);
q.Normalize();
return q;
}
else
{

View File

@@ -270,6 +270,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
TestHelpers.InMethod();
LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.64, 59.43723, 765.3421, 4.00987);
// make that nonsense a quaternion
testValue.Normalize();
LSL_Types.list testList = new LSL_Types.list(testValue);
Assert.AreEqual(testValue, testList.GetQuaternionItem(0));