mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
Resolve merge commits, stage 1
This commit is contained in:
@@ -677,7 +677,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
|
||||
public event DeRezObject OnDeRezObject;
|
||||
public event Action<IClientAPI> OnRegionHandShakeReply;
|
||||
public event GenericCall1 OnRequestWearables;
|
||||
public event GenericCall1 OnCompleteMovementToRegion;
|
||||
public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
|
||||
public event UpdateAgent OnPreAgentUpdate;
|
||||
public event UpdateAgent OnAgentUpdate;
|
||||
public event AgentRequestSit OnAgentRequestSit;
|
||||
@@ -806,7 +806,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
|
||||
public event ScriptReset OnScriptReset;
|
||||
public event GetScriptRunning OnGetScriptRunning;
|
||||
public event SetScriptRunning OnSetScriptRunning;
|
||||
public event UpdateVector OnAutoPilotGo;
|
||||
public event Action<Vector3, bool> OnAutoPilotGo;
|
||||
public event TerrainUnacked OnUnackedTerrain;
|
||||
public event ActivateGesture OnActivateGesture;
|
||||
public event DeactivateGesture OnDeactivateGesture;
|
||||
@@ -899,7 +899,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Scene.AddNewClient(this);
|
||||
Scene.AddNewClient(this, PresenceType.User);
|
||||
|
||||
// Mimicking LLClientView which gets always set appearance from client.
|
||||
Scene scene = (Scene)Scene;
|
||||
@@ -919,7 +919,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
|
||||
|
||||
if (OnCompleteMovementToRegion != null)
|
||||
{
|
||||
OnCompleteMovementToRegion(this);
|
||||
OnCompleteMovementToRegion(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,16 +47,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
|
||||
[Test]
|
||||
public void TestBasic()
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
TestScene scene = SceneSetupHelpers.SetupScene();
|
||||
TestScene scene = SceneHelpers.SetupScene();
|
||||
IConfigSource configSource = new IniConfigSource();
|
||||
IConfig config = configSource.AddConfig("Groups");
|
||||
config.Set("Enabled", true);
|
||||
config.Set("Module", "GroupsModule");
|
||||
config.Set("DebugEnabled", true);
|
||||
SceneSetupHelpers.SetupSceneModules(
|
||||
SceneHelpers.SetupSceneModules(
|
||||
scene, configSource, new object[] { new MockGroupsServicesConnector() });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using Mono.Addins;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.Framework.Monitoring
|
||||
{
|
||||
/// <summary>
|
||||
/// An experimental module to return data on services used by the simulator.
|
||||
/// </summary>
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MonitorServicesModule")]
|
||||
public class MonitorServicesModule : ISharedRegionModule
|
||||
{
|
||||
protected Scene m_scene;
|
||||
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public string Name { get { return "Services Health Monitoring Module"; } }
|
||||
|
||||
public Type ReplaceableInterface { get { return null; } }
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (m_scene == null)
|
||||
{
|
||||
m_scene = scene;
|
||||
|
||||
// m_scene.AddCommand(this, "monitor services",
|
||||
// "monitor services",
|
||||
// "Returns the status of services used by the simulator. Experimental.",
|
||||
// HandleMonitorServices);
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
}
|
||||
|
||||
protected void HandleMonitorServices(string module, string[] args)
|
||||
{
|
||||
MainConsole.Instance.Output(GenerateServicesReport());
|
||||
}
|
||||
|
||||
protected string GenerateServicesReport()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("This is an experimental module. Please don't rely on these results\n");
|
||||
sb.Append("Asset service: ");
|
||||
|
||||
try
|
||||
{
|
||||
CheckAssetService();
|
||||
sb.Append("OK");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
sb.AppendFormat("FAIL ({0})", e.Message);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
protected void CheckAssetService()
|
||||
{
|
||||
// Try to fetch an asset that will not exist (and hence avoid hitting cache)
|
||||
m_scene.AssetService.Get(UUID.Random().ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
277
OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
Executable file
277
OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
Executable file
@@ -0,0 +1,277 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
using Mono.Addins;
|
||||
using Nini.Config;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
namespace OpenSim.Region.OptionalModules.PhysicsParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// </remarks>
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "PhysicsParameters")]
|
||||
public class PhysicsParameters : ISharedRegionModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private static string LogHeader = "[PHYSICS PARAMETERS]";
|
||||
|
||||
private List<Scene> m_scenes = new List<Scene>();
|
||||
private static bool m_commandsLoaded = false;
|
||||
|
||||
#region ISharedRegionModule
|
||||
public string Name { get { return "Runtime Physics Parameter Module"; } }
|
||||
|
||||
public Type ReplaceableInterface { get { return null; } }
|
||||
|
||||
public void Initialise(IConfigSource source)
|
||||
{
|
||||
// m_log.DebugFormat("{0}: INITIALIZED MODULE", LogHeader);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
// m_log.DebugFormat("[{0}: POST INITIALIZED MODULE", LogHeader);
|
||||
InstallInterfaces();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
// m_log.DebugFormat("{0}: CLOSED MODULE", LogHeader);
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
// m_log.DebugFormat("{0}: REGION {1} ADDED", LogHeader, scene.RegionInfo.RegionName);
|
||||
m_scenes.Add(scene);
|
||||
}
|
||||
|
||||
public void RemoveRegion(Scene scene)
|
||||
{
|
||||
// m_log.DebugFormat("{0}: REGION {1} REMOVED", LogHeader, scene.RegionInfo.RegionName);
|
||||
if (m_scenes.Contains(scene))
|
||||
m_scenes.Remove(scene);
|
||||
}
|
||||
|
||||
public void RegionLoaded(Scene scene)
|
||||
{
|
||||
// m_log.DebugFormat("{0}: REGION {1} LOADED", LogHeader, scene.RegionInfo.RegionName);
|
||||
}
|
||||
#endregion INonSharedRegionModule
|
||||
|
||||
private const string getInvocation = "physics get [<param>|ALL]";
|
||||
private const string setInvocation = "physics set <param> [<value>|TRUE|FALSE] [localID|ALL]";
|
||||
private const string listInvocation = "physics list";
|
||||
private void InstallInterfaces()
|
||||
{
|
||||
if (!m_commandsLoaded)
|
||||
{
|
||||
MainConsole.Instance.Commands.AddCommand("Physics", false, "physics set",
|
||||
"physics set",
|
||||
"Set physics parameter from currently selected region" + Environment.NewLine
|
||||
+ "Invocation: " + setInvocation,
|
||||
ProcessPhysicsSet);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Physics", false, "physics get",
|
||||
"physics get",
|
||||
"Get physics parameter from currently selected region" + Environment.NewLine
|
||||
+ "Invocation: " + getInvocation,
|
||||
ProcessPhysicsGet);
|
||||
|
||||
MainConsole.Instance.Commands.AddCommand("Physics", false, "physics list",
|
||||
"physics list",
|
||||
"List settable physics parameters" + Environment.NewLine
|
||||
+ "Invocation: " + listInvocation,
|
||||
ProcessPhysicsList);
|
||||
|
||||
m_commandsLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: extend get so you can get a value from an individual localID
|
||||
private void ProcessPhysicsGet(string module, string[] cmdparms)
|
||||
{
|
||||
if (cmdparms.Length != 3)
|
||||
{
|
||||
WriteError("Parameter count error. Invocation: " + getInvocation);
|
||||
return;
|
||||
}
|
||||
string parm = cmdparms[2];
|
||||
|
||||
if (SceneManager.Instance == null || SceneManager.Instance.CurrentScene == null)
|
||||
{
|
||||
WriteError("Error: no region selected. Use 'change region' to select a region.");
|
||||
return;
|
||||
}
|
||||
|
||||
Scene scene = SceneManager.Instance.CurrentScene;
|
||||
IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters;
|
||||
if (physScene != null)
|
||||
{
|
||||
if (parm.ToLower() == "all")
|
||||
{
|
||||
foreach (PhysParameterEntry ppe in physScene.GetParameterList())
|
||||
{
|
||||
float val = 0.0f;
|
||||
if (physScene.GetPhysicsParameter(ppe.name, out val))
|
||||
{
|
||||
WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, ppe.name, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, ppe.name, "unknown");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float val = 0.0f;
|
||||
if (physScene.GetPhysicsParameter(parm, out val))
|
||||
{
|
||||
WriteOut(" {0}/{1} = {2}", scene.RegionInfo.RegionName, parm, val);
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteError("Failed fetch of parameter '{0}' from region '{1}'", parm, scene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteError("Region '{0}' physics engine has no gettable physics parameters", scene.RegionInfo.RegionName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void ProcessPhysicsSet(string module, string[] cmdparms)
|
||||
{
|
||||
if (cmdparms.Length < 4 || cmdparms.Length > 5)
|
||||
{
|
||||
WriteError("Parameter count error. Invocation: " + getInvocation);
|
||||
return;
|
||||
}
|
||||
string parm = "xxx";
|
||||
float val = 0f;
|
||||
uint localID = (uint)PhysParameterEntry.APPLY_TO_NONE; // set default value
|
||||
try
|
||||
{
|
||||
parm = cmdparms[2];
|
||||
string valparm = cmdparms[3].ToLower();
|
||||
if (valparm == "true")
|
||||
val = PhysParameterEntry.NUMERIC_TRUE;
|
||||
else
|
||||
{
|
||||
if (valparm == "false")
|
||||
val = PhysParameterEntry.NUMERIC_FALSE;
|
||||
else
|
||||
val = float.Parse(valparm, Culture.NumberFormatInfo);
|
||||
}
|
||||
if (cmdparms.Length > 4)
|
||||
{
|
||||
if (cmdparms[4].ToLower() == "all")
|
||||
localID = (uint)PhysParameterEntry.APPLY_TO_ALL;
|
||||
else
|
||||
localID = uint.Parse(cmdparms[2], Culture.NumberFormatInfo);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
WriteError(" Error parsing parameters. Invocation: " + setInvocation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (SceneManager.Instance == null || SceneManager.Instance.CurrentScene == null)
|
||||
{
|
||||
WriteError("Error: no region selected. Use 'change region' to select a region.");
|
||||
return;
|
||||
}
|
||||
|
||||
Scene scene = SceneManager.Instance.CurrentScene;
|
||||
IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters;
|
||||
if (physScene != null)
|
||||
{
|
||||
if (!physScene.SetPhysicsParameter(parm, val, localID))
|
||||
{
|
||||
WriteError("Failed set of parameter '{0}' for region '{1}'", parm, scene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteOut("Region '{0}'s physics engine has no settable physics parameters", scene.RegionInfo.RegionName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void ProcessPhysicsList(string module, string[] cmdparms)
|
||||
{
|
||||
if (SceneManager.Instance == null || SceneManager.Instance.CurrentScene == null)
|
||||
{
|
||||
WriteError("Error: no region selected. Use 'change region' to select a region.");
|
||||
return;
|
||||
}
|
||||
Scene scene = SceneManager.Instance.CurrentScene;
|
||||
|
||||
IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters;
|
||||
if (physScene != null)
|
||||
{
|
||||
WriteOut("Available physics parameters:");
|
||||
PhysParameterEntry[] parms = physScene.GetParameterList();
|
||||
foreach (PhysParameterEntry ent in parms)
|
||||
{
|
||||
WriteOut(" {0}: {1}", ent.name, ent.desc);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteError("Current regions's physics engine has no settable physics parameters");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void WriteOut(string msg, params object[] args)
|
||||
{
|
||||
m_log.InfoFormat(msg, args);
|
||||
// MainConsole.Instance.OutputFormat(msg, args);
|
||||
}
|
||||
|
||||
private void WriteError(string msg, params object[] args)
|
||||
{
|
||||
m_log.ErrorFormat(msg, args);
|
||||
// MainConsole.Instance.OutputFormat(msg, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
|
||||
m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
|
||||
m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded;
|
||||
|
||||
if(m_uri != string.Empty)
|
||||
{
|
||||
RRAlert("shutdown");
|
||||
}
|
||||
|
||||
m_scene = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
|
||||
info.channel = channel;
|
||||
info.uri = uri;
|
||||
|
||||
bool success = SynchronousRestObjectPoster.BeginPostObject<XmlRpcInfo, bool>(
|
||||
bool success = SynchronousRestObjectRequester.MakeRequest<XmlRpcInfo, bool>(
|
||||
"POST", m_ServerURI+"/RegisterChannel/", info);
|
||||
|
||||
if (!success)
|
||||
@@ -125,7 +125,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
|
||||
|
||||
if (m_Channels.ContainsKey(itemID))
|
||||
{
|
||||
bool success = SynchronousRestObjectPoster.BeginPostObject<UUID, bool>(
|
||||
bool success = SynchronousRestObjectRequester.MakeRequest<UUID, bool>(
|
||||
"POST", m_ServerURI+"/RemoveChannel/", m_Channels[itemID]);
|
||||
|
||||
if (!success)
|
||||
|
||||
@@ -37,6 +37,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
{
|
||||
public class NPCAvatar : IClientAPI
|
||||
{
|
||||
/// <summary>
|
||||
/// Signal whether the avatar should land when it reaches a move target
|
||||
/// </summary>
|
||||
public bool LandAtTarget { get; set; }
|
||||
|
||||
private readonly string m_firstname;
|
||||
private readonly string m_lastname;
|
||||
private readonly Vector3 m_startPos;
|
||||
@@ -99,6 +104,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot,
|
||||
Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
|
||||
{
|
||||
@@ -189,7 +195,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
public event DeRezObject OnDeRezObject;
|
||||
public event Action<IClientAPI> OnRegionHandShakeReply;
|
||||
public event GenericCall1 OnRequestWearables;
|
||||
public event GenericCall1 OnCompleteMovementToRegion;
|
||||
public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
|
||||
public event UpdateAgent OnPreAgentUpdate;
|
||||
public event UpdateAgent OnAgentUpdate;
|
||||
public event AgentRequestSit OnAgentRequestSit;
|
||||
@@ -327,7 +333,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
public event ScriptReset OnScriptReset;
|
||||
public event GetScriptRunning OnGetScriptRunning;
|
||||
public event SetScriptRunning OnSetScriptRunning;
|
||||
public event UpdateVector OnAutoPilotGo;
|
||||
public event Action<Vector3, bool> OnAutoPilotGo;
|
||||
|
||||
public event TerrainUnacked OnUnackedTerrain;
|
||||
|
||||
@@ -744,12 +750,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
{
|
||||
OnRegionHandShakeReply(this);
|
||||
}
|
||||
|
||||
if (OnCompleteMovementToRegion != null)
|
||||
{
|
||||
OnCompleteMovementToRegion(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,32 +44,119 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
// private const bool m_enabled = false;
|
||||
|
||||
private Dictionary<UUID,NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
|
||||
private Dictionary<UUID,AvatarAppearance> m_appearanceCache = new Dictionary<UUID, AvatarAppearance>();
|
||||
private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
{
|
||||
scene.RegisterModuleInterface<INPCModule>(this);
|
||||
}
|
||||
IConfig config = source.Configs["NPC"];
|
||||
|
||||
private AvatarAppearance GetAppearance(UUID target, Scene scene)
|
||||
{
|
||||
if (m_appearanceCache.ContainsKey(target))
|
||||
return m_appearanceCache[target];
|
||||
|
||||
AvatarAppearance appearance = scene.AvatarService.GetAppearance(target);
|
||||
if (appearance != null)
|
||||
if (config != null && config.GetBoolean("Enabled", false))
|
||||
{
|
||||
m_appearanceCache.Add(target, appearance);
|
||||
return appearance;
|
||||
scene.RegisterModuleInterface<INPCModule>(this);
|
||||
scene.EventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement;
|
||||
}
|
||||
|
||||
return new AvatarAppearance();
|
||||
}
|
||||
|
||||
public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom)
|
||||
public void HandleOnSignificantClientMovement(ScenePresence presence)
|
||||
{
|
||||
lock (m_avatars)
|
||||
{
|
||||
if (m_avatars.ContainsKey(presence.UUID) && presence.MovingToTarget)
|
||||
{
|
||||
double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget);
|
||||
// m_log.DebugFormat(
|
||||
// "[NPC MODULE]: Abs pos of {0} is {1}, target {2}, distance {3}",
|
||||
// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);
|
||||
|
||||
// Check the error term of the current position in relation to the target position
|
||||
if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT)
|
||||
{
|
||||
// We are close enough to the target
|
||||
m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name);
|
||||
|
||||
presence.Velocity = Vector3.Zero;
|
||||
presence.AbsolutePosition = presence.MoveToPositionTarget;
|
||||
presence.ResetMoveToTarget();
|
||||
|
||||
if (presence.PhysicsActor.Flying)
|
||||
{
|
||||
// A horrible hack to stop the NPC dead in its tracks rather than having them overshoot
|
||||
// the target if flying.
|
||||
// We really need to be more subtle (slow the avatar as it approaches the target) or at
|
||||
// least be able to set collision status once, rather than 5 times to give it enough
|
||||
// weighting so that that PhysicsActor thinks it really is colliding.
|
||||
for (int i = 0; i < 5; i++)
|
||||
presence.PhysicsActor.IsColliding = true;
|
||||
|
||||
// Vector3 targetPos = presence.MoveToPositionTarget;
|
||||
if (m_avatars[presence.UUID].LandAtTarget)
|
||||
presence.PhysicsActor.Flying = false;
|
||||
|
||||
// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
|
||||
// if (targetPos.Z - terrainHeight < 0.2)
|
||||
// {
|
||||
// presence.PhysicsActor.Flying = false;
|
||||
// }
|
||||
}
|
||||
|
||||
// m_log.DebugFormat(
|
||||
// "[NPC MODULE]: AgentControlFlags {0}, MovementFlag {1} for {2}",
|
||||
// presence.AgentControlFlags, presence.MovementFlag, presence.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}",
|
||||
// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget);
|
||||
|
||||
Vector3 agent_control_v3 = new Vector3();
|
||||
presence.HandleMoveToTargetUpdate(ref agent_control_v3);
|
||||
presence.AddNewMovement(agent_control_v3);
|
||||
}
|
||||
//
|
||||
//// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null);
|
||||
|
||||
//
|
||||
//
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNPC(UUID agentId, Scene scene)
|
||||
{
|
||||
ScenePresence sp = scene.GetScenePresence(agentId);
|
||||
if (sp == null || sp.IsChildAgent)
|
||||
return false;
|
||||
|
||||
lock (m_avatars)
|
||||
return m_avatars.ContainsKey(agentId);
|
||||
}
|
||||
|
||||
public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
|
||||
{
|
||||
ScenePresence sp = scene.GetScenePresence(agentId);
|
||||
if (sp == null || sp.IsChildAgent)
|
||||
return false;
|
||||
|
||||
lock (m_avatars)
|
||||
if (!m_avatars.ContainsKey(agentId))
|
||||
return false;
|
||||
|
||||
scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false);
|
||||
|
||||
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
|
||||
sp.Appearance = npcAppearance;
|
||||
scene.AttachmentsModule.RezAttachments(sp);
|
||||
|
||||
IAvatarFactory module = scene.RequestModuleInterface<IAvatarFactory>();
|
||||
module.SendAppearance(sp.UUID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public UUID CreateNPC(
|
||||
string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance)
|
||||
{
|
||||
NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene);
|
||||
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
|
||||
@@ -84,12 +171,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
acd.lastname = lastname;
|
||||
acd.ServiceURLs = new Dictionary<string, object>();
|
||||
|
||||
AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene);
|
||||
AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
|
||||
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
|
||||
acd.Appearance = npcAppearance;
|
||||
|
||||
// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++)
|
||||
// {
|
||||
// m_log.DebugFormat(
|
||||
// "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
|
||||
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
|
||||
// }
|
||||
|
||||
scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
|
||||
scene.AddNewClient(npcAvatar);
|
||||
scene.AddNewClient(npcAvatar, PresenceType.Npc);
|
||||
|
||||
ScenePresence sp;
|
||||
if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
|
||||
@@ -97,13 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
m_log.DebugFormat(
|
||||
"[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID);
|
||||
|
||||
// Shouldn't call this - temporary.
|
||||
sp.CompleteMovement(npcAvatar);
|
||||
|
||||
// sp.SendAppearanceToAllOtherAgents();
|
||||
//
|
||||
// // Send animations back to the avatar as well
|
||||
// sp.Animator.SendAnimPack();
|
||||
sp.CompleteMovement(npcAvatar, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -118,7 +205,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
return npcAvatar.AgentId;
|
||||
}
|
||||
|
||||
public void Autopilot(UUID agentID, Scene scene, Vector3 pos)
|
||||
public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget)
|
||||
{
|
||||
lock (m_avatars)
|
||||
{
|
||||
@@ -126,32 +213,72 @@ namespace OpenSim.Region.OptionalModules.World.NPC
|
||||
{
|
||||
ScenePresence sp;
|
||||
scene.TryGetScenePresence(agentID, out sp);
|
||||
sp.DoAutoPilot(0, pos, m_avatars[agentID]);
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
|
||||
sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget);
|
||||
|
||||
m_avatars[agentID].LandAtTarget = landAtTarget;
|
||||
sp.MoveToTarget(pos, noFly);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Say(UUID agentID, Scene scene, string text)
|
||||
public bool StopMoveToTarget(UUID agentID, Scene scene)
|
||||
{
|
||||
lock (m_avatars)
|
||||
{
|
||||
if (m_avatars.ContainsKey(agentID))
|
||||
{
|
||||
ScenePresence sp;
|
||||
scene.TryGetScenePresence(agentID, out sp);
|
||||
|
||||
sp.Velocity = Vector3.Zero;
|
||||
sp.ResetMoveToTarget();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Say(UUID agentID, Scene scene, string text)
|
||||
{
|
||||
lock (m_avatars)
|
||||
{
|
||||
if (m_avatars.ContainsKey(agentID))
|
||||
{
|
||||
ScenePresence sp;
|
||||
scene.TryGetScenePresence(agentID, out sp);
|
||||
|
||||
m_avatars[agentID].Say(text);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void DeleteNPC(UUID agentID, Scene scene)
|
||||
public bool DeleteNPC(UUID agentID, Scene scene)
|
||||
{
|
||||
lock (m_avatars)
|
||||
{
|
||||
if (m_avatars.ContainsKey(agentID))
|
||||
{
|
||||
scene.RemoveClient(agentID);
|
||||
scene.RemoveClient(agentID, false);
|
||||
m_avatars.Remove(agentID);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
|
||||
@@ -27,11 +27,14 @@
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
|
||||
using OpenSim.Region.CoreModules.Framework.UserManagement;
|
||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
@@ -47,25 +50,112 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
|
||||
[Test]
|
||||
public void TestCreate()
|
||||
{
|
||||
TestHelper.InMethod();
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
config.AddConfig("NPC");
|
||||
config.Configs["NPC"].Set("Enabled", "true");
|
||||
|
||||
AvatarFactoryModule afm = new AvatarFactoryModule();
|
||||
UserManagementModule umm = new UserManagementModule();
|
||||
|
||||
TestScene scene = SceneHelpers.SetupScene();
|
||||
SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule());
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
|
||||
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
|
||||
|
||||
// 8 is the index of the first baked texture in AvatarAppearance
|
||||
UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
|
||||
Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
|
||||
Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
|
||||
originalTef.TextureID = originalFace8TextureId;
|
||||
|
||||
// We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
|
||||
// ScenePresence.SendInitialData() to reset our entire appearance.
|
||||
scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
|
||||
|
||||
afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null);
|
||||
|
||||
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
|
||||
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);
|
||||
|
||||
ScenePresence npc = scene.GetScenePresence(npcId);
|
||||
|
||||
Assert.That(npc, Is.Not.Null);
|
||||
Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
|
||||
Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMove()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
IConfigSource config = new IniConfigSource();
|
||||
|
||||
config.AddConfig("Modules");
|
||||
config.Configs["Modules"].Set("AvatarServices", "LocalAvatarServicesConnector");
|
||||
config.AddConfig("AvatarService");
|
||||
config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService");
|
||||
config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll");
|
||||
config.AddConfig("NPC");
|
||||
config.Configs["NPC"].Set("Enabled", "true");
|
||||
|
||||
TestScene scene = SceneSetupHelpers.SetupScene();
|
||||
SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule(), new LocalAvatarServicesConnector());
|
||||
TestScene scene = SceneHelpers.SetupScene();
|
||||
SceneHelpers.SetupSceneModules(scene, config, new NPCModule());
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
|
||||
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
|
||||
|
||||
Vector3 startPos = new Vector3(128, 128, 30);
|
||||
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
|
||||
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, UUID.Zero);
|
||||
UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance);
|
||||
|
||||
ScenePresence npc = scene.GetScenePresence(npcId);
|
||||
Assert.That(npc, Is.Not.Null);
|
||||
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
|
||||
|
||||
// For now, we'll make the scene presence fly to simplify this test, but this needs to change.
|
||||
npc.PhysicsActor.Flying = true;
|
||||
|
||||
scene.Update();
|
||||
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
|
||||
|
||||
Vector3 targetPos = startPos + new Vector3(0, 0, 10);
|
||||
npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false);
|
||||
|
||||
Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
|
||||
|
||||
scene.Update();
|
||||
|
||||
// We should really check the exact figure.
|
||||
Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X));
|
||||
Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y));
|
||||
Assert.That(npc.AbsolutePosition.Z, Is.GreaterThan(startPos.Z));
|
||||
Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.Z));
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
scene.Update();
|
||||
|
||||
double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
|
||||
Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move");
|
||||
Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
|
||||
Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE));
|
||||
|
||||
// Try a second movement
|
||||
startPos = npc.AbsolutePosition;
|
||||
targetPos = startPos + new Vector3(10, 0, 0);
|
||||
npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false);
|
||||
|
||||
scene.Update();
|
||||
|
||||
// We should really check the exact figure.
|
||||
Assert.That(npc.AbsolutePosition.X, Is.GreaterThan(startPos.X));
|
||||
Assert.That(npc.AbsolutePosition.X, Is.LessThan(targetPos.X));
|
||||
Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y));
|
||||
Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z));
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
scene.Update();
|
||||
|
||||
distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
|
||||
Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move");
|
||||
Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,7 +381,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
|
||||
{
|
||||
SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
|
||||
|
||||
|
||||
m_scene.DeleteSceneObject(selectedTree.ParentGroup, false);
|
||||
m_scene.ForEachClient(delegate(IClientAPI controller)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user