aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorubit2012-09-18 02:17:16 +0200
committerubit2012-09-18 02:17:16 +0200
commite9af09084c1b970c06066b6e275c75412281ff69 (patch)
treeb2f83ce26048f0e77f749ba291cec8c988470f09
parentMerge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork (diff)
parent***TEST*** still bad... create inventory itens for model textures and meshs.... (diff)
downloadopensim-SC-e9af09084c1b970c06066b6e275c75412281ff69.zip
opensim-SC-e9af09084c1b970c06066b6e275c75412281ff69.tar.gz
opensim-SC-e9af09084c1b970c06066b6e275c75412281ff69.tar.bz2
opensim-SC-e9af09084c1b970c06066b6e275c75412281ff69.tar.xz
Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs130
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs79
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs23
3 files changed, 169 insertions, 63 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index ddb69c4..3789ee9 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
489 cost = (uint)baseCost; 489 cost = (uint)baseCost;
490 } 490 }
491 491
492 // check funds
492 if (mm != null) 493 if (mm != null)
493 { 494 {
494 if (!mm.UploadCovered(client.AgentId, (int)cost)) 495 if (!mm.UploadCovered(client.AgentId, (int)cost))
@@ -565,26 +566,41 @@ namespace OpenSim.Region.ClientStack.Linden
565 sbyte assType = 0; 566 sbyte assType = 0;
566 sbyte inType = 0; 567 sbyte inType = 0;
567 568
569 IClientAPI client = null;
570
571 IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>();
572 if (mm != null)
573 {
574 // make sure client still has enougth credit
575 if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost))
576 {
577 m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client);
578 if (client != null)
579 client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
580 return;
581 }
582 }
583
568 if (inventoryType == "sound") 584 if (inventoryType == "sound")
569 { 585 {
570 inType = 1; 586 inType = (sbyte)InventoryType.Sound;
571 assType = 1; 587 assType = (sbyte)AssetType.Sound;
572 } 588 }
573 else if (inventoryType == "animation") 589 else if (inventoryType == "animation")
574 { 590 {
575 inType = 19; 591 inType = (sbyte)InventoryType.Animation;
576 assType = 20; 592 assType = (sbyte)AssetType.Animation;
577 } 593 }
578 else if (inventoryType == "wearable") 594 else if (inventoryType == "wearable")
579 { 595 {
580 inType = 18; 596 inType = (sbyte)InventoryType.Wearable;
581 switch (assetType) 597 switch (assetType)
582 { 598 {
583 case "bodypart": 599 case "bodypart":
584 assType = 13; 600 assType = (sbyte)AssetType.Bodypart;
585 break; 601 break;
586 case "clothing": 602 case "clothing":
587 assType = 5; 603 assType = (sbyte)AssetType.Clothing;
588 break; 604 break;
589 } 605 }
590 } 606 }
@@ -601,6 +617,7 @@ namespace OpenSim.Region.ClientStack.Linden
601 OSDArray texture_list = (OSDArray)request["texture_list"]; 617 OSDArray texture_list = (OSDArray)request["texture_list"];
602 SceneObjectGroup grp = null; 618 SceneObjectGroup grp = null;
603 619
620 // create and store texture assets
604 List<UUID> textures = new List<UUID>(); 621 List<UUID> textures = new List<UUID>();
605 for (int i = 0; i < texture_list.Count; i++) 622 for (int i = 0; i < texture_list.Count; i++)
606 { 623 {
@@ -608,14 +625,97 @@ namespace OpenSim.Region.ClientStack.Linden
608 textureAsset.Data = texture_list[i].AsBinary(); 625 textureAsset.Data = texture_list[i].AsBinary();
609 m_assetService.Store(textureAsset); 626 m_assetService.Store(textureAsset);
610 textures.Add(textureAsset.FullID); 627 textures.Add(textureAsset.FullID);
628
629 // save it to inventory
630 if (AddNewInventoryItem != null)
631 {
632 string name = assetName;
633 if (name.Length > 25)
634 name = name.Substring(0, 24);
635 name += "_Texture#" + i.ToString();
636 InventoryItemBase texitem = new InventoryItemBase();
637 texitem.Owner = m_HostCapsObj.AgentID;
638 texitem.CreatorId = m_HostCapsObj.AgentID.ToString();
639 texitem.CreatorData = String.Empty;
640 texitem.ID = UUID.Random();
641 texitem.AssetID = textureAsset.FullID;
642 texitem.Description = "mesh model texture";
643 texitem.Name = name;
644 texitem.AssetType = (int)AssetType.Texture;
645 texitem.InvType = (int)InventoryType.Texture;
646 texitem.Folder = UUID.Zero; // send to default
647
648 // If we set PermissionMask.All then when we rez the item the next permissions will replace the current
649 // (owner) permissions. This becomes a problem if next permissions are changed.
650 texitem.CurrentPermissions
651 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
652
653 texitem.BasePermissions = (uint)PermissionMask.All;
654 texitem.EveryOnePermissions = 0;
655 texitem.NextPermissions = (uint)PermissionMask.All;
656 texitem.CreationDate = Util.UnixTimeSinceEpoch();
657
658 AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0);
659 texitem = null;
660 }
661
662 textureAsset = null;
663
611 } 664 }
612 665
666 // create and store meshs assets
667 List<UUID> meshAssets = new List<UUID>();
613 for (int i = 0; i < mesh_list.Count; i++) 668 for (int i = 0; i < mesh_list.Count; i++)
614 { 669 {
670 AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, "");
671 meshAsset.Data = mesh_list[i].AsBinary();
672 m_assetService.Store(meshAsset);
673 meshAssets.Add(meshAsset.FullID);
674
675 // save it to inventory
676 if (AddNewInventoryItem != null)
677 {
678 string name = assetName;
679 if (name.Length > 25)
680 name = name.Substring(0, 24);
681 name += "_Mesh#" + i.ToString();
682 InventoryItemBase meshitem = new InventoryItemBase();
683 meshitem.Owner = m_HostCapsObj.AgentID;
684 meshitem.CreatorId = m_HostCapsObj.AgentID.ToString();
685 meshitem.CreatorData = String.Empty;
686 meshitem.ID = UUID.Random();
687 meshitem.AssetID = meshAsset.FullID;
688 meshitem.Description = "mesh ";
689 meshitem.Name = name;
690 meshitem.AssetType = (int)AssetType.Mesh;
691 meshitem.InvType = (int)InventoryType.Mesh;
692 meshitem.Folder = UUID.Zero; // send to default
693
694 // If we set PermissionMask.All then when we rez the item the next permissions will replace the current
695 // (owner) permissions. This becomes a problem if next permissions are changed.
696 meshitem.CurrentPermissions
697 = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
698
699 meshitem.BasePermissions = (uint)PermissionMask.All;
700 meshitem.EveryOnePermissions = 0;
701 meshitem.NextPermissions = (uint)PermissionMask.All;
702 meshitem.CreationDate = Util.UnixTimeSinceEpoch();
703
704 AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0);
705 meshitem = null;
706 }
707
708 meshAsset = null;
709 }
710
711 // build prims from instances
712 for (int i = 0; i < instance_list.Count; i++)
713 {
615 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); 714 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
616 715
617 Primitive.TextureEntry textureEntry 716 Primitive.TextureEntry textureEntry
618 = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE); 717 = new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
718
619 OSDMap inner_instance_list = (OSDMap)instance_list[i]; 719 OSDMap inner_instance_list = (OSDMap)instance_list[i];
620 720
621 OSDArray face_list = (OSDArray)inner_instance_list["face_list"]; 721 OSDArray face_list = (OSDArray)inner_instance_list["face_list"];
@@ -660,14 +760,14 @@ namespace OpenSim.Region.ClientStack.Linden
660 760
661 pbs.TextureEntry = textureEntry.GetBytes(); 761 pbs.TextureEntry = textureEntry.GetBytes();
662 762
663 AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, ""); 763 int meshindx = inner_instance_list["mesh"].AsInteger();
664 meshAsset.Data = mesh_list[i].AsBinary(); 764 if (meshAssets.Count > meshindx)
665 m_assetService.Store(meshAsset); 765 {
666 766 pbs.SculptEntry = true;
667 pbs.SculptEntry = true; 767 pbs.SculptType = (byte)SculptType.Mesh;
668 pbs.SculptTexture = meshAsset.FullID; 768 pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction
669 pbs.SculptType = (byte)SculptType.Mesh; 769 // data will be requested from asset on rez (i hope)
670 pbs.SculptData = meshAsset.Data; 770 }
671 771
672 Vector3 position = inner_instance_list["position"].AsVector3(); 772 Vector3 position = inner_instance_list["position"].AsVector3();
673 Vector3 scale = inner_instance_list["scale"].AsVector3(); 773 Vector3 scale = inner_instance_list["scale"].AsVector3();
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
42 const float physMeshSizeWth = 6f; // counts 7x 42 const float physMeshSizeWth = 6f; // counts 7x
43 const float physHullSizeWth = 8f; // counts 9x 43 const float physHullSizeWth = 8f; // counts 9x
44 44
45 // stream cost size factors 45 // stream cost area factors
46 const float highLodFactor = 17.36f; 46 const float highLodFactor = 17.36f;
47 const float midLodFactor = 277.78f; 47 const float midLodFactor = 277.78f;
48 const float lowLodFactor = 1111.11f; 48 const float lowLodFactor = 1111.11f;
@@ -94,13 +94,12 @@ namespace OpenSim.Region.ClientStack.Linden
94 totalcost += textures_cost; 94 totalcost += textures_cost;
95 } 95 }
96 96
97 float meshsfee = 0;
98
99 // meshs assets cost 97 // meshs assets cost
100 98 float meshsfee = 0;
101 int numberMeshs = 0; 99 int numberMeshs = 0;
100 bool haveMeshs = false;
102 List<ameshCostParam> meshsCosts = new List<ameshCostParam>(); 101 List<ameshCostParam> meshsCosts = new List<ameshCostParam>();
103 // a model could have no mesh actually 102
104 if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0) 103 if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0)
105 { 104 {
106 numberMeshs = resources.mesh_list.Array.Count; 105 numberMeshs = resources.mesh_list.Array.Count;
@@ -117,6 +116,7 @@ namespace OpenSim.Region.ClientStack.Linden
117 meshsCosts.Add(curCost); 116 meshsCosts.Add(curCost);
118 meshsfee += curCost.costFee; 117 meshsfee += curCost.costFee;
119 } 118 }
119 haveMeshs = true;
120 } 120 }
121 121
122 // instances (prims) cost 122 // instances (prims) cost
@@ -126,44 +126,43 @@ namespace OpenSim.Region.ClientStack.Linden
126 { 126 {
127 Hashtable inst = (Hashtable)resources.instance_list.Array[i]; 127 Hashtable inst = (Hashtable)resources.instance_list.Array[i];
128 128
129 // streamming cost 129 if (haveMeshs && inst.ContainsKey("mesh"))
130 // assume all instances have a mesh
131 // but in general they can have normal prims
132 // but for now that seems not suported
133 // when they do, we will need to inspect pbs information
134 // and have cost funtions for all prims types
135 // don't check for shape type none, since
136 // that could be used to upload meshs with low cost
137 // changing later inworld
138
139 ArrayList ascale = (ArrayList)inst["scale"];
140 Vector3 scale;
141 double tmp;
142 tmp = (double)ascale[0];
143 scale.X = (float)tmp;
144 tmp = (double)ascale[1];
145 scale.Y = (float)tmp;
146 tmp = (double)ascale[2];
147 scale.Z = (float)tmp;
148
149 float sqdiam = scale.LengthSquared();
150
151 mesh = (int)inst["mesh"];
152
153 if(mesh >= numberMeshs)
154 { 130 {
155 error = "Unable to upload mesh model. incoerent information."; 131 mesh = (int)inst["mesh"];
156 return false;
157 }
158 132
159 ameshCostParam curCost = meshsCosts[mesh]; 133 if (mesh >= numberMeshs)
160 float mesh_streaming = streamingCost(curCost, sqdiam); 134 {
135 error = "Unable to upload mesh model. incoerent information.";
136 return false;
137 }
138
139 // streamming cost
140 ArrayList ascale = (ArrayList)inst["scale"];
141 Vector3 scale;
142 double tmp;
143 tmp = (double)ascale[0];
144 scale.X = (float)tmp;
145 tmp = (double)ascale[1];
146 scale.Y = (float)tmp;
147 tmp = (double)ascale[2];
148 scale.Z = (float)tmp;
161 149
162 meshcostdata.model_streaming_cost += mesh_streaming; 150 float sqdiam = scale.LengthSquared();
163 151
164 meshcostdata.physics_cost += curCost.physicsCost; 152 ameshCostParam curCost = meshsCosts[mesh];
153 float mesh_streaming = streamingCost(curCost, sqdiam);
154
155 meshcostdata.model_streaming_cost += mesh_streaming;
156 meshcostdata.physics_cost += curCost.physicsCost;
157 }
158 else // instance as no mesh ??
159 {
160 // to do later if needed
161 meshcostdata.model_streaming_cost += 0.5f;
162 meshcostdata.physics_cost += 1.0f;
163 }
165 164
166 // unscripted and static prim server cost 165 // assume unscripted and static prim server cost
167 meshcostdata.simulation_cost += 0.5f; 166 meshcostdata.simulation_cost += 0.5f;
168 // charge for prims creation 167 // charge for prims creation
169 meshsfee += primCreationCost; 168 meshsfee += primCreationCost;
@@ -174,6 +173,10 @@ namespace OpenSim.Region.ClientStack.Linden
174 else 173 else
175 meshcostdata.resource_cost = meshcostdata.physics_cost; 174 meshcostdata.resource_cost = meshcostdata.physics_cost;
176 175
176 if (meshcostdata.resource_cost < meshcostdata.simulation_cost)
177 meshcostdata.resource_cost = meshcostdata.simulation_cost;
178
179
177 if (meshsfee < ModelMinCost) 180 if (meshsfee < ModelMinCost)
178 meshsfee = ModelMinCost; 181 meshsfee = ModelMinCost;
179 182
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
149 HasEvents = (x, y) => { return this.responses.ContainsKey(x); }; 149 HasEvents = (x, y) => { return this.responses.ContainsKey(x); };
150 GetEvents = (x, y, s) => 150 GetEvents = (x, y, s) =>
151 { 151 {
152 try 152 lock (responses)
153 { 153 {
154 return this.responses[x]; 154 try
155 } 155 {
156 finally 156 return this.responses[x];
157 { 157 }
158 responses.Remove(x); 158 finally
159 {
160 responses.Remove(x);
161 }
159 } 162 }
160 }; 163 };
161 164
@@ -218,14 +221,14 @@ namespace OpenSim.Region.ClientStack.Linden
218 response["content_type"] = "text/plain"; 221 response["content_type"] = "text/plain";
219 response["keepalive"] = false; 222 response["keepalive"] = false;
220 response["reusecontext"] = false; 223 response["reusecontext"] = false;
221 224 lock (responses)
222 responses[requestID] = response; 225 responses[requestID] = response;
223 return; 226 return;
224 } 227 }
225 228
226 response = m_getTextureHandler.Handle(request); 229 response = m_getTextureHandler.Handle(request);
227 230 lock (responses)
228 responses[requestID] = response; 231 responses[requestID] = response;
229 } 232 }
230 } 233 }
231 234