diff options
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 81 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 17 |
2 files changed, 82 insertions, 16 deletions
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 | |||
117 | private bool m_dumpAssetsToFile = false; | 117 | private bool m_dumpAssetsToFile = false; |
118 | private string m_regionName; | 118 | private string m_regionName; |
119 | private int m_levelUpload = 0; | 119 | private int m_levelUpload = 0; |
120 | private float m_PrimScaleMin = 0.001f; | ||
121 | |||
122 | private enum FileAgentInventoryState : int | ||
123 | { | ||
124 | idle = 0, | ||
125 | processRequest = 1, | ||
126 | waitUpload = 2, | ||
127 | processUpload = 3 | ||
128 | } | ||
129 | private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; | ||
130 | |||
120 | // private bool m_addNewTextures = false; | 131 | // private bool m_addNewTextures = false; |
121 | // private bool m_addNewMeshes = false; | 132 | // private bool m_addNewMeshes = false; |
122 | 133 | ||
@@ -132,6 +143,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
132 | m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys; | 143 | m_ModelCost.PhysicalPrimScaleMax = m_Scene.m_maxPhys; |
133 | // m_ModelCost.PrimScaleMin = ?? | 144 | // m_ModelCost.PrimScaleMin = ?? |
134 | // m_ModelCost.ObjectLinkedPartsMax = ?? | 145 | // m_ModelCost.ObjectLinkedPartsMax = ?? |
146 | // m_PrimScaleMin = ?? | ||
135 | 147 | ||
136 | IConfigSource config = m_Scene.Config; | 148 | IConfigSource config = m_Scene.Config; |
137 | if (config != null) | 149 | if (config != null) |
@@ -158,6 +170,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
158 | ItemUpdatedCall = m_Scene.CapsUpdateInventoryItemAsset; | 170 | ItemUpdatedCall = m_Scene.CapsUpdateInventoryItemAsset; |
159 | TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset; | 171 | TaskScriptUpdatedCall = m_Scene.CapsUpdateTaskInventoryScriptAsset; |
160 | GetClient = m_Scene.SceneGraph.GetControllingClient; | 172 | GetClient = m_Scene.SceneGraph.GetControllingClient; |
173 | |||
174 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | ||
161 | } | 175 | } |
162 | 176 | ||
163 | /// <summary> | 177 | /// <summary> |
@@ -224,9 +238,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
224 | IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); | 238 | IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); |
225 | m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); | 239 | m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); |
226 | IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); | 240 | IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); |
227 | m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); | 241 | m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); |
228 | |||
229 | |||
230 | 242 | ||
231 | m_HostCapsObj.RegisterHandler( | 243 | m_HostCapsObj.RegisterHandler( |
232 | "CopyInventoryFromNotecard", | 244 | "CopyInventoryFromNotecard", |
@@ -439,6 +451,35 @@ namespace OpenSim.Region.ClientStack.Linden | |||
439 | //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); | 451 | //m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString()); |
440 | //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); | 452 | //m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type); |
441 | 453 | ||
454 | // start by getting the client | ||
455 | IClientAPI client = null; | ||
456 | m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); | ||
457 | |||
458 | // check current state so we only have one service at a time | ||
459 | lock (m_ModelCost) | ||
460 | { | ||
461 | switch (m_FileAgentInventoryState) | ||
462 | { | ||
463 | case FileAgentInventoryState.processRequest: | ||
464 | case FileAgentInventoryState.processUpload: | ||
465 | if (client != null) | ||
466 | client.SendAgentAlertMessage("Unable to upload asset. Processing previus request", false); | ||
467 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | ||
468 | errorResponse.uploader = ""; | ||
469 | errorResponse.state = "error"; | ||
470 | return errorResponse; | ||
471 | break; | ||
472 | case FileAgentInventoryState.waitUpload: | ||
473 | // todo stop current uploader server | ||
474 | break; | ||
475 | case FileAgentInventoryState.idle: | ||
476 | default: | ||
477 | break; | ||
478 | } | ||
479 | |||
480 | m_FileAgentInventoryState = FileAgentInventoryState.processRequest; | ||
481 | } | ||
482 | |||
442 | uint cost = 0; | 483 | uint cost = 0; |
443 | LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); | 484 | LLSDAssetUploadResponseData meshcostdata = new LLSDAssetUploadResponseData(); |
444 | 485 | ||
@@ -447,15 +488,12 @@ namespace OpenSim.Region.ClientStack.Linden | |||
447 | llsdRequest.asset_type == "mesh" || | 488 | llsdRequest.asset_type == "mesh" || |
448 | llsdRequest.asset_type == "sound") | 489 | llsdRequest.asset_type == "sound") |
449 | { | 490 | { |
450 | ScenePresence avatar = null; | 491 | ScenePresence avatar = null; |
451 | IClientAPI client = null; | ||
452 | m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); | 492 | m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar); |
453 | 493 | ||
454 | // check user level | 494 | // check user level |
455 | if (avatar != null) | 495 | if (avatar != null) |
456 | { | 496 | { |
457 | client = avatar.ControllingClient; | ||
458 | |||
459 | if (avatar.UserLevel < m_levelUpload) | 497 | if (avatar.UserLevel < m_levelUpload) |
460 | { | 498 | { |
461 | if (client != null) | 499 | if (client != null) |
@@ -464,6 +502,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
464 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | 502 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); |
465 | errorResponse.uploader = ""; | 503 | errorResponse.uploader = ""; |
466 | errorResponse.state = "error"; | 504 | errorResponse.state = "error"; |
505 | lock (m_ModelCost) | ||
506 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | ||
467 | return errorResponse; | 507 | return errorResponse; |
468 | } | 508 | } |
469 | } | 509 | } |
@@ -490,6 +530,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
490 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | 530 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); |
491 | errorResponse.uploader = ""; | 531 | errorResponse.uploader = ""; |
492 | errorResponse.state = "error"; | 532 | errorResponse.state = "error"; |
533 | lock (m_ModelCost) | ||
534 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | ||
493 | return errorResponse; | 535 | return errorResponse; |
494 | } | 536 | } |
495 | cost = (uint)modelcost; | 537 | cost = (uint)modelcost; |
@@ -509,6 +551,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
509 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); | 551 | LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); |
510 | errorResponse.uploader = ""; | 552 | errorResponse.uploader = ""; |
511 | errorResponse.state = "error"; | 553 | errorResponse.state = "error"; |
554 | lock (m_ModelCost) | ||
555 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | ||
512 | return errorResponse; | 556 | return errorResponse; |
513 | } | 557 | } |
514 | } | 558 | } |
@@ -555,8 +599,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
555 | } | 599 | } |
556 | 600 | ||
557 | uploader.OnUpLoad += UploadCompleteHandler; | 601 | uploader.OnUpLoad += UploadCompleteHandler; |
558 | return uploadResponse; | ||
559 | 602 | ||
603 | lock (m_ModelCost) | ||
604 | m_FileAgentInventoryState = FileAgentInventoryState.waitUpload; | ||
605 | |||
606 | return uploadResponse; | ||
560 | } | 607 | } |
561 | 608 | ||
562 | /// <summary> | 609 | /// <summary> |
@@ -569,6 +616,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
569 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | 616 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, |
570 | string assetType, uint cost) | 617 | string assetType, uint cost) |
571 | { | 618 | { |
619 | lock (m_ModelCost) | ||
620 | m_FileAgentInventoryState = FileAgentInventoryState.processUpload; | ||
621 | |||
572 | m_log.DebugFormat( | 622 | m_log.DebugFormat( |
573 | "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", | 623 | "[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}", |
574 | assetID, inventoryItem, inventoryType, assetType); | 624 | assetID, inventoryItem, inventoryType, assetType); |
@@ -730,12 +780,19 @@ namespace OpenSim.Region.ClientStack.Linden | |||
730 | // build prims from instances | 780 | // build prims from instances |
731 | for (int i = 0; i < instance_list.Count; i++) | 781 | for (int i = 0; i < instance_list.Count; i++) |
732 | { | 782 | { |
783 | OSDMap inner_instance_list = (OSDMap)instance_list[i]; | ||
784 | |||
785 | // skip prims that are 2 small | ||
786 | Vector3 scale = inner_instance_list["scale"].AsVector3(); | ||
787 | |||
788 | if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) | ||
789 | continue; | ||
790 | |||
733 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); | 791 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); |
734 | 792 | ||
735 | Primitive.TextureEntry textureEntry | 793 | Primitive.TextureEntry textureEntry |
736 | = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); | 794 | = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); |
737 | 795 | ||
738 | OSDMap inner_instance_list = (OSDMap)instance_list[i]; | ||
739 | 796 | ||
740 | OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; | 797 | OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; |
741 | for (uint face = 0; face < face_list.Count; face++) | 798 | for (uint face = 0; face < face_list.Count; face++) |
@@ -789,7 +846,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
789 | } | 846 | } |
790 | 847 | ||
791 | Vector3 position = inner_instance_list["position"].AsVector3(); | 848 | Vector3 position = inner_instance_list["position"].AsVector3(); |
792 | Vector3 scale = inner_instance_list["scale"].AsVector3(); | ||
793 | Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); | 849 | Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); |
794 | 850 | ||
795 | // no longer used - begin ------------------------ | 851 | // no longer used - begin ------------------------ |
@@ -903,6 +959,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
903 | { | 959 | { |
904 | AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); | 960 | AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost); |
905 | } | 961 | } |
962 | lock (m_ModelCost) | ||
963 | m_FileAgentInventoryState = FileAgentInventoryState.idle; | ||
906 | } | 964 | } |
907 | 965 | ||
908 | /// <summary> | 966 | /// <summary> |
@@ -1270,8 +1328,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1270 | 1328 | ||
1271 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); | 1329 | res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); |
1272 | 1330 | ||
1273 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
1274 | m_timeoutTimer.Stop(); | 1331 | m_timeoutTimer.Stop(); |
1332 | httpListener.RemoveStreamHandler("POST", uploaderPath); | ||
1275 | 1333 | ||
1276 | // TODO: probably make this a better set of extensions here | 1334 | // TODO: probably make this a better set of extensions here |
1277 | string extension = ".jp2"; | 1335 | string extension = ".jp2"; |
@@ -1289,7 +1347,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1289 | { | 1347 | { |
1290 | handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); | 1348 | handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType); |
1291 | } | 1349 | } |
1292 | |||
1293 | return res; | 1350 | return res; |
1294 | } | 1351 | } |
1295 | 1352 | ||
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 | |||
73 | const int bytesPerCoord = 6; // 3 coords, 2 bytes per each | 73 | const int bytesPerCoord = 6; // 3 coords, 2 bytes per each |
74 | 74 | ||
75 | // control prims dimensions | 75 | // control prims dimensions |
76 | public float PrimScaleMin = 0.01f; | 76 | public float PrimScaleMin = 0.001f; |
77 | public float NonPhysicalPrimScaleMax = 256f; | 77 | public float NonPhysicalPrimScaleMax = 256f; |
78 | public float PhysicalPrimScaleMax = 10f; | 78 | public float PhysicalPrimScaleMax = 10f; |
79 | public int ObjectLinkedPartsMax = 512; | 79 | public int ObjectLinkedPartsMax = 512; |
@@ -171,6 +171,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
171 | 171 | ||
172 | 172 | ||
173 | int mesh; | 173 | int mesh; |
174 | int skipedSmall = 0; | ||
174 | for (int i = 0; i < numberInstances; i++) | 175 | for (int i = 0; i < numberInstances; i++) |
175 | { | 176 | { |
176 | Hashtable inst = (Hashtable)resources.instance_list.Array[i]; | 177 | Hashtable inst = (Hashtable)resources.instance_list.Array[i]; |
@@ -187,8 +188,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
187 | 188 | ||
188 | if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) | 189 | if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) |
189 | { | 190 | { |
190 | error = " upload fail: Model contains parts with a dimension lower than 0.01. Please adjust scaling"; | 191 | // error = " upload fail: Model contains parts with a dimension lower than 0.001. Please adjust scaling"; |
191 | return false; | 192 | // return false; |
193 | skipedSmall++; | ||
194 | continue; | ||
192 | } | 195 | } |
193 | 196 | ||
194 | if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) | 197 | if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) |
@@ -229,7 +232,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
229 | // charge for prims creation | 232 | // charge for prims creation |
230 | meshsfee += primCreationCost; | 233 | meshsfee += primCreationCost; |
231 | } | 234 | } |
232 | 235 | ||
236 | if (skipedSmall >0 && skipedSmall > numberInstances / 2) | ||
237 | { | ||
238 | error = "Upload failed: Model contains too much prims smaller than minimum size to ignore"; | ||
239 | return false; | ||
240 | } | ||
241 | |||
233 | if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) | 242 | if (meshcostdata.physics_cost <= meshcostdata.model_streaming_cost) |
234 | meshcostdata.resource_cost = meshcostdata.model_streaming_cost; | 243 | meshcostdata.resource_cost = meshcostdata.model_streaming_cost; |
235 | else | 244 | else |