From eb6d63ab8ee1c37b10fb885e4f0c672af90ce1ec Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 6 May 2010 23:02:24 -0700 Subject: [PATCH] improve handling of undersize sculpt textures --- OpenSim/Region/Physics/Meshing/SculptMap.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/Meshing/SculptMap.cs b/OpenSim/Region/Physics/Meshing/SculptMap.cs index 4d3f82b22b..4906cf6a33 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMap.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMap.cs @@ -60,21 +60,23 @@ namespace PrimMesher int numLodPixels = lod * 2 * lod * 2; // (32 * 2)^2 = 64^2 pixels for default sculpt map image + bool needsScaling = false; + width = bmW; height = bmH; while (width * height > numLodPixels) { width >>= 1; height >>= 1; + needsScaling = true; } - width >>= 1; - height >>= 1; + try { - if (!(bmW == width * 2 && bmH == height * 2)) - bm = ScaleImage(bm, width * 2, height * 2, + if (needsScaling) + bm = ScaleImage(bm, width, height, System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor); } @@ -83,6 +85,11 @@ namespace PrimMesher throw new Exception("Exception in ScaleImage(): e: " + e.ToString()); } + if (width * height > lod * lod) + { + width >>= 1; + height >>= 1; + } int numBytes = (width + 1) * (height + 1); redBytes = new byte[numBytes];