mirror of
https://github.com/opensim/opensim.git
synced 2026-07-31 13:55:35 +08:00
Merge branch 'master' into httptests
This commit is contained in:
@@ -68,7 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
|
||||
void SetMinEventDelay(UUID itemID, double delay);
|
||||
int GetStartParameter(UUID itemID);
|
||||
|
||||
void SetScriptState(UUID itemID, bool state);
|
||||
void SetScriptState(UUID itemID, bool state, bool self);
|
||||
bool GetScriptState(UUID itemID);
|
||||
void SetState(UUID itemID, string newState);
|
||||
void ApiResetScript(UUID itemID);
|
||||
|
||||
@@ -521,7 +521,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if ((item = GetScriptByName(name)) != UUID.Zero)
|
||||
{
|
||||
m_ScriptEngine.SetScriptState(item, run == 0 ? false : true);
|
||||
m_ScriptEngine.SetScriptState(item, run == 0 ? false : true, item == m_item.ItemID);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -14358,6 +14358,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return contacts.ToArray();
|
||||
}
|
||||
|
||||
private ContactResult? GroundIntersection2(Vector3 rayStart, Vector3 rayEnd)
|
||||
{
|
||||
// get work copies
|
||||
float sx = rayStart.X;
|
||||
float ex = rayEnd.X;
|
||||
float sy = rayStart.Y;
|
||||
float ey = rayEnd.Y;
|
||||
|
||||
float dx = ex - sx;
|
||||
float dy = ey - sy;
|
||||
|
||||
// region size info
|
||||
float rsx = World.RegionInfo.RegionSizeX;
|
||||
|
||||
float tmp;
|
||||
|
||||
// region bounds
|
||||
if(sx < 0)
|
||||
{
|
||||
if(ex < 0) // totally outside
|
||||
return null;
|
||||
if(dx <= 0) // out and going away
|
||||
return null;
|
||||
else if(ex >= rsx)
|
||||
ex = rsx - 0.001f;
|
||||
tmp = -sx / dx;
|
||||
sy += dy * dx;
|
||||
sx = 0;
|
||||
}
|
||||
else if(sx >= rsx)
|
||||
{
|
||||
if(ex >= rsx) // totally outside
|
||||
return null;
|
||||
if(dx >= 0) // out and going away
|
||||
return null;
|
||||
else if(ex < 0)
|
||||
ex = 0;
|
||||
tmp = (rsx - sx) / dx;
|
||||
sy += dy * dx;
|
||||
sx = rsx - 0.001f;
|
||||
}
|
||||
|
||||
float rsy = World.RegionInfo.RegionSizeY;
|
||||
if(sy < 0)
|
||||
{
|
||||
if(dy <= 0) // out and going away
|
||||
return null;
|
||||
else if(ey >= rsy)
|
||||
ey = rsy - 0.001f;
|
||||
tmp = -sy / dy;
|
||||
sx += dy * dx;
|
||||
sy = 0;
|
||||
}
|
||||
else if(sy >= rsy)
|
||||
{
|
||||
if(dy >= 0) // out and going away
|
||||
return null;
|
||||
else if(ey < 0)
|
||||
ey = 0;
|
||||
tmp = (rsy - sy) / dy;
|
||||
sx += dy * dx;
|
||||
sy = rsy - 0.001f;
|
||||
}
|
||||
|
||||
if(sx < 0 || sx >= rsx)
|
||||
return null;
|
||||
|
||||
float sz = rayStart.Z;
|
||||
float ez = rayEnd.Z;
|
||||
float dz = ez - sz;
|
||||
|
||||
float dist = dx * dx + dy * dy + dz * dz;
|
||||
if(dist < 0.001)
|
||||
return null;
|
||||
dist = (float)Math.Sqrt(dist);
|
||||
tmp = 1.0f / dist;
|
||||
Vector3 rayn = new Vector3(dx * tmp, dy * tmp, dz * tmp);
|
||||
|
||||
ContactResult? result = null;
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private ContactResult? GroundIntersection(Vector3 rayStart, Vector3 rayEnd)
|
||||
{
|
||||
double[,] heightfield = World.Heightmap.GetDoubles();
|
||||
@@ -16024,8 +16109,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
catch (InvalidCastException e)
|
||||
{
|
||||
Error(originFunc,string.Format(
|
||||
" error running rule #{1}: arg #{2} ",
|
||||
rulesParsed, idx - idxStart) + e.Message);
|
||||
" error running rule #{0}: arg #{1} {2}",
|
||||
rulesParsed, idx - idxStart, e.Message));
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
idx++;
|
||||
try
|
||||
{
|
||||
iQ = rules.GetQuaternionItem(idx);
|
||||
iQ = rules.GetVector4Item(idx);
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
@@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
idx++;
|
||||
try
|
||||
{
|
||||
iQ = rules.GetQuaternionItem(idx);
|
||||
iQ = rules.GetVector4Item(idx);
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
@@ -342,7 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
idx++;
|
||||
try
|
||||
{
|
||||
iQ = rules.GetQuaternionItem(idx);
|
||||
iQ = rules.GetVector4Item(idx);
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
@@ -532,7 +532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
idx++;
|
||||
try
|
||||
{
|
||||
iQ = rules.GetQuaternionItem(idx);
|
||||
iQ = rules.GetVector4Item(idx);
|
||||
}
|
||||
catch (InvalidCastException)
|
||||
{
|
||||
@@ -654,7 +654,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
break;
|
||||
case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
|
||||
idx++;
|
||||
iQ = rules.GetQuaternionItem(idx);
|
||||
iQ = rules.GetVector4Item(idx);
|
||||
try
|
||||
{
|
||||
wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
|
||||
|
||||
@@ -924,26 +924,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
{
|
||||
try
|
||||
{
|
||||
// DISPLAY ERROR INWORLD
|
||||
string text = FormatException(e);
|
||||
|
||||
if (text.Length > 1000)
|
||||
text = text.Substring(0, 1000);
|
||||
Engine.World.SimChat(Utils.StringToBytes(text),
|
||||
ChatTypeEnum.DebugChannel, 2147483647,
|
||||
Part.AbsolutePosition,
|
||||
Part.Name, Part.UUID, false);
|
||||
if(e.InnerException != null && e.InnerException is ScriptException)
|
||||
{
|
||||
string text = e.InnerException.Message +
|
||||
"(script: " + ScriptName +
|
||||
" event: " + data.EventName +
|
||||
" at " + Part.AbsolutePosition + ")";
|
||||
if (text.Length > 1000)
|
||||
text = text.Substring(0, 1000);
|
||||
Engine.World.SimChat(Utils.StringToBytes(text),
|
||||
ChatTypeEnum.DebugChannel, 2147483647,
|
||||
Part.AbsolutePosition,
|
||||
Part.Name, Part.UUID, false);
|
||||
m_log.Debug(string.Format(
|
||||
"[SCRIPT INSTANCE]: {0} (at event {1}, part {2} {3} at {4} in {5}",
|
||||
e.InnerException.Message,
|
||||
data.EventName,
|
||||
PrimName,
|
||||
Part.UUID,
|
||||
Part.AbsolutePosition,
|
||||
Part.ParentGroup.Scene.Name));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// DISPLAY ERROR INWORLD
|
||||
string text = FormatException(e);
|
||||
|
||||
if (text.Length > 1000)
|
||||
text = text.Substring(0, 1000);
|
||||
Engine.World.SimChat(Utils.StringToBytes(text),
|
||||
ChatTypeEnum.DebugChannel, 2147483647,
|
||||
Part.AbsolutePosition,
|
||||
Part.Name, Part.UUID, false);
|
||||
|
||||
|
||||
m_log.Debug(string.Format(
|
||||
"[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ",
|
||||
ScriptName,
|
||||
data.EventName,
|
||||
PrimName,
|
||||
Part.UUID,
|
||||
Part.AbsolutePosition,
|
||||
Part.ParentGroup.Scene.Name),
|
||||
e);
|
||||
m_log.Debug(string.Format(
|
||||
"[SCRIPT INSTANCE]: Runtime error in script {0} (event {1}), part {2} {3} at {4} in {5} ",
|
||||
ScriptName,
|
||||
data.EventName,
|
||||
PrimName,
|
||||
Part.UUID,
|
||||
Part.AbsolutePosition,
|
||||
Part.ParentGroup.Scene.Name),
|
||||
e);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
@@ -700,6 +700,31 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||
}
|
||||
}
|
||||
|
||||
// use LSL_Types.Quaternion to parse and store a vector4 for lightShare
|
||||
public LSL_Types.Quaternion GetVector4Item(int itemIndex)
|
||||
{
|
||||
if (Data[itemIndex] is LSL_Types.Quaternion)
|
||||
{
|
||||
LSL_Types.Quaternion q = (LSL_Types.Quaternion)Data[itemIndex];
|
||||
return q;
|
||||
}
|
||||
else if(Data[itemIndex] is OpenMetaverse.Quaternion)
|
||||
{
|
||||
LSL_Types.Quaternion q = new LSL_Types.Quaternion(
|
||||
(OpenMetaverse.Quaternion)Data[itemIndex]);
|
||||
q.Normalize();
|
||||
return q;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidCastException(string.Format(
|
||||
"{0} expected but {1} given",
|
||||
typeof(LSL_Types.Quaternion).Name,
|
||||
Data[itemIndex] != null ?
|
||||
Data[itemIndex].GetType().Name : "null"));
|
||||
}
|
||||
}
|
||||
|
||||
public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
|
||||
{
|
||||
if (Data[itemIndex] is LSL_Types.Quaternion)
|
||||
|
||||
@@ -1854,15 +1854,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void SetScriptState(UUID itemID, bool running)
|
||||
public void SetScriptState(UUID itemID, bool running, bool self)
|
||||
{
|
||||
IScriptInstance instance = GetInstance(itemID);
|
||||
if (instance != null)
|
||||
{
|
||||
if (running)
|
||||
instance.Start();
|
||||
instance.Start();
|
||||
else
|
||||
instance.Stop(100);
|
||||
{
|
||||
if(self)
|
||||
{
|
||||
instance.Running = false;
|
||||
throw new EventAbortException();
|
||||
}
|
||||
else
|
||||
instance.Stop(100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user