mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
BulletSim: add osGetPhysicsEngineType() LSL function and update
the physics engines to return the name that is specified in the INI
file ("physics = XXX") as the type of engine.
This os function is a little different than the others in that it
does not throw an exception of one is not privilaged to use it.
It merely returns an empty string.
This commit is contained in:
@@ -49,7 +49,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
|
||||
|
||||
public PhysicsScene GetScene(string sceneIdentifier)
|
||||
{
|
||||
return new BasicScene(sceneIdentifier);
|
||||
return new BasicScene(GetName(), sceneIdentifier);
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
|
||||
@@ -49,8 +49,10 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
|
||||
|
||||
//protected internal string sceneIdentifier;
|
||||
|
||||
public BasicScene(string _sceneIdentifier)
|
||||
public BasicScene(string engineType, string _sceneIdentifier)
|
||||
{
|
||||
EngineType = engineType;
|
||||
Name = EngineType + "/" + _sceneIdentifier;
|
||||
//sceneIdentifier = _sceneIdentifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BSPlugin : IPhysicsPlugin
|
||||
{
|
||||
if (_mScene == null)
|
||||
{
|
||||
_mScene = new BSScene(sceneIdentifier);
|
||||
_mScene = new BSScene(GetName(), sceneIdentifier);
|
||||
}
|
||||
return (_mScene);
|
||||
}
|
||||
|
||||
@@ -167,11 +167,16 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||
public bool VehiclePhysicalLoggingEnabled { get; private set; }
|
||||
|
||||
#region Construction and Initialization
|
||||
public BSScene(string identifier)
|
||||
public BSScene(string engineType, string identifier)
|
||||
{
|
||||
m_initialized = false;
|
||||
// we are passed the name of the region we're working for.
|
||||
|
||||
// The name of the region we're working for is passed to us. Keep for identification.
|
||||
RegionName = identifier;
|
||||
|
||||
// Set identifying variables in the PhysicsScene interface.
|
||||
EngineType = engineType;
|
||||
Name = EngineType + "/" + RegionName;
|
||||
}
|
||||
|
||||
public override void Initialise(IMesher meshmerizer, IConfigSource config)
|
||||
|
||||
@@ -62,13 +62,20 @@ namespace OpenSim.Region.Physics.Manager
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// Name of this scene. Useful in debug messages to distinguish one OdeScene instance from another.
|
||||
/// A unique identifying string for this instance of the physics engine.
|
||||
/// Useful in debug messages to distinguish one OdeScene instance from another.
|
||||
/// Usually set to include the region name that the physics engine is acting for.
|
||||
/// </summary>
|
||||
public string Name { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// A string identifying the family of this physics engine. Most common values returned
|
||||
/// are "OpenDynamicsEngine" and "BulletSim" but others are possible.
|
||||
/// </summary>
|
||||
public string EngineType { get; protected set; }
|
||||
|
||||
// The only thing that should register for this event is the SceneGraph
|
||||
// Anything else could cause problems.
|
||||
|
||||
public event physicsCrash OnPhysicsCrash;
|
||||
|
||||
public static PhysicsScene Null
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||
// http://opensimulator.org/mantis/view.php?id=2750).
|
||||
d.InitODE();
|
||||
|
||||
m_scene = new OdeScene(sceneIdentifier);
|
||||
m_scene = new OdeScene(GetName(), sceneIdentifier);
|
||||
}
|
||||
|
||||
return m_scene;
|
||||
|
||||
@@ -526,11 +526,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||
/// These settings need to be tweaked 'exactly' right or weird stuff happens.
|
||||
/// </summary>
|
||||
/// <param value="name">Name of the scene. Useful in debug messages.</param>
|
||||
public OdeScene(string name)
|
||||
public OdeScene(string engineType, string name)
|
||||
{
|
||||
m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name);
|
||||
|
||||
Name = name;
|
||||
EngineType = engineType;
|
||||
|
||||
nearCallback = near;
|
||||
triCallback = TriCallback;
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace OpenSim.Region.Physics.POSPlugin
|
||||
|
||||
public PhysicsScene GetScene(string sceneIdentifier)
|
||||
{
|
||||
return new POSScene(sceneIdentifier);
|
||||
return new POSScene(GetName(), sceneIdentifier);
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
|
||||
@@ -43,8 +43,10 @@ namespace OpenSim.Region.Physics.POSPlugin
|
||||
|
||||
//protected internal string sceneIdentifier;
|
||||
|
||||
public POSScene(String _sceneIdentifier)
|
||||
public POSScene(string engineType, String _sceneIdentifier)
|
||||
{
|
||||
EngineType = engineType;
|
||||
Name = EngineType + "/" + _sceneIdentifier;
|
||||
//sceneIdentifier = _sceneIdentifier;
|
||||
}
|
||||
|
||||
|
||||
@@ -245,11 +245,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
|
||||
}
|
||||
|
||||
// Returns of the function is allowed. Throws a script exception if not allowed.
|
||||
public void CheckThreatLevel(ThreatLevel level, string function)
|
||||
{
|
||||
if (!m_OSFunctionsEnabled)
|
||||
OSSLError(String.Format("{0} permission denied. All OS functions are disabled.", function)); // throws
|
||||
|
||||
string reasonWhyNot = CheckThreatLevelTest(level, function);
|
||||
if (!String.IsNullOrEmpty(reasonWhyNot))
|
||||
{
|
||||
OSSLError(reasonWhyNot);
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if function is allowed. Returns an empty string if function permitted
|
||||
// or a string explaining why this function can't be used.
|
||||
private string CheckThreatLevelTest(ThreatLevel level, string function)
|
||||
{
|
||||
if (!m_FunctionPerms.ContainsKey(function))
|
||||
{
|
||||
FunctionPerms perms = new FunctionPerms();
|
||||
@@ -329,10 +341,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
// Allow / disallow by threat level
|
||||
if (level > m_MaxThreatLevel)
|
||||
OSSLError(
|
||||
return
|
||||
String.Format(
|
||||
"{0} permission denied. Allowed threat level is {1} but function threat level is {2}.",
|
||||
function, m_MaxThreatLevel, level));
|
||||
function, m_MaxThreatLevel, level);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -342,7 +354,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
if (m_FunctionPerms[function].AllowedOwners.Contains(m_host.OwnerID))
|
||||
{
|
||||
// prim owner is in the list of allowed owners
|
||||
return;
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
UUID ownerID = m_item.OwnerID;
|
||||
@@ -354,7 +366,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero)
|
||||
{
|
||||
return;
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
if (land.LandData.OwnerID == ownerID)
|
||||
{
|
||||
return;
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +387,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
//Only Estate Managers may use the function
|
||||
if (World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(ownerID) && World.RegionInfo.EstateSettings.EstateOwner != ownerID)
|
||||
{
|
||||
return;
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,25 +396,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
if (World.RegionInfo.EstateSettings.EstateOwner == ownerID)
|
||||
{
|
||||
return;
|
||||
return String.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_FunctionPerms[function].AllowedCreators.Contains(m_item.CreatorID))
|
||||
OSSLError(
|
||||
return(
|
||||
String.Format("{0} permission denied. Script creator is not in the list of users allowed to execute this function and prim owner also has no permission.",
|
||||
function));
|
||||
|
||||
if (m_item.CreatorID != ownerID)
|
||||
{
|
||||
if ((m_item.CurrentPermissions & (uint)PermissionMask.Modify) != 0)
|
||||
OSSLError(
|
||||
String.Format("{0} permission denied. Script permissions error.",
|
||||
function));
|
||||
return String.Format("{0} permission denied. Script permissions error.", function);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return String.Empty;
|
||||
}
|
||||
|
||||
internal void OSSLDeprecated(string function, string replacement)
|
||||
@@ -1558,6 +1569,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
}
|
||||
}
|
||||
|
||||
public string osGetPhysicsEngineType()
|
||||
{
|
||||
// High because it can be used to target attacks to known weaknesses
|
||||
// This would allow a new class of griefer scripts that don't even
|
||||
// require their user to know what they are doing (see script
|
||||
// kiddie)
|
||||
// Because it would be nice if scripts didn't blow up if the information
|
||||
// about the physics engine, this function returns an empty string if
|
||||
// the user does not have permission to see it. This as opposed to
|
||||
// throwing an exception.
|
||||
m_host.AddScriptLPS(1);
|
||||
string ret = String.Empty;
|
||||
if (String.IsNullOrEmpty(CheckThreatLevelTest(ThreatLevel.High, "osGetPhysicsEngineType")))
|
||||
{
|
||||
if (m_ScriptEngine.World.PhysicsScene != null)
|
||||
{
|
||||
ret = m_ScriptEngine.World.PhysicsScene.EngineType;
|
||||
// An old physics engine might have an uninitialized engine type
|
||||
if (ret == null)
|
||||
ret = "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public string osGetSimulatorVersion()
|
||||
{
|
||||
// High because it can be used to target attacks to known weaknesses
|
||||
|
||||
@@ -259,6 +259,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
|
||||
string osGetScriptEngineName();
|
||||
string osGetSimulatorVersion();
|
||||
string osGetPhysicsEngineType();
|
||||
Object osParseJSONNew(string JSON);
|
||||
Hashtable osParseJSON(string JSON);
|
||||
|
||||
|
||||
@@ -420,6 +420,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
return m_OSSL_Functions.osGetScriptEngineName();
|
||||
}
|
||||
|
||||
public string osGetPhysicsEngineType()
|
||||
{
|
||||
return m_OSSL_Functions.osGetPhysicsEngineType();
|
||||
}
|
||||
|
||||
public string osGetSimulatorVersion()
|
||||
{
|
||||
return m_OSSL_Functions.osGetSimulatorVersion();
|
||||
|
||||
Reference in New Issue
Block a user