Allow terrain heightmaps to be loaded directly from URIs via the remote admin plugin
See http://opensimulator.org/mantis/view.php?id=4418 Thanks StrawberryFride Seemysql-performance
parent
07786786fc
commit
c0f3a4c833
|
@ -315,8 +315,21 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
|||
|
||||
ITerrainModule terrainModule = region.RequestModuleInterface<ITerrainModule>();
|
||||
if (null == terrainModule) throw new Exception("terrain module not available");
|
||||
terrainModule.LoadFromFile(file);
|
||||
|
||||
if (Uri.IsWellFormedUriString(file, UriKind.Absolute))
|
||||
{
|
||||
m_log.Info("[RADMIN]: Terrain path is URL");
|
||||
Uri result;
|
||||
if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result))
|
||||
{
|
||||
// the url is valid
|
||||
string fileType = file.Substring(file.LastIndexOf('/') + 1);
|
||||
terrainModule.LoadFromStream(fileType, result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
terrainModule.LoadFromFile(file);
|
||||
}
|
||||
responseData["success"] = false;
|
||||
|
||||
response.Value = responseData;
|
||||
|
|
|
@ -29,6 +29,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Net;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenMetaverse;
|
||||
|
@ -258,6 +259,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a terrain file from the specified URI
|
||||
/// </summary>
|
||||
/// <param name="filename">The name of the terrain to load</param>
|
||||
/// <param name="pathToTerrainHeightmap">The URI to the terrain height map</param>
|
||||
public void LoadFromStream(string filename, Uri pathToTerrainHeightmap)
|
||||
{
|
||||
LoadFromStream(filename, URIFetch(pathToTerrainHeightmap));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a terrain file from a stream and installs it in the scene.
|
||||
/// </summary>
|
||||
|
@ -267,7 +278,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
{
|
||||
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
|
||||
{
|
||||
if (@filename.EndsWith(loader.Key))
|
||||
if (filename.EndsWith(loader.Key))
|
||||
{
|
||||
lock (m_scene)
|
||||
{
|
||||
|
@ -295,6 +306,25 @@ namespace OpenSim.Region.CoreModules.World.Terrain
|
|||
throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
|
||||
}
|
||||
|
||||
private static Stream URIFetch(Uri uri)
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
|
||||
|
||||
// request.Credentials = credentials;
|
||||
|
||||
request.ContentLength = 0;
|
||||
request.KeepAlive = false;
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
Stream file = response.GetResponseStream();
|
||||
|
||||
if (response.ContentLength == 0)
|
||||
throw new Exception(String.Format("{0} returned an empty file", uri.ToString()));
|
||||
|
||||
// return new BufferedStream(file, (int) response.ContentLength);
|
||||
return new BufferedStream(file, 1000000);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Modify Land
|
||||
/// </summary>
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// </param>
|
||||
/// <param name="stream"></param>
|
||||
void LoadFromStream(string filename, Stream stream);
|
||||
|
||||
void LoadFromStream(string filename, System.Uri pathToTerrainHeightmap);
|
||||
/// <summary>
|
||||
/// Save a terrain to a stream.
|
||||
/// </summary>
|
||||
|
|
|
@ -2393,6 +2393,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
||||
item = InventoryService.GetItem(item);
|
||||
presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/);
|
||||
|
||||
if (m_AvatarFactory != null)
|
||||
{
|
||||
m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue