aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-12-05 00:21:42 +0000
committerJustin Clark-Casey (justincc)2014-12-05 00:21:42 +0000
commitf3ab7c0f5c7675bd33cc5725c278318bef25b4aa (patch)
tree32eee10ef30922c06cc97768421c83879e036b63 /OpenSim/Region
parentMake "fache assets" console command more efficient by only updating access ti... (diff)
downloadopensim-SC-f3ab7c0f5c7675bd33cc5725c278318bef25b4aa.zip
opensim-SC-f3ab7c0f5c7675bd33cc5725c278318bef25b4aa.tar.gz
opensim-SC-f3ab7c0f5c7675bd33cc5725c278318bef25b4aa.tar.bz2
opensim-SC-f3ab7c0f5c7675bd33cc5725c278318bef25b4aa.tar.xz
refactor: rename IteratingUuidGather.AddAssetUuidToInspect() and RecordAssetUuids() to AddForInspection() as this properly describes what both of these methods do.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs233
2 files changed, 120 insertions, 115 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index fc932b0..2ddb599 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -607,7 +607,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
607 IDictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>(); 607 IDictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>();
608 IteratingHGUuidGatherer uuidGatherer 608 IteratingHGUuidGatherer uuidGatherer
609 = new IteratingHGUuidGatherer(Scene.AssetService, url, ids); 609 = new IteratingHGUuidGatherer(Scene.AssetService, url, ids);
610 uuidGatherer.RecordAssetUuids(so); 610 uuidGatherer.AddForInspection(so);
611 611
612 while (!uuidGatherer.Complete) 612 while (!uuidGatherer.Complete)
613 { 613 {
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index cacacf8..2c5353f 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -706,7 +706,12 @@ namespace OpenSim.Region.Framework.Scenes
706 m_assetUuidsToInspect = new Queue<UUID>(); 706 m_assetUuidsToInspect = new Queue<UUID>();
707 } 707 }
708 708
709 public bool AddAssetUuidToInspect(UUID uuid) 709 /// <summary>
710 /// Adds the asset uuid for inspection during the gathering process.
711 /// </summary>
712 /// <returns><c>true</c>, if for inspection was added, <c>false</c> otherwise.</returns>
713 /// <param name="uuid">UUID.</param>
714 public bool AddForInspection(UUID uuid)
710 { 715 {
711 if (m_assetUuidsToInspect.Contains(uuid)) 716 if (m_assetUuidsToInspect.Contains(uuid))
712 return false; 717 return false;
@@ -715,6 +720,107 @@ namespace OpenSim.Region.Framework.Scenes
715 720
716 return true; 721 return true;
717 } 722 }
723
724 /// <summary>
725 /// Gather all the asset uuids associated with a given object.
726 /// </summary>
727 /// <remarks>
728 /// This includes both those directly associated with
729 /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
730 /// within this object).
731 /// </remarks>
732 /// <param name="sceneObject">The scene object for which to gather assets</param>
733 public void AddForInspection(SceneObjectGroup sceneObject)
734 {
735 // m_log.DebugFormat(
736 // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
737
738 SceneObjectPart[] parts = sceneObject.Parts;
739 for (int i = 0; i < parts.Length; i++)
740 {
741 SceneObjectPart part = parts[i];
742
743 // m_log.DebugFormat(
744 // "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);
745
746 try
747 {
748 Primitive.TextureEntry textureEntry = part.Shape.Textures;
749 if (textureEntry != null)
750 {
751 // Get the prim's default texture. This will be used for faces which don't have their own texture
752 if (textureEntry.DefaultTexture != null)
753 RecordTextureEntryAssetUuids(textureEntry.DefaultTexture);
754
755 if (textureEntry.FaceTextures != null)
756 {
757 // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture)
758 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
759 {
760 if (texture != null)
761 RecordTextureEntryAssetUuids(texture);
762 }
763 }
764 }
765
766 // If the prim is a sculpt then preserve this information too
767 if (part.Shape.SculptTexture != UUID.Zero)
768 m_gatheredAssetUuids[part.Shape.SculptTexture] = (sbyte)AssetType.Texture;
769
770 if (part.Shape.ProjectionTextureUUID != UUID.Zero)
771 m_gatheredAssetUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture;
772
773 if (part.CollisionSound != UUID.Zero)
774 m_gatheredAssetUuids[part.CollisionSound] = (sbyte)AssetType.Sound;
775
776 if (part.ParticleSystem.Length > 0)
777 {
778 try
779 {
780 Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0);
781 if (ps.Texture != UUID.Zero)
782 m_gatheredAssetUuids[ps.Texture] = (sbyte)AssetType.Texture;
783 }
784 catch (Exception)
785 {
786 m_log.WarnFormat(
787 "[UUID GATHERER]: Could not check particle system for part {0} {1} in object {2} {3} since it is corrupt. Continuing.",
788 part.Name, part.UUID, sceneObject.Name, sceneObject.UUID);
789 }
790 }
791
792 TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
793
794 // Now analyze this prim's inventory items to preserve all the uuids that they reference
795 foreach (TaskInventoryItem tii in taskDictionary.Values)
796 {
797 // m_log.DebugFormat(
798 // "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}",
799 // tii.Name, tii.Type, part.Name, part.UUID);
800
801 if (!m_gatheredAssetUuids.ContainsKey(tii.AssetID))
802 AddForInspection(tii.AssetID, (sbyte)tii.Type);
803 }
804
805 // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed
806 // to be called with scene objects that are in a scene (e.g. in the case of hg asset mapping and
807 // inventory transfer. There needs to be a way for a module to register a method without assuming a
808 // Scene.EventManager is present.
809 // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
810
811
812 // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs
813 RecordMaterialsUuids(part);
814 }
815 catch (Exception e)
816 {
817 m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e);
818 m_log.DebugFormat(
819 "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)",
820 part.Shape.TextureEntry.Length);
821 }
822 }
823 }
718 824
719 /// <summary> 825 /// <summary>
720 /// Gathers the next set of assets returned by the next uuid to get from the asset service. 826 /// Gathers the next set of assets returned by the next uuid to get from the asset service.
@@ -804,7 +910,7 @@ namespace OpenSim.Region.Framework.Scenes
804 } 910 }
805 } 911 }
806 912
807 private void RecordAssetUuids(UUID assetUuid, sbyte assetType) 913 private void AddForInspection(UUID assetUuid, sbyte assetType)
808 { 914 {
809 // Here, we want to collect uuids which require further asset fetches but mark the others as gathered 915 // Here, we want to collect uuids which require further asset fetches but mark the others as gathered
810 try 916 try
@@ -813,27 +919,27 @@ namespace OpenSim.Region.Framework.Scenes
813 919
814 if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType) 920 if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType)
815 { 921 {
816 AddAssetUuidToInspect(assetUuid); 922 AddForInspection(assetUuid);
817 } 923 }
818 else if ((sbyte)AssetType.Gesture == assetType) 924 else if ((sbyte)AssetType.Gesture == assetType)
819 { 925 {
820 AddAssetUuidToInspect(assetUuid); 926 AddForInspection(assetUuid);
821 } 927 }
822 else if ((sbyte)AssetType.Notecard == assetType) 928 else if ((sbyte)AssetType.Notecard == assetType)
823 { 929 {
824 AddAssetUuidToInspect(assetUuid); 930 AddForInspection(assetUuid);
825 } 931 }
826 else if ((sbyte)AssetType.LSLText == assetType) 932 else if ((sbyte)AssetType.LSLText == assetType)
827 { 933 {
828 AddAssetUuidToInspect(assetUuid); 934 AddForInspection(assetUuid);
829 } 935 }
830 else if ((sbyte)OpenSimAssetType.Material == assetType) 936 else if ((sbyte)OpenSimAssetType.Material == assetType)
831 { 937 {
832 AddAssetUuidToInspect(assetUuid); 938 AddForInspection(assetUuid);
833 } 939 }
834 else if ((sbyte)AssetType.Object == assetType) 940 else if ((sbyte)AssetType.Object == assetType)
835 { 941 {
836 AddAssetUuidToInspect(assetUuid); 942 AddForInspection(assetUuid);
837 } 943 }
838 } 944 }
839 catch (Exception) 945 catch (Exception)
@@ -846,107 +952,6 @@ namespace OpenSim.Region.Framework.Scenes
846 } 952 }
847 953
848 /// <summary> 954 /// <summary>
849 /// Gather all the asset uuids associated with a given object.
850 /// </summary>
851 /// <remarks>
852 /// This includes both those directly associated with
853 /// it (e.g. face textures) and recursively, those of items within it's inventory (e.g. objects contained
854 /// within this object).
855 /// </remarks>
856 /// <param name="sceneObject">The scene object for which to gather assets</param>
857 public void RecordAssetUuids(SceneObjectGroup sceneObject)
858 {
859 // m_log.DebugFormat(
860 // "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
861
862 SceneObjectPart[] parts = sceneObject.Parts;
863 for (int i = 0; i < parts.Length; i++)
864 {
865 SceneObjectPart part = parts[i];
866
867 // m_log.DebugFormat(
868 // "[ARCHIVER]: Getting part {0}, {1} for object {2}", part.Name, part.UUID, sceneObject.UUID);
869
870 try
871 {
872 Primitive.TextureEntry textureEntry = part.Shape.Textures;
873 if (textureEntry != null)
874 {
875 // Get the prim's default texture. This will be used for faces which don't have their own texture
876 if (textureEntry.DefaultTexture != null)
877 RecordTextureEntryAssetUuids(textureEntry.DefaultTexture);
878
879 if (textureEntry.FaceTextures != null)
880 {
881 // Loop through the rest of the texture faces (a non-null face means the face is different from DefaultTexture)
882 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
883 {
884 if (texture != null)
885 RecordTextureEntryAssetUuids(texture);
886 }
887 }
888 }
889
890 // If the prim is a sculpt then preserve this information too
891 if (part.Shape.SculptTexture != UUID.Zero)
892 m_gatheredAssetUuids[part.Shape.SculptTexture] = (sbyte)AssetType.Texture;
893
894 if (part.Shape.ProjectionTextureUUID != UUID.Zero)
895 m_gatheredAssetUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture;
896
897 if (part.CollisionSound != UUID.Zero)
898 m_gatheredAssetUuids[part.CollisionSound] = (sbyte)AssetType.Sound;
899
900 if (part.ParticleSystem.Length > 0)
901 {
902 try
903 {
904 Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0);
905 if (ps.Texture != UUID.Zero)
906 m_gatheredAssetUuids[ps.Texture] = (sbyte)AssetType.Texture;
907 }
908 catch (Exception)
909 {
910 m_log.WarnFormat(
911 "[UUID GATHERER]: Could not check particle system for part {0} {1} in object {2} {3} since it is corrupt. Continuing.",
912 part.Name, part.UUID, sceneObject.Name, sceneObject.UUID);
913 }
914 }
915
916 TaskInventoryDictionary taskDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
917
918 // Now analyze this prim's inventory items to preserve all the uuids that they reference
919 foreach (TaskInventoryItem tii in taskDictionary.Values)
920 {
921 // m_log.DebugFormat(
922 // "[ARCHIVER]: Analysing item {0} asset type {1} in {2} {3}",
923 // tii.Name, tii.Type, part.Name, part.UUID);
924
925 if (!m_gatheredAssetUuids.ContainsKey(tii.AssetID))
926 RecordAssetUuids(tii.AssetID, (sbyte)tii.Type);
927 }
928
929 // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed
930 // to be called with scene objects that are in a scene (e.g. in the case of hg asset mapping and
931 // inventory transfer. There needs to be a way for a module to register a method without assuming a
932 // Scene.EventManager is present.
933 // part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
934
935
936 // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs
937 RecordMaterialsUuids(part);
938 }
939 catch (Exception e)
940 {
941 m_log.ErrorFormat("[UUID GATHERER]: Failed to get part - {0}", e);
942 m_log.DebugFormat(
943 "[UUID GATHERER]: Texture entry length for prim was {0} (min is 46)",
944 part.Shape.TextureEntry.Length);
945 }
946 }
947 }
948
949 /// <summary>
950 /// Collect all the asset uuids found in one face of a Texture Entry. 955 /// Collect all the asset uuids found in one face of a Texture Entry.
951 /// </summary> 956 /// </summary>
952 private void RecordTextureEntryAssetUuids(Primitive.TextureEntryFace texture) 957 private void RecordTextureEntryAssetUuids(Primitive.TextureEntryFace texture)
@@ -954,7 +959,7 @@ namespace OpenSim.Region.Framework.Scenes
954 m_gatheredAssetUuids[texture.TextureID] = (sbyte)AssetType.Texture; 959 m_gatheredAssetUuids[texture.TextureID] = (sbyte)AssetType.Texture;
955 960
956 if (texture.MaterialID != UUID.Zero) 961 if (texture.MaterialID != UUID.Zero)
957 AddAssetUuidToInspect(texture.MaterialID); 962 AddForInspection(texture.MaterialID);
958 } 963 }
959 964
960 /// <summary> 965 /// <summary>
@@ -962,7 +967,7 @@ namespace OpenSim.Region.Framework.Scenes
962 /// stored in legacy format in part.DynAttrs 967 /// stored in legacy format in part.DynAttrs
963 /// </summary> 968 /// </summary>
964 /// <param name="part"></param> 969 /// <param name="part"></param>
965 public void RecordMaterialsUuids(SceneObjectPart part) 970 private void RecordMaterialsUuids(SceneObjectPart part)
966 { 971 {
967 // scan thru the dynAttrs map of this part for any textures used as materials 972 // scan thru the dynAttrs map of this part for any textures used as materials
968 OSD osdMaterials = null; 973 OSD osdMaterials = null;
@@ -1053,7 +1058,7 @@ namespace OpenSim.Region.Framework.Scenes
1053 UUID uuid = new UUID(uuidMatch.Value); 1058 UUID uuid = new UUID(uuidMatch.Value);
1054 // m_log.DebugFormat("[ARCHIVER]: Recording {0} in text", uuid); 1059 // m_log.DebugFormat("[ARCHIVER]: Recording {0} in text", uuid);
1055 1060
1056 AddAssetUuidToInspect(uuid); 1061 AddForInspection(uuid);
1057 } 1062 }
1058 } 1063 }
1059 1064
@@ -1088,14 +1093,14 @@ namespace OpenSim.Region.Framework.Scenes
1088 if (CoalescedSceneObjectsSerializer.TryFromXml(xml, out coa)) 1093 if (CoalescedSceneObjectsSerializer.TryFromXml(xml, out coa))
1089 { 1094 {
1090 foreach (SceneObjectGroup sog in coa.Objects) 1095 foreach (SceneObjectGroup sog in coa.Objects)
1091 RecordAssetUuids(sog); 1096 AddForInspection(sog);
1092 } 1097 }
1093 else 1098 else
1094 { 1099 {
1095 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml); 1100 SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml);
1096 1101
1097 if (null != sog) 1102 if (null != sog)
1098 RecordAssetUuids(sog); 1103 AddForInspection(sog);
1099 } 1104 }
1100 } 1105 }
1101 1106