aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
diff options
context:
space:
mode:
authorDahlia Trimble2009-05-29 02:46:35 +0000
committerDahlia Trimble2009-05-29 02:46:35 +0000
commitdb4f8d129887cd4fdd5603918590b3c940191882 (patch)
tree1bc01eb0e30135b30e0dcdbefad680b5af575109 /OpenSim/Region/Physics/Meshing/Meshmerizer.cs
parentMaking the delegate handlers async in async Get, to make things consistent. T... (diff)
downloadopensim-SC-db4f8d129887cd4fdd5603918590b3c940191882.zip
opensim-SC-db4f8d129887cd4fdd5603918590b3c940191882.tar.gz
opensim-SC-db4f8d129887cd4fdd5603918590b3c940191882.tar.bz2
opensim-SC-db4f8d129887cd4fdd5603918590b3c940191882.tar.xz
Experimental decoded sculpt map caching
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/Meshmerizer.cs')
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs65
1 files changed, 48 insertions, 17 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index 3e14fc4..21f922f 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -37,6 +37,7 @@ using System.Drawing.Imaging;
37using PrimMesher; 37using PrimMesher;
38using log4net; 38using log4net;
39using System.Reflection; 39using System.Reflection;
40using System.IO;
40 41
41namespace OpenSim.Region.Physics.Meshing 42namespace OpenSim.Region.Physics.Meshing
42{ 43{
@@ -70,6 +71,8 @@ namespace OpenSim.Region.Physics.Meshing
70 private const string baseDir = null; //"rawFiles"; 71 private const string baseDir = null; //"rawFiles";
71#endif 72#endif
72 73
74 private string decodedScultMapPath = "j2kDecodeCache";
75
73 private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh 76 private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
74 77
75 78
@@ -176,34 +179,62 @@ namespace OpenSim.Region.Physics.Meshing
176 List<Face> faces; 179 List<Face> faces;
177 180
178 Image idata = null; 181 Image idata = null;
182 string decodedSculptFileName = "";
179 183
180 if (primShape.SculptEntry) 184 if (primShape.SculptEntry)
181 { 185 {
182 if (primShape.SculptData.Length == 0) 186 if (primShape.SculptData.Length == 0)
183 return null; 187 return null;
184 188
185 try 189 if (primShape.SculptTexture != null)
186 {
187 ManagedImage managedImage; // we never use this
188 OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata);
189
190 }
191 catch (DllNotFoundException)
192 {
193 m_log.Error("[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!");
194 return null;
195 }
196 catch (IndexOutOfRangeException)
197 { 190 {
198 m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed"); 191 decodedSculptFileName = System.IO.Path.Combine(decodedScultMapPath, "smap_" + primShape.SculptTexture.ToString());
199 return null; 192 try
193 {
194 if (File.Exists(decodedSculptFileName))
195 {
196 idata = Image.FromFile(decodedSculptFileName);
197 }
198 }
199 catch (Exception e)
200 {
201 m_log.Error("[SCULPT]: unable to load cached sculpt map " + decodedSculptFileName + " " + e.Message);
202
203 }
204 if (idata != null)
205 m_log.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString());
200 } 206 }
201 catch (Exception) 207
208 if (idata == null)
202 { 209 {
203 m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed!"); 210 try
204 return null; 211 {
212 ManagedImage managedImage; // we never use this
213 OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata);
214
215 //if (File.Exists(System.IO.Path.GetDirectoryName(decodedScultMapPath)))
216 try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); }
217 catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); }
218 }
219 catch (DllNotFoundException)
220 {
221 m_log.Error("[PHYSICS]: OpenJpeg is not installed correctly on this system. Physics Proxy generation failed. Often times this is because of an old version of GLIBC. You must have version 2.4 or above!");
222 return null;
223 }
224 catch (IndexOutOfRangeException)
225 {
226 m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed");
227 return null;
228 }
229 catch (Exception)
230 {
231 m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed!");
232 return null;
233 }
205 } 234 }
206 235
236
237
207 PrimMesher.SculptMesh.SculptType sculptType; 238 PrimMesher.SculptMesh.SculptType sculptType;
208 switch ((OpenMetaverse.SculptType)primShape.SculptType) 239 switch ((OpenMetaverse.SculptType)primShape.SculptType)
209 { 240 {