aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs3
-rw-r--r--OpenSim/Region/Physics/UbitMeshing/SculptMap.cs83
-rw-r--r--OpenSim/Region/Physics/UbitMeshing/SculptMesh.cs7
3 files changed, 78 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs b/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs
index 88efd6d..3b1bdfb 100644
--- a/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs
@@ -314,6 +314,9 @@ namespace OpenSim.Region.Physics.Meshing
314 coords[f.v3].X, coords[f.v3].Y, coords[f.v3].Z)); 314 coords[f.v3].X, coords[f.v3].Y, coords[f.v3].Z));
315 } 315 }
316 316
317 coords.Clear();
318 faces.Clear();
319
317 return mesh; 320 return mesh;
318 } 321 }
319 322
diff --git a/OpenSim/Region/Physics/UbitMeshing/SculptMap.cs b/OpenSim/Region/Physics/UbitMeshing/SculptMap.cs
index 054caf3..1c75db6 100644
--- a/OpenSim/Region/Physics/UbitMeshing/SculptMap.cs
+++ b/OpenSim/Region/Physics/UbitMeshing/SculptMap.cs
@@ -56,11 +56,12 @@ namespace PrimMesher
56 56
57 int numLodPixels = lod * lod; // (32 * 2)^2 = 64^2 pixels for default sculpt map image 57 int numLodPixels = lod * lod; // (32 * 2)^2 = 64^2 pixels for default sculpt map image
58 58
59 bool smallMap = bmW * bmH <= numLodPixels;
60 bool needsScaling = false; 59 bool needsScaling = false;
60 bool smallMap = false;
61 61
62 width = bmW; 62 width = bmW;
63 height = bmH; 63 height = bmH;
64
64 while (width * height > numLodPixels * 4) 65 while (width * height > numLodPixels * 4)
65 { 66 {
66 width >>= 1; 67 width >>= 1;
@@ -81,9 +82,12 @@ namespace PrimMesher
81 82
82 if (width * height > numLodPixels) 83 if (width * height > numLodPixels)
83 { 84 {
85 smallMap = false;
84 width >>= 1; 86 width >>= 1;
85 height >>= 1; 87 height >>= 1;
86 } 88 }
89 else
90 smallMap = true;
87 91
88 int numBytes = (width + 1) * (height + 1); 92 int numBytes = (width + 1) * (height + 1);
89 redBytes = new byte[numBytes]; 93 redBytes = new byte[numBytes];
@@ -91,21 +95,18 @@ namespace PrimMesher
91 blueBytes = new byte[numBytes]; 95 blueBytes = new byte[numBytes];
92 96
93 int byteNdx = 0; 97 int byteNdx = 0;
98 Color c;
94 99
95 try 100 try
96 { 101 {
97 for (int y = 0; y <= height; y++) 102 for (int y = 0; y <= height; y++)
98 { 103 {
99 for (int x = 0; x <= width; x++) 104 for (int x = 0; x < width; x++)
100 { 105 {
101 Color c;
102
103 if (smallMap) 106 if (smallMap)
104 c = bm.GetPixel(x < width ? x : x - 1, 107 c = bm.GetPixel(x, y < height ? y : y - 1);
105 y < height ? y : y - 1);
106 else 108 else
107 c = bm.GetPixel(x < width ? x * 2 : x * 2 - 1, 109 c = bm.GetPixel(x * 2, y < height ? y * 2 : y * 2 - 1);
108 y < height ? y * 2 : y * 2 - 1);
109 110
110 redBytes[byteNdx] = c.R; 111 redBytes[byteNdx] = c.R;
111 greenBytes[byteNdx] = c.G; 112 greenBytes[byteNdx] = c.G;
@@ -113,6 +114,17 @@ namespace PrimMesher
113 114
114 ++byteNdx; 115 ++byteNdx;
115 } 116 }
117
118 if (smallMap)
119 c = bm.GetPixel(width - 1, y < height ? y : y - 1);
120 else
121 c = bm.GetPixel(width * 2 - 1, y < height ? y * 2 : y * 2 - 1);
122
123 redBytes[byteNdx] = c.R;
124 greenBytes[byteNdx] = c.G;
125 blueBytes[byteNdx] = c.B;
126
127 ++byteNdx;
116 } 128 }
117 } 129 }
118 catch (Exception e) 130 catch (Exception e)
@@ -160,14 +172,25 @@ namespace PrimMesher
160 Bitmap scaledImage = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb); 172 Bitmap scaledImage = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb);
161 173
162 Color c; 174 Color c;
163 float xscale = srcImage.Width / destWidth; 175
164 float yscale = srcImage.Height / destHeight; 176
177 // will let last step to be eventually diferent, as seems to be in sl
178
179 float xscale = (float)srcImage.Width / (float)destWidth;
180 float yscale = (float)srcImage.Height / (float)destHeight;
181
182 int lastsx = srcImage.Width - 1;
183 int lastsy = srcImage.Height - 1;
184 int lastdx = destWidth - 1;
185 int lastdy = destHeight - 1;
165 186
166 float sy = 0.5f; 187 float sy = 0.5f;
167 for (int y = 0; y < destHeight; y++) 188 float sx;
189
190 for (int y = 0; y < lastdy; y++)
168 { 191 {
169 float sx = 0.5f; 192 sx = 0.5f;
170 for (int x = 0; x < destWidth; x++) 193 for (int x = 0; x < lastdx; x++)
171 { 194 {
172 try 195 try
173 { 196 {
@@ -177,11 +200,43 @@ namespace PrimMesher
177 catch (IndexOutOfRangeException) 200 catch (IndexOutOfRangeException)
178 { 201 {
179 } 202 }
180
181 sx += xscale; 203 sx += xscale;
182 } 204 }
205 try
206 {
207 c = srcImage.GetPixel(lastsx, (int)(sy));
208 scaledImage.SetPixel(lastdx, y, Color.FromArgb(c.R, c.G, c.B));
209 }
210 catch (IndexOutOfRangeException)
211 {
212 }
213
183 sy += yscale; 214 sy += yscale;
184 } 215 }
216
217 sx = 0.5f;
218 for (int x = 0; x < lastdx; x++)
219 {
220 try
221 {
222 c = srcImage.GetPixel((int)(sx), lastsy);
223 scaledImage.SetPixel(x, lastdy, Color.FromArgb(c.R, c.G, c.B));
224 }
225 catch (IndexOutOfRangeException)
226 {
227 }
228
229 sx += xscale;
230 }
231 try
232 {
233 c = srcImage.GetPixel(lastsx, lastsy);
234 scaledImage.SetPixel(lastdx, lastdy, Color.FromArgb(c.R, c.G, c.B));
235 }
236 catch (IndexOutOfRangeException)
237 {
238 }
239
185 srcImage.Dispose(); 240 srcImage.Dispose();
186 return scaledImage; 241 return scaledImage;
187 } 242 }
diff --git a/OpenSim/Region/Physics/UbitMeshing/SculptMesh.cs b/OpenSim/Region/Physics/UbitMeshing/SculptMesh.cs
index 655b325..bc1375b 100644
--- a/OpenSim/Region/Physics/UbitMeshing/SculptMesh.cs
+++ b/OpenSim/Region/Physics/UbitMeshing/SculptMesh.cs
@@ -48,7 +48,12 @@ namespace PrimMesher
48 { 48 {
49 if (mirror) 49 if (mirror)
50 invert = !invert; 50 invert = !invert;
51 _SculptMesh(new SculptMap(sculptBitmap, lod).ToRows(mirror), sculptType, invert); 51
52 SculptMap smap = new SculptMap(sculptBitmap, lod);
53
54 List<List<Coord>> rows = smap.ToRows(mirror);
55
56 _SculptMesh(rows, sculptType, invert);
52 } 57 }
53 58
54 private void _SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool invert) 59 private void _SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool invert)