Add "show object pos <start-coord> to <end-coord>" command to simulator console.

This allows you to display details of all objects in a given bounding box.
Values parts of the co-ord can be left out as appropriate (e.g. to get all objects between the ground and z=30.
See "help show object pos" for more details.
connector_plugin
Justin Clark-Casey (justincc) 2012-10-05 03:52:42 +01:00
parent 8cd1dc8d60
commit 130768b16a
2 changed files with 80 additions and 0 deletions

View File

@ -533,6 +533,19 @@ namespace OpenSim.Framework
return (x + y - (min >> 1) - (min >> 2) + (min >> 4));
}
/// <summary>
/// Determines whether a point is inside a bounding box.
/// </summary>
/// <param name='v'>/param>
/// <param name='min'></param>
/// <param name='max'></param>
/// <returns></returns>
public static bool IsInsideBox(Vector3 v, Vector3 min, Vector3 max)
{
return v.X >= min.X & v.Y >= min.Y && v.Z >= min.Z
&& v.X <= max.X && v.Y <= max.Y && v.Z <= max.Z;
}
/// <summary>
/// Are the co-ordinates of the new region visible from the old region?
/// </summary>

View File

@ -123,6 +123,25 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
"If --regex is specified then the name is treatead as a regular expression",
HandleShowObjectByName);
m_console.Commands.AddCommand(
"Objects",
false,
"show object pos",
"show object pos <start-coord> to <end-coord>",
"Show details of scene objects within the given area.",
"Each component of the coord is comma separated. There must be no spaces between the commas.\n"
+ "If you don't care about the z component you can simply omit it.\n"
+ "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n"
+ "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n"
+ "If you want to specify the minimum value of a component then you can use -~ instead of a number\n"
+ "e.g.\n"
+ "show object pos 20,20,20 to 40,40,40\n"
+ "show object pos 20,20 to 40,40\n"
+ "show object pos ,20,20 to ,40,40\n"
+ "show object pos ,,30 to ,,~\n"
+ "show object pos ,,-~ to ,,30\n",
HandleShowObjectByPos);
m_console.Commands.AddCommand(
"Objects",
false,
@ -228,6 +247,54 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands
m_console.OutputFormat(sb.ToString());
}
private void HandleShowObjectByPos(string module, string[] cmdparams)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))
return;
if (cmdparams.Length < 5)
{
m_console.OutputFormat("Usage: show object pos <start-coord> to <end-coord>");
return;
}
string rawConsoleStartVector = cmdparams[3];
Vector3 startVector;
if (!ConsoleUtil.TryParseConsoleMinVector(rawConsoleStartVector, out startVector))
{
m_console.OutputFormat("Error: Start vector {0} does not have a valid format", rawConsoleStartVector);
return;
}
string rawConsoleEndVector = cmdparams[5];
Vector3 endVector;
if (!ConsoleUtil.TryParseConsoleMaxVector(rawConsoleEndVector, out endVector))
{
m_console.OutputFormat("Error: End vector {0} does not have a valid format", rawConsoleEndVector);
return;
}
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
Action<SceneObjectGroup> searchAction
= so => { if (Util.IsInsideBox(so.AbsolutePosition, startVector, endVector)) { sceneObjects.Add(so); }};
m_scene.ForEachSOG(searchAction);
StringBuilder sb = new StringBuilder();
foreach (SceneObjectGroup so in sceneObjects)
{
AddSceneObjectReport(sb, so);
sb.Append("\n");
}
sb.AppendFormat("{0} objects found in {1}\n", sceneObjects.Count, m_scene.Name);
m_console.OutputFormat(sb.ToString());
}
private void HandleShowPartByUuid(string module, string[] cmd)
{
if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene))