diff options
Diffstat (limited to 'OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs')
-rw-r--r-- | OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs | 64 |
1 files changed, 3 insertions, 61 deletions
diff --git a/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs b/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs index 44c8972..2933d86 100644 --- a/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs | |||
@@ -74,10 +74,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
74 | private const string baseDir = null; //"rawFiles"; | 74 | private const string baseDir = null; //"rawFiles"; |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | private bool cacheSculptMaps = true; | ||
78 | private bool cacheSculptAlphaMaps = true; | ||
79 | |||
80 | private string decodedSculptMapPath = null; | ||
81 | private bool useMeshiesPhysicsMesh = false; | 77 | private bool useMeshiesPhysicsMesh = false; |
82 | 78 | ||
83 | private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh | 79 | private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh |
@@ -92,29 +88,9 @@ namespace OpenSim.Region.Physics.Meshing | |||
92 | IConfig start_config = config.Configs["Startup"]; | 88 | IConfig start_config = config.Configs["Startup"]; |
93 | IConfig mesh_config = config.Configs["Mesh"]; | 89 | IConfig mesh_config = config.Configs["Mesh"]; |
94 | 90 | ||
95 | decodedSculptMapPath = start_config.GetString("DecodedSculptMapPath","j2kDecodeCache"); | ||
96 | |||
97 | cacheSculptMaps = start_config.GetBoolean("CacheSculptMaps", cacheSculptMaps); | ||
98 | |||
99 | if (Environment.OSVersion.Platform == PlatformID.Unix) | ||
100 | { | ||
101 | cacheSculptAlphaMaps = false; | ||
102 | } | ||
103 | else | ||
104 | cacheSculptAlphaMaps = cacheSculptMaps; | ||
105 | |||
106 | if(mesh_config != null) | 91 | if(mesh_config != null) |
107 | useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh); | 92 | useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh); |
108 | 93 | ||
109 | try | ||
110 | { | ||
111 | if (!Directory.Exists(decodedSculptMapPath)) | ||
112 | Directory.CreateDirectory(decodedSculptMapPath); | ||
113 | } | ||
114 | catch (Exception e) | ||
115 | { | ||
116 | m_log.WarnFormat("[SCULPT]: Unable to create {0} directory: ", decodedSculptMapPath, e.Message); | ||
117 | } | ||
118 | } | 94 | } |
119 | 95 | ||
120 | /// <summary> | 96 | /// <summary> |
@@ -444,7 +420,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
444 | // physics_shape is an array of OSDMaps, one for each submesh | 420 | // physics_shape is an array of OSDMaps, one for each submesh |
445 | if (decodedMeshOsd is OSDArray) | 421 | if (decodedMeshOsd is OSDArray) |
446 | { | 422 | { |
447 | // Console.WriteLine("decodedMeshOsd for {0} - {1}", primName, Util.GetFormattedXml(decodedMeshOsd)); | 423 | // Console.WriteLine("decodedMeshOsd for {0} - {1}", primName, Util.GetFormattedXml(decodedMeshOsd)); |
448 | 424 | ||
449 | decodedMeshOsdArray = (OSDArray)decodedMeshOsd; | 425 | decodedMeshOsdArray = (OSDArray)decodedMeshOsd; |
450 | foreach (OSD subMeshOsd in decodedMeshOsdArray) | 426 | foreach (OSD subMeshOsd in decodedMeshOsdArray) |
@@ -717,29 +693,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
717 | faces = new List<Face>(); | 693 | faces = new List<Face>(); |
718 | PrimMesher.SculptMesh sculptMesh; | 694 | PrimMesher.SculptMesh sculptMesh; |
719 | Image idata = null; | 695 | Image idata = null; |
720 | string decodedSculptFileName = ""; | ||
721 | 696 | ||
722 | if (cacheSculptMaps && primShape.SculptTexture != UUID.Zero) | ||
723 | { | ||
724 | decodedSculptFileName = System.IO.Path.Combine(decodedSculptMapPath, "smap_" + primShape.SculptTexture.ToString()); | ||
725 | try | ||
726 | { | ||
727 | if (File.Exists(decodedSculptFileName)) | ||
728 | { | ||
729 | idata = Image.FromFile(decodedSculptFileName); | ||
730 | } | ||
731 | } | ||
732 | catch (Exception e) | ||
733 | { | ||
734 | m_log.Error("[SCULPT]: unable to load cached sculpt map " + decodedSculptFileName + " " + e.Message); | ||
735 | |||
736 | } | ||
737 | //if (idata != null) | ||
738 | // m_log.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString()); | ||
739 | } | ||
740 | |||
741 | if (idata == null) | ||
742 | { | ||
743 | if (primShape.SculptData == null || primShape.SculptData.Length == 0) | 697 | if (primShape.SculptData == null || primShape.SculptData.Length == 0) |
744 | return false; | 698 | return false; |
745 | 699 | ||
@@ -748,25 +702,15 @@ namespace OpenSim.Region.Physics.Meshing | |||
748 | OpenMetaverse.Imaging.ManagedImage unusedData; | 702 | OpenMetaverse.Imaging.ManagedImage unusedData; |
749 | OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); | 703 | OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); |
750 | 704 | ||
705 | unusedData = null; | ||
706 | |||
751 | if (idata == null) | 707 | if (idata == null) |
752 | { | 708 | { |
753 | // In some cases it seems that the decode can return a null bitmap without throwing | 709 | // In some cases it seems that the decode can return a null bitmap without throwing |
754 | // an exception | 710 | // an exception |
755 | m_log.WarnFormat("[PHYSICS]: OpenJPEG decoded sculpt data for {0} to a null bitmap. Ignoring.", primName); | 711 | m_log.WarnFormat("[PHYSICS]: OpenJPEG decoded sculpt data for {0} to a null bitmap. Ignoring.", primName); |
756 | |||
757 | return false; | 712 | return false; |
758 | } | 713 | } |
759 | |||
760 | unusedData = null; | ||
761 | |||
762 | //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); | ||
763 | |||
764 | if (cacheSculptMaps && (cacheSculptAlphaMaps || (((ImageFlags)(idata.Flags) & ImageFlags.HasAlpha) ==0))) | ||
765 | // don't cache images with alpha channel in linux since mono can't load them correctly) | ||
766 | { | ||
767 | try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } | ||
768 | catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); } | ||
769 | } | ||
770 | } | 714 | } |
771 | catch (DllNotFoundException) | 715 | catch (DllNotFoundException) |
772 | { | 716 | { |
@@ -783,7 +727,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
783 | m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message); | 727 | m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message); |
784 | return false; | 728 | return false; |
785 | } | 729 | } |
786 | } | ||
787 | 730 | ||
788 | PrimMesher.SculptMesh.SculptType sculptType; | 731 | PrimMesher.SculptMesh.SculptType sculptType; |
789 | // remove mirror and invert bits | 732 | // remove mirror and invert bits |
@@ -1048,7 +991,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
1048 | return ((hash << 5) + hash) + (ulong)(c >> 8); | 991 | return ((hash << 5) + hash) + (ulong)(c >> 8); |
1049 | } | 992 | } |
1050 | 993 | ||
1051 | |||
1052 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod) | 994 | public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod) |
1053 | { | 995 | { |
1054 | return CreateMesh(primName, primShape, size, lod, false,false); | 996 | return CreateMesh(primName, primShape, size, lod, false,false); |