aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
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
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')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs2
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs65
3 files changed, 55 insertions, 20 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index e0a50a1..a60ae83 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2967,8 +2967,12 @@ namespace OpenSim.Region.Framework.Scenes
2967 { 2967 {
2968 if (part.Shape.SculptEntry && part.Shape.SculptTexture != UUID.Zero) 2968 if (part.Shape.SculptEntry && part.Shape.SculptTexture != UUID.Zero)
2969 { 2969 {
2970 m_scene.AssetService.Get( 2970 // check if a previously decoded sculpt map has been cached
2971 part.Shape.SculptTexture.ToString(), part, AssetReceived); 2971 if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + part.Shape.SculptTexture.ToString())))
2972 part.SculptTextureCallback(part.Shape.SculptTexture, null);
2973 else
2974 m_scene.AssetService.Get(
2975 part.Shape.SculptTexture.ToString(), part, AssetReceived);
2972 } 2976 }
2973 } 2977 }
2974 } 2978 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 719b028..7065d2f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2268,7 +2268,7 @@ if (m_shape != null) {
2268 { 2268 {
2269 if (m_shape.SculptEntry) 2269 if (m_shape.SculptEntry)
2270 { 2270 {
2271 if (texture != null) 2271 //if (texture != null) // null could mean a cached sculpt map has been found
2272 { 2272 {
2273 m_shape.SculptData = texture.Data; 2273 m_shape.SculptData = texture.Data;
2274 if (PhysActor != null) 2274 if (PhysActor != null)
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 {