Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

This commit is contained in:
Justin Clark-Casey (justincc)
2012-04-13 22:34:36 +01:00
17 changed files with 278 additions and 53 deletions

View File

@@ -10367,7 +10367,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ret.Add(new LSL_Integer(av.RunningScriptCount() * 16384));
break;
case ScriptBaseClass.OBJECT_SCRIPT_TIME:
ret.Add(new LSL_Float(0));
ret.Add(new LSL_Float(av.ScriptExecutionTime() / 1000.0f));
break;
case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
ret.Add(new LSL_Integer(1));
@@ -10435,9 +10435,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ret.Add(new LSL_Integer(obj.ParentGroup.RunningScriptCount() * 16384));
break;
case ScriptBaseClass.OBJECT_SCRIPT_TIME:
// Average cpu time per simulator frame expended on all scripts in the object
// Not currently available at Object level
ret.Add(new LSL_Float(0));
// Average cpu time in seconds per simulator frame expended on all scripts in the object
ret.Add(new LSL_Float(obj.ParentGroup.ScriptExecutionTime() / 1000.0f));
break;
case ScriptBaseClass.OBJECT_PRIM_EQUIVALENCE:
// according to the SL wiki A prim or linkset will have prim

View File

@@ -3038,5 +3038,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return ScriptBaseClass.TRUE;
}
/// <summary>
/// Sets terrain estate texture
/// </summary>
/// <param name="level"></param>
/// <param name="texture"></param>
/// <returns></returns>
public void osSetTerrainTexture(int level, LSL_Key texture)
{
CheckThreatLevel(ThreatLevel.High, "osSetTerrainTexture");
m_host.AddScriptLPS(1);
//Check to make sure that the script's owner is the estate manager/master
//World.Permissions.GenericEstatePermission(
if (World.Permissions.IsGod(m_host.OwnerID))
{
if (level < 0 || level > 3)
return;
UUID textureID = new UUID();
if (!UUID.TryParse(texture, out textureID))
return;
// estate module is required
IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
if (estate != null)
estate.setEstateTerrainBaseTexture(level, textureID);
}
}
/// <summary>
/// Sets terrain heights of estate
/// </summary>
/// <param name="corner"></param>
/// <param name="low"></param>
/// <param name="high"></param>
/// <returns></returns>
public void osSetTerrainTextureHeight(int corner, double low, double high)
{
CheckThreatLevel(ThreatLevel.High, "osSetTerrainTextureHeight");
m_host.AddScriptLPS(1);
//Check to make sure that the script's owner is the estate manager/master
//World.Permissions.GenericEstatePermission(
if (World.Permissions.IsGod(m_host.OwnerID))
{
if (corner < 0 || corner > 3)
return;
// estate module is required
IEstateModule estate = World.RequestModuleInterface<IEstateModule>();
if (estate != null)
estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
}
}
}
}

View File

@@ -234,5 +234,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_Integer osInviteToGroup(LSL_Key agentId);
LSL_Integer osEjectFromGroup(LSL_Key agentId);
void osSetTerrainTexture(int level, LSL_Key texture);
void osSetTerrainTextureHeight(int corner, double low, double high);
}
}

View File

@@ -878,5 +878,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osEjectFromGroup(agentId);
}
public void osSetTerrainTexture(int level, LSL_Key texture)
{
m_OSSL_Functions.osSetTerrainTexture(level, texture);
}
public void osSetTerrainTextureHeight(int corner, double low, double high)
{
m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high);
}
}
}

View File

@@ -1907,47 +1907,61 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (!topScripts.ContainsKey(si.LocalID))
topScripts[si.RootLocalID] = 0;
// long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
// float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond);
// Execution time of the script adjusted by it's measurement period to make scripts started at
// different times comparable.
// float adjustedExecutionTime
// = (float)si.MeasurementPeriodExecutionTime
// / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod)
// / TimeSpan.TicksPerMillisecond;
long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
// Avoid divide by zerp
if (ticksElapsed == 0)
ticksElapsed = 1;
// Scale execution time to the ideal 55 fps frame time for these reasons.
//
// 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
// 'script execution time per frame', which is the original purpose of this value.
//
// 2) Giving the raw execution times is misleading since scripts start at different times, making
// it impossible to compare scripts.
//
// 3) Scaling the raw execution time to the time that the script has been running is better but
// is still misleading since a script that has just been rezzed may appear to have been running
// for much longer.
//
// 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
// since the figure does not represent actual execution time and very hard running scripts will
// never exceed 18ms (though this is a very high number for script execution so is a warning sign).
float adjustedExecutionTime
= ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
topScripts[si.RootLocalID] += adjustedExecutionTime;
topScripts[si.RootLocalID] += CalculateAdjustedExectionTime(si, tickNow);
}
}
return topScripts;
}
public float GetScriptExecutionTime(List<UUID> itemIDs)
{
if (itemIDs == null|| itemIDs.Count == 0)
{
return 0.0f;
}
float time = 0.0f;
long tickNow = Util.EnvironmentTickCount();
IScriptInstance si;
// Calculate the time for all scripts that this engine is executing
// Ignore any others
foreach (UUID id in itemIDs)
{
si = GetInstance(id);
if (si != null && si.Running)
{
time += CalculateAdjustedExectionTime(si, tickNow);
}
}
return time;
}
private float CalculateAdjustedExectionTime(IScriptInstance si, long tickNow)
{
long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
// Avoid divide by zero
if (ticksElapsed == 0)
ticksElapsed = 1;
// Scale execution time to the ideal 55 fps frame time for these reasons.
//
// 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
// 'script execution time per frame', which is the original purpose of this value.
//
// 2) Giving the raw execution times is misleading since scripts start at different times, making
// it impossible to compare scripts.
//
// 3) Scaling the raw execution time to the time that the script has been running is better but
// is still misleading since a script that has just been rezzed may appear to have been running
// for much longer.
//
// 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
// since the figure does not represent actual execution time and very hard running scripts will
// never exceed 18ms (though this is a very high number for script execution so is a warning sign).
return ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
}
public void SuspendScript(UUID itemID)
{
// m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID);