diff options
author | UbitUmarov | 2014-10-11 10:01:26 +0100 |
---|---|---|
committer | UbitUmarov | 2014-10-11 10:01:26 +0100 |
commit | 1a6ef2d60e4aff73e614ef45a0040c45316707f3 (patch) | |
tree | fd9e84ceb05e17e5c2a14bc079d656756fdbaa47 /OpenSim/Region/ClientStack | |
parent | Merge branch 'master' into ubitworkmaster (diff) | |
download | opensim-SC_OLD-1a6ef2d60e4aff73e614ef45a0040c45316707f3.zip opensim-SC_OLD-1a6ef2d60e4aff73e614ef45a0040c45316707f3.tar.gz opensim-SC_OLD-1a6ef2d60e4aff73e614ef45a0040c45316707f3.tar.bz2 opensim-SC_OLD-1a6ef2d60e4aff73e614ef45a0040c45316707f3.tar.xz |
check for avatar skeleton data on meshs headers on cost estimation. Dont
let a model have more than one mesh with skeleton, for testing create a
mesh inventory item, for this meshs. Add also option to read a avatar
collider replacement. This information still needs to be saved somewhere
so it can be checked on attachment, etc, without parsing the mesh asset again.
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 68 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | 44 |
2 files changed, 101 insertions, 11 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 75634e0..3a070c3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
58 | string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, | 58 | string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, |
59 | byte[] data, string inventoryType, string assetType, | 59 | byte[] data, string inventoryType, string assetType, |
60 | int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, | 60 | int cost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, |
61 | bool IsAtestUpload, ref string error); | 61 | bool IsAtestUpload, bool avatarSkeleton, bool avatarCollider, ref string error); |
62 | 62 | ||
63 | public delegate UUID UpdateItem(UUID itemID, byte[] data); | 63 | public delegate UUID UpdateItem(UUID itemID, byte[] data); |
64 | 64 | ||
@@ -531,6 +531,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
531 | int nreqmeshs= 0; | 531 | int nreqmeshs= 0; |
532 | int nreqinstances = 0; | 532 | int nreqinstances = 0; |
533 | bool IsAtestUpload = false; | 533 | bool IsAtestUpload = false; |
534 | bool avatarSkeleton = false; | ||
535 | bool avatarCollider = false; | ||
534 | 536 | ||
535 | string assetName = llsdRequest.name; | 537 | string assetName = llsdRequest.name; |
536 | 538 | ||
@@ -580,8 +582,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
580 | string error; | 582 | string error; |
581 | int modelcost; | 583 | int modelcost; |
582 | 584 | ||
585 | |||
583 | if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, | 586 | if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, |
584 | meshcostdata, out error, ref warning)) | 587 | meshcostdata,out avatarSkeleton, out avatarCollider, out error, ref warning)) |
585 | { | 588 | { |
586 | LLSDAssetUploadError resperror = new LLSDAssetUploadError(); | 589 | LLSDAssetUploadError resperror = new LLSDAssetUploadError(); |
587 | resperror.message = error; | 590 | resperror.message = error; |
@@ -664,7 +667,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
664 | AssetUploader uploader = | 667 | AssetUploader uploader = |
665 | new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, | 668 | new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type, |
666 | llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, | 669 | llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost, |
667 | texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload); | 670 | texturesFolder, nreqtextures, nreqmeshs, nreqinstances, IsAtestUpload, avatarSkeleton, avatarCollider); |
668 | 671 | ||
669 | m_HostCapsObj.HttpListener.AddStreamHandler( | 672 | m_HostCapsObj.HttpListener.AddStreamHandler( |
670 | new BinaryStreamHandler( | 673 | new BinaryStreamHandler( |
@@ -711,7 +714,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
711 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, | 714 | UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType, |
712 | string assetType, int cost, | 715 | string assetType, int cost, |
713 | UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, | 716 | UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, |
714 | bool IsAtestUpload, ref string error) | 717 | bool IsAtestUpload,bool avatarSkeleton, bool avatarCollider, ref string error) |
715 | { | 718 | { |
716 | 719 | ||
717 | lock (m_ModelCost) | 720 | lock (m_ModelCost) |
@@ -877,12 +880,60 @@ namespace OpenSim.Region.ClientStack.Linden | |||
877 | List<UUID> meshAssets = new List<UUID>(); | 880 | List<UUID> meshAssets = new List<UUID>(); |
878 | for (int i = 0; i < mesh_list.Count; i++) | 881 | for (int i = 0; i < mesh_list.Count; i++) |
879 | { | 882 | { |
883 | /* | ||
884 | // do we really need this heavy thing? | ||
885 | OSD osd = OSDParser.DeserializeLLSDBinary(mesh_list[i]); | ||
886 | if (osd is OSDMap) | ||
887 | { | ||
888 | OSDMap mosd = (OSDMap)osd; | ||
889 | if (mosd.ContainsKey("skeleton")) | ||
890 | { | ||
891 | OSDMap skeleton = (OSDMap)mosd["skeleton"]; | ||
892 | int sksize = skeleton["size"].AsInteger(); | ||
893 | } | ||
894 | } | ||
895 | */ | ||
896 | |||
880 | AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr); | 897 | AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, creatorIDstr); |
881 | meshAsset.Data = mesh_list[i].AsBinary(); | 898 | meshAsset.Data = mesh_list[i].AsBinary(); |
882 | if (istest) | 899 | if (istest) |
883 | meshAsset.Local = true; | 900 | meshAsset.Local = true; |
884 | m_assetService.Store(meshAsset); | 901 | m_assetService.Store(meshAsset); |
885 | meshAssets.Add(meshAsset.FullID); | 902 | meshAssets.Add(meshAsset.FullID); |
903 | |||
904 | |||
905 | // test code | ||
906 | if (avatarSkeleton) | ||
907 | { | ||
908 | string name = assetName; | ||
909 | if (name.Length > 25) | ||
910 | name = name.Substring(0, 24); | ||
911 | name += "_Mesh#" + i.ToString(); | ||
912 | InventoryItemBase meshitem = new InventoryItemBase(); | ||
913 | meshitem.Owner = m_HostCapsObj.AgentID; | ||
914 | meshitem.CreatorId = creatorIDstr; | ||
915 | meshitem.CreatorData = String.Empty; | ||
916 | meshitem.ID = UUID.Random(); | ||
917 | meshitem.AssetID = meshAsset.FullID; | ||
918 | meshitem.Description = "mesh "; | ||
919 | meshitem.Name = name; | ||
920 | meshitem.AssetType = (int)AssetType.Mesh; | ||
921 | meshitem.InvType = (int)InventoryType.Mesh; | ||
922 | meshitem.Folder = UUID.Zero; // send to default | ||
923 | |||
924 | // If we set PermissionMask.All then when we rez the item the next permissions will replace the current | ||
925 | // (owner) permissions. This becomes a problem if next permissions are changed. | ||
926 | meshitem.CurrentPermissions | ||
927 | = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer); | ||
928 | |||
929 | meshitem.BasePermissions = (uint)PermissionMask.All; | ||
930 | meshitem.EveryOnePermissions = 0; | ||
931 | meshitem.NextPermissions = (uint)PermissionMask.All; | ||
932 | meshitem.CreationDate = Util.UnixTimeSinceEpoch(); | ||
933 | |||
934 | m_Scene.AddInventoryItem(client, meshitem); | ||
935 | meshitem = null; | ||
936 | } | ||
886 | } | 937 | } |
887 | 938 | ||
888 | int skipedMeshs = 0; | 939 | int skipedMeshs = 0; |
@@ -1540,12 +1591,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1540 | private int m_nreqmeshs; | 1591 | private int m_nreqmeshs; |
1541 | private int m_nreqinstances; | 1592 | private int m_nreqinstances; |
1542 | private bool m_IsAtestUpload; | 1593 | private bool m_IsAtestUpload; |
1594 | private bool m_avatarSkeleton; | ||
1595 | private bool m_avatarCollider; | ||
1543 | 1596 | ||
1544 | public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, | 1597 | public AssetUploader(string assetName, string description, UUID assetID, UUID inventoryItem, |
1545 | UUID parentFolderID, string invType, string assetType, string path, | 1598 | UUID parentFolderID, string invType, string assetType, string path, |
1546 | IHttpServer httpServer, bool dumpAssetsToFile, | 1599 | IHttpServer httpServer, bool dumpAssetsToFile, |
1547 | int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, | 1600 | int totalCost, UUID texturesFolder, int nreqtextures, int nreqmeshs, int nreqinstances, |
1548 | bool IsAtestUpload) | 1601 | bool IsAtestUpload,bool avatarSkeleton, bool avatarCollider) |
1549 | { | 1602 | { |
1550 | m_assetName = assetName; | 1603 | m_assetName = assetName; |
1551 | m_assetDes = description; | 1604 | m_assetDes = description; |
@@ -1564,6 +1617,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1564 | m_nreqmeshs = nreqmeshs; | 1617 | m_nreqmeshs = nreqmeshs; |
1565 | m_nreqinstances = nreqinstances; | 1618 | m_nreqinstances = nreqinstances; |
1566 | m_IsAtestUpload = IsAtestUpload; | 1619 | m_IsAtestUpload = IsAtestUpload; |
1620 | m_avatarSkeleton = avatarSkeleton; | ||
1621 | m_avatarCollider = avatarCollider; | ||
1567 | 1622 | ||
1568 | m_timeoutTimer.Elapsed += TimedOut; | 1623 | m_timeoutTimer.Elapsed += TimedOut; |
1569 | m_timeoutTimer.Interval = 120000; | 1624 | m_timeoutTimer.Interval = 120000; |
@@ -1608,7 +1663,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
1608 | if (handlerUpLoad != null) | 1663 | if (handlerUpLoad != null) |
1609 | { | 1664 | { |
1610 | handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, | 1665 | handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType, |
1611 | m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, ref m_error); | 1666 | m_cost, m_texturesFolder, m_nreqtextures, m_nreqmeshs, m_nreqinstances, m_IsAtestUpload, |
1667 | m_avatarSkeleton, m_avatarCollider, ref m_error); | ||
1612 | } | 1668 | } |
1613 | if (m_IsAtestUpload) | 1669 | if (m_IsAtestUpload) |
1614 | { | 1670 | { |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs index 4a3fae6..db6f9fd 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/MeshCost.cs | |||
@@ -96,12 +96,18 @@ namespace OpenSim.Region.ClientStack.Linden | |||
96 | // basicCost input region assets upload cost | 96 | // basicCost input region assets upload cost |
97 | // totalcost returns model total upload fee | 97 | // totalcost returns model total upload fee |
98 | // meshcostdata returns detailed costs for viewer | 98 | // meshcostdata returns detailed costs for viewer |
99 | public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, | 99 | // avatarSkeleton if mesh includes a avatar skeleton |
100 | LLSDAssetUploadResponseData meshcostdata, out string error, ref string warning) | 100 | // useAvatarCollider if we should use physics mesh for avatar |
101 | public bool MeshModelCost(LLSDAssetResource resources, int basicCost, out int totalcost, | ||
102 | LLSDAssetUploadResponseData meshcostdata,out bool avatarSkeleton, out bool useAvatarCollider, | ||
103 | out string error, ref string warning) | ||
101 | { | 104 | { |
102 | totalcost = 0; | 105 | totalcost = 0; |
103 | error = string.Empty; | 106 | error = string.Empty; |
104 | 107 | ||
108 | avatarSkeleton = false; | ||
109 | useAvatarCollider = false; | ||
110 | |||
105 | if (resources == null || | 111 | if (resources == null || |
106 | resources.instance_list == null || | 112 | resources.instance_list == null || |
107 | resources.instance_list.Array.Count == 0) | 113 | resources.instance_list.Array.Count == 0) |
@@ -145,6 +151,10 @@ namespace OpenSim.Region.ClientStack.Linden | |||
145 | float meshsfee = 0; | 151 | float meshsfee = 0; |
146 | int numberMeshs = 0; | 152 | int numberMeshs = 0; |
147 | bool haveMeshs = false; | 153 | bool haveMeshs = false; |
154 | |||
155 | bool curskeleton; | ||
156 | bool curAvatarPhys; | ||
157 | |||
148 | List<ameshCostParam> meshsCosts = new List<ameshCostParam>(); | 158 | List<ameshCostParam> meshsCosts = new List<ameshCostParam>(); |
149 | 159 | ||
150 | if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0) | 160 | if (resources.mesh_list != null && resources.mesh_list.Array.Count > 0) |
@@ -156,10 +166,20 @@ namespace OpenSim.Region.ClientStack.Linden | |||
156 | ameshCostParam curCost = new ameshCostParam(); | 166 | ameshCostParam curCost = new ameshCostParam(); |
157 | byte[] data = (byte[])resources.mesh_list.Array[i]; | 167 | byte[] data = (byte[])resources.mesh_list.Array[i]; |
158 | 168 | ||
159 | if (!MeshCost(data, curCost, out error)) | 169 | if (!MeshCost(data, curCost,out curskeleton, out curAvatarPhys, out error)) |
160 | { | 170 | { |
161 | return false; | 171 | return false; |
162 | } | 172 | } |
173 | |||
174 | if (curskeleton) | ||
175 | { | ||
176 | if (avatarSkeleton) | ||
177 | { | ||
178 | error = "model can only contain a avatar skeleton"; | ||
179 | return false; | ||
180 | } | ||
181 | avatarSkeleton = true; | ||
182 | } | ||
163 | meshsCosts.Add(curCost); | 183 | meshsCosts.Add(curCost); |
164 | meshsfee += curCost.costFee; | 184 | meshsfee += curCost.costFee; |
165 | } | 185 | } |
@@ -273,7 +293,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
273 | } | 293 | } |
274 | 294 | ||
275 | // single mesh asset cost | 295 | // single mesh asset cost |
276 | private bool MeshCost(byte[] data, ameshCostParam cost, out string error) | 296 | private bool MeshCost(byte[] data, ameshCostParam cost,out bool skeleton, out bool avatarPhys, out string error) |
277 | { | 297 | { |
278 | cost.highLODSize = 0; | 298 | cost.highLODSize = 0; |
279 | cost.medLODSize = 0; | 299 | cost.medLODSize = 0; |
@@ -284,6 +304,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
284 | 304 | ||
285 | error = string.Empty; | 305 | error = string.Empty; |
286 | 306 | ||
307 | skeleton = false; | ||
308 | avatarPhys = false; | ||
309 | |||
287 | if (data == null || data.Length == 0) | 310 | if (data == null || data.Length == 0) |
288 | { | 311 | { |
289 | error = "Missing model information."; | 312 | error = "Missing model information."; |
@@ -330,6 +353,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
330 | 353 | ||
331 | int submesh_offset = -1; | 354 | int submesh_offset = -1; |
332 | 355 | ||
356 | if (map.ContainsKey("skeleton")) | ||
357 | { | ||
358 | tmpmap = (OSDMap)map["skeleton"]; | ||
359 | if (tmpmap.ContainsKey("offset") && tmpmap.ContainsKey("size")) | ||
360 | { | ||
361 | int sksize = tmpmap["size"].AsInteger(); | ||
362 | if(sksize > 0) | ||
363 | skeleton = true; | ||
364 | } | ||
365 | } | ||
366 | |||
333 | if (map.ContainsKey("physics_convex")) | 367 | if (map.ContainsKey("physics_convex")) |
334 | { | 368 | { |
335 | tmpmap = (OSDMap)map["physics_convex"]; | 369 | tmpmap = (OSDMap)map["physics_convex"]; |