From f4ded3af63e4a71ffd8ee7f1a422ec600f59b845 Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 1 Nov 2013 01:40:56 -0700 Subject: discard alpha in 4-plane sculpt textures before generating physics proxy mesh --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Physics/Meshing') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index fc679e7..4ad0cb1 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -629,21 +629,16 @@ namespace OpenSim.Region.Physics.Meshing try { - OpenMetaverse.Imaging.ManagedImage unusedData; - OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); + OpenMetaverse.Imaging.ManagedImage managedImage; - if (idata == null) - { - // In some cases it seems that the decode can return a null bitmap without throwing - // an exception - m_log.WarnFormat("[PHYSICS]: OpenJPEG decoded sculpt data for {0} to a null bitmap. Ignoring.", primName); - - return false; - } + OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage); - unusedData = null; + if ((managedImage.Channels & OpenMetaverse.Imaging.ManagedImage.ImageChannels.Alpha) != 0) + managedImage.ConvertChannels(managedImage.Channels & ~OpenMetaverse.Imaging.ManagedImage.ImageChannels.Alpha); - //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); + Bitmap imgData = OpenMetaverse.Imaging.LoadTGAClass.LoadTGA(new MemoryStream(managedImage.ExportTGA())); + idata = (Image)imgData; + managedImage = null; if (cacheSculptMaps) { -- cgit v1.1 From 7faf286d0025da04497e2b593f629c6582607c78 Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 1 Nov 2013 13:45:09 -0700 Subject: add null check for jpeg2000 sculpt image decode failure. Note: the j2kDecodeCache folder should be cleared after updating to this revision so that sculpts containing alpha can be re-decoded and successfully meshed. --- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'OpenSim/Region/Physics/Meshing') diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 4ad0cb1..1f08b03 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -633,6 +633,15 @@ namespace OpenSim.Region.Physics.Meshing OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage); + if (managedImage == null) + { + // In some cases it seems that the decode can return a null bitmap without throwing + // an exception + m_log.WarnFormat("[PHYSICS]: OpenJPEG decoded sculpt data for {0} to a null bitmap. Ignoring.", primName); + + return false; + } + if ((managedImage.Channels & OpenMetaverse.Imaging.ManagedImage.ImageChannels.Alpha) != 0) managedImage.ConvertChannels(managedImage.Channels & ~OpenMetaverse.Imaging.ManagedImage.ImageChannels.Alpha); -- cgit v1.1