From 2aa7a22129e2b5c226d3937c31bdcbdbc65a20f8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Sep 2012 23:09:07 +0200 Subject: Sequence/throttle asset retrievals. --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 2 + .../Connectors/Asset/AssetServicesConnector.cs | 104 +++++++++++++-------- 2 files changed, 69 insertions(+), 37 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 6121371..11852eb 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -1471,6 +1471,8 @@ namespace OpenSim.Framework.Servers.HttpServer else responseString = (string)responsedata["str_response_string"]; contentType = (string)responsedata["content_type"]; + if (responseString == null) + responseString = String.Empty; } catch { diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs index daf38bc..9d6d9ad 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs @@ -27,6 +27,7 @@ using log4net; using System; +using System.Threading; using System.Collections.Generic; using System.IO; using System.Reflection; @@ -50,7 +51,7 @@ namespace OpenSim.Services.Connectors private IImprovedAssetCache m_Cache = null; private int m_retryCounter; private Dictionary> m_retryQueue = new Dictionary>(); - private Timer m_retryTimer; + private System.Timers.Timer m_retryTimer; private delegate void AssetRetrievedEx(AssetBase asset); // Keeps track of concurrent requests for the same asset, so that it's only loaded once. @@ -61,6 +62,8 @@ namespace OpenSim.Services.Connectors private Dictionary m_UriMap = new Dictionary(); + private Thread[] m_fetchThreads; + public AssetServicesConnector() { } @@ -96,7 +99,7 @@ namespace OpenSim.Services.Connectors } - m_retryTimer = new Timer(); + m_retryTimer = new System.Timers.Timer(); m_retryTimer.Elapsed += new ElapsedEventHandler(retryCheck); m_retryTimer.Interval = 60000; @@ -112,6 +115,14 @@ namespace OpenSim.Services.Connectors m_UriMap[prefix] = groupHost; //m_log.DebugFormat("[ASSET]: Using {0} for prefix {1}", groupHost, prefix); } + + m_fetchThreads = new Thread[2]; + + for (int i = 0 ; i < 2 ; i++) + { + m_fetchThreads[i] = new Thread(AssetRequestProcessor); + m_fetchThreads[i].Start(); + } } private string MapServer(string id) @@ -261,37 +272,25 @@ namespace OpenSim.Services.Connectors return null; } - public bool Get(string id, Object sender, AssetRetrieved handler) + private class QueuedAssetRequest { - string uri = MapServer(id) + "/assets/" + id; - - AssetBase asset = null; - if (m_Cache != null) - asset = m_Cache.Get(id); + public string uri; + public string id; + } - if (asset == null || asset.Data == null || asset.Data.Length == 0) - { - lock (m_AssetHandlers) - { - AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); }); + private OpenMetaverse.BlockingQueue m_requestQueue = + new OpenMetaverse.BlockingQueue(); -// AssetRetrievedEx handlers; - List handlers; - if (m_AssetHandlers.TryGetValue(id, out handlers)) - { - // Someone else is already loading this asset. It will notify our handler when done. -// handlers += handlerEx; - handlers.Add(handlerEx); - return true; - } + private void AssetRequestProcessor() + { + QueuedAssetRequest r; - // Load the asset ourselves -// handlers += handlerEx; - handlers = new List(); - handlers.Add(handlerEx); + while (true) + { + r = m_requestQueue.Dequeue(); - m_AssetHandlers.Add(id, handlers); - } + string uri = r.uri; + string id = r.id; bool success = false; try @@ -301,16 +300,7 @@ namespace OpenSim.Services.Connectors { if (m_Cache != null) m_Cache.Cache(a); -/* - AssetRetrievedEx handlers; - lock (m_AssetHandlers) - { - handlers = m_AssetHandlers[id]; - m_AssetHandlers.Remove(id); - } - handlers.Invoke(a); -*/ List handlers; lock (m_AssetHandlers) { @@ -340,6 +330,46 @@ namespace OpenSim.Services.Connectors } } } + } + + public bool Get(string id, Object sender, AssetRetrieved handler) + { + string uri = MapServer(id) + "/assets/" + id; + + AssetBase asset = null; + if (m_Cache != null) + asset = m_Cache.Get(id); + + if (asset == null || asset.Data == null || asset.Data.Length == 0) + { + lock (m_AssetHandlers) + { + AssetRetrievedEx handlerEx = new AssetRetrievedEx(delegate(AssetBase _asset) { handler(id, sender, _asset); }); + +// AssetRetrievedEx handlers; + List handlers; + if (m_AssetHandlers.TryGetValue(id, out handlers)) + { + // Someone else is already loading this asset. It will notify our handler when done. +// handlers += handlerEx; + handlers.Add(handlerEx); + return true; + } + + // Load the asset ourselves +// handlers += handlerEx; + handlers = new List(); + handlers.Add(handlerEx); + + m_AssetHandlers.Add(id, handlers); + } + + QueuedAssetRequest request = new QueuedAssetRequest(); + request.id = id; + request.uri = uri; + + m_requestQueue.Enqueue(request); + } else { handler(id, sender, asset); -- cgit v1.1 From a97436f2f16c2ef217963545349149cdbf9c21b8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 16 Sep 2012 16:42:30 +0200 Subject: Catch a nullref in the code to suppress GetTexture warnign spam we can't do a thing about anyway. --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 11852eb..2582b7b 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -640,7 +640,7 @@ namespace OpenSim.Framework.Servers.HttpServer // Every month or so this will wrap and give bad numbers, not really a problem // since its just for reporting int tickdiff = requestEndTick - requestStartTick; - if (tickdiff > 3000 && requestHandler.Name != "GetTexture") + if (tickdiff > 3000 && (requestHandler == null || requestHandler.Name == null || requestHandler.Name != "GetTexture")) { m_log.InfoFormat( "[BASE HTTP SERVER]: Slow handling of {0} {1} {2} {3} from {4} took {5}ms", -- cgit v1.1 From a76ce4f64d6f19e508d8e6f4d12e8f79f6880895 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 16 Sep 2012 22:50:35 +0200 Subject: Make the agent being kicked a child agent first so there won't be a ghost --- OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 1492302..716cc69 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs @@ -256,7 +256,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods if (sp.IsChildAgent) return; sp.ControllingClient.Kick(reason); - sp.Scene.IncomingCloseAgent(sp.UUID); + sp.MakeChildAgent(); + sp.ControllingClient.Close(); } private void OnIncomingInstantMessage(GridInstantMessage msg) -- cgit v1.1 From 7d5942d15445810e4b00289b80c33a4fba7b093b Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 16 Sep 2012 22:51:04 +0200 Subject: Make IncomingCloseChildAgent not send a stop packet. This may prevent a viewer from being logged out after an otherwise successful teleport. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9b9ad80..8034bc6 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4326,7 +4326,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); if (presence != null) { - presence.ControllingClient.Close(); + presence.ControllingClient.Close(false); return true; } -- cgit v1.1 From a79bafaaaf3df2a0e1663bf9317ee53eb06db204 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 16 Sep 2012 22:52:45 +0200 Subject: Change the close tmeout from 2 to 3 seconds on teleport. This may prevent being logged out after a successful teleport. --- .../Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 9090f64..880b2cc 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -648,7 +648,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer // // This sleep can be increased if necessary. However, whilst it's active, // an agent cannot teleport back to this region if it has teleported away. - Thread.Sleep(2000); + Thread.Sleep(3000); sp.Scene.IncomingCloseAgent(sp.UUID); } -- cgit v1.1 From 8dae7928d39399c2ac3d6a0dbd9a1362b2e0f68d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 16 Sep 2012 23:41:34 +0200 Subject: Make agent creation at destination asynchronous. Failures here are pretty much guaranteed to be fatal and the few times this would dosconnect an agent are more than made up for by the increased throughput of replying and closing the connection vs. keeping it open during the heavy work. Also causes better feedback to the viewer as the time is now split between Requesting Teleport and Connectiong to Destination. --- OpenSim/Server/Handlers/Simulation/AgentHandlers.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index d772c39..0bd8269 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -443,7 +443,15 @@ namespace OpenSim.Server.Handlers.Simulation // subclasses can override this protected virtual bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out string reason) { - return m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason); + reason = String.Empty; + + Util.FireAndForget(x => + { + string r; + m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out r); + }); + + return true; } } -- cgit v1.1 From f2308c819e3b8550507146f0490f2fc143a4abc1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 17 Sep 2012 12:58:59 +0200 Subject: Remove spammy "axislock" debug. --- OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index fbc6134..61d5a1d 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -902,7 +902,7 @@ namespace OpenSim.Region.Physics.OdePlugin axis.X = (axis.X > 0) ? 1f : 0f; axis.Y = (axis.Y > 0) ? 1f : 0f; axis.Z = (axis.Z > 0) ? 1f : 0f; - m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); +// m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); AddChange(changes.AngLock, axis); } else -- cgit v1.1 From 5bbc4fb2a5e0f357e0c880a722617d4f2b655203 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 13:39:38 +0100 Subject: missing file for suport of mesh upload cost --- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 596 +++++++++++++++++++++ 1 file changed, 596 insertions(+) create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs new file mode 100644 index 0000000..8adacab --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -0,0 +1,596 @@ +// Proprietary code of Avination Virtual Limited +// (c) 2012 Melanie Thielker, Leal Duarte +// + +using System; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using System.Text; + +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +using OpenSim.Framework; +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Framework.Capabilities; + +using ComponentAce.Compression.Libs.zlib; + +using OSDArray = OpenMetaverse.StructuredData.OSDArray; +using OSDMap = OpenMetaverse.StructuredData.OSDMap; + +namespace OpenSim.Region.ClientStack.Linden +{ + public class ModelCost + { + float ModelMinCost = 5.0f; // try to favor small meshs versus sculpts + + // scale prices relative to basic cost + const float ModelCostScale = 1.0f; + + const float primCreationCost = 0.01f; // 256 prims cost extra 2.56 + + // weigthed size to money convertion + const float bytecost = 1e-4f; + + // for mesh upload fees based on compressed data sizes + // not using streaming physics and server costs as SL apparently does ?? + + const float medSizeWth = 1f; // 2x + const float lowSizeWth = 1.5f; // 2.5x + const float lowestSizeWth = 2f; // 3x + // favor potencial optimized meshs versus automatic decomposition + const float physMeshSizeWth = 6f; // counts 7x + const float physHullSizeWth = 8f; // counts 9x + + // price compression to promote complex meshs + const float feeCompressionBase = 50.0f; // transition from linear to log cost + const float feeCompressionScale = 250.0f; // 10000 scales to 1000 + + // stream cost size factors + const float highLodFactor = 17.36f; + const float midLodFactor = 277.78f; + const float lowLodFactor = 1111.11f; + + const int bytesPerCoord = 6; // 3 coords, 2 bytes per each + + private class ameshCostParam + { + public int highLODSize; + public int medLODSize; + public int lowLODSize; + public int lowestLODSize; + public float costFee; + public float physicsCost; + } + + public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, LLSDAssetUploadResponseData meshcostdata, out string error) + { + totalcost = 0; + error = string.Empty; + + if (resources == null || + resources.instance_list == null || + resources.instance_list.Array.Count == 0) + { + error = "Unable to upload mesh model. missing information."; + return false; + } + + meshcostdata.model_streaming_cost = 0.0; + meshcostdata.simulation_cost = 0.0; + meshcostdata.physics_cost = 0.0; + meshcostdata.resource_cost = 0.0; + + meshcostdata.upload_price_breakdown.mesh_instance = 0; + meshcostdata.upload_price_breakdown.mesh_physics = 0; + meshcostdata.upload_price_breakdown.mesh_streaming = 0; + meshcostdata.upload_price_breakdown.model = 0; + + int itmp; + + // textures cost + if (resources.texture_list != null && resources.texture_list.Array.Count > 0) + { + int textures_cost = resources.texture_list.Array.Count; + textures_cost *= basicCost; + + meshcostdata.upload_price_breakdown.texture = textures_cost; + totalcost += textures_cost; + } + + float meshsfee = 0; + + // meshs assets cost + + int numberMeshs = 0; + List meshsCosts = new List(); + // a model could have no mesh actually + if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0) + { + numberMeshs = resources.mesh_list.Array.Count; + + for (int i = 0; i < numberMeshs; i++) + { + ameshCostParam curCost = new ameshCostParam(); + byte[] data = (byte[])resources.mesh_list.Array[i]; + + if (!MeshCost(data, curCost, out error)) + { + return false; + } + meshsCosts.Add(curCost); + meshsfee += curCost.costFee; + } + } + + // instances (prims) cost + int numberInstances = resources.instance_list.Array.Count; + int mesh; + for (int i = 0; i < numberInstances; i++) + { + Hashtable inst = (Hashtable)resources.instance_list.Array[i]; + + // streamming cost + // assume all instances have a mesh + // but in general they can have normal prims + // but for now that seems not suported + // when they do, we will need to inspect pbs information + // and have cost funtions for all prims types + // don't check for shape type none, since + // that could be used to upload meshs with low cost + // changing later inworld + + ArrayList ascale = (ArrayList)inst["scale"]; + Vector3 scale; + double tmp; + tmp = (double)ascale[0]; + scale.X = (float)tmp; + tmp = (double)ascale[1]; + scale.Y = (float)tmp; + tmp = (double)ascale[2]; + scale.Z = (float)tmp; + + float sqdiam = scale.LengthSquared(); + + mesh = (int)inst["mesh"]; + + if(mesh >= numberMeshs) + { + error = "Unable to upload mesh model. incoerent information."; + return false; + } + + ameshCostParam curCost = meshsCosts[mesh]; + float mesh_streaming = streamingCost(curCost, sqdiam); + + meshcostdata.model_streaming_cost += mesh_streaming; + + meshcostdata.physics_cost += curCost.physicsCost; + + // unscripted and static prim server cost + meshcostdata.simulation_cost += 0.5f; + // charge for prims creation + meshsfee += primCreationCost; + } + + if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) + meshcostdata.resource_cost = meshcostdata.model_streaming_cost; + else + meshcostdata.resource_cost = meshcostdata.physics_cost; + + if (meshsfee < ModelMinCost) + meshsfee = ModelMinCost; + + meshsfee *= ModelCostScale; + meshsfee += 0.5f; // rounding + + totalcost += (int)meshsfee; + + // breakdown prices + // don't seem to be in use so removed code for now + + return true; + } + + private bool MeshCost(byte[] data, ameshCostParam cost, out string error) + { + cost.highLODSize = 0; + cost.medLODSize = 0; + cost.lowLODSize = 0; + cost.lowestLODSize = 0; + cost.physicsCost = 0.0f; + cost.costFee = 0.0f; + + error = string.Empty; + + if (data == null || data.Length == 0) + { + error = "Unable to upload mesh model. missing information."; + return false; + } + + OSD meshOsd = null; + int start = 0; + + error = "Unable to upload mesh model. Invalid data"; + + using (MemoryStream ms = new MemoryStream(data)) + { + try + { + OSD osd = OSDParser.DeserializeLLSDBinary(ms); + if (osd is OSDMap) + meshOsd = (OSDMap)osd; + else + return false; + } + catch (Exception e) + { + return false; + } + start = (int)ms.Position; + } + + OSDMap map = (OSDMap)meshOsd; + OSDMap tmpmap; + + int highlod_size = 0; + int medlod_size = 0; + int lowlod_size = 0; + int lowestlod_size = 0; + int skin_size = 0; + + int hulls_size = 0; + int phys_nhulls; + int phys_hullsvertices = 0; + + int physmesh_size = 0; + int phys_ntriangles = 0; + + int submesh_offset = -1; + + if (map.ContainsKey("physics_convex")) + { + tmpmap = (OSDMap)map["physics_convex"]; + if (tmpmap.ContainsKey("offset")) + submesh_offset = tmpmap["offset"].AsInteger() + start; + if (tmpmap.ContainsKey("size")) + hulls_size = tmpmap["size"].AsInteger(); + } + + if (submesh_offset < 0 || hulls_size == 0) + { + error = "Unable to upload mesh model. missing physics_convex block"; + return false; + } + + if (!hulls(data, submesh_offset, hulls_size, out phys_hullsvertices, out phys_nhulls)) + { + error = "Unable to upload mesh model. bad physics_convex block"; + return false; + } + + submesh_offset = -1; + + // only look for LOD meshs sizes + + if (map.ContainsKey("high_lod")) + { + tmpmap = (OSDMap)map["high_lod"]; + // see at least if there is a offset for this one + if (tmpmap.ContainsKey("offset")) + submesh_offset = tmpmap["offset"].AsInteger() + start; + if (tmpmap.ContainsKey("size")) + highlod_size = tmpmap["size"].AsInteger(); + } + + if (submesh_offset < 0 || highlod_size <= 0) + { + error = "Unable to upload mesh model. missing high_lod"; + return false; + } + + bool haveprev = true; + + if (map.ContainsKey("medium_lod")) + { + tmpmap = (OSDMap)map["medium_lod"]; + if (tmpmap.ContainsKey("size")) + medlod_size = tmpmap["size"].AsInteger(); + else + haveprev = false; + } + + if (haveprev && map.ContainsKey("low_lod")) + { + tmpmap = (OSDMap)map["low_lod"]; + if (tmpmap.ContainsKey("size")) + lowlod_size = tmpmap["size"].AsInteger(); + else + haveprev = false; + } + + if (haveprev && map.ContainsKey("lowest_lod")) + { + tmpmap = (OSDMap)map["lowest_lod"]; + if (tmpmap.ContainsKey("size")) + lowestlod_size = tmpmap["size"].AsInteger(); + } + + if (map.ContainsKey("skin")) + { + tmpmap = (OSDMap)map["skin"]; + if (tmpmap.ContainsKey("size")) + skin_size = tmpmap["size"].AsInteger(); + } + + cost.highLODSize = highlod_size; + cost.medLODSize = medlod_size; + cost.lowLODSize = lowlod_size; + cost.lowestLODSize = lowestlod_size; + + submesh_offset = -1; + + if (map.ContainsKey("physics_mesh")) + { + tmpmap = (OSDMap)map["physics_mesh"]; + if (tmpmap.ContainsKey("offset")) + submesh_offset = tmpmap["offset"].AsInteger() + start; + if (tmpmap.ContainsKey("size")) + physmesh_size = tmpmap["size"].AsInteger(); + + if (submesh_offset >= 0 || physmesh_size > 0) + { + + if (!submesh(data, submesh_offset, physmesh_size, out phys_ntriangles)) + { + error = "Unable to upload mesh model. parsing error"; + return false; + } + } + } + + // upload is done in convex shape type so only one hull + phys_hullsvertices++; + cost.physicsCost = 0.04f * phys_hullsvertices; + + float sfee; + + sfee = data.Length; // start with total compressed data size + + // penalize lod meshs that should be more builder optimized + sfee += medSizeWth * medlod_size; + sfee += lowSizeWth * lowlod_size; + sfee += lowestSizeWth * lowlod_size; + + // physics + // favor potencial optimized meshs versus automatic decomposition + if (physmesh_size != 0) + sfee += physMeshSizeWth * (physmesh_size + hulls_size / 4); // reduce cost of mandatory convex hull + else + sfee += physHullSizeWth * hulls_size; + + // bytes to money + sfee *= bytecost; + + // fee compression + if (sfee > feeCompressionBase) + { + sfee -= feeCompressionBase; + sfee = feeCompressionScale * (float)Math.Log10((double)sfee); + sfee += feeCompressionBase; + } + + + + cost.costFee = sfee; + return true; + } + + private bool submesh(byte[] data, int offset, int size, out int ntriangles) + { + ntriangles = 0; + + OSD decodedMeshOsd = new OSD(); + byte[] meshBytes = new byte[size]; + System.Buffer.BlockCopy(data, offset, meshBytes, 0, size); + try + { + using (MemoryStream inMs = new MemoryStream(meshBytes)) + { + using (MemoryStream outMs = new MemoryStream()) + { + using (ZOutputStream zOut = new ZOutputStream(outMs)) + { + byte[] readBuffer = new byte[4096]; + int readLen = 0; + while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0) + { + zOut.Write(readBuffer, 0, readLen); + } + zOut.Flush(); + outMs.Seek(0, SeekOrigin.Begin); + + byte[] decompressedBuf = outMs.GetBuffer(); + decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); + } + } + } + } + catch (Exception e) + { + return false; + } + + OSDArray decodedMeshOsdArray = null; + if ((!decodedMeshOsd is OSDArray)) + return false; + + byte[] dummy; + + decodedMeshOsdArray = (OSDArray)decodedMeshOsd; + foreach (OSD subMeshOsd in decodedMeshOsdArray) + { + if (subMeshOsd is OSDMap) + { + OSDMap subtmpmap = (OSDMap)subMeshOsd; + if (subtmpmap.ContainsKey("NoGeometry") && ((OSDBoolean)subtmpmap["NoGeometry"])) + continue; + + if (!subtmpmap.ContainsKey("Position")) + return false; + + if (subtmpmap.ContainsKey("TriangleList")) + { + dummy = subtmpmap["TriangleList"].AsBinary(); + ntriangles += dummy.Length / bytesPerCoord; + } + else + return false; + } + } + + return true; + } + + private bool hulls(byte[] data, int offset, int size, out int nvertices, out int nhulls) + { + nvertices = 0; + nhulls = 1; + + OSD decodedMeshOsd = new OSD(); + byte[] meshBytes = new byte[size]; + System.Buffer.BlockCopy(data, offset, meshBytes, 0, size); + try + { + using (MemoryStream inMs = new MemoryStream(meshBytes)) + { + using (MemoryStream outMs = new MemoryStream()) + { + using (ZOutputStream zOut = new ZOutputStream(outMs)) + { + byte[] readBuffer = new byte[4096]; + int readLen = 0; + while ((readLen = inMs.Read(readBuffer, 0, readBuffer.Length)) > 0) + { + zOut.Write(readBuffer, 0, readLen); + } + zOut.Flush(); + outMs.Seek(0, SeekOrigin.Begin); + + byte[] decompressedBuf = outMs.GetBuffer(); + decodedMeshOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); + } + } + } + } + catch (Exception e) + { + return false; + } + + OSDMap cmap = (OSDMap)decodedMeshOsd; + if (cmap == null) + return false; + + byte[] dummy; + + // must have one of this + if (cmap.ContainsKey("BoundingVerts")) + { + dummy = cmap["BoundingVerts"].AsBinary(); + nvertices = dummy.Length / bytesPerCoord; + } + else + return false; + +/* upload is done with convex shape type + if (cmap.ContainsKey("HullList")) + { + dummy = cmap["HullList"].AsBinary(); + nhulls += dummy.Length; + } + + + if (cmap.ContainsKey("Positions")) + { + dummy = cmap["Positions"].AsBinary(); + nvertices = dummy.Length / bytesPerCoord; + } + */ + + return true; + } + + private float streamingCost(ameshCostParam curCost, float sqdiam) + { + // compute efective areas + float ma = 262144f; + + float mh = sqdiam * highLodFactor; + if (mh > ma) + mh = ma; + float mm = sqdiam * midLodFactor; + if (mm > ma) + mm = ma; + + float ml = sqdiam * lowLodFactor; + if (ml > ma) + ml = ma; + + float mlst = ma; + + mlst -= ml; + ml -= mm; + mm -= mh; + + if (mlst < 1.0f) + mlst = 1.0f; + if (ml < 1.0f) + ml = 1.0f; + if (mm < 1.0f) + mm = 1.0f; + if (mh < 1.0f) + mh = 1.0f; + + ma = mlst + ml + mm + mh; + + // get LODs compressed sizes + // giving 384 bytes bonus + int lst = curCost.lowestLODSize - 384; + int l = curCost.lowLODSize - 384; + int m = curCost.medLODSize - 384; + int h = curCost.highLODSize - 384; + + // use previus higher LOD size on missing ones + if (m <= 0) + m = h; + if (l <= 0) + l = m; + if (lst <= 0) + lst = l; + + // force minumum sizes + if (lst < 16) + lst = 16; + if (l < 16) + l = 16; + if (m < 16) + m = 16; + if (h < 16) + h = 16; + + // compute cost weighted by relative effective areas + + float cost = (float)lst * mlst + (float)l * ml + (float)m * mm + (float)h * mh; + cost /= ma; + + cost *= 0.004f; // overall tunning parameter + + return cost; + } + } +} -- cgit v1.1 From 5915dfc26f0fe02411588ddea2791d69cb67d1ed Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 15:37:05 +0100 Subject: Make use of mesh cost functions --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 29 ++++++++-------------- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 8 +++--- 2 files changed, 13 insertions(+), 24 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 580c005..ce3ca8b 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -429,6 +429,7 @@ namespace OpenSim.Region.ClientStack.Linden //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); uint cost = 0; + LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); if (llsdRequest.asset_type == "texture" || llsdRequest.asset_type == "animation" || @@ -467,11 +468,15 @@ namespace OpenSim.Region.ClientStack.Linden if (llsdRequest.asset_type == "mesh") { - cost += 20; // Constant for now to test showing a price + string error; + int modelcost; + ModelCost mc = new ModelCost(); - if (llsdRequest.asset_resources == null) + if (!mc.MeshModelCost(llsdRequest.asset_resources, mm.UploadCharge, out modelcost, + meshcostdata, out error)) { - client.SendAgentAlertMessage("Unable to upload asset. missing information.", false); + + client.SendAgentAlertMessage(error, false); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; @@ -479,10 +484,7 @@ namespace OpenSim.Region.ClientStack.Linden return errorResponse; } - uint textures_cost = (uint)llsdRequest.asset_resources.texture_list.Array.Count; - textures_cost *= (uint)mm.UploadCharge; - - cost += textures_cost; + cost = (uint)modelcost; } else { @@ -536,20 +538,9 @@ namespace OpenSim.Region.ClientStack.Linden uploadResponse.state = "upload"; uploadResponse.upload_price = (int)cost; - // use fake values for now if (llsdRequest.asset_type == "mesh") { - uploadResponse.data = new LLSDAssetUploadResponseData(); - uploadResponse.data.model_streaming_cost = 1.0; - uploadResponse.data.simulation_cost = 1.5; - - uploadResponse.data.physics_cost = 2.0; - uploadResponse.data.resource_cost = 3.0; - uploadResponse.data.upload_price_breakdown.mesh_instance = 1; - uploadResponse.data.upload_price_breakdown.mesh_physics = 2; - uploadResponse.data.upload_price_breakdown.mesh_streaming = 3; - uploadResponse.data.upload_price_breakdown.texture = 5; - uploadResponse.data.upload_price_breakdown.model = 4; + uploadResponse.data = meshcostdata; } uploader.OnUpLoad += UploadCompleteHandler; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 8adacab..0b5d3fa 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -27,9 +27,6 @@ namespace OpenSim.Region.ClientStack.Linden { float ModelMinCost = 5.0f; // try to favor small meshs versus sculpts - // scale prices relative to basic cost - const float ModelCostScale = 1.0f; - const float primCreationCost = 0.01f; // 256 prims cost extra 2.56 // weigthed size to money convertion @@ -70,7 +67,7 @@ namespace OpenSim.Region.ClientStack.Linden { totalcost = 0; error = string.Empty; - + if (resources == null || resources.instance_list == null || resources.instance_list.Array.Count == 0) @@ -184,7 +181,8 @@ namespace OpenSim.Region.ClientStack.Linden if (meshsfee < ModelMinCost) meshsfee = ModelMinCost; - meshsfee *= ModelCostScale; + // scale cost with basic cost changes relative to 10 + meshsfee *= (float)basicCost / 10.0f; meshsfee += 0.5f; // rounding totalcost += (int)meshsfee; -- cgit v1.1 From df77724bbc30ab03f95508bd1b2f4539ed1206e3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 15:50:59 +0100 Subject: let mesh model estimator work even without money module, so other estimations can work --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ce3ca8b..ddb69c4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -462,35 +462,35 @@ namespace OpenSim.Region.ClientStack.Linden { IMoneyModule mm = m_Scene.RequestModuleInterface(); + int baseCost = 0; if (mm != null) + baseCost = mm.UploadCharge; + + if (llsdRequest.asset_type == "mesh") { - // XPTO: The cost should be calculated about here + string error; + int modelcost; + ModelCost mc = new ModelCost(); - if (llsdRequest.asset_type == "mesh") + if (!mc.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, + meshcostdata, out error)) { - string error; - int modelcost; - ModelCost mc = new ModelCost(); - - if (!mc.MeshModelCost(llsdRequest.asset_resources, mm.UploadCharge, out modelcost, - meshcostdata, out error)) - { - - client.SendAgentAlertMessage(error, false); + client.SendAgentAlertMessage(error, false); - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); - errorResponse.uploader = ""; - errorResponse.state = "error"; - return errorResponse; - } - - cost = (uint)modelcost; - } - else - { - cost = (uint)mm.UploadCharge; + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; } + cost = (uint)modelcost; + } + else + { + cost = (uint)baseCost; + } + if (mm != null) + { if (!mm.UploadCovered(client.AgentId, (int)cost)) { client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); -- cgit v1.1 From 1740325392f9771e629ca290a608f26df85fb169 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 17:49:10 +0100 Subject: removed broken fee compression --- .../ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 0b5d3fa..622a2d9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -42,10 +42,6 @@ namespace OpenSim.Region.ClientStack.Linden const float physMeshSizeWth = 6f; // counts 7x const float physHullSizeWth = 8f; // counts 9x - // price compression to promote complex meshs - const float feeCompressionBase = 50.0f; // transition from linear to log cost - const float feeCompressionScale = 250.0f; // 10000 scales to 1000 - // stream cost size factors const float highLodFactor = 17.36f; const float midLodFactor = 277.78f; @@ -373,17 +369,7 @@ namespace OpenSim.Region.ClientStack.Linden // bytes to money sfee *= bytecost; - - // fee compression - if (sfee > feeCompressionBase) - { - sfee -= feeCompressionBase; - sfee = feeCompressionScale * (float)Math.Log10((double)sfee); - sfee += feeCompressionBase; - } - - - + cost.costFee = sfee; return true; } -- cgit v1.1 From 7f5b1182efab9e7a80293622fa658d8d1a7b1fc8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 19:09:51 +0100 Subject: same cleanup --- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 79 +++++++++++----------- 1 file changed, 41 insertions(+), 38 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 622a2d9..ba73a25 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.ClientStack.Linden const float physMeshSizeWth = 6f; // counts 7x const float physHullSizeWth = 8f; // counts 9x - // stream cost size factors + // stream cost area factors const float highLodFactor = 17.36f; const float midLodFactor = 277.78f; const float lowLodFactor = 1111.11f; @@ -94,13 +94,12 @@ namespace OpenSim.Region.ClientStack.Linden totalcost += textures_cost; } - float meshsfee = 0; - // meshs assets cost - + float meshsfee = 0; int numberMeshs = 0; + bool haveMeshs = false; List meshsCosts = new List(); - // a model could have no mesh actually + if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0) { numberMeshs = resources.mesh_list.Array.Count; @@ -117,6 +116,7 @@ namespace OpenSim.Region.ClientStack.Linden meshsCosts.Add(curCost); meshsfee += curCost.costFee; } + haveMeshs = true; } // instances (prims) cost @@ -126,44 +126,43 @@ namespace OpenSim.Region.ClientStack.Linden { Hashtable inst = (Hashtable)resources.instance_list.Array[i]; - // streamming cost - // assume all instances have a mesh - // but in general they can have normal prims - // but for now that seems not suported - // when they do, we will need to inspect pbs information - // and have cost funtions for all prims types - // don't check for shape type none, since - // that could be used to upload meshs with low cost - // changing later inworld - - ArrayList ascale = (ArrayList)inst["scale"]; - Vector3 scale; - double tmp; - tmp = (double)ascale[0]; - scale.X = (float)tmp; - tmp = (double)ascale[1]; - scale.Y = (float)tmp; - tmp = (double)ascale[2]; - scale.Z = (float)tmp; - - float sqdiam = scale.LengthSquared(); - - mesh = (int)inst["mesh"]; - - if(mesh >= numberMeshs) + if (haveMeshs && inst.ContainsKey("mesh")) { - error = "Unable to upload mesh model. incoerent information."; - return false; - } + mesh = (int)inst["mesh"]; - ameshCostParam curCost = meshsCosts[mesh]; - float mesh_streaming = streamingCost(curCost, sqdiam); + if (mesh >= numberMeshs) + { + error = "Unable to upload mesh model. incoerent information."; + return false; + } + + // streamming cost + ArrayList ascale = (ArrayList)inst["scale"]; + Vector3 scale; + double tmp; + tmp = (double)ascale[0]; + scale.X = (float)tmp; + tmp = (double)ascale[1]; + scale.Y = (float)tmp; + tmp = (double)ascale[2]; + scale.Z = (float)tmp; - meshcostdata.model_streaming_cost += mesh_streaming; + float sqdiam = scale.LengthSquared(); - meshcostdata.physics_cost += curCost.physicsCost; + ameshCostParam curCost = meshsCosts[mesh]; + float mesh_streaming = streamingCost(curCost, sqdiam); + + meshcostdata.model_streaming_cost += mesh_streaming; + meshcostdata.physics_cost += curCost.physicsCost; + } + else // instance as no mesh ?? + { + // to do later if needed + meshcostdata.model_streaming_cost += 0.5f; + meshcostdata.physics_cost += 1.0f; + } - // unscripted and static prim server cost + // assume unscripted and static prim server cost meshcostdata.simulation_cost += 0.5f; // charge for prims creation meshsfee += primCreationCost; @@ -174,6 +173,10 @@ namespace OpenSim.Region.ClientStack.Linden else meshcostdata.resource_cost = meshcostdata.physics_cost; + if (meshcostdata.resource_cost < meshcostdata.simulation_cost) + meshcostdata.resource_cost = meshcostdata.simulation_cost; + + if (meshsfee < ModelMinCost) meshsfee = ModelMinCost; -- cgit v1.1 From c3666c9ec3f0e32443094fbcb683dec7b457a3e6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 19:38:05 +0100 Subject: make sure client still has money at upload --- .../ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ddb69c4..4ba8254 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -489,6 +489,7 @@ namespace OpenSim.Region.ClientStack.Linden cost = (uint)baseCost; } + // check funds if (mm != null) { if (!mm.UploadCovered(client.AgentId, (int)cost)) @@ -565,6 +566,21 @@ namespace OpenSim.Region.ClientStack.Linden sbyte assType = 0; sbyte inType = 0; + IClientAPI client = null; + + IMoneyModule mm = m_Scene.RequestModuleInterface(); + if (mm != null) + { + // make sure client still has enougth credit + if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost)) + { + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + return; + } + } + if (inventoryType == "sound") { inType = 1; -- cgit v1.1 From c1eec3b82818f91f66580cecc32c2ac9a9d2d968 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 21:15:07 +0100 Subject: on upload store mesh list contents as mesh assets. Build prims by instances not meshs. (some prims can have same mesh) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 31 ++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 4ba8254..ace188c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -617,6 +617,7 @@ namespace OpenSim.Region.ClientStack.Linden OSDArray texture_list = (OSDArray)request["texture_list"]; SceneObjectGroup grp = null; + // create and store texture assets List textures = new List(); for (int i = 0; i < texture_list.Count; i++) { @@ -624,14 +625,28 @@ namespace OpenSim.Region.ClientStack.Linden textureAsset.Data = texture_list[i].AsBinary(); m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); + textureAsset = null; } + // create and store meshs assets + List meshAssets = new List(); for (int i = 0; i < mesh_list.Count; i++) { + AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); + meshAsset.Data = mesh_list[i].AsBinary(); + m_assetService.Store(meshAsset); + meshAssets.Add(meshAsset.FullID); + meshAsset = null; + } + + // build prims from instances + for (int i = 0; i < instance_list.Count; i++) + { PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); Primitive.TextureEntry textureEntry = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); + OSDMap inner_instance_list = (OSDMap)instance_list[i]; OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; @@ -676,14 +691,14 @@ namespace OpenSim.Region.ClientStack.Linden pbs.TextureEntry = textureEntry.GetBytes(); - AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); - meshAsset.Data = mesh_list[i].AsBinary(); - m_assetService.Store(meshAsset); - - pbs.SculptEntry = true; - pbs.SculptTexture = meshAsset.FullID; - pbs.SculptType = (byte)SculptType.Mesh; - pbs.SculptData = meshAsset.Data; + int meshindx = inner_instance_list["mesh"].AsInteger(); + if (meshAssets.Count > meshindx) + { + pbs.SculptEntry = true; + pbs.SculptType = (byte)SculptType.Mesh; + pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction + // data will be requested from asset on rez (i hope) + } Vector3 position = inner_instance_list["position"].AsVector3(); Vector3 scale = inner_instance_list["scale"].AsVector3(); -- cgit v1.1 From fd20ef5c91f5db119d17b1974805b6d4fc2abad3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Sep 2012 22:35:36 +0100 Subject: add some locks to GetTextureModule --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 5b125ea..0ac56ec 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -149,13 +149,16 @@ namespace OpenSim.Region.ClientStack.Linden HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; GetEvents = (x, y, s) => { - try + lock (responses) { - return this.responses[x]; - } - finally - { - responses.Remove(x); + try + { + return this.responses[x]; + } + finally + { + responses.Remove(x); + } } }; @@ -218,14 +221,14 @@ namespace OpenSim.Region.ClientStack.Linden response["content_type"] = "text/plain"; response["keepalive"] = false; response["reusecontext"] = false; - - responses[requestID] = response; + lock (responses) + responses[requestID] = response; return; } response = m_getTextureHandler.Handle(request); - - responses[requestID] = response; + lock (responses) + responses[requestID] = response; } } -- cgit v1.1 From e8ba26eac8fdc438ffb72391d00c852ec1fc9950 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 18 Sep 2012 01:07:44 +0100 Subject: ***TEST*** still bad... create inventory itens for model textures and meshs. Issues: meshs get into root folder, viewer and viewer does not update inventory until relog ( the upload funtion needs to return more information) ,etc. Droping a mesh into a prim, makes viewer think we dropped a sculpt map, but it does work, viewer displays the mesh and physics work (as physics is stored at the sculpt information fields). Textures show up in Textures folder, just its to costly to find that default folder as is.. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 83 ++++++++++++++++++++-- 1 file changed, 76 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index ace188c..3789ee9 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -583,24 +583,24 @@ namespace OpenSim.Region.ClientStack.Linden if (inventoryType == "sound") { - inType = 1; - assType = 1; + inType = (sbyte)InventoryType.Sound; + assType = (sbyte)AssetType.Sound; } else if (inventoryType == "animation") { - inType = 19; - assType = 20; + inType = (sbyte)InventoryType.Animation; + assType = (sbyte)AssetType.Animation; } else if (inventoryType == "wearable") { - inType = 18; + inType = (sbyte)InventoryType.Wearable; switch (assetType) { case "bodypart": - assType = 13; + assType = (sbyte)AssetType.Bodypart; break; case "clothing": - assType = 5; + assType = (sbyte)AssetType.Clothing; break; } } @@ -625,7 +625,42 @@ namespace OpenSim.Region.ClientStack.Linden textureAsset.Data = texture_list[i].AsBinary(); m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); + + // save it to inventory + if (AddNewInventoryItem != null) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Texture#" + i.ToString(); + InventoryItemBase texitem = new InventoryItemBase(); + texitem.Owner = m_HostCapsObj.AgentID; + texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); + texitem.CreatorData = String.Empty; + texitem.ID = UUID.Random(); + texitem.AssetID = textureAsset.FullID; + texitem.Description = "mesh model texture"; + texitem.Name = name; + texitem.AssetType = (int)AssetType.Texture; + texitem.InvType = (int)InventoryType.Texture; + texitem.Folder = UUID.Zero; // send to default + + // If we set PermissionMask.All then when we rez the item the next permissions will replace the current + // (owner) permissions. This becomes a problem if next permissions are changed. + texitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + texitem.BasePermissions = (uint)PermissionMask.All; + texitem.EveryOnePermissions = 0; + texitem.NextPermissions = (uint)PermissionMask.All; + texitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); + texitem = null; + } + textureAsset = null; + } // create and store meshs assets @@ -636,6 +671,40 @@ namespace OpenSim.Region.ClientStack.Linden meshAsset.Data = mesh_list[i].AsBinary(); m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); + + // save it to inventory + if (AddNewInventoryItem != null) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Mesh#" + i.ToString(); + InventoryItemBase meshitem = new InventoryItemBase(); + meshitem.Owner = m_HostCapsObj.AgentID; + meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); + meshitem.CreatorData = String.Empty; + meshitem.ID = UUID.Random(); + meshitem.AssetID = meshAsset.FullID; + meshitem.Description = "mesh "; + meshitem.Name = name; + meshitem.AssetType = (int)AssetType.Mesh; + meshitem.InvType = (int)InventoryType.Mesh; + meshitem.Folder = UUID.Zero; // send to default + + // If we set PermissionMask.All then when we rez the item the next permissions will replace the current + // (owner) permissions. This becomes a problem if next permissions are changed. + meshitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + meshitem.BasePermissions = (uint)PermissionMask.All; + meshitem.EveryOnePermissions = 0; + meshitem.NextPermissions = (uint)PermissionMask.All; + meshitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); + meshitem = null; + } + meshAsset = null; } -- cgit v1.1 From ac2380bbfa5f7f2be8a5a9197f099a88988bce22 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 18 Sep 2012 02:12:07 +0200 Subject: Add booleans to control whether we actually crete inventory items --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 3789ee9..cb6f7a1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -116,6 +116,8 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_dumpAssetsToFile = false; private string m_regionName; private int m_levelUpload = 0; + private bool m_addNewTextures = false; + private bool m_addNewMeshes = false; public BunchOfCaps(Scene scene, Caps caps) { @@ -627,7 +629,7 @@ namespace OpenSim.Region.ClientStack.Linden textures.Add(textureAsset.FullID); // save it to inventory - if (AddNewInventoryItem != null) + if (m_addNewTextures && AddNewInventoryItem != null) { string name = assetName; if (name.Length > 25) @@ -673,7 +675,7 @@ namespace OpenSim.Region.ClientStack.Linden meshAssets.Add(meshAsset.FullID); // save it to inventory - if (AddNewInventoryItem != null) + if (m_addNewMeshes && AddNewInventoryItem != null) { string name = assetName; if (name.Length > 25) -- cgit v1.1 From 51ca84afdfc8a4c3c884b5ab9bd4dffe662087a6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Sep 2012 00:29:16 +0100 Subject: coment out mesh model upload code to add textures and individual meshs assets to inventory, since it may actually be a bad ideia since good model textures are deply related to it and there is no current use for independent mesh assets. Added the option to have a reduced free for textures (2.5 C$ as is, total textures cost rounded to nearest int) compensating for the fact that they can't be used outside the model or its parts. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 380 +++++++++++---------- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 79 +++-- 2 files changed, 255 insertions(+), 204 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index cb6f7a1..073f175 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -116,8 +116,8 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_dumpAssetsToFile = false; private string m_regionName; private int m_levelUpload = 0; - private bool m_addNewTextures = false; - private bool m_addNewMeshes = false; +// private bool m_addNewTextures = false; +// private bool m_addNewMeshes = false; public BunchOfCaps(Scene scene, Caps caps) { @@ -608,172 +608,181 @@ namespace OpenSim.Region.ClientStack.Linden } else if (inventoryType == "object") { - inType = (sbyte)InventoryType.Object; - assType = (sbyte)AssetType.Object; - - List positions = new List(); - List rotations = new List(); - OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); - OSDArray instance_list = (OSDArray)request["instance_list"]; - OSDArray mesh_list = (OSDArray)request["mesh_list"]; - OSDArray texture_list = (OSDArray)request["texture_list"]; - SceneObjectGroup grp = null; - - // create and store texture assets - List textures = new List(); - for (int i = 0; i < texture_list.Count; i++) + if (assetType == "mesh") // this code for now is for mesh models uploads only { - AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, ""); - textureAsset.Data = texture_list[i].AsBinary(); - m_assetService.Store(textureAsset); - textures.Add(textureAsset.FullID); - - // save it to inventory - if (m_addNewTextures && AddNewInventoryItem != null) + inType = (sbyte)InventoryType.Object; + assType = (sbyte)AssetType.Object; + + List positions = new List(); + List rotations = new List(); + OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); + OSDArray instance_list = (OSDArray)request["instance_list"]; + OSDArray mesh_list = (OSDArray)request["mesh_list"]; + OSDArray texture_list = (OSDArray)request["texture_list"]; + SceneObjectGroup grp = null; + + // create and store texture assets + List textures = new List(); + for (int i = 0; i < texture_list.Count; i++) { - string name = assetName; - if (name.Length > 25) - name = name.Substring(0, 24); - name += "_Texture#" + i.ToString(); - InventoryItemBase texitem = new InventoryItemBase(); - texitem.Owner = m_HostCapsObj.AgentID; - texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); - texitem.CreatorData = String.Empty; - texitem.ID = UUID.Random(); - texitem.AssetID = textureAsset.FullID; - texitem.Description = "mesh model texture"; - texitem.Name = name; - texitem.AssetType = (int)AssetType.Texture; - texitem.InvType = (int)InventoryType.Texture; - texitem.Folder = UUID.Zero; // send to default - - // If we set PermissionMask.All then when we rez the item the next permissions will replace the current - // (owner) permissions. This becomes a problem if next permissions are changed. - texitem.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - - texitem.BasePermissions = (uint)PermissionMask.All; - texitem.EveryOnePermissions = 0; - texitem.NextPermissions = (uint)PermissionMask.All; - texitem.CreationDate = Util.UnixTimeSinceEpoch(); - - AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); - texitem = null; + AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, ""); + textureAsset.Data = texture_list[i].AsBinary(); + m_assetService.Store(textureAsset); + textures.Add(textureAsset.FullID); + /* + don't do this + replace it by optionaly making model textures cost less than if individually uploaded + since they can't be used for other purpuses + + // save it to inventory + if (m_addNewTextures && AddNewInventoryItem != null) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Texture#" + i.ToString(); + InventoryItemBase texitem = new InventoryItemBase(); + texitem.Owner = m_HostCapsObj.AgentID; + texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); + texitem.CreatorData = String.Empty; + texitem.ID = UUID.Random(); + texitem.AssetID = textureAsset.FullID; + texitem.Description = "mesh model texture"; + texitem.Name = name; + texitem.AssetType = (int)AssetType.Texture; + texitem.InvType = (int)InventoryType.Texture; + texitem.Folder = UUID.Zero; // send to default + + // If we set PermissionMask.All then when we rez the item the next permissions will replace the current + // (owner) permissions. This becomes a problem if next permissions are changed. + texitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + texitem.BasePermissions = (uint)PermissionMask.All; + texitem.EveryOnePermissions = 0; + texitem.NextPermissions = (uint)PermissionMask.All; + texitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); + texitem = null; + } + */ + textureAsset = null; } - textureAsset = null; - - } - - // create and store meshs assets - List meshAssets = new List(); - for (int i = 0; i < mesh_list.Count; i++) - { - AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); - meshAsset.Data = mesh_list[i].AsBinary(); - m_assetService.Store(meshAsset); - meshAssets.Add(meshAsset.FullID); - - // save it to inventory - if (m_addNewMeshes && AddNewInventoryItem != null) + // create and store meshs assets + List meshAssets = new List(); + for (int i = 0; i < mesh_list.Count; i++) { - string name = assetName; - if (name.Length > 25) - name = name.Substring(0, 24); - name += "_Mesh#" + i.ToString(); - InventoryItemBase meshitem = new InventoryItemBase(); - meshitem.Owner = m_HostCapsObj.AgentID; - meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); - meshitem.CreatorData = String.Empty; - meshitem.ID = UUID.Random(); - meshitem.AssetID = meshAsset.FullID; - meshitem.Description = "mesh "; - meshitem.Name = name; - meshitem.AssetType = (int)AssetType.Mesh; - meshitem.InvType = (int)InventoryType.Mesh; - meshitem.Folder = UUID.Zero; // send to default - - // If we set PermissionMask.All then when we rez the item the next permissions will replace the current - // (owner) permissions. This becomes a problem if next permissions are changed. - meshitem.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - - meshitem.BasePermissions = (uint)PermissionMask.All; - meshitem.EveryOnePermissions = 0; - meshitem.NextPermissions = (uint)PermissionMask.All; - meshitem.CreationDate = Util.UnixTimeSinceEpoch(); - - AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); - meshitem = null; + AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); + meshAsset.Data = mesh_list[i].AsBinary(); + m_assetService.Store(meshAsset); + meshAssets.Add(meshAsset.FullID); + + /* this was a test, funny and showed viewers deal with mesh inventory itens + * nut also same reason as for textures + * let integrated in a model cost eventually less than hipotetical independent meshs assets + * that will be in inventory + // save it to inventory + if (m_addNewMeshes && AddNewInventoryItem != null) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Mesh#" + i.ToString(); + InventoryItemBase meshitem = new InventoryItemBase(); + meshitem.Owner = m_HostCapsObj.AgentID; + meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); + meshitem.CreatorData = String.Empty; + meshitem.ID = UUID.Random(); + meshitem.AssetID = meshAsset.FullID; + meshitem.Description = "mesh "; + meshitem.Name = name; + meshitem.AssetType = (int)AssetType.Mesh; + meshitem.InvType = (int)InventoryType.Mesh; + meshitem.Folder = UUID.Zero; // send to default + + // If we set PermissionMask.All then when we rez the item the next permissions will replace the current + // (owner) permissions. This becomes a problem if next permissions are changed. + meshitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + meshitem.BasePermissions = (uint)PermissionMask.All; + meshitem.EveryOnePermissions = 0; + meshitem.NextPermissions = (uint)PermissionMask.All; + meshitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); + meshitem = null; + } + */ + meshAsset = null; } - meshAsset = null; - } - - // build prims from instances - for (int i = 0; i < instance_list.Count; i++) - { - PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); + // build prims from instances + for (int i = 0; i < instance_list.Count; i++) + { + PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); - Primitive.TextureEntry textureEntry - = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); + Primitive.TextureEntry textureEntry + = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); - OSDMap inner_instance_list = (OSDMap)instance_list[i]; + OSDMap inner_instance_list = (OSDMap)instance_list[i]; - OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; - for (uint face = 0; face < face_list.Count; face++) - { - OSDMap faceMap = (OSDMap)face_list[(int)face]; - Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face); - if(faceMap.ContainsKey("fullbright")) - f.Fullbright = faceMap["fullbright"].AsBoolean(); - if (faceMap.ContainsKey ("diffuse_color")) - f.RGBA = faceMap["diffuse_color"].AsColor4(); + OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; + for (uint face = 0; face < face_list.Count; face++) + { + OSDMap faceMap = (OSDMap)face_list[(int)face]; + Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face); + if (faceMap.ContainsKey("fullbright")) + f.Fullbright = faceMap["fullbright"].AsBoolean(); + if (faceMap.ContainsKey("diffuse_color")) + f.RGBA = faceMap["diffuse_color"].AsColor4(); - int textureNum = faceMap["image"].AsInteger(); - float imagerot = faceMap["imagerot"].AsInteger(); - float offsets = (float)faceMap["offsets"].AsReal(); - float offsett = (float)faceMap["offsett"].AsReal(); - float scales = (float)faceMap["scales"].AsReal(); - float scalet = (float)faceMap["scalet"].AsReal(); + int textureNum = faceMap["image"].AsInteger(); + float imagerot = faceMap["imagerot"].AsInteger(); + float offsets = (float)faceMap["offsets"].AsReal(); + float offsett = (float)faceMap["offsett"].AsReal(); + float scales = (float)faceMap["scales"].AsReal(); + float scalet = (float)faceMap["scalet"].AsReal(); - if(imagerot != 0) - f.Rotation = imagerot; + if (imagerot != 0) + f.Rotation = imagerot; - if(offsets != 0) - f.OffsetU = offsets; + if (offsets != 0) + f.OffsetU = offsets; - if (offsett != 0) - f.OffsetV = offsett; + if (offsett != 0) + f.OffsetV = offsett; - if (scales != 0) - f.RepeatU = scales; + if (scales != 0) + f.RepeatU = scales; - if (scalet != 0) - f.RepeatV = scalet; + if (scalet != 0) + f.RepeatV = scalet; - if (textures.Count > textureNum) - f.TextureID = textures[textureNum]; - else - f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE; + if (textures.Count > textureNum) + f.TextureID = textures[textureNum]; + else + f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE; - textureEntry.FaceTextures[face] = f; - } + textureEntry.FaceTextures[face] = f; + } - pbs.TextureEntry = textureEntry.GetBytes(); + pbs.TextureEntry = textureEntry.GetBytes(); - int meshindx = inner_instance_list["mesh"].AsInteger(); - if (meshAssets.Count > meshindx) - { - pbs.SculptEntry = true; - pbs.SculptType = (byte)SculptType.Mesh; - pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction - // data will be requested from asset on rez (i hope) - } + int meshindx = inner_instance_list["mesh"].AsInteger(); + if (meshAssets.Count > meshindx) + { + pbs.SculptEntry = true; + pbs.SculptType = (byte)SculptType.Mesh; + pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction + // data will be requested from asset on rez (i hope) + } - Vector3 position = inner_instance_list["position"].AsVector3(); - Vector3 scale = inner_instance_list["scale"].AsVector3(); - Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); + Vector3 position = inner_instance_list["position"].AsVector3(); + Vector3 scale = inner_instance_list["scale"].AsVector3(); + Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); // no longer used - begin ------------------------ // int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); @@ -793,23 +802,23 @@ namespace OpenSim.Region.ClientStack.Linden // int owner_mask = permissions["owner_mask"].AsInteger(); // no longer used - end ------------------------ - UUID owner_id = m_HostCapsObj.AgentID; + UUID owner_id = m_HostCapsObj.AgentID; - SceneObjectPart prim - = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); + SceneObjectPart prim + = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); - prim.Scale = scale; - prim.OffsetPosition = position; - rotations.Add(rotation); - positions.Add(position); - prim.UUID = UUID.Random(); - prim.CreatorID = owner_id; - prim.OwnerID = owner_id; - prim.GroupID = UUID.Zero; - prim.LastOwnerID = prim.OwnerID; - prim.CreationDate = Util.UnixTimeSinceEpoch(); - prim.Name = assetName; - prim.Description = ""; + prim.Scale = scale; + prim.OffsetPosition = position; + rotations.Add(rotation); + positions.Add(position); + prim.UUID = UUID.Random(); + prim.CreatorID = owner_id; + prim.OwnerID = owner_id; + prim.GroupID = UUID.Zero; + prim.LastOwnerID = prim.OwnerID; + prim.CreationDate = Util.UnixTimeSinceEpoch(); + prim.Name = assetName; + prim.Description = ""; // prim.BaseMask = (uint)base_mask; // prim.EveryoneMask = (uint)everyone_mask; @@ -817,32 +826,39 @@ namespace OpenSim.Region.ClientStack.Linden // prim.NextOwnerMask = (uint)next_owner_mask; // prim.OwnerMask = (uint)owner_mask; - if (grp == null) - grp = new SceneObjectGroup(prim); - else - grp.AddPart(prim); - } + if (grp == null) + grp = new SceneObjectGroup(prim); + else + grp.AddPart(prim); + } - // Fix first link number - if (grp.Parts.Length > 1) - grp.RootPart.LinkNum++; + // Fix first link number + if (grp.Parts.Length > 1) + grp.RootPart.LinkNum++; - Vector3 rootPos = positions[0]; - grp.AbsolutePosition = rootPos; - for (int i = 0; i < positions.Count; i++) - { - Vector3 offset = positions[i] - rootPos; - grp.Parts[i].OffsetPosition = offset; + Vector3 rootPos = positions[0]; + grp.AbsolutePosition = rootPos; + for (int i = 0; i < positions.Count; i++) + { + Vector3 offset = positions[i] - rootPos; + grp.Parts[i].OffsetPosition = offset; + } + + for (int i = 0; i < rotations.Count; i++) + { + if (i != 0) + grp.Parts[i].RotationOffset = rotations[i]; + } + + grp.UpdateGroupRotationR(rotations[0]); + data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); } - for (int i = 0; i < rotations.Count; i++) + else // not a mesh model { - if (i != 0) - grp.Parts[i].RotationOffset = rotations[i]; + m_log.ErrorFormat("[CAPS Asset Upload] got unsuported assetType for object upload"); + return; } - - grp.UpdateGroupRotationR(rotations[0]); - data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); } AssetBase asset; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index ba73a25..5096a91 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -25,40 +25,67 @@ namespace OpenSim.Region.ClientStack.Linden { public class ModelCost { - float ModelMinCost = 5.0f; // try to favor small meshs versus sculpts - - const float primCreationCost = 0.01f; // 256 prims cost extra 2.56 - - // weigthed size to money convertion - const float bytecost = 1e-4f; - - // for mesh upload fees based on compressed data sizes - // not using streaming physics and server costs as SL apparently does ?? - + // upload fee tunning paramenters + // fees are normalized to 1.0 + // this parameters scale them to basic cost ( so 1.0 translates to 10 ) + + public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) + public float ModelTextureCostFactor = 0.25f; //(2.5c$) scale textures fee to basic. + // promote integration in a model + // since they will not show up in inventory + public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures + + // itens costs in normalized values + // ie will be multiplied by basicCost and factors above + const float primCreationCost = 0.002f; // extra cost for each prim creation overhead + // weigthed size to normalized cost + const float bytecost = 1e-5f; + + // mesh upload fees based on compressed data sizes + // several data sections are counted more that once + // to promote user optimization + // following parameters control how many extra times they are added + // to global size. + // LOD meshs const float medSizeWth = 1f; // 2x const float lowSizeWth = 1.5f; // 2.5x const float lowestSizeWth = 2f; // 3x - // favor potencial optimized meshs versus automatic decomposition + // favor potencially physical optimized meshs versus automatic decomposition const float physMeshSizeWth = 6f; // counts 7x - const float physHullSizeWth = 8f; // counts 9x - + const float physHullSizeWth = 8f; // counts 9x + // stream cost area factors + // more or less like SL const float highLodFactor = 17.36f; const float midLodFactor = 277.78f; const float lowLodFactor = 1111.11f; + // physics cost is below, identical to SL, assuming shape type convex + // server cost is below identical to SL assuming non scripted non physical object + + // internal const int bytesPerCoord = 6; // 3 coords, 2 bytes per each + // storage for a single mesh asset cost parameters private class ameshCostParam { + // LOD sizes for size dependent streaming cost public int highLODSize; public int medLODSize; public int lowLODSize; public int lowestLODSize; + // normalized fee based on compressed data sizes public float costFee; + // physics cost public float physicsCost; } + // calculates a mesh model costs + // returns false on error, with a reason on parameter error + // resources input LLSD request + // basicCost input region assets upload cost + // totalcost returns model total upload fee + // meshcostdata returns detailed costs for viewer public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, LLSDAssetUploadResponseData meshcostdata, out string error) { totalcost = 0; @@ -87,11 +114,12 @@ namespace OpenSim.Region.ClientStack.Linden // textures cost if (resources.texture_list != null && resources.texture_list.Array.Count > 0) { - int textures_cost = resources.texture_list.Array.Count; - textures_cost *= basicCost; + float textures_cost = (float)(resources.texture_list.Array.Count * basicCost); + textures_cost *= ModelTextureCostFactor; - meshcostdata.upload_price_breakdown.texture = textures_cost; - totalcost += textures_cost; + itmp = (int)(textures_cost + 0.5f); // round + meshcostdata.upload_price_breakdown.texture = itmp; + totalcost += itmp; } // meshs assets cost @@ -176,12 +204,16 @@ namespace OpenSim.Region.ClientStack.Linden if (meshcostdata.resource_cost < meshcostdata.simulation_cost) meshcostdata.resource_cost = meshcostdata.simulation_cost; + // scale cost + // at this point a cost of 1.0 whould mean basic cost + meshsfee *= ModelMeshCostFactor; + + if (meshsfee < ModelMinCostFactor) + meshsfee = ModelMinCostFactor; - if (meshsfee < ModelMinCost) - meshsfee = ModelMinCost; + // actually scale it to basic cost + meshsfee *= (float)basicCost; - // scale cost with basic cost changes relative to 10 - meshsfee *= (float)basicCost / 10.0f; meshsfee += 0.5f; // rounding totalcost += (int)meshsfee; @@ -192,6 +224,7 @@ namespace OpenSim.Region.ClientStack.Linden return true; } + // single mesh asset cost private bool MeshCost(byte[] data, ameshCostParam cost, out string error) { cost.highLODSize = 0; @@ -377,6 +410,7 @@ namespace OpenSim.Region.ClientStack.Linden return true; } + // parses a LOD or physics mesh component private bool submesh(byte[] data, int offset, int size, out int ntriangles) { ntriangles = 0; @@ -443,6 +477,7 @@ namespace OpenSim.Region.ClientStack.Linden return true; } + // parses convex hulls component private bool hulls(byte[] data, int offset, int size, out int nvertices, out int nhulls) { nvertices = 0; @@ -512,6 +547,7 @@ namespace OpenSim.Region.ClientStack.Linden return true; } + // returns streaming cost from on mesh LODs sizes in curCost and square of prim size length private float streamingCost(ameshCostParam curCost, float sqdiam) { // compute efective areas @@ -571,7 +607,6 @@ namespace OpenSim.Region.ClientStack.Linden h = 16; // compute cost weighted by relative effective areas - float cost = (float)lst * mlst + (float)l * ml + (float)m * mm + (float)h * mh; cost /= ma; -- cgit v1.1 From fb32604b413052ddedccba36247e676427c48824 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Sep 2012 01:33:16 +0100 Subject: create a single ModelCost provider for the caps instance. Let it know and check scene prim size limits. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 14 ++++-- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 56 +++++++++++++++++----- 2 files changed, 56 insertions(+), 14 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 073f175..0fb6c99 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -87,6 +87,7 @@ namespace OpenSim.Region.ClientStack.Linden private Scene m_Scene; private Caps m_HostCapsObj; + private ModelCost m_ModelCost; private static readonly string m_requestPath = "0000/"; // private static readonly string m_mapLayerPath = "0001/"; @@ -123,6 +124,15 @@ namespace OpenSim.Region.ClientStack.Linden { m_Scene = scene; m_HostCapsObj = caps; + + // create a model upload cost provider + m_ModelCost = new ModelCost(); + // tell it about scene object limits + m_ModelCost.NonPhysicalPrimScaleMax = m_Scene.m_maxNonphys; + m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys; +// m_ModelCost.PrimScaleMin = ?? +// m_ModelCost.ObjectLinkedPartsMax = ?? + IConfigSource config = m_Scene.Config; if (config != null) { @@ -193,7 +203,6 @@ namespace OpenSim.Region.ClientStack.Linden { try { - // I don't think this one works... m_HostCapsObj.RegisterHandler( "NewFileAgentInventory", new LLSDStreamhandler( @@ -472,9 +481,8 @@ namespace OpenSim.Region.ClientStack.Linden { string error; int modelcost; - ModelCost mc = new ModelCost(); - if (!mc.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, + if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, meshcostdata, out error)) { client.SendAgentAlertMessage(error, false); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 5096a91..62f1d06 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -23,8 +23,14 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap; namespace OpenSim.Region.ClientStack.Linden { + public struct ModelPrimLimits + { + + } + public class ModelCost { + // upload fee tunning paramenters // fees are normalized to 1.0 // this parameters scale them to basic cost ( so 1.0 translates to 10 ) @@ -66,6 +72,12 @@ namespace OpenSim.Region.ClientStack.Linden // internal const int bytesPerCoord = 6; // 3 coords, 2 bytes per each + // control prims dimensions + public float PrimScaleMin = 0.01f; + public float NonPhysicalPrimScaleMax = 256f; + public float PhysicalPrimScaleMax = 10f; + public int ObjectLinkedPartsMax = 512; + // storage for a single mesh asset cost parameters private class ameshCostParam { @@ -98,7 +110,15 @@ namespace OpenSim.Region.ClientStack.Linden error = "Unable to upload mesh model. missing information."; return false; } - + + int numberInstances = resources.instance_list.Array.Count; + + if( numberInstances > ObjectLinkedPartsMax ) + { + error = "upload failed: Model whould have two many linked prims"; + return false; + } + meshcostdata.model_streaming_cost = 0.0; meshcostdata.simulation_cost = 0.0; meshcostdata.physics_cost = 0.0; @@ -148,12 +168,35 @@ namespace OpenSim.Region.ClientStack.Linden } // instances (prims) cost - int numberInstances = resources.instance_list.Array.Count; + + int mesh; for (int i = 0; i < numberInstances; i++) { Hashtable inst = (Hashtable)resources.instance_list.Array[i]; + ArrayList ascale = (ArrayList)inst["scale"]; + Vector3 scale; + double tmp; + tmp = (double)ascale[0]; + scale.X = (float)tmp; + tmp = (double)ascale[1]; + scale.Y = (float)tmp; + tmp = (double)ascale[2]; + scale.Z = (float)tmp; + + if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) + { + error = " upload fail: Model contains parts with a dimension lower than 0.01. Please adjust scaling"; + return false; + } + + if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) + { + error = "upload fail: Model contains parts larger than maximum allowed. Please adjust scaling"; + return false; + } + if (haveMeshs && inst.ContainsKey("mesh")) { mesh = (int)inst["mesh"]; @@ -165,15 +208,6 @@ namespace OpenSim.Region.ClientStack.Linden } // streamming cost - ArrayList ascale = (ArrayList)inst["scale"]; - Vector3 scale; - double tmp; - tmp = (double)ascale[0]; - scale.X = (float)tmp; - tmp = (double)ascale[1]; - scale.Y = (float)tmp; - tmp = (double)ascale[2]; - scale.Z = (float)tmp; float sqdiam = scale.LengthSquared(); -- cgit v1.1 From 5317b1053f2b8fd81f71c0b95c79aaa03efb47e4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 19 Sep 2012 03:53:51 +0100 Subject: be more tolerant to small prims, skipping them, only failing if they are more than half of total. Add a state control to NewFileAgentInventory to avoid more than one at a time per client. ( Incomplete and possible not that good) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 81 ++++++++++++++++++---- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 17 +++-- 2 files changed, 82 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 0fb6c99..d66076d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -117,6 +117,17 @@ namespace OpenSim.Region.ClientStack.Linden private bool m_dumpAssetsToFile = false; private string m_regionName; private int m_levelUpload = 0; + private float m_PrimScaleMin = 0.001f; + + private enum FileAgentInventoryState : int + { + idle = 0, + processRequest = 1, + waitUpload = 2, + processUpload = 3 + } + private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; + // private bool m_addNewTextures = false; // private bool m_addNewMeshes = false; @@ -132,6 +143,7 @@ namespace OpenSim.Region.ClientStack.Linden m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys; // m_ModelCost.PrimScaleMin = ?? // m_ModelCost.ObjectLinkedPartsMax = ?? +// m_PrimScaleMin = ?? IConfigSource config = m_Scene.Config; if (config != null) @@ -158,6 +170,8 @@ namespace OpenSim.Region.ClientStack.Linden ItemUpdatedCall = m_Scene.CapsUpdateInventoryItemAsset; TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset; GetClient = m_Scene.SceneGraph.GetControllingClient; + + m_FileAgentInventoryState = FileAgentInventoryState.idle; } /// @@ -224,9 +238,7 @@ namespace OpenSim.Region.ClientStack.Linden IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); - m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); - - + m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); m_HostCapsObj.RegisterHandler( "CopyInventoryFromNotecard", @@ -439,6 +451,35 @@ namespace OpenSim.Region.ClientStack.Linden //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); + // start by getting the client + IClientAPI client = null; + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); + + // check current state so we only have one service at a time + lock (m_ModelCost) + { + switch (m_FileAgentInventoryState) + { + case FileAgentInventoryState.processRequest: + case FileAgentInventoryState.processUpload: + if (client != null) + client.SendAgentAlertMessage("Unable to upload asset. Processing previus request", false); + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + return errorResponse; + break; + case FileAgentInventoryState.waitUpload: + // todo stop current uploader server + break; + case FileAgentInventoryState.idle: + default: + break; + } + + m_FileAgentInventoryState = FileAgentInventoryState.processRequest; + } + uint cost = 0; LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); @@ -447,15 +488,12 @@ namespace OpenSim.Region.ClientStack.Linden llsdRequest.asset_type == "mesh" || llsdRequest.asset_type == "sound") { - ScenePresence avatar = null; - IClientAPI client = null; + ScenePresence avatar = null; m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); // check user level if (avatar != null) { - client = avatar.ControllingClient; - if (avatar.UserLevel < m_levelUpload) { if (client != null) @@ -464,6 +502,8 @@ namespace OpenSim.Region.ClientStack.Linden LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } } @@ -490,6 +530,8 @@ namespace OpenSim.Region.ClientStack.Linden LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } cost = (uint)modelcost; @@ -509,6 +551,8 @@ namespace OpenSim.Region.ClientStack.Linden LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } } @@ -555,8 +599,11 @@ namespace OpenSim.Region.ClientStack.Linden } uploader.OnUpLoad += UploadCompleteHandler; - return uploadResponse; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.waitUpload; + + return uploadResponse; } /// @@ -569,6 +616,9 @@ namespace OpenSim.Region.ClientStack.Linden UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, string assetType, uint cost) { + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.processUpload; + m_log.DebugFormat( "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", assetID, inventoryItem, inventoryType, assetType); @@ -730,12 +780,19 @@ namespace OpenSim.Region.ClientStack.Linden // build prims from instances for (int i = 0; i < instance_list.Count; i++) { + OSDMap inner_instance_list = (OSDMap)instance_list[i]; + + // skip prims that are 2 small + Vector3 scale = inner_instance_list["scale"].AsVector3(); + + if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) + continue; + PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); Primitive.TextureEntry textureEntry = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); - OSDMap inner_instance_list = (OSDMap)instance_list[i]; OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; for (uint face = 0; face < face_list.Count; face++) @@ -789,7 +846,6 @@ namespace OpenSim.Region.ClientStack.Linden } Vector3 position = inner_instance_list["position"].AsVector3(); - Vector3 scale = inner_instance_list["scale"].AsVector3(); Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); // no longer used - begin ------------------------ @@ -903,6 +959,8 @@ namespace OpenSim.Region.ClientStack.Linden { AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); } + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; } /// @@ -1270,8 +1328,8 @@ namespace OpenSim.Region.ClientStack.Linden res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - httpListener.RemoveStreamHandler("POST", uploaderPath); m_timeoutTimer.Stop(); + httpListener.RemoveStreamHandler("POST", uploaderPath); // TODO: probably make this a better set of extensions here string extension = ".jp2"; @@ -1289,7 +1347,6 @@ namespace OpenSim.Region.ClientStack.Linden { handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); } - return res; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 62f1d06..ece40ac 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -73,7 +73,7 @@ namespace OpenSim.Region.ClientStack.Linden const int bytesPerCoord = 6; // 3 coords, 2 bytes per each // control prims dimensions - public float PrimScaleMin = 0.01f; + public float PrimScaleMin = 0.001f; public float NonPhysicalPrimScaleMax = 256f; public float PhysicalPrimScaleMax = 10f; public int ObjectLinkedPartsMax = 512; @@ -171,6 +171,7 @@ namespace OpenSim.Region.ClientStack.Linden int mesh; + int skipedSmall = 0; for (int i = 0; i < numberInstances; i++) { Hashtable inst = (Hashtable)resources.instance_list.Array[i]; @@ -187,8 +188,10 @@ namespace OpenSim.Region.ClientStack.Linden if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) { - error = " upload fail: Model contains parts with a dimension lower than 0.01. Please adjust scaling"; - return false; +// error = " upload fail: Model contains parts with a dimension lower than 0.001. Please adjust scaling"; +// return false; + skipedSmall++; + continue; } if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) @@ -229,7 +232,13 @@ namespace OpenSim.Region.ClientStack.Linden // charge for prims creation meshsfee += primCreationCost; } - + + if (skipedSmall >0 && skipedSmall > numberInstances / 2) + { + error = "Upload failed: Model contains too much prims smaller than minimum size to ignore"; + return false; + } + if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) meshcostdata.resource_cost = meshcostdata.model_streaming_cost; else -- cgit v1.1 From 629138d4fa16821d9572b58abe234b973ccf945e Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 Sep 2012 13:01:34 +0200 Subject: Change texture price back to 10 C$ --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index ece40ac..44a2914 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -36,9 +36,8 @@ namespace OpenSim.Region.ClientStack.Linden // this parameters scale them to basic cost ( so 1.0 translates to 10 ) public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) - public float ModelTextureCostFactor = 0.25f; //(2.5c$) scale textures fee to basic. - // promote integration in a model - // since they will not show up in inventory + public float ModelTextureCostFactor = 1.00f; // keep full price because texture price + // is based on it's storage needs not on usability public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures // itens costs in normalized values -- cgit v1.1 From bf987f96d2339f1471ad5fc5b3df5a7a8b484d6e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 20 Sep 2012 14:32:30 +0100 Subject: Fix model upload rotations and offsets ( i hope ) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 159 ++++++++------------- 1 file changed, 56 insertions(+), 103 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index d66076d..a139ea8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -128,9 +128,6 @@ namespace OpenSim.Region.ClientStack.Linden } private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; -// private bool m_addNewTextures = false; -// private bool m_addNewMeshes = false; - public BunchOfCaps(Scene scene, Caps caps) { m_Scene = scene; @@ -641,6 +638,7 @@ namespace OpenSim.Region.ClientStack.Linden } } + // strings to types if (inventoryType == "sound") { inType = (sbyte)InventoryType.Sound; @@ -687,45 +685,6 @@ namespace OpenSim.Region.ClientStack.Linden textureAsset.Data = texture_list[i].AsBinary(); m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); - /* - don't do this - replace it by optionaly making model textures cost less than if individually uploaded - since they can't be used for other purpuses - - // save it to inventory - if (m_addNewTextures && AddNewInventoryItem != null) - { - string name = assetName; - if (name.Length > 25) - name = name.Substring(0, 24); - name += "_Texture#" + i.ToString(); - InventoryItemBase texitem = new InventoryItemBase(); - texitem.Owner = m_HostCapsObj.AgentID; - texitem.CreatorId = m_HostCapsObj.AgentID.ToString(); - texitem.CreatorData = String.Empty; - texitem.ID = UUID.Random(); - texitem.AssetID = textureAsset.FullID; - texitem.Description = "mesh model texture"; - texitem.Name = name; - texitem.AssetType = (int)AssetType.Texture; - texitem.InvType = (int)InventoryType.Texture; - texitem.Folder = UUID.Zero; // send to default - - // If we set PermissionMask.All then when we rez the item the next permissions will replace the current - // (owner) permissions. This becomes a problem if next permissions are changed. - texitem.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - - texitem.BasePermissions = (uint)PermissionMask.All; - texitem.EveryOnePermissions = 0; - texitem.NextPermissions = (uint)PermissionMask.All; - texitem.CreationDate = Util.UnixTimeSinceEpoch(); - - AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); - texitem = null; - } - */ - textureAsset = null; } // create and store meshs assets @@ -736,47 +695,9 @@ namespace OpenSim.Region.ClientStack.Linden meshAsset.Data = mesh_list[i].AsBinary(); m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); - - /* this was a test, funny and showed viewers deal with mesh inventory itens - * nut also same reason as for textures - * let integrated in a model cost eventually less than hipotetical independent meshs assets - * that will be in inventory - // save it to inventory - if (m_addNewMeshes && AddNewInventoryItem != null) - { - string name = assetName; - if (name.Length > 25) - name = name.Substring(0, 24); - name += "_Mesh#" + i.ToString(); - InventoryItemBase meshitem = new InventoryItemBase(); - meshitem.Owner = m_HostCapsObj.AgentID; - meshitem.CreatorId = m_HostCapsObj.AgentID.ToString(); - meshitem.CreatorData = String.Empty; - meshitem.ID = UUID.Random(); - meshitem.AssetID = meshAsset.FullID; - meshitem.Description = "mesh "; - meshitem.Name = name; - meshitem.AssetType = (int)AssetType.Mesh; - meshitem.InvType = (int)InventoryType.Mesh; - meshitem.Folder = UUID.Zero; // send to default - - // If we set PermissionMask.All then when we rez the item the next permissions will replace the current - // (owner) permissions. This becomes a problem if next permissions are changed. - meshitem.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); - - meshitem.BasePermissions = (uint)PermissionMask.All; - meshitem.EveryOnePermissions = 0; - meshitem.NextPermissions = (uint)PermissionMask.All; - meshitem.CreationDate = Util.UnixTimeSinceEpoch(); - - AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0); - meshitem = null; - } - */ - meshAsset = null; } + int skipedMeshs = 0; // build prims from instances for (int i = 0; i < instance_list.Count; i++) { @@ -784,9 +705,12 @@ namespace OpenSim.Region.ClientStack.Linden // skip prims that are 2 small Vector3 scale = inner_instance_list["scale"].AsVector3(); - + if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) + { + skipedMeshs++; continue; + } PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); @@ -836,21 +760,33 @@ namespace OpenSim.Region.ClientStack.Linden pbs.TextureEntry = textureEntry.GetBytes(); - int meshindx = inner_instance_list["mesh"].AsInteger(); - if (meshAssets.Count > meshindx) + bool hasmesh = false; + if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ... { - pbs.SculptEntry = true; - pbs.SculptType = (byte)SculptType.Mesh; - pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction - // data will be requested from asset on rez (i hope) + int meshindx = inner_instance_list["mesh"].AsInteger(); + if (meshAssets.Count > meshindx) + { + pbs.SculptEntry = true; + pbs.SculptType = (byte)SculptType.Mesh; + pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction + // data will be requested from asset on rez (i hope) + hasmesh = true; + } } Vector3 position = inner_instance_list["position"].AsVector3(); Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); + // for now viwers do send fixed defaults + // but this may change +// int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); + byte physicsShapeType = (byte)PhysShapeType.prim; // default for mesh is simple convex + if(hasmesh) + physicsShapeType = (byte) PhysShapeType.convex; // default for mesh is simple convex +// int material = inner_instance_list["material"].AsInteger(); + byte material = (byte)Material.Wood; + // no longer used - begin ------------------------ -// int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger(); -// int material = inner_instance_list["material"].AsInteger(); // int mesh = inner_instance_list["mesh"].AsInteger(); // OSDMap permissions = (OSDMap)inner_instance_list["permissions"]; @@ -872,7 +808,7 @@ namespace OpenSim.Region.ClientStack.Linden = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); prim.Scale = scale; - prim.OffsetPosition = position; +// prim.OffsetPosition = position; rotations.Add(rotation); positions.Add(position); prim.UUID = UUID.Random(); @@ -883,6 +819,8 @@ namespace OpenSim.Region.ClientStack.Linden prim.CreationDate = Util.UnixTimeSinceEpoch(); prim.Name = assetName; prim.Description = ""; + prim.Material = material; + prim.PhysicsShapeType = physicsShapeType; // prim.BaseMask = (uint)base_mask; // prim.EveryoneMask = (uint)everyone_mask; @@ -896,25 +834,40 @@ namespace OpenSim.Region.ClientStack.Linden grp.AddPart(prim); } - // Fix first link number + Vector3 rootPos = positions[0]; + if (grp.Parts.Length > 1) + { + // Fix first link number grp.RootPart.LinkNum++; - Vector3 rootPos = positions[0]; - grp.AbsolutePosition = rootPos; - for (int i = 0; i < positions.Count; i++) - { - Vector3 offset = positions[i] - rootPos; - grp.Parts[i].OffsetPosition = offset; - } + Quaternion rootRotConj = Quaternion.Conjugate(rotations[0]); + Quaternion tmprot; + Vector3 offset; + + // fix children rotations and positions + for (int i = 1; i < rotations.Count; i++) + { + tmprot = rotations[i]; + tmprot = rootRotConj * tmprot; + + grp.Parts[i].RotationOffset = tmprot; - for (int i = 0; i < rotations.Count; i++) + offset = positions[i] - rootPos; + + offset *= rootRotConj; + grp.Parts[i].OffsetPosition = offset; + } + + grp.AbsolutePosition = rootPos; + grp.UpdateGroupRotationR(rotations[0]); + } + else { - if (i != 0) - grp.Parts[i].RotationOffset = rotations[i]; + grp.AbsolutePosition = rootPos; + grp.UpdateGroupRotationR(rotations[0]); } - grp.UpdateGroupRotationR(rotations[0]); data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); } -- cgit v1.1 From 9ff6c85325bfe8a046abaf72267e215f05ec893e Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 20 Sep 2012 15:39:46 +0200 Subject: Make uploads free for now - we will have to announce this --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 44a2914..8099069 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -35,10 +35,13 @@ namespace OpenSim.Region.ClientStack.Linden // fees are normalized to 1.0 // this parameters scale them to basic cost ( so 1.0 translates to 10 ) - public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) - public float ModelTextureCostFactor = 1.00f; // keep full price because texture price + public float ModelMeshCostFactor = 0f; //Free + public float ModelMinCostFactor = 0f; // Free + //public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) + //public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures + + //public float ModelTextureCostFactor = 1.00f; // keep full price because texture price // is based on it's storage needs not on usability - public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures // itens costs in normalized values // ie will be multiplied by basicCost and factors above -- cgit v1.1 From 5d63c20122351296298d9ec841a569e1c008ba4b Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 20 Sep 2012 15:41:16 +0200 Subject: refix prior commit --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 8099069..da701ba 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.ClientStack.Linden //public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) //public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures - //public float ModelTextureCostFactor = 1.00f; // keep full price because texture price + public float ModelTextureCostFactor = 1.00f; // keep full price because texture price // is based on it's storage needs not on usability // itens costs in normalized values -- cgit v1.1 From f9c24c9414134af04fea3dd6ff39800856aec10e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 21 Sep 2012 11:50:14 +0100 Subject: read model upload cost parameters from config [Economy] section --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 21 +++++++++++++++++++++ .../ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 6 ++---- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index a139ea8..1b47fca 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -118,6 +118,7 @@ namespace OpenSim.Region.ClientStack.Linden private string m_regionName; private int m_levelUpload = 0; private float m_PrimScaleMin = 0.001f; + private bool m_enableFreeTestModelUpload = false; private enum FileAgentInventoryState : int { @@ -142,6 +143,11 @@ namespace OpenSim.Region.ClientStack.Linden // m_ModelCost.ObjectLinkedPartsMax = ?? // m_PrimScaleMin = ?? + float modelTextureUploadFactor = m_ModelCost.ModelTextureCostFactor; + float modelUploadFactor = m_ModelCost.ModelMeshCostFactor; + float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor; + + IConfigSource config = m_Scene.Config; if (config != null) { @@ -156,6 +162,20 @@ namespace OpenSim.Region.ClientStack.Linden { m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); } + // economy for model upload + IConfig EconomyConfig = config.Configs["Economy"]; + if (EconomyConfig != null) + { + modelUploadFactor = EconomyConfig.GetFloat("MeshModelUploadCostFactor", modelUploadFactor); + modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor); + modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor); + m_enableFreeTestModelUpload = EconomyConfig.GetBoolean("MeshModelUploadAllowFreeTest", false); + + m_ModelCost.ModelMeshCostFactor = modelUploadFactor; + m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor; + m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor; + } + } m_assetService = m_Scene.AssetService; @@ -912,6 +932,7 @@ namespace OpenSim.Region.ClientStack.Linden { AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); } + lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index ece40ac..830c46d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -31,14 +31,12 @@ namespace OpenSim.Region.ClientStack.Linden public class ModelCost { - // upload fee tunning paramenters + // upload fee defaults // fees are normalized to 1.0 // this parameters scale them to basic cost ( so 1.0 translates to 10 ) public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) - public float ModelTextureCostFactor = 0.25f; //(2.5c$) scale textures fee to basic. - // promote integration in a model - // since they will not show up in inventory + public float ModelTextureCostFactor = 1.0f; // scale textures fee to basic. public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures // itens costs in normalized values -- cgit v1.1 From 7de67d5680b2eb028bb17fae0d80d1f78ccd3a19 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 22 Sep 2012 12:00:14 +0100 Subject: removed unused data in MeshUploadFlag response --- .../ClientStack/Linden/Caps/MeshUploadFlagModule.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs index 44a6883..0251ac4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs @@ -129,15 +129,15 @@ namespace OpenSim.Region.ClientStack.Linden // m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request"); OSDMap data = new OSDMap(); - ScenePresence sp = m_scene.GetScenePresence(m_agentID); - data["username"] = sp.Firstname + "." + sp.Lastname; - data["display_name_next_update"] = new OSDDate(DateTime.Now); - data["legacy_first_name"] = sp.Firstname; +// ScenePresence sp = m_scene.GetScenePresence(m_agentID); +// data["username"] = sp.Firstname + "." + sp.Lastname; +// data["display_name_next_update"] = new OSDDate(DateTime.Now); +// data["legacy_first_name"] = sp.Firstname; data["mesh_upload_status"] = "valid"; - data["display_name"] = sp.Firstname + " " + sp.Lastname; - data["legacy_last_name"] = sp.Lastname; - data["id"] = m_agentID; - data["is_display_name_default"] = true; +// data["display_name"] = sp.Firstname + " " + sp.Lastname; +// data["legacy_last_name"] = sp.Lastname; +// data["id"] = m_agentID; +// data["is_display_name_default"] = true; //Send back data Hashtable responsedata = new Hashtable(); -- cgit v1.1 From 4bba72b7afc104ea5a42acb6206c1c07fbba099b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 22 Sep 2012 16:47:15 +0100 Subject: removed AssetUploaderWithCost, fixing AssetUploader. add parsing of some more needed fields in request --- OpenSim/Capabilities/LLSDAssetUploadRequest.cs | 4 ++ .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 66 ++++++++-------------- 2 files changed, 28 insertions(+), 42 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Capabilities/LLSDAssetUploadRequest.cs b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs index f981bf0..6779cc1 100644 --- a/OpenSim/Capabilities/LLSDAssetUploadRequest.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadRequest.cs @@ -45,6 +45,10 @@ namespace OpenSim.Framework.Capabilities public string asset_type = String.Empty; public string description = String.Empty; public UUID folder_id = UUID.Zero; + public UUID texture_folder_id = UUID.Zero; + public int next_owner_mask = 0; + public int group_mask = 0; + public int everyone_mask = 0; public string inventory_type = String.Empty; public string name = String.Empty; public LLSDAssetResource asset_resources = new LLSDAssetResource(); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 1b47fca..b64453a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -54,8 +54,8 @@ using OSDMap = OpenMetaverse.StructuredData.OSDMap; namespace OpenSim.Region.ClientStack.Linden { public delegate void UpLoadedAsset( - string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, - byte[] data, string inventoryType, string assetType); + string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, + byte[] data, string inventoryType, string assetType, int cost); public delegate UUID UpdateItem(UUID itemID, byte[] data); @@ -119,6 +119,7 @@ namespace OpenSim.Region.ClientStack.Linden private int m_levelUpload = 0; private float m_PrimScaleMin = 0.001f; private bool m_enableFreeTestModelUpload = false; + private bool m_enableModelUploadTextureToInventory = false; private enum FileAgentInventoryState : int { @@ -147,7 +148,6 @@ namespace OpenSim.Region.ClientStack.Linden float modelUploadFactor = m_ModelCost.ModelMeshCostFactor; float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor; - IConfigSource config = m_Scene.Config; if (config != null) { @@ -170,12 +170,12 @@ namespace OpenSim.Region.ClientStack.Linden modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor); modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor); m_enableFreeTestModelUpload = EconomyConfig.GetBoolean("MeshModelUploadAllowFreeTest", false); + m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", false); m_ModelCost.ModelMeshCostFactor = modelUploadFactor; m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor; m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor; } - } m_assetService = m_Scene.AssetService; @@ -426,37 +426,13 @@ namespace OpenSim.Region.ClientStack.Linden return UUID.Zero; } - - private delegate void UploadWithCostCompleteDelegate(string assetName, - string assetDescription, UUID assetID, UUID inventoryItem, - UUID parentFolder, byte[] data, string inventoryType, - string assetType, uint cost); - - private class AssetUploaderWithCost : AssetUploader +/* + private class AssetUploaderExtraParameters { - private uint m_cost; + public int total_cost; + public UUID textureFolder = UUID.Zero; +*/ - public event UploadWithCostCompleteDelegate OnUpLoad; - - public AssetUploaderWithCost(string assetName, string description, UUID assetID, - UUID inventoryItem, UUID parentFolderID, string invType, string assetType, - string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) : - base(assetName, description, assetID, inventoryItem, parentFolderID, - invType, assetType, path, httpServer, dumpAssetsToFile) - { - m_cost = cost; - - base.OnUpLoad += UploadCompleteHandler; - } - - private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, - UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType) - { - OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder, - data, inventoryType, assetType, m_cost); - } - } /// /// @@ -497,7 +473,7 @@ namespace OpenSim.Region.ClientStack.Linden m_FileAgentInventoryState = FileAgentInventoryState.processRequest; } - uint cost = 0; + int cost = 0; LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); if (llsdRequest.asset_type == "texture" || @@ -551,11 +527,11 @@ namespace OpenSim.Region.ClientStack.Linden m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; } - cost = (uint)modelcost; + cost = modelcost; } else { - cost = (uint)baseCost; + cost = baseCost; } // check funds @@ -584,8 +560,8 @@ namespace OpenSim.Region.ClientStack.Linden UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); - AssetUploaderWithCost uploader = - new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, + AssetUploader uploader = + new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); m_HostCapsObj.HttpListener.AddStreamHandler( @@ -631,7 +607,7 @@ namespace OpenSim.Region.ClientStack.Linden /// public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType, uint cost) + string assetType, int cost) { lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.processUpload; @@ -920,6 +896,7 @@ namespace OpenSim.Region.ClientStack.Linden // If we set PermissionMask.All then when we rez the item the next permissions will replace the current // (owner) permissions. This becomes a problem if next permissions are changed. + item.CurrentPermissions = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); @@ -930,7 +907,7 @@ namespace OpenSim.Region.ClientStack.Linden if (AddNewInventoryItem != null) { - AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); + AddNewInventoryItem(m_HostCapsObj.AgentID, item,(uint) cost); } lock (m_ModelCost) @@ -1247,6 +1224,7 @@ namespace OpenSim.Region.ClientStack.Linden private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + public event UpLoadedAsset OnUpLoad; private UpLoadedAsset handlerUpLoad = null; @@ -1261,11 +1239,14 @@ namespace OpenSim.Region.ClientStack.Linden private string m_invType = String.Empty; private string m_assetType = String.Empty; + private int m_cost; + private Timer m_timeoutTimer = new Timer(); + public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, - IHttpServer httpServer, bool dumpAssetsToFile) + IHttpServer httpServer, bool dumpAssetsToFile, int totalCost) { m_assetName = assetName; m_assetDes = description; @@ -1277,6 +1258,7 @@ namespace OpenSim.Region.ClientStack.Linden m_assetType = assetType; m_invType = invType; m_dumpAssetsToFile = dumpAssetsToFile; + m_cost = totalCost; m_timeoutTimer.Elapsed += TimedOut; m_timeoutTimer.Interval = 120000; @@ -1319,7 +1301,7 @@ namespace OpenSim.Region.ClientStack.Linden handlerUpLoad = OnUpLoad; if (handlerUpLoad != null) { - handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); + handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost); } return res; } -- cgit v1.1 From 11e05217df2de7ce7da581a2332ee4871f75a527 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 22 Sep 2012 21:14:15 +0100 Subject: report asset upload errors the right away --- OpenSim/Capabilities/LLSDAssetUploadComplete.cs | 2 + OpenSim/Capabilities/LLSDAssetUploadResponse.cs | 10 +++ .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 80 +++++++++++++++++----- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 24 +++---- 4 files changed, 87 insertions(+), 29 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs index ab6cee5..596a556 100644 --- a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs @@ -30,12 +30,14 @@ using OpenMetaverse; namespace OpenSim.Framework.Capabilities { + [LLSDType("MAP")] public class LLSDAssetUploadComplete { public string new_asset = String.Empty; public UUID new_inventory_item = UUID.Zero; public string state = String.Empty; + public LLSDAssetUploadError error = null; //public bool success = false; public LLSDAssetUploadComplete() diff --git a/OpenSim/Capabilities/LLSDAssetUploadResponse.cs b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs index 18285b5..7c4bc97 100644 --- a/OpenSim/Capabilities/LLSDAssetUploadResponse.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadResponse.cs @@ -26,10 +26,18 @@ */ using System; +using OpenMetaverse; namespace OpenSim.Framework.Capabilities { [OSDMap] + public class LLSDAssetUploadError + { + public string message = String.Empty; + public UUID identifier = UUID.Zero; + } + + [OSDMap] public class LLSDAssetUploadResponsePricebrkDown { public int mesh_streaming; @@ -56,11 +64,13 @@ namespace OpenSim.Framework.Capabilities public string state = String.Empty; public int upload_price = 0; public LLSDAssetUploadResponseData data = null; + public LLSDAssetUploadError error = null; public LLSDAssetUploadResponse() { } } + [OSDMap] public class LLSDNewFileAngentInventoryVariablePriceReplyResponse { diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index b64453a..a934113 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.Linden { public delegate void UpLoadedAsset( string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, - byte[] data, string inventoryType, string assetType, int cost); + byte[] data, string inventoryType, string assetType, int cost, ref string error); public delegate UUID UpdateItem(UUID itemID, byte[] data); @@ -455,11 +455,14 @@ namespace OpenSim.Region.ClientStack.Linden { case FileAgentInventoryState.processRequest: case FileAgentInventoryState.processUpload: - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Processing previus request", false); + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = "Uploader busy processing previus request"; + resperror.identifier = UUID.Zero; + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + errorResponse.error = resperror; return errorResponse; break; case FileAgentInventoryState.waitUpload: @@ -489,12 +492,15 @@ namespace OpenSim.Region.ClientStack.Linden { if (avatar.UserLevel < m_levelUpload) { - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = "Insufficient permissions to upload"; + resperror.identifier = UUID.Zero; + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + errorResponse.error = resperror; lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; @@ -518,11 +524,15 @@ namespace OpenSim.Region.ClientStack.Linden if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, meshcostdata, out error)) { - client.SendAgentAlertMessage(error, false); + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = error; + resperror.identifier = UUID.Zero; LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + errorResponse.error = resperror; + lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; @@ -539,11 +549,14 @@ namespace OpenSim.Region.ClientStack.Linden { if (!mm.UploadCovered(client.AgentId, (int)cost)) { - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = "Insuficient funds"; + resperror.identifier = UUID.Zero; LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; + errorResponse.error = resperror; lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.idle; return errorResponse; @@ -607,8 +620,9 @@ namespace OpenSim.Region.ClientStack.Linden /// public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType, int cost) + string assetType, int cost, ref string error) { + lock (m_ModelCost) m_FileAgentInventoryState = FileAgentInventoryState.processUpload; @@ -619,17 +633,13 @@ namespace OpenSim.Region.ClientStack.Linden sbyte assType = 0; sbyte inType = 0; - IClientAPI client = null; - IMoneyModule mm = m_Scene.RequestModuleInterface(); if (mm != null) { // make sure client still has enougth credit if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost)) { - m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); - if (client != null) - client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); + error = "Insufficient funds."; return; } } @@ -668,6 +678,25 @@ namespace OpenSim.Region.ClientStack.Linden List positions = new List(); List rotations = new List(); OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); + + // compare and get updated information + + bool mismatchError = true; + + while (mismatchError) + { + mismatchError = false; + } + + if (mismatchError) + { + error = "Upload and fee estimation information don't match"; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; + + return; + } + OSDArray instance_list = (OSDArray)request["instance_list"]; OSDArray mesh_list = (OSDArray)request["mesh_list"]; OSDArray texture_list = (OSDArray)request["texture_list"]; @@ -1240,7 +1269,8 @@ namespace OpenSim.Region.ClientStack.Linden private string m_invType = String.Empty; private string m_assetType = String.Empty; private int m_cost; - + private string m_error = String.Empty; + private Timer m_timeoutTimer = new Timer(); @@ -1278,12 +1308,13 @@ namespace OpenSim.Region.ClientStack.Linden UUID inv = inventoryItemID; string res = String.Empty; LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); +/* uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = inv; uploadComplete.state = "complete"; res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); - +*/ m_timeoutTimer.Stop(); httpListener.RemoveStreamHandler("POST", uploaderPath); @@ -1301,8 +1332,25 @@ namespace OpenSim.Region.ClientStack.Linden handlerUpLoad = OnUpLoad; if (handlerUpLoad != null) { - handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost); + handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost, ref m_error); } + if(m_error == String.Empty) + { + uploadComplete.new_asset = newAssetID.ToString(); + uploadComplete.new_inventory_item = inv; + uploadComplete.state = "complete"; + } + else + { + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = m_error; + resperror.identifier = inv; + + uploadComplete.error = resperror; + uploadComplete.state = "failed"; + } + + res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); return res; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 830c46d..7a80c72 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -105,7 +105,7 @@ namespace OpenSim.Region.ClientStack.Linden resources.instance_list == null || resources.instance_list.Array.Count == 0) { - error = "Unable to upload mesh model. missing information."; + error = "missing model information."; return false; } @@ -113,7 +113,7 @@ namespace OpenSim.Region.ClientStack.Linden if( numberInstances > ObjectLinkedPartsMax ) { - error = "upload failed: Model whould have two many linked prims"; + error = "Model whould have more than " + ObjectLinkedPartsMax.ToString() + " linked prims"; return false; } @@ -186,15 +186,13 @@ namespace OpenSim.Region.ClientStack.Linden if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) { -// error = " upload fail: Model contains parts with a dimension lower than 0.001. Please adjust scaling"; -// return false; skipedSmall++; continue; } if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) { - error = "upload fail: Model contains parts larger than maximum allowed. Please adjust scaling"; + error = "Model contains parts with sides larger than " + NonPhysicalPrimScaleMax.ToString() + "m. Please ajust scale"; return false; } @@ -204,7 +202,7 @@ namespace OpenSim.Region.ClientStack.Linden if (mesh >= numberMeshs) { - error = "Unable to upload mesh model. incoerent information."; + error = "Incoerent model information."; return false; } @@ -233,7 +231,7 @@ namespace OpenSim.Region.ClientStack.Linden if (skipedSmall >0 && skipedSmall > numberInstances / 2) { - error = "Upload failed: Model contains too much prims smaller than minimum size to ignore"; + error = "Model contains too many prims smaller than " + PrimScaleMin.ToString() + "m"; return false; } @@ -279,14 +277,14 @@ namespace OpenSim.Region.ClientStack.Linden if (data == null || data.Length == 0) { - error = "Unable to upload mesh model. missing information."; + error = "Missing model information."; return false; } OSD meshOsd = null; int start = 0; - error = "Unable to upload mesh model. Invalid data"; + error = "Invalid model data"; using (MemoryStream ms = new MemoryStream(data)) { @@ -334,13 +332,13 @@ namespace OpenSim.Region.ClientStack.Linden if (submesh_offset < 0 || hulls_size == 0) { - error = "Unable to upload mesh model. missing physics_convex block"; + error = "Missing physics_convex block"; return false; } if (!hulls(data, submesh_offset, hulls_size, out phys_hullsvertices, out phys_nhulls)) { - error = "Unable to upload mesh model. bad physics_convex block"; + error = "Bad physics_convex block"; return false; } @@ -360,7 +358,7 @@ namespace OpenSim.Region.ClientStack.Linden if (submesh_offset < 0 || highlod_size <= 0) { - error = "Unable to upload mesh model. missing high_lod"; + error = "Missing high_lod block"; return false; } @@ -418,7 +416,7 @@ namespace OpenSim.Region.ClientStack.Linden if (!submesh(data, submesh_offset, physmesh_size, out phys_ntriangles)) { - error = "Unable to upload mesh model. parsing error"; + error = "Model data parsing error"; return false; } } -- cgit v1.1 From 64db9e41143c36ee1638f2c453b4645ff4ed008f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 23 Sep 2012 15:04:10 +0100 Subject: try to allow free uploads for testing, if users prefix names with "TEST-". Let textures get into inventory again. Both features under config control. Have direct warnings to client, including a final one on upload complete since i see nothing. problems: textures don't showup in inventory til relog, also issues with permitions. A few more changes --- OpenSim/Capabilities/LLSDAssetUploadComplete.cs | 1 + .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 225 +++++++++++++++++---- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 26 ++- 3 files changed, 211 insertions(+), 41 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs index 596a556..ae8eb09 100644 --- a/OpenSim/Capabilities/LLSDAssetUploadComplete.cs +++ b/OpenSim/Capabilities/LLSDAssetUploadComplete.cs @@ -36,6 +36,7 @@ namespace OpenSim.Framework.Capabilities { public string new_asset = String.Empty; public UUID new_inventory_item = UUID.Zero; +// public UUID new_texture_folder_id = UUID.Zero; public string state = String.Empty; public LLSDAssetUploadError error = null; //public bool success = false; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index a934113..21a1005 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -55,7 +55,9 @@ namespace OpenSim.Region.ClientStack.Linden { public delegate void UpLoadedAsset( string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, - byte[] data, string inventoryType, string assetType, int cost, ref string error); + byte[] data, string inventoryType, string assetType, + int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, + bool IsAtestUpload, ref string error); public delegate UUID UpdateItem(UUID itemID, byte[] data); @@ -118,8 +120,9 @@ namespace OpenSim.Region.ClientStack.Linden private string m_regionName; private int m_levelUpload = 0; private float m_PrimScaleMin = 0.001f; - private bool m_enableFreeTestModelUpload = false; + private bool m_enableFreeTestUpload = false; private bool m_enableModelUploadTextureToInventory = false; + private UUID m_testAssetsCreatorID = UUID.Zero; private enum FileAgentInventoryState : int { @@ -148,6 +151,9 @@ namespace OpenSim.Region.ClientStack.Linden float modelUploadFactor = m_ModelCost.ModelMeshCostFactor; float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor; + // can be UUID.zero. This is me at OSG, should be a valid grid ID, is case a bad config + UUID.TryParse("58e06f33-ea8c-4ff6-9af5-420606926118", out m_testAssetsCreatorID); + IConfigSource config = m_Scene.Config; if (config != null) { @@ -169,9 +175,18 @@ namespace OpenSim.Region.ClientStack.Linden modelUploadFactor = EconomyConfig.GetFloat("MeshModelUploadCostFactor", modelUploadFactor); modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor); modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor); - m_enableFreeTestModelUpload = EconomyConfig.GetBoolean("MeshModelUploadAllowFreeTest", false); m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", false); + m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", false); + string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", m_testAssetsCreatorID.ToString()); + if (testcreator != "") + { + UUID id; + UUID.TryParse(testcreator, out id); + if (id != null) + m_testAssetsCreatorID = id; + } + m_ModelCost.ModelMeshCostFactor = modelUploadFactor; m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor; m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor; @@ -426,13 +441,6 @@ namespace OpenSim.Region.ClientStack.Linden return UUID.Zero; } -/* - private class AssetUploaderExtraParameters - { - public int total_cost; - public UUID textureFolder = UUID.Zero; -*/ - /// /// @@ -477,6 +485,11 @@ namespace OpenSim.Region.ClientStack.Linden } int cost = 0; + int nreqtextures = 0; + int nreqmeshs= 0; + int nreqinstances = 0; + bool IsAtestUpload = false; + LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); if (llsdRequest.asset_type == "texture" || @@ -496,7 +509,6 @@ namespace OpenSim.Region.ClientStack.Linden resperror.message = "Insufficient permissions to upload"; resperror.identifier = UUID.Zero; - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); errorResponse.uploader = ""; errorResponse.state = "error"; @@ -516,13 +528,15 @@ namespace OpenSim.Region.ClientStack.Linden if (mm != null) baseCost = mm.UploadCharge; + string warning = String.Empty; + if (llsdRequest.asset_type == "mesh") { string error; int modelcost; - + if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, - meshcostdata, out error)) + meshcostdata, out error, ref warning)) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); resperror.message = error; @@ -544,8 +558,21 @@ namespace OpenSim.Region.ClientStack.Linden cost = baseCost; } + if (m_enableFreeTestUpload && cost > 0 && mm != null) + { + string str = llsdRequest.name; + if (str.Length > 5 && str.StartsWith("TEST-")) + { + warning += "Upload will have no cost, but for personal test purposes only. Other uses are forbiden"; + IsAtestUpload = true; + } + } + + if (client != null && warning != String.Empty) + client.SendAgentAlertMessage(warning, true); + // check funds - if (mm != null) + if (!IsAtestUpload && mm != null && cost >0) { if (!mm.UploadCovered(client.AgentId, (int)cost)) { @@ -572,10 +599,15 @@ namespace OpenSim.Region.ClientStack.Linden UUID newInvItem = UUID.Random(); UUID parentFolder = llsdRequest.folder_id; string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000"); + UUID texturesFolder = UUID.Zero; + + if(!IsAtestUpload && m_enableModelUploadTextureToInventory) + texturesFolder = llsdRequest.texture_folder_id; AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, - llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost); + llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, + texturesFolder, nreqtextures, nreqmeshs, nreqinstances,IsAtestUpload); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( @@ -620,7 +652,9 @@ namespace OpenSim.Region.ClientStack.Linden /// public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID, UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, - string assetType, int cost, ref string error) + string assetType, int cost, + UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, + bool IsAtestUpload, ref string error) { lock (m_ModelCost) @@ -633,6 +667,18 @@ namespace OpenSim.Region.ClientStack.Linden sbyte assType = 0; sbyte inType = 0; + UUID owner_id = m_HostCapsObj.AgentID; + UUID creatorID; + + bool istest = IsAtestUpload && m_enableFreeTestUpload && (cost > 0); + + if (istest) + creatorID = m_testAssetsCreatorID; + else + creatorID = owner_id; + + string creatorIDstr = creatorID.ToString(); + IMoneyModule mm = m_Scene.RequestModuleInterface(); if (mm != null) { @@ -703,20 +749,56 @@ namespace OpenSim.Region.ClientStack.Linden SceneObjectGroup grp = null; // create and store texture assets + bool doTextInv = (!istest && m_enableModelUploadTextureToInventory && + texturesFolder != UUID.Zero); + + List textures = new List(); + for (int i = 0; i < texture_list.Count; i++) { - AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, ""); + AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, creatorIDstr); textureAsset.Data = texture_list[i].AsBinary(); m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); + + if (doTextInv) + { + string name = assetName; + if (name.Length > 25) + name = name.Substring(0, 24); + name += "_Texture#" + i.ToString(); + InventoryItemBase texitem = new InventoryItemBase(); + texitem.Owner = m_HostCapsObj.AgentID; + texitem.CreatorId = creatorIDstr; + texitem.CreatorData = String.Empty; + texitem.ID = UUID.Random(); + texitem.AssetID = textureAsset.FullID; + texitem.Description = "mesh model texture"; + texitem.Name = name; + texitem.AssetType = (int)AssetType.Texture; + texitem.InvType = (int)InventoryType.Texture; + texitem.Folder = texturesFolder; + + texitem.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + texitem.BasePermissions = (uint)PermissionMask.All; + texitem.EveryOnePermissions = 0; + texitem.NextPermissions = (uint)PermissionMask.All; + texitem.CreationDate = Util.UnixTimeSinceEpoch(); + + AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); + texitem = null; + // this aren't showing up in viewer until relog :( + } } // create and store meshs assets List meshAssets = new List(); for (int i = 0; i < mesh_list.Count; i++) { - AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); + AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr); meshAsset.Data = mesh_list[i].AsBinary(); m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); @@ -827,7 +909,7 @@ namespace OpenSim.Region.ClientStack.Linden // int owner_mask = permissions["owner_mask"].AsInteger(); // no longer used - end ------------------------ - UUID owner_id = m_HostCapsObj.AgentID; + SceneObjectPart prim = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); @@ -837,13 +919,29 @@ namespace OpenSim.Region.ClientStack.Linden rotations.Add(rotation); positions.Add(position); prim.UUID = UUID.Random(); - prim.CreatorID = owner_id; + prim.CreatorID = creatorID; prim.OwnerID = owner_id; prim.GroupID = UUID.Zero; - prim.LastOwnerID = prim.OwnerID; + prim.LastOwnerID = creatorID; prim.CreationDate = Util.UnixTimeSinceEpoch(); - prim.Name = assetName; - prim.Description = ""; + + if (grp == null) + prim.Name = assetName; + else + prim.Name = assetName + "#" + i.ToString(); + + if (istest) + { + prim.BaseMask = (uint)(PermissionMask.Move | PermissionMask.Modify); + prim.EveryoneMask = 0; + prim.GroupMask = 0; + prim.NextOwnerMask = 0; + prim.OwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify); + + prim.Description = "For personal testing only. Other uses are forbiden"; + } + else + prim.Description = ""; prim.Material = material; prim.PhysicsShapeType = physicsShapeType; @@ -854,7 +952,10 @@ namespace OpenSim.Region.ClientStack.Linden // prim.OwnerMask = (uint)owner_mask; if (grp == null) + { grp = new SceneObjectGroup(prim); + grp.LastOwnerID = creatorID; + } else grp.AddPart(prim); } @@ -904,7 +1005,7 @@ namespace OpenSim.Region.ClientStack.Linden } AssetBase asset; - asset = new AssetBase(assetID, assetName, assType, m_HostCapsObj.AgentID.ToString()); + asset = new AssetBase(assetID, assetName, assType, creatorIDstr); asset.Data = data; if (AddNewAsset != null) AddNewAsset(asset); @@ -913,11 +1014,14 @@ namespace OpenSim.Region.ClientStack.Linden InventoryItemBase item = new InventoryItemBase(); item.Owner = m_HostCapsObj.AgentID; - item.CreatorId = m_HostCapsObj.AgentID.ToString(); + item.CreatorId = creatorIDstr; item.CreatorData = String.Empty; item.ID = inventoryItem; item.AssetID = asset.FullID; - item.Description = assetDescription; + if (istest) + item.Description = "For personal testing only. Other uses are forbiden"; + else + item.Description = assetDescription; item.Name = assetName; item.AssetType = assType; item.InvType = inType; @@ -926,17 +1030,53 @@ namespace OpenSim.Region.ClientStack.Linden // If we set PermissionMask.All then when we rez the item the next permissions will replace the current // (owner) permissions. This becomes a problem if next permissions are changed. - item.CurrentPermissions - = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + if (istest) + { + item.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Modify); + + item.BasePermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); + item.EveryOnePermissions = 0; + item.NextPermissions = 0; + } + else + { + item.CurrentPermissions + = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); + + item.BasePermissions = (uint)PermissionMask.All; + item.EveryOnePermissions = 0; + item.NextPermissions = (uint)PermissionMask.All; + } - item.BasePermissions = (uint)PermissionMask.All; - item.EveryOnePermissions = 0; - item.NextPermissions = (uint)PermissionMask.All; item.CreationDate = Util.UnixTimeSinceEpoch(); + IClientAPI client = null; + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); + if (AddNewInventoryItem != null) { - AddNewInventoryItem(m_HostCapsObj.AgentID, item,(uint) cost); + if (istest) + { + AddNewInventoryItem(m_HostCapsObj.AgentID, item, 0); + if (client != null) + client.SendAgentAlertMessage("Upload complete with no cost for personal testing purposes only. Other uses are forbiden", true); + } + else + { + AddNewInventoryItem(m_HostCapsObj.AgentID, item, (uint)cost); + if (client != null) + { + // let users see anything.. i don't so far + string str; + if (cost > 0) + // dont remember where is money unit name to put here + str = "Upload complete. charged " + cost.ToString() + "$"; + else + str = "Upload complete"; + client.SendAgentAlertMessage(str, true); + } + } } lock (m_ModelCost) @@ -1272,11 +1412,17 @@ namespace OpenSim.Region.ClientStack.Linden private string m_error = String.Empty; private Timer m_timeoutTimer = new Timer(); - + private UUID m_texturesFolder; + private int m_nreqtextures; + private int m_nreqmeshs; + private int m_nreqinstances; + private bool m_IsAtestUpload; public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolderID, string invType, string assetType, string path, - IHttpServer httpServer, bool dumpAssetsToFile, int totalCost) + IHttpServer httpServer, bool dumpAssetsToFile, + int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, + bool IsAtestUpload) { m_assetName = assetName; m_assetDes = description; @@ -1290,6 +1436,12 @@ namespace OpenSim.Region.ClientStack.Linden m_dumpAssetsToFile = dumpAssetsToFile; m_cost = totalCost; + m_texturesFolder = texturesFolder; + m_nreqtextures = nreqtextures; + m_nreqmeshs = nreqmeshs; + m_nreqinstances = nreqinstances; + m_IsAtestUpload = IsAtestUpload; + m_timeoutTimer.Elapsed += TimedOut; m_timeoutTimer.Interval = 120000; m_timeoutTimer.AutoReset = false; @@ -1332,12 +1484,15 @@ namespace OpenSim.Region.ClientStack.Linden handlerUpLoad = OnUpLoad; if (handlerUpLoad != null) { - handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost, ref m_error); + handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, + m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, ref m_error); } if(m_error == String.Empty) { uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_inventory_item = inv; +// if (m_texturesFolder != UUID.Zero) +// uploadComplete.new_texture_folder_id = m_texturesFolder; uploadComplete.state = "complete"; } else diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 7a80c72..f03d8d8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -96,7 +96,8 @@ namespace OpenSim.Region.ClientStack.Linden // basicCost input region assets upload cost // totalcost returns model total upload fee // meshcostdata returns detailed costs for viewer - public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, LLSDAssetUploadResponseData meshcostdata, out string error) + public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, + LLSDAssetUploadResponseData meshcostdata, out string error, ref string warning) { totalcost = 0; error = string.Empty; @@ -229,10 +230,18 @@ namespace OpenSim.Region.ClientStack.Linden meshsfee += primCreationCost; } - if (skipedSmall >0 && skipedSmall > numberInstances / 2) + if (skipedSmall > 0) { - error = "Model contains too many prims smaller than " + PrimScaleMin.ToString() + "m"; - return false; + if (skipedSmall > numberInstances / 2) + { + error = "Model contains too many prims smaller than " + PrimScaleMin.ToString() + + "m minimum allowed size. Please check scalling"; + return false; + } + else + warning += skipedSmall.ToString() + " of the requested " +numberInstances.ToString() + + " model prims will not upload because they are smaller than " + PrimScaleMin.ToString() + + "m minimum allowed size. Please check scalling "; } if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) @@ -403,9 +412,14 @@ namespace OpenSim.Region.ClientStack.Linden submesh_offset = -1; - if (map.ContainsKey("physics_mesh")) - { + tmpmap = null; + if(map.ContainsKey("physics_mesh")) tmpmap = (OSDMap)map["physics_mesh"]; + else if (map.ContainsKey("physics_shape")) // old naming + tmpmap = (OSDMap)map["physics_shape"]; + + if(tmpmap != null) + { if (tmpmap.ContainsKey("offset")) submesh_offset = tmpmap["offset"].AsInteger() + start; if (tmpmap.ContainsKey("size")) -- cgit v1.1 From a5d969d92f906b035da1a0489a7e4163d3e43aad Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 23 Sep 2012 20:57:36 +0200 Subject: Comment out asset error for sculpts/meshes. If an asset is missing it's missing. We can't put it back so we don't need to know. --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 56d289f..e6ad89c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2146,10 +2146,10 @@ namespace OpenSim.Region.Framework.Scenes { if (asset != null) SculptTextureCallback(asset); - else - m_log.WarnFormat( - "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", - Name, UUID, id); +// else +// m_log.WarnFormat( +// "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", +// Name, UUID, id); } /// -- cgit v1.1 From 2d02405186841d5aeea30b608d106212f5fee1c3 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 23 Sep 2012 23:16:25 +0200 Subject: Change the poll service to use a thread pool for replies to make sure the event queues aren't blocked by other traffic. --- .../HttpServer/PollServiceRequestManager.cs | 45 ++++++++++++++++++---- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index db088e7..c13c65b 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -33,6 +33,7 @@ using log4net; using HttpServer; using OpenSim.Framework; using OpenSim.Framework.Monitoring; +using Amib.Threading; /* @@ -185,6 +186,8 @@ namespace OpenSim.Framework.Servers.HttpServer private bool m_running = true; private int slowCount = 0; + private SmartThreadPool m_threadPool = new SmartThreadPool(20000, 12, 2); + // private int m_timeout = 1000; // increase timeout 250; now use the event one public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout) @@ -353,18 +356,46 @@ namespace OpenSim.Framework.Servers.HttpServer continue; } - try + // "Normal" means the viewer evebt queue. We need to push these out fast. + // Process them inline. The rest go to the thread pool. + if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Normal) { - Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); - DoHTTPGruntWork(m_server, req, responsedata); + try + { + Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); + DoHTTPGruntWork(m_server, req, responsedata); + } + catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream + { + // Ignore it, no need to reply + } + finally + { + str.Close(); + } } - catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream + else { - // Ignore it, no need to reply + m_threadPool.QueueWorkItem(x => + { + try + { + Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); + DoHTTPGruntWork(m_server, req, responsedata); + } + catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream + { + // Ignore it, no need to reply + } + finally + { + str.Close(); + } + + return null; + }, null); } - str.Close(); - } else { -- cgit v1.1 From 68ece236a6cd8a2a9bc009287e43debdc6e9a79d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 23 Sep 2012 23:55:28 +0200 Subject: Protect the responses map with a lock. Also remove ugly "this." type of member notation. --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 14 ++++++----- .../Linden/Caps/WebFetchInvDescModule.cs | 28 ++++++++++++---------- 2 files changed, 24 insertions(+), 18 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 0ac56ec..2000279 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -146,14 +146,14 @@ namespace OpenSim.Region.ClientStack.Linden { m_scene = scene; - HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; + HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; GetEvents = (x, y, s) => { lock (responses) { try { - return this.responses[x]; + return responses[x]; } finally { @@ -165,15 +165,15 @@ namespace OpenSim.Region.ClientStack.Linden Request = (x, y) => { y["RequestID"] = x.ToString(); - lock (this.requests) - this.requests.Add(y); + lock (requests) + requests.Add(y); m_queue.Enqueue(this); }; NoEvents = (x, y) => { - lock (this.requests) + lock (requests) { Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); requests.Remove(request); @@ -198,7 +198,7 @@ namespace OpenSim.Region.ClientStack.Linden try { - lock (this.requests) + lock (requests) { request = requests[0]; requests.RemoveAt(0); @@ -221,8 +221,10 @@ namespace OpenSim.Region.ClientStack.Linden response["content_type"] = "text/plain"; response["keepalive"] = false; response["reusecontext"] = false; + lock (responses) responses[requestID] = response; + return; } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 4908c2c..f76ea74 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -144,31 +144,34 @@ namespace OpenSim.Region.ClientStack.Linden public PollServiceInventoryEventArgs(UUID pId) : base(null, null, null, null, pId, 30000) { - HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; + HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; GetEvents = (x, y, s) => { - try + lock (responses) { - return this.responses[x]; - } - finally - { - responses.Remove(x); + try + { + return responses[x]; + } + finally + { + responses.Remove(x); + } } }; Request = (x, y) => { y["RequestID"] = x.ToString(); - lock (this.requests) - this.requests.Add(y); + lock (requests) + requests.Add(y); m_queue.Enqueue(this); }; NoEvents = (x, y) => { - lock (this.requests) + lock (requests) { Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); requests.Remove(request); @@ -192,7 +195,7 @@ namespace OpenSim.Region.ClientStack.Linden try { - lock (this.requests) + lock (requests) { request = requests[0]; requests.RemoveAt(0); @@ -214,7 +217,8 @@ namespace OpenSim.Region.ClientStack.Linden response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null); - responses[requestID] = response; + lock (responses) + responses[requestID] = response; } } -- cgit v1.1 From 6963b96bd05b17624a2e46726b033e179d50b280 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 24 Sep 2012 13:41:48 +0200 Subject: If an asset upload transaction doesn't exist for a CreateInventory request, simply process it as if UUID.Zero had been given. --- .../AssetTransaction/AgentAssetsTransactions.cs | 12 +++-- .../AssetTransaction/AssetTransactionModule.cs | 4 +- .../InventoryAccess/InventoryAccessModule.cs | 57 +++++++++++----------- .../Interfaces/IAgentAssetTransactions.cs | 2 +- 4 files changed, 38 insertions(+), 37 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs index b557ffe..8a4fd8f 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AgentAssetsTransactions.cs @@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } } - public void RequestCreateInventoryItem(IClientAPI remoteClient, + public bool RequestCreateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) @@ -160,14 +160,16 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction } if (uploader != null) + { uploader.RequestCreateInventoryItem( remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); - else - m_log.ErrorFormat( - "[AGENT ASSET TRANSACTIONS]: Could not find uploader with transaction ID {0} when handling request to create inventory item {1} from {2}", - transactionID, name, remoteClient.Name); + + return true; + } + + return false; } /// diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index 7081989..441c4ff 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs @@ -158,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction /// /// /// - public void HandleItemCreationFromTransaction(IClientAPI remoteClient, + public bool HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask) @@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId); - transactions.RequestCreateInventoryItem(remoteClient, transactionID, + return transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask); } diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 9a56f42..305a818 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -186,44 +186,43 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (folder == null || folder.Owner != remoteClient.AgentId) return; - if (transactionID == UUID.Zero) + if (transactionID != UUID.Zero) { - ScenePresence presence; - if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) + IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; + if (agentTransactions != null) { - byte[] data = null; + if (agentTransactions.HandleItemCreationFromTransaction( + remoteClient, transactionID, folderID, callbackID, description, + name, invType, assetType, wearableType, nextOwnerMask)) + return; + } + } - if (invType == (sbyte)InventoryType.Landmark && presence != null) - { - string suffix = string.Empty, prefix = string.Empty; - string strdata = GenerateLandmark(presence, out prefix, out suffix); - data = Encoding.ASCII.GetBytes(strdata); - name = prefix + name; - description += suffix; - } + ScenePresence presence; + if (m_Scene.TryGetScenePresence(remoteClient.AgentId, out presence)) + { + byte[] data = null; - AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); - m_Scene.AssetService.Store(asset); - m_Scene.CreateNewInventoryItem( - remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, - name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); - } - else + if (invType == (sbyte)InventoryType.Landmark && presence != null) { - m_log.ErrorFormat( - "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", - remoteClient.AgentId); + string suffix = string.Empty, prefix = string.Empty; + string strdata = GenerateLandmark(presence, out prefix, out suffix); + data = Encoding.ASCII.GetBytes(strdata); + name = prefix + name; + description += suffix; } + + AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); + m_Scene.AssetService.Store(asset); + m_Scene.CreateNewInventoryItem( + remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, + name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); } else { - IAgentAssetTransactions agentTransactions = m_Scene.AgentTransactionsModule; - if (agentTransactions != null) - { - agentTransactions.HandleItemCreationFromTransaction( - remoteClient, transactionID, folderID, callbackID, description, - name, invType, assetType, wearableType, nextOwnerMask); - } + m_log.ErrorFormat( + "[INVENTORY ACCESS MODULE]: ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", + remoteClient.AgentId); } } diff --git a/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs b/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs index 0cc8fb6..e0aad2b 100644 --- a/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs +++ b/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs @@ -36,7 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item); - void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, + bool HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask); -- cgit v1.1 From ca67ee60ac0e0c26d6d32fc68d48ef63570f034d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 24 Sep 2012 21:22:08 +0100 Subject: add missing transactionID in SendInventoryItemCreateUpdate. and make use of it on inventoryAccessModule, etc. Most likelly it's needs where there is a transactionID not zero --- OpenSim/Framework/IClientAPI.cs | 1 + OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 8 +++++++- .../InventoryAccess/InventoryAccessModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 19 +++++++++++++++---- .../InternetRelayClientView/Server/IRCClientView.cs | 7 ++++++- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 4 ++++ OpenSim/Tests/Common/Mock/TestClient.cs | 4 ++++ 7 files changed, 38 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 6be2bd7..5909ce1 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1158,6 +1158,7 @@ namespace OpenSim.Framework /// /// void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId); + void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId); void SendRemoveInventoryItem(UUID itemID); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 7749ef3..ee28914 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -2067,9 +2067,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(bulkUpdate, ThrottleOutPacketType.Asset); } - /// IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase) public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId) { + SendInventoryItemCreateUpdate(Item, UUID.Zero, callbackId); + } + + /// IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase) + public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId) + { const uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All; UpdateCreateInventoryItemPacket InventoryReply @@ -2079,6 +2084,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // TODO: don't create new blocks if recycling an old packet InventoryReply.AgentData.AgentID = AgentId; InventoryReply.AgentData.SimApproved = true; + InventoryReply.AgentData.TransactionID = transactionID; InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1]; InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock(); InventoryReply.InventoryData[0].ItemID = Item.ID; diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 305a818..50f5f68 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -216,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess m_Scene.AssetService.Store(asset); m_Scene.CreateNewInventoryItem( remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, - name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); + name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate,transactionID); } else { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 2d9a035..dd9210f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -904,11 +904,22 @@ namespace OpenSim.Region.Framework.Scenes public void CreateNewInventoryItem( IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, string description, uint flags, uint callbackID, - AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) + AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate, UUID transationID) { CreateNewInventoryItem( remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, - (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate); + (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate, transationID); + } + + + private void CreateNewInventoryItem( + IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, + string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, + uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) + { + CreateNewInventoryItem(remoteClient, creatorID, creatorData, folderID, + name, description, flags, callbackID, asset, invType, + baseMask, currentMask, everyoneMask, nextOwnerMask, groupMask, creationDate, UUID.Zero); } /// @@ -933,7 +944,7 @@ namespace OpenSim.Region.Framework.Scenes private void CreateNewInventoryItem( IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, - uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) + uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,UUID transationID) { InventoryItemBase item = new InventoryItemBase(); item.Owner = remoteClient.AgentId; @@ -956,7 +967,7 @@ namespace OpenSim.Region.Framework.Scenes if (AddInventoryItem(item)) { - remoteClient.SendInventoryItemCreateUpdate(item, callbackID); + remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID); } else { diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 3b83e58..a484300 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1100,7 +1100,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId) { - + + } + + public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId) + { + } public void SendRemoveInventoryItem(UUID itemID) diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index d00a6c0..7c693b6 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -739,6 +739,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId) + { + } + public virtual void SendRemoveInventoryItem(UUID itemID) { } diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 6add130..49a8d26 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -716,6 +716,10 @@ namespace OpenSim.Tests.Common.Mock { } + public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId) + { + } + public virtual void SendRemoveInventoryItem(UUID itemID) { } -- cgit v1.1 From a1a0a90720e65ce104699abb6dcd46b5cb34a6db Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 24 Sep 2012 22:57:33 +0100 Subject: more upload changes (plus untouch prebuild.xml) --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 183 ++++++++++++++------- .../Linden/Caps/BunchOfCaps/MeshCost.cs | 13 +- 2 files changed, 128 insertions(+), 68 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 21a1005..4a323d8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -118,12 +118,20 @@ namespace OpenSim.Region.ClientStack.Linden private IAssetService m_assetService; private bool m_dumpAssetsToFile = false; private string m_regionName; + private int m_levelUpload = 0; - private float m_PrimScaleMin = 0.001f; - private bool m_enableFreeTestUpload = false; - private bool m_enableModelUploadTextureToInventory = false; + + private bool m_enableFreeTestUpload = false; // allows "TEST-" prefix hack + private bool m_ForceFreeTestUpload = false; // forces all uploads to be test + + private bool m_enableModelUploadTextureToInventory = false; // place uploaded textures also in inventory + // may not be visible till relog + + private bool m_RestrictFreeTestUploadPerms = false; // reduces also the permitions. Needs a creator defined!! private UUID m_testAssetsCreatorID = UUID.Zero; + private float m_PrimScaleMin = 0.001f; + private enum FileAgentInventoryState : int { idle = 0, @@ -143,16 +151,16 @@ namespace OpenSim.Region.ClientStack.Linden // tell it about scene object limits m_ModelCost.NonPhysicalPrimScaleMax = m_Scene.m_maxNonphys; m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys; -// m_ModelCost.PrimScaleMin = ?? + // m_ModelCost.ObjectLinkedPartsMax = ?? -// m_PrimScaleMin = ?? +// m_ModelCost.PrimScaleMin = ?? + m_PrimScaleMin = m_ModelCost.PrimScaleMin; float modelTextureUploadFactor = m_ModelCost.ModelTextureCostFactor; float modelUploadFactor = m_ModelCost.ModelMeshCostFactor; float modelMinUploadCostFactor = m_ModelCost.ModelMinCostFactor; - - // can be UUID.zero. This is me at OSG, should be a valid grid ID, is case a bad config - UUID.TryParse("58e06f33-ea8c-4ff6-9af5-420606926118", out m_testAssetsCreatorID); + float modelPrimCreationCost = m_ModelCost.primCreationCost; + float modelMeshByteCost = m_ModelCost.bytecost; IConfigSource config = m_Scene.Config; if (config != null) @@ -175,10 +183,16 @@ namespace OpenSim.Region.ClientStack.Linden modelUploadFactor = EconomyConfig.GetFloat("MeshModelUploadCostFactor", modelUploadFactor); modelTextureUploadFactor = EconomyConfig.GetFloat("MeshModelUploadTextureCostFactor", modelTextureUploadFactor); modelMinUploadCostFactor = EconomyConfig.GetFloat("MeshModelMinCostFactor", modelMinUploadCostFactor); - m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", false); + // next 2 are normalized so final cost is afected by modelUploadFactor above and normal cost + modelPrimCreationCost = EconomyConfig.GetFloat("ModelPrimCreationCost", modelPrimCreationCost); + modelMeshByteCost = EconomyConfig.GetFloat("ModelMeshByteCost", modelMeshByteCost); - m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", false); - string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", m_testAssetsCreatorID.ToString()); + m_enableModelUploadTextureToInventory = EconomyConfig.GetBoolean("MeshModelAllowTextureToInventory", m_enableModelUploadTextureToInventory); + + m_RestrictFreeTestUploadPerms = EconomyConfig.GetBoolean("m_RestrictFreeTestUploadPerms", m_RestrictFreeTestUploadPerms); + m_enableFreeTestUpload = EconomyConfig.GetBoolean("AllowFreeTestUpload", m_enableFreeTestUpload); + m_ForceFreeTestUpload = EconomyConfig.GetBoolean("ForceFreeTestUpload", m_ForceFreeTestUpload); + string testcreator = EconomyConfig.GetString("TestAssetsCreatorID", ""); if (testcreator != "") { UUID id; @@ -190,6 +204,8 @@ namespace OpenSim.Region.ClientStack.Linden m_ModelCost.ModelMeshCostFactor = modelUploadFactor; m_ModelCost.ModelTextureCostFactor = modelTextureUploadFactor; m_ModelCost.ModelMinCostFactor = modelMinUploadCostFactor; + m_ModelCost.primCreationCost = modelPrimCreationCost; + m_ModelCost.bytecost = modelMeshByteCost; } } @@ -490,6 +506,8 @@ namespace OpenSim.Region.ClientStack.Linden int nreqinstances = 0; bool IsAtestUpload = false; + string assetName = llsdRequest.name; + LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); if (llsdRequest.asset_type == "texture" || @@ -497,7 +515,7 @@ namespace OpenSim.Region.ClientStack.Linden llsdRequest.asset_type == "mesh" || llsdRequest.asset_type == "sound") { - ScenePresence avatar = null; + ScenePresence avatar = null; m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); // check user level @@ -519,7 +537,7 @@ namespace OpenSim.Region.ClientStack.Linden } } - // check funds + // check test upload and funds if (client != null) { IMoneyModule mm = m_Scene.RequestModuleInterface(); @@ -558,41 +576,53 @@ namespace OpenSim.Region.ClientStack.Linden cost = baseCost; } - if (m_enableFreeTestUpload && cost > 0 && mm != null) + if (cost > 0 && mm != null) { - string str = llsdRequest.name; - if (str.Length > 5 && str.StartsWith("TEST-")) + // check for test upload + + if (m_ForceFreeTestUpload) // all are test { - warning += "Upload will have no cost, but for personal test purposes only. Other uses are forbiden"; + if (!(assetName.Length > 5 && assetName.StartsWith("TEST-"))) // has normal name lets change it + assetName = "TEST-" + assetName; + IsAtestUpload = true; } - } - - if (client != null && warning != String.Empty) - client.SendAgentAlertMessage(warning, true); - // check funds - if (!IsAtestUpload && mm != null && cost >0) - { - if (!mm.UploadCovered(client.AgentId, (int)cost)) + else if (m_enableFreeTestUpload) // only if prefixed with "TEST-" { - LLSDAssetUploadError resperror = new LLSDAssetUploadError(); - resperror.message = "Insuficient funds"; - resperror.identifier = UUID.Zero; - LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); - errorResponse.uploader = ""; - errorResponse.state = "error"; - errorResponse.error = resperror; - lock (m_ModelCost) - m_FileAgentInventoryState = FileAgentInventoryState.idle; - return errorResponse; + IsAtestUpload = (assetName.Length > 5 && assetName.StartsWith("TEST-")); + } + + + if(IsAtestUpload) // let user know, still showing cost estimation + warning += "Upload will have no cost, for personal test purposes only. Other uses are forbiden. Items may not work on another region"; + + // check funds + else + { + if (!mm.UploadCovered(client.AgentId, (int)cost)) + { + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = "Insuficient funds"; + resperror.identifier = UUID.Zero; + + LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); + errorResponse.uploader = ""; + errorResponse.state = "error"; + errorResponse.error = resperror; + lock (m_ModelCost) + m_FileAgentInventoryState = FileAgentInventoryState.idle; + return errorResponse; + } } } + + if (client != null && warning != String.Empty) + client.SendAgentAlertMessage(warning, true); } } - - string assetName = llsdRequest.name; + string assetDes = llsdRequest.description; string capsBase = "/CAPS/" + m_HostCapsObj.CapsObjectPath; UUID newAsset = UUID.Random(); @@ -607,7 +637,7 @@ namespace OpenSim.Region.ClientStack.Linden AssetUploader uploader = new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, - texturesFolder, nreqtextures, nreqmeshs, nreqinstances,IsAtestUpload); + texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload); m_HostCapsObj.HttpListener.AddStreamHandler( new BinaryStreamHandler( @@ -667,12 +697,16 @@ namespace OpenSim.Region.ClientStack.Linden sbyte assType = 0; sbyte inType = 0; + IClientAPI client = null; + UUID owner_id = m_HostCapsObj.AgentID; UUID creatorID; bool istest = IsAtestUpload && m_enableFreeTestUpload && (cost > 0); - if (istest) + bool restrictPerms = m_RestrictFreeTestUploadPerms && istest; + + if (istest && m_testAssetsCreatorID != UUID.Zero) creatorID = m_testAssetsCreatorID; else creatorID = owner_id; @@ -755,10 +789,19 @@ namespace OpenSim.Region.ClientStack.Linden List textures = new List(); + + if (doTextInv) + m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); + + if(client == null) // don't put textures in inventory if there is no client + doTextInv = false; + for (int i = 0; i < texture_list.Count; i++) { AssetBase textureAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Texture, creatorIDstr); textureAsset.Data = texture_list[i].AsBinary(); + if (istest) + textureAsset.Local = true; m_assetService.Store(textureAsset); textures.Add(textureAsset.FullID); @@ -788,9 +831,8 @@ namespace OpenSim.Region.ClientStack.Linden texitem.NextPermissions = (uint)PermissionMask.All; texitem.CreationDate = Util.UnixTimeSinceEpoch(); - AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0); + m_Scene.AddInventoryItem(client, texitem); texitem = null; - // this aren't showing up in viewer until relog :( } } @@ -800,6 +842,8 @@ namespace OpenSim.Region.ClientStack.Linden { AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr); meshAsset.Data = mesh_list[i].AsBinary(); + if (istest) + meshAsset.Local = true; m_assetService.Store(meshAsset); meshAssets.Add(meshAsset.FullID); } @@ -908,14 +952,12 @@ namespace OpenSim.Region.ClientStack.Linden // UUID owner_id = permissions["owner_id"].AsUUID(); // int owner_mask = permissions["owner_mask"].AsInteger(); // no longer used - end ------------------------ - - + SceneObjectPart prim = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); prim.Scale = scale; -// prim.OffsetPosition = position; rotations.Add(rotation); positions.Add(position); prim.UUID = UUID.Random(); @@ -930,18 +972,20 @@ namespace OpenSim.Region.ClientStack.Linden else prim.Name = assetName + "#" + i.ToString(); - if (istest) + if (restrictPerms) { prim.BaseMask = (uint)(PermissionMask.Move | PermissionMask.Modify); prim.EveryoneMask = 0; prim.GroupMask = 0; prim.NextOwnerMask = 0; prim.OwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify); + } + if(istest) prim.Description = "For personal testing only. Other uses are forbiden"; - } else prim.Description = ""; + prim.Material = material; prim.PhysicsShapeType = physicsShapeType; @@ -1007,6 +1051,8 @@ namespace OpenSim.Region.ClientStack.Linden AssetBase asset; asset = new AssetBase(assetID, assetName, assType, creatorIDstr); asset.Data = data; + if (istest) + asset.Local = true; if (AddNewAsset != null) AddNewAsset(asset); else if (m_assetService != null) @@ -1019,7 +1065,10 @@ namespace OpenSim.Region.ClientStack.Linden item.ID = inventoryItem; item.AssetID = asset.FullID; if (istest) + { item.Description = "For personal testing only. Other uses are forbiden"; + item.Flags = (uint) (InventoryItemFlags.SharedSingleReference); + } else item.Description = assetDescription; item.Name = assetName; @@ -1030,7 +1079,7 @@ namespace OpenSim.Region.ClientStack.Linden // If we set PermissionMask.All then when we rez the item the next permissions will replace the current // (owner) permissions. This becomes a problem if next permissions are changed. - if (istest) + if (restrictPerms) { item.CurrentPermissions = (uint)(PermissionMask.Move | PermissionMask.Modify); @@ -1051,16 +1100,18 @@ namespace OpenSim.Region.ClientStack.Linden item.CreationDate = Util.UnixTimeSinceEpoch(); - IClientAPI client = null; m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); if (AddNewInventoryItem != null) { if (istest) { + m_Scene.AddInventoryItem(client, item); +/* AddNewInventoryItem(m_HostCapsObj.AgentID, item, 0); if (client != null) - client.SendAgentAlertMessage("Upload complete with no cost for personal testing purposes only. Other uses are forbiden", true); + client.SendAgentAlertMessage("Upload will have no cost, for personal test purposes only. Other uses are forbiden. Items may not work on a another region" , true); + */ } else { @@ -1487,22 +1538,34 @@ namespace OpenSim.Region.ClientStack.Linden handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, ref m_error); } - if(m_error == String.Empty) - { - uploadComplete.new_asset = newAssetID.ToString(); - uploadComplete.new_inventory_item = inv; -// if (m_texturesFolder != UUID.Zero) -// uploadComplete.new_texture_folder_id = m_texturesFolder; - uploadComplete.state = "complete"; - } - else + if (m_IsAtestUpload) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); - resperror.message = m_error; + resperror.message = "Upload SUCESSEFULL for testing purposes only. Other uses are forbiden. Item may not work on other region"; resperror.identifier = inv; uploadComplete.error = resperror; - uploadComplete.state = "failed"; + uploadComplete.state = "Upload4Testing"; + } + else + { + if (m_error == String.Empty) + { + uploadComplete.new_asset = newAssetID.ToString(); + uploadComplete.new_inventory_item = inv; + // if (m_texturesFolder != UUID.Zero) + // uploadComplete.new_texture_folder_id = m_texturesFolder; + uploadComplete.state = "complete"; + } + else + { + LLSDAssetUploadError resperror = new LLSDAssetUploadError(); + resperror.message = m_error; + resperror.identifier = inv; + + uploadComplete.error = resperror; + uploadComplete.state = "failed"; + } } res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 66bb429..4a3fae6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs @@ -35,18 +35,15 @@ namespace OpenSim.Region.ClientStack.Linden // fees are normalized to 1.0 // this parameters scale them to basic cost ( so 1.0 translates to 10 ) - public float ModelMeshCostFactor = 0f; //Free - public float ModelMinCostFactor = 0f; // Free - //public float ModelMeshCostFactor = 1.0f; // scale total cost relative to basic (excluding textures) - //public float ModelMinCostFactor = 0.5f; // minimum total model free excluding textures + public float ModelMeshCostFactor = 0.0f; // scale total cost relative to basic (excluding textures) + public float ModelTextureCostFactor = 1.0f; // scale textures fee to basic. + public float ModelMinCostFactor = 0.0f; // 0.5f; // minimum total model free excluding textures - public float ModelTextureCostFactor = 1.00f; // keep full price because texture price - // is based on it's storage needs not on usability // itens costs in normalized values // ie will be multiplied by basicCost and factors above - const float primCreationCost = 0.002f; // extra cost for each prim creation overhead + public float primCreationCost = 0.002f; // extra cost for each prim creation overhead // weigthed size to normalized cost - const float bytecost = 1e-5f; + public float bytecost = 1e-5f; // mesh upload fees based on compressed data sizes // several data sections are counted more that once -- cgit v1.1 From 421071bd8a489b90d3ddd58add7135b178f59381 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 24 Sep 2012 23:19:57 +0200 Subject: Text changes for upload messages --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 4a323d8..c705f10 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -596,7 +596,7 @@ namespace OpenSim.Region.ClientStack.Linden if(IsAtestUpload) // let user know, still showing cost estimation - warning += "Upload will have no cost, for personal test purposes only. Other uses are forbiden. Items may not work on another region"; + warning += "Upload will have no cost, for testing purposes only. Other uses are prohibited. Items will not work after 48 hours or on other regions"; // check funds else @@ -982,7 +982,7 @@ namespace OpenSim.Region.ClientStack.Linden } if(istest) - prim.Description = "For personal testing only. Other uses are forbiden"; + prim.Description = "For testing only. Other uses are prohibited"; else prim.Description = ""; @@ -1066,7 +1066,7 @@ namespace OpenSim.Region.ClientStack.Linden item.AssetID = asset.FullID; if (istest) { - item.Description = "For personal testing only. Other uses are forbiden"; + item.Description = "For testing only. Other uses are prohibited"; item.Flags = (uint) (InventoryItemFlags.SharedSingleReference); } else @@ -1541,7 +1541,7 @@ namespace OpenSim.Region.ClientStack.Linden if (m_IsAtestUpload) { LLSDAssetUploadError resperror = new LLSDAssetUploadError(); - resperror.message = "Upload SUCESSEFULL for testing purposes only. Other uses are forbiden. Item may not work on other region"; + resperror.message = "Upload SUCESSEFULL for testing purposes only. Other uses are prohibited. Item will not work after 48 hours or on other regions"; resperror.identifier = inv; uploadComplete.error = resperror; -- cgit v1.1 From 2cb17d6fbb4cfc5157cec0f3e4589db007a117b3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Sep 2012 03:38:45 +0100 Subject: change GetTextureModule processing --- .../ClientStack/Linden/Caps/GetTextureModule.cs | 60 +++++++++++----------- 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 2000279..1ccddd2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -53,6 +53,14 @@ namespace OpenSim.Region.ClientStack.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GetTextureModule")] public class GetTextureModule : INonSharedRegionModule { + + struct aPollRequest + { + public PollServiceTextureEventArgs thepoll; + public UUID reqID; + public Hashtable request; + } + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; @@ -64,8 +72,8 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_capsDict = new Dictionary(); private static Thread[] m_workerThreads = null; - private static OpenMetaverse.BlockingQueue m_queue = - new OpenMetaverse.BlockingQueue(); + private static OpenMetaverse.BlockingQueue m_queue = + new OpenMetaverse.BlockingQueue(); #region ISharedRegionModule Members @@ -104,7 +112,7 @@ namespace OpenSim.Region.ClientStack.Linden String.Format("TextureWorkerThread{0}", i), ThreadPriority.Normal, false, - true, + false, null, int.MaxValue); } @@ -129,7 +137,8 @@ namespace OpenSim.Region.ClientStack.Linden ~GetTextureModule() { foreach (Thread t in m_workerThreads) - t.Abort(); + Watchdog.AbortThread(t.ManagedThreadId); + } private class PollServiceTextureEventArgs : PollServiceEventArgs @@ -142,7 +151,12 @@ namespace OpenSim.Region.ClientStack.Linden private Scene m_scene; public PollServiceTextureEventArgs(UUID pId, Scene scene) : - base(null, null, null, null, pId, 30000) + base(null, null, null, null, pId, int.MaxValue) + // this should never timeout + // each request must be processed and return a response + // noevents can possible be use for nice shutdown, but not sure now + // the execution will provide a proper response even if it fails + { m_scene = scene; @@ -164,13 +178,15 @@ namespace OpenSim.Region.ClientStack.Linden Request = (x, y) => { - y["RequestID"] = x.ToString(); - lock (requests) - requests.Add(y); + aPollRequest reqinfo = new aPollRequest(); + reqinfo.thepoll = this; + reqinfo.reqID = x; + reqinfo.request = y; - m_queue.Enqueue(this); + m_queue.Enqueue(reqinfo); }; + // this should never happen except possible on shutdown NoEvents = (x, y) => { lock (requests) @@ -191,27 +207,14 @@ namespace OpenSim.Region.ClientStack.Linden }; } - public void Process() + public void Process(aPollRequest requestinfo) { Hashtable response; - Hashtable request = null; - try - { - lock (requests) - { - request = requests[0]; - requests.RemoveAt(0); - } - } - catch - { - return; - } - - UUID requestID = new UUID(request["RequestID"].ToString()); + UUID requestID = requestinfo.reqID; // If the avatar is gone, don't bother to get the texture + if (m_scene.GetScenePresence(Id) == null) { response = new Hashtable(); @@ -228,7 +231,7 @@ namespace OpenSim.Region.ClientStack.Linden return; } - response = m_getTextureHandler.Handle(request); + response = m_getTextureHandler.Handle(requestinfo.request); lock (responses) responses[requestID] = response; } @@ -275,11 +278,10 @@ namespace OpenSim.Region.ClientStack.Linden { while (true) { - PollServiceTextureEventArgs args = m_queue.Dequeue(); + aPollRequest poolreq = m_queue.Dequeue(); - args.Process(); + poolreq.thepoll.Process(poolreq); } } } - } -- cgit v1.1 From 4d681bfde617371bf14fb74da595887a33ec688b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Sep 2012 03:59:19 +0100 Subject: do the same to webFecthInvDescModule --- .../Linden/Caps/WebFetchInvDescModule.cs | 58 ++++++++++------------ 1 file changed, 25 insertions(+), 33 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index f76ea74..0f305b1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -52,6 +52,13 @@ namespace OpenSim.Region.ClientStack.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] public class WebFetchInvDescModule : INonSharedRegionModule { + struct aPollRequest + { + public PollServiceInventoryEventArgs thepoll; + public UUID reqID; + public Hashtable request; + } + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; @@ -64,8 +71,8 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_capsDict = new Dictionary(); private static Thread[] m_workerThreads = null; - private static OpenMetaverse.BlockingQueue m_queue = - new OpenMetaverse.BlockingQueue(); + private static OpenMetaverse.BlockingQueue m_queue = + new OpenMetaverse.BlockingQueue(); #region ISharedRegionModule Members @@ -131,18 +138,16 @@ namespace OpenSim.Region.ClientStack.Linden ~WebFetchInvDescModule() { foreach (Thread t in m_workerThreads) - t.Abort(); + Watchdog.AbortThread(t.ManagedThreadId); } private class PollServiceInventoryEventArgs : PollServiceEventArgs { - private List requests = - new List(); private Dictionary responses = new Dictionary(); public PollServiceInventoryEventArgs(UUID pId) : - base(null, null, null, null, pId, 30000) + base(null, null, null, null, pId, int.MaxValue) { HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; GetEvents = (x, y, s) => @@ -162,21 +167,23 @@ namespace OpenSim.Region.ClientStack.Linden Request = (x, y) => { - y["RequestID"] = x.ToString(); - lock (requests) - requests.Add(y); + aPollRequest reqinfo = new aPollRequest(); + reqinfo.thepoll = this; + reqinfo.reqID = x; + reqinfo.request = y; - m_queue.Enqueue(this); + m_queue.Enqueue(reqinfo); }; NoEvents = (x, y) => { +/* lock (requests) { Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); requests.Remove(request); } - +*/ Hashtable response = new Hashtable(); response["int_response_code"] = 500; @@ -189,24 +196,9 @@ namespace OpenSim.Region.ClientStack.Linden }; } - public void Process() + public void Process(aPollRequest requestinfo) { - Hashtable request = null; - - try - { - lock (requests) - { - request = requests[0]; - requests.RemoveAt(0); - } - } - catch - { - return; - } - - UUID requestID = new UUID(request["RequestID"].ToString()); + UUID requestID = requestinfo.reqID; Hashtable response = new Hashtable(); @@ -215,7 +207,8 @@ namespace OpenSim.Region.ClientStack.Linden response["keepalive"] = false; response["reusecontext"] = false; - response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest(request["body"].ToString(), String.Empty, String.Empty, null, null); + response["str_response_string"] = m_webFetchHandler.FetchInventoryDescendentsRequest( + requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null); lock (responses) responses[requestID] = response; @@ -226,8 +219,7 @@ namespace OpenSim.Region.ClientStack.Linden { string capUrl = "/CAPS/" + UUID.Random() + "/"; - // Register this as a poll service - // absurd large timeout to tune later to make a bit less than viewer + // Register this as a poll service PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); args.Type = PollServiceEventArgs.EventType.Inventory; @@ -263,9 +255,9 @@ namespace OpenSim.Region.ClientStack.Linden { while (true) { - PollServiceInventoryEventArgs args = m_queue.Dequeue(); + aPollRequest poolreq = m_queue.Dequeue(); - args.Process(); + poolreq.thepoll.Process(poolreq); } } } -- cgit v1.1 From ef3d44240ef0f4fe714ff0ea76a89be1e23fcb4e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 25 Sep 2012 04:03:15 +0100 Subject: missed change --- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 1ccddd2..b16076d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -189,12 +189,13 @@ namespace OpenSim.Region.ClientStack.Linden // this should never happen except possible on shutdown NoEvents = (x, y) => { +/* lock (requests) { Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString()); requests.Remove(request); } - +*/ Hashtable response = new Hashtable(); response["int_response_code"] = 500; -- cgit v1.1 From 5d986002fdb6d91426529f14344d7b2d133c6633 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 00:17:54 +0100 Subject: fix priorityQueue to correctly use the fairness counts starting at 8 for nonimediate queues. Imediate queues where not taken into account so it was unused. --- OpenSim/Framework/PriorityQueue.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/PriorityQueue.cs b/OpenSim/Framework/PriorityQueue.cs index e7a7f7f..e4f1111 100644 --- a/OpenSim/Framework/PriorityQueue.cs +++ b/OpenSim/Framework/PriorityQueue.cs @@ -45,7 +45,8 @@ namespace OpenSim.Framework /// /// Total number of queues (priorities) available /// - public const uint NumberOfQueues = 12; + + public const uint NumberOfQueues = 12; // includes immediate queues, m_queueCounts need to be set acording /// /// Number of queuest (priorities) that are processed immediately @@ -60,7 +61,8 @@ namespace OpenSim.Framework // each pass. weighted towards the higher priority queues private uint m_nextQueue = 0; private uint m_countFromQueue = 0; - private uint[] m_queueCounts = { 8, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 1 }; + // first queues are imediate, so no counts + private uint[] m_queueCounts = {0, 0, 8, 4, 4, 2, 2, 2, 2, 1, 1, 1}; // next request is a counter of the number of updates queued, it provides // a total ordering on the updates coming through the queue and is more @@ -137,7 +139,7 @@ namespace OpenSim.Framework /// public bool TryDequeue(out IEntityUpdate value, out Int32 timeinqueue) { - // If there is anything in priority queue 0, return it first no + // If there is anything in imediate queues, return it first no // matter what else. Breaks fairness. But very useful. for (int iq = 0; iq < NumberOfImmediateQueues; iq++) { @@ -172,14 +174,13 @@ namespace OpenSim.Framework } // Find the next non-immediate queue with updates in it - for (int i = 0; i < NumberOfQueues; ++i) + for (uint i = NumberOfImmediateQueues; i < NumberOfQueues; ++i) { - m_nextQueue = (uint)((m_nextQueue + 1) % NumberOfQueues); - m_countFromQueue = m_queueCounts[m_nextQueue]; + m_nextQueue++; + if(m_nextQueue >= NumberOfQueues) + m_nextQueue = NumberOfImmediateQueues; - // if this is one of the immediate queues, just skip it - if (m_nextQueue < NumberOfImmediateQueues) - continue; + m_countFromQueue = m_queueCounts[m_nextQueue]; if (m_heaps[m_nextQueue].Count > 0) { @@ -189,7 +190,6 @@ namespace OpenSim.Framework m_lookupTable.Remove(item.Value.Entity.LocalId); timeinqueue = Util.EnvironmentTickCountSubtract(item.EntryTime); value = item.Value; - return true; } } -- cgit v1.1 From 654dd289f263a4eef4f2aa70a1cb8d289ec7e04c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 03:05:27 +0100 Subject: more changes to PollService --- .../Servers/HttpServer/PollServiceEventArgs.cs | 1 + .../HttpServer/PollServiceRequestManager.cs | 41 +++++++++------------- .../ClientStack/Linden/Caps/GetTextureModule.cs | 7 +++- .../Linden/Caps/WebFetchInvDescModule.cs | 1 + 4 files changed, 25 insertions(+), 25 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index a80b1d7..9b27a6e 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -47,6 +47,7 @@ namespace OpenSim.Framework.Servers.HttpServer public UUID Id; public int TimeOutms; public EventType Type; + public bool GetEventsNeedsRequest = true; public enum EventType : int { diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index c13c65b..c234537 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -205,7 +205,7 @@ namespace OpenSim.Framework.Servers.HttpServer String.Format("PollServiceWorkerThread{0}", i), ThreadPriority.Normal, false, - true, + false, null, int.MaxValue); } @@ -344,35 +344,36 @@ namespace OpenSim.Framework.Servers.HttpServer { if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) { - try + string strreq = ""; + if (req.PollServiceArgs.GetEventsNeedsRequest) { - str = new StreamReader(req.Request.Body); + try + { + str = new StreamReader(req.Request.Body); + strreq = str.ReadToEnd(); + str.Close(); + } + catch + { + continue; + } } - catch (System.ArgumentException) - { - // Stream was not readable means a child agent - // was closed due to logout, leaving the - // Event Queue request orphaned. + + Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, strreq); + + if (responsedata == null) continue; - } - // "Normal" means the viewer evebt queue. We need to push these out fast. - // Process them inline. The rest go to the thread pool. if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Normal) { try { - Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); DoHTTPGruntWork(m_server, req, responsedata); } catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream { // Ignore it, no need to reply } - finally - { - str.Close(); - } } else { @@ -380,27 +381,19 @@ namespace OpenSim.Framework.Servers.HttpServer { try { - Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); DoHTTPGruntWork(m_server, req, responsedata); } catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream { // Ignore it, no need to reply } - finally - { - str.Close(); - } return null; }, null); } - } else { -// if ((Environment.TickCount - req.RequestTime) > m_timeout) - if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) { DoHTTPGruntWork(m_server, req, diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index b16076d..8a607fb 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -160,7 +160,11 @@ namespace OpenSim.Region.ClientStack.Linden { m_scene = scene; - HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; + HasEvents = (x, y) => + { + lock (responses) + return responses.ContainsKey(x); + }; GetEvents = (x, y, s) => { lock (responses) @@ -247,6 +251,7 @@ namespace OpenSim.Region.ClientStack.Linden PollServiceTextureEventArgs args = new PollServiceTextureEventArgs(agentID, m_scene); args.Type = PollServiceEventArgs.EventType.Texture; + args.GetEventsNeedsRequest = false; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); string hostName = m_scene.RegionInfo.ExternalHostName; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 0f305b1..56070c6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -223,6 +223,7 @@ namespace OpenSim.Region.ClientStack.Linden PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); args.Type = PollServiceEventArgs.EventType.Inventory; + args.GetEventsNeedsRequest = false; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); string hostName = m_scene.RegionInfo.ExternalHostName; -- cgit v1.1 From 67fa6577461bf1e2a39c501f73d8bfc9045ee69e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 04:52:19 +0100 Subject: keep watchdog happy using it to kill his threads --- .../Framework/Servers/HttpServer/PollServiceRequestManager.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index c234537..cc9ddc2 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -278,15 +278,7 @@ namespace OpenSim.Framework.Servers.HttpServer Thread.Sleep(1000); // let the world move foreach (Thread t in m_workerThreads) - { - try - { - t.Abort(); - } - catch - { - } - } + Watchdog.AbortThread(t.ManagedThreadId); try { -- cgit v1.1 From abb4b9fcae6f8091774325615a37e4e44351b9a6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 15:11:59 +0100 Subject: UriModule GetEvents also doesn't need a request body --- OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 13762f7..d4a4832 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -186,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; + args.GetEventsNeedsRequest = false; m_HttpServer.AddPollServiceHTTPHandler(uri, args); // m_log.DebugFormat( -- cgit v1.1 From 7e3eba1064197024690c5b3cae4c2cf87319e48c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 15:41:57 +0100 Subject: Seems nothing actually need the request body for getevents. so change control flag to false --- OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs | 10 ++++++++-- .../Servers/HttpServer/PollServiceRequestManager.cs | 3 ++- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 12 ++---------- .../Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 1 - OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 1 - 5 files changed, 12 insertions(+), 15 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index 9b27a6e..f85509a 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -46,8 +46,14 @@ namespace OpenSim.Framework.Servers.HttpServer public RequestMethod Request; public UUID Id; public int TimeOutms; - public EventType Type; - public bool GetEventsNeedsRequest = true; + public EventType Type; + // must be set true for cases where GetEvents needs to access the request body + // at each pool. http can start processing before having the full body + // but not sure if this is active for poll events + // if original coder thinked its needed i keep it + // if the Event has a Request method this seems to smoke for now + // seems for now nothing actually uses this so default to false + public bool GetEventsNeedsRequestBody = false; public enum EventType : int { diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index cc9ddc2..c379747 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -337,10 +337,11 @@ namespace OpenSim.Framework.Servers.HttpServer if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) { string strreq = ""; - if (req.PollServiceArgs.GetEventsNeedsRequest) + if (req.PollServiceArgs.GetEventsNeedsRequestBody) { try { + // should we try to seek back? fear we can't str = new StreamReader(req.Request.Body); strreq = str.ReadToEnd(); str.Close(); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 8a607fb..5169f65 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -151,12 +151,7 @@ namespace OpenSim.Region.ClientStack.Linden private Scene m_scene; public PollServiceTextureEventArgs(UUID pId, Scene scene) : - base(null, null, null, null, pId, int.MaxValue) - // this should never timeout - // each request must be processed and return a response - // noevents can possible be use for nice shutdown, but not sure now - // the execution will provide a proper response even if it fails - + base(null, null, null, null, pId, int.MaxValue) { m_scene = scene; @@ -219,7 +214,6 @@ namespace OpenSim.Region.ClientStack.Linden UUID requestID = requestinfo.reqID; // If the avatar is gone, don't bother to get the texture - if (m_scene.GetScenePresence(Id) == null) { response = new Hashtable(); @@ -246,12 +240,10 @@ namespace OpenSim.Region.ClientStack.Linden { string capUrl = "/CAPS/" + UUID.Random() + "/"; - // Register this as a poll service - // absurd large timeout to tune later to make a bit less than viewer + // Register this as a poll service PollServiceTextureEventArgs args = new PollServiceTextureEventArgs(agentID, m_scene); args.Type = PollServiceEventArgs.EventType.Texture; - args.GetEventsNeedsRequest = false; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); string hostName = m_scene.RegionInfo.ExternalHostName; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 56070c6..0f305b1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -223,7 +223,6 @@ namespace OpenSim.Region.ClientStack.Linden PollServiceInventoryEventArgs args = new PollServiceInventoryEventArgs(agentID); args.Type = PollServiceEventArgs.EventType.Inventory; - args.GetEventsNeedsRequest = false; MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args); string hostName = m_scene.RegionInfo.ExternalHostName; diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index d4a4832..13762f7 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -186,7 +186,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000); args.Type = PollServiceEventArgs.EventType.LslHttp; - args.GetEventsNeedsRequest = false; m_HttpServer.AddPollServiceHTTPHandler(uri, args); // m_log.DebugFormat( -- cgit v1.1 From 617f1b9223375a2dda925e26c395901810d37697 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 16:17:49 +0100 Subject: just remove the damm thing --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 1 + .../Servers/HttpServer/PollServiceEventArgs.cs | 9 +-------- .../Servers/HttpServer/PollServiceRequestManager.cs | 18 +----------------- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- .../Region/ClientStack/Linden/Caps/GetTextureModule.cs | 2 +- .../ClientStack/Linden/Caps/WebFetchInvDescModule.cs | 2 +- .../Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 2 +- 7 files changed, 7 insertions(+), 29 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 2582b7b..788a0b9 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -317,6 +317,7 @@ namespace OpenSim.Framework.Servers.HttpServer StreamReader reader = new StreamReader(requestStream, encoding); string requestBody = reader.ReadToEnd(); + reader.Close(); Hashtable keysvals = new Hashtable(); Hashtable headervals = new Hashtable(); diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs index f85509a..d0a37d0 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs @@ -34,7 +34,7 @@ namespace OpenSim.Framework.Servers.HttpServer public delegate void RequestMethod(UUID requestID, Hashtable request); public delegate bool HasEventsMethod(UUID requestID, UUID pId); - public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId, string request); + public delegate Hashtable GetEventsMethod(UUID requestID, UUID pId); public delegate Hashtable NoEventsMethod(UUID requestID, UUID pId); @@ -47,13 +47,6 @@ namespace OpenSim.Framework.Servers.HttpServer public UUID Id; public int TimeOutms; public EventType Type; - // must be set true for cases where GetEvents needs to access the request body - // at each pool. http can start processing before having the full body - // but not sure if this is active for poll events - // if original coder thinked its needed i keep it - // if the Event has a Request method this seems to smoke for now - // seems for now nothing actually uses this so default to false - public bool GetEventsNeedsRequestBody = false; public enum EventType : int { diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index c379747..c09bf14 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -336,23 +336,7 @@ namespace OpenSim.Framework.Servers.HttpServer { if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id)) { - string strreq = ""; - if (req.PollServiceArgs.GetEventsNeedsRequestBody) - { - try - { - // should we try to seek back? fear we can't - str = new StreamReader(req.Request.Body); - strreq = str.ReadToEnd(); - str.Close(); - } - catch - { - continue; - } - } - - Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, strreq); + Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id); if (responsedata == null) continue; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index ebfe687..e113c60 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -419,7 +419,7 @@ namespace OpenSim.Region.ClientStack.Linden } } - public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) + public Hashtable GetEvents(UUID requestID, UUID pAgentId) { if (DebugLevel >= 2) m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 5169f65..cc65981 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -160,7 +160,7 @@ namespace OpenSim.Region.ClientStack.Linden lock (responses) return responses.ContainsKey(x); }; - GetEvents = (x, y, s) => + GetEvents = (x, y) => { lock (responses) { diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 0f305b1..0caeddf 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs @@ -150,7 +150,7 @@ namespace OpenSim.Region.ClientStack.Linden base(null, null, null, null, pId, int.MaxValue) { HasEvents = (x, y) => { lock (responses) return responses.ContainsKey(x); }; - GetEvents = (x, y, s) => + GetEvents = (x, y) => { lock (responses) { diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 13762f7..56221aa 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -444,7 +444,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } } } - private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) + private Hashtable GetEvents(UUID requestID, UUID sessionID) { UrlData url = null; RequestData requestData = null; -- cgit v1.1 From be9cef8682cddf9589976f543e98e886d16098a1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 16:20:26 +0100 Subject: missing file --- OpenSim/Framework/Console/RemoteConsole.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index 50eb173..3e3c2b3 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -425,7 +425,7 @@ namespace OpenSim.Framework.Console return false; } - private Hashtable GetEvents(UUID RequestID, UUID sessionID, string request) + private Hashtable GetEvents(UUID RequestID, UUID sessionID) { ConsoleConnection c = null; -- cgit v1.1 From 9a042696440e7dd9502f78b80ae8441642912dd3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 16:49:39 +0100 Subject: fix GetTextureHandler range --- OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 4e755aa..0df16d6 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -187,7 +187,11 @@ namespace OpenSim.Capabilities.Handlers response["headers"] = headers; string range = String.Empty; - if (((Hashtable)request["headers"])["Range"] != null) + + if (((Hashtable)request["headers"])["range"] != null) + range = (string)((Hashtable)request["headers"])["range"]; + + else if (((Hashtable)request["headers"])["Range"] != null) range = (string)((Hashtable)request["headers"])["Range"]; if (!String.IsNullOrEmpty(range)) // JP2's only -- cgit v1.1 From c3ea00f16e8582ec547f4fb927119a1e5f1b16f3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 20:31:34 +0100 Subject: add assettype mesh to list of binary assets --- OpenSim/Framework/AssetBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index ff240be..5da8e11 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -150,7 +150,8 @@ namespace OpenSim.Framework Type == (sbyte)AssetType.SnapshotFolder || Type == (sbyte)AssetType.TrashFolder || Type == (sbyte)AssetType.ImageJPEG || - Type == (sbyte) AssetType.ImageTGA || + Type == (sbyte)AssetType.ImageTGA || + Type == (sbyte)AssetType.Mesh || Type == (sbyte) AssetType.LSLBytecode); } } -- cgit v1.1 From a70352db17a26eb01fea30eb6a7d6159d52a4916 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 26 Sep 2012 21:03:31 +0100 Subject: don't send a partial contents report if we are sending all data --- .../Handlers/GetTexture/GetTextureHandler.cs | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs index 0df16d6..b3a4d61 100644 --- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs +++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs @@ -217,17 +217,22 @@ namespace OpenSim.Capabilities.Handlers //m_log.Debug("Serving " + start + " to " + end + " of " + texture.Data.Length + " bytes for texture " + texture.ID); - // Always return PartialContent, even if the range covered the entire data length - // We were accidentally sending back 404 before in this situation - // https://issues.apache.org/bugzilla/show_bug.cgi?id=51878 supports sending 206 even if the - // entire range is requested, and viewer 3.2.2 (and very probably earlier) seems fine with this. - response["int_response_code"] = (int)System.Net.HttpStatusCode.PartialContent; response["content-type"] = texture.Metadata.ContentType; - headers["Content-Range"] = String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length); - - byte[] d = new byte[len]; - Array.Copy(texture.Data, start, d, 0, len); - response["bin_response_data"] = d; + + if (start == 0 && len == texture.Data.Length) // well redudante maybe + { + response["int_response_code"] = (int)System.Net.HttpStatusCode.OK; + response["bin_response_data"] = texture.Data; + } + else + { + response["int_response_code"] = (int)System.Net.HttpStatusCode.PartialContent; + headers["Content-Range"] = String.Format("bytes {0}-{1}/{2}", start, end, texture.Data.Length); + + byte[] d = new byte[len]; + Array.Copy(texture.Data, start, d, 0, len); + response["bin_response_data"] = d; + } // response.Body.Write(texture.Data, start, len); } } -- cgit v1.1 From 2998a2df6a6c56f52d56d85bcec869e4a76ad169 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 26 Sep 2012 22:30:09 +0200 Subject: Streamline and improve llGetMass --- .../Shared/Api/Implementation/LSL_Api.cs | 40 +++++++++------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index f9b4bfd..05aaebf 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10599,31 +10599,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID key = new UUID(); if (UUID.TryParse(id, out key)) { - try - { - /* - SceneObjectPart obj = World.GetSceneObjectPart(World.Entities[key].LocalId); - if (obj != null) - return (double)obj.GetMass(); - */ - // return total object mass - SceneObjectGroup obj = World.GetGroupByPrim(World.Entities[key].LocalId); - if (obj != null) - return obj.GetMass(); + // return total object mass + SceneObjectPart part = World.GetSceneObjectPart(key); + if (part != null) + return part.ParentGroup.GetMass(); - // the object is null so the key is for an avatar - ScenePresence avatar = World.GetScenePresence(key); - if (avatar != null) - if (avatar.IsChildAgent) - // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass - // child agents have a mass of 1.0 - return 1; - else - return (double)avatar.GetMass(); - } - catch (KeyNotFoundException) + // the object is null so the key is for an avatar + ScenePresence avatar = World.GetScenePresence(key); + if (avatar != null) { - return 0; // The Object/Agent not in the region so just return zero + if (avatar.IsChildAgent) + { + // reference http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetObjectMass + // child agents have a mass of 1.0 + return 1; + } + else + { + return (double)avatar.GetMass(); + } } } return 0; -- cgit v1.1 From a0065ad61611b1a078116327f826b109bd90dba4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 27 Sep 2012 00:14:50 +0100 Subject: create a new PollServiceHttpRequest req per loop since they can be sent to another working thread --- OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index c09bf14..4be8bf4 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -321,13 +321,9 @@ namespace OpenSim.Framework.Servers.HttpServer private void PoolWorkerJob() { - PollServiceHttpRequest req; - StreamReader str; - -// while (true) while (m_running) { - req = m_requests.Dequeue(5000); + PollServiceHttpRequest req = m_requests.Dequeue(5000); Watchdog.UpdateThread(); if (req != null) -- cgit v1.1