Return null from CreateMeshFromPrimMesher if OpenJPEG decoding of the sculpt data fails.

This is to address http://opensimulator.org/mantis/view.php?id=5612
bulletsim
Justin Clark-Casey (justincc) 2011-07-29 21:49:23 +01:00
parent f3c5a5b745
commit 5043be13fb
1 changed files with 11 additions and 1 deletions

View File

@ -456,11 +456,21 @@ namespace OpenSim.Region.Physics.Meshing
{ {
OpenMetaverse.Imaging.ManagedImage unusedData; OpenMetaverse.Imaging.ManagedImage unusedData;
OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata); OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata);
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 null;
}
unusedData = null; unusedData = null;
//idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData); //idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData);
if (cacheSculptMaps && idata != null) if (cacheSculptMaps)
{ {
try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); } try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); }
catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); } catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); }