From 05cbf0b502f65ebae5330e4db27fc8cf85a83b48 Mon Sep 17 00:00:00 2001
From: Dahlia Trimble
Date: Fri, 29 May 2009 06:50:15 +0000
Subject: reinstate a hopefully more robust experimental decoded sculpt map
 caching scheme

---
 OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 18 +++++++++++-------
 OpenSim/Region/Framework/Scenes/SceneObjectPart.cs  |  4 ++--
 OpenSim/Region/Physics/Meshing/Meshmerizer.cs       |  8 +++++---
 3 files changed, 18 insertions(+), 12 deletions(-)

(limited to 'OpenSim')

diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 37ab581..4446fa4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -2967,10 +2967,13 @@ namespace OpenSim.Region.Framework.Scenes
                         {
                             if (part.Shape.SculptEntry && part.Shape.SculptTexture != UUID.Zero)
                             {
-                                //// check if a previously decoded sculpt map has been cached
-                                //if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + part.Shape.SculptTexture.ToString())))
-                                //    part.SculptTextureCallback(part.Shape.SculptTexture, null);
-                                //else
+                                // check if a previously decoded sculpt map has been cached
+                                if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + part.Shape.SculptTexture.ToString())))
+                                {
+                                    m_log.Debug("[SCULPT]: found cached sculpt map - calling AssetReceived");
+                                    part.SculptTextureCallback(part.Shape.SculptTexture, null);
+                                }
+                                else
                                     m_scene.AssetService.Get(
                                         part.Shape.SculptTexture.ToString(), part, AssetReceived);
                             }
@@ -2982,10 +2985,11 @@ namespace OpenSim.Region.Framework.Scenes
 
         protected void AssetReceived(string id, Object sender, AssetBase asset)
         {
-            if (asset != null)
+            SceneObjectPart sop = (SceneObjectPart)sender;
+
+            if (sop != null)
             {
-                SceneObjectPart sop = (SceneObjectPart)sender;
-                if (sop != null)
+                if (asset != null)
                     sop.SculptTextureCallback(asset.FullID, asset);
             }
         }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 093dd73..71d4d33 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2269,9 +2269,9 @@ if (m_shape != null) {
             if (m_shape.SculptEntry)
             {
                 // commented out for sculpt map caching test - null could mean a cached sculpt map has been found
-                if (texture != null)
+                //if (texture != null)
                 {
-                    //if (texture != null)
+                    if (texture != null)
                         m_shape.SculptData = texture.Data;
 
                     if (PhysActor != null)
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index 6832507..f3e79c9 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -71,7 +71,7 @@ namespace OpenSim.Region.Physics.Meshing
         private const string baseDir = null; //"rawFiles";
 #endif
 
-        private bool cacheSculptMaps = false;
+        private bool cacheSculptMaps = true;
         private string decodedScultMapPath = "j2kDecodeCache";
 
         private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
@@ -184,8 +184,8 @@ namespace OpenSim.Region.Physics.Meshing
 
             if (primShape.SculptEntry)
             {
-                if (primShape.SculptData.Length == 0)
-                    return null;
+                //if (primShape.SculptData.Length == 0)
+                //    return null;
 
                 if (cacheSculptMaps && primShape.SculptTexture != null)
                 {
@@ -196,6 +196,8 @@ namespace OpenSim.Region.Physics.Meshing
                         {
                             idata = Image.FromFile(decodedSculptFileName);
                         }
+                        else if (primShape.SculptData.Length == 0)
+                            return null;
                     }
                     catch (Exception e)
                     {
-- 
cgit v1.1