Experimental decoded sculpt map caching
parent
1e9cb2f8fc
commit
db4f8d1298
|
@ -2967,6 +2967,10 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
if (part.Shape.SculptEntry && part.Shape.SculptTexture != UUID.Zero)
|
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
|
||||||
m_scene.AssetService.Get(
|
m_scene.AssetService.Get(
|
||||||
part.Shape.SculptTexture.ToString(), part, AssetReceived);
|
part.Shape.SculptTexture.ToString(), part, AssetReceived);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2268,7 +2268,7 @@ if (m_shape != null) {
|
||||||
{
|
{
|
||||||
if (m_shape.SculptEntry)
|
if (m_shape.SculptEntry)
|
||||||
{
|
{
|
||||||
if (texture != null)
|
//if (texture != null) // null could mean a cached sculpt map has been found
|
||||||
{
|
{
|
||||||
m_shape.SculptData = texture.Data;
|
m_shape.SculptData = texture.Data;
|
||||||
if (PhysActor != null)
|
if (PhysActor != null)
|
||||||
|
|
|
@ -37,6 +37,7 @@ using System.Drawing.Imaging;
|
||||||
using PrimMesher;
|
using PrimMesher;
|
||||||
using log4net;
|
using log4net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace OpenSim.Region.Physics.Meshing
|
namespace OpenSim.Region.Physics.Meshing
|
||||||
{
|
{
|
||||||
|
@ -70,6 +71,8 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
private const string baseDir = null; //"rawFiles";
|
private const string baseDir = null; //"rawFiles";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private string decodedScultMapPath = "j2kDecodeCache";
|
||||||
|
|
||||||
private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
|
private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,17 +179,42 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
List<Face> faces;
|
List<Face> faces;
|
||||||
|
|
||||||
Image idata = null;
|
Image idata = null;
|
||||||
|
string decodedSculptFileName = "";
|
||||||
|
|
||||||
if (primShape.SculptEntry)
|
if (primShape.SculptEntry)
|
||||||
{
|
{
|
||||||
if (primShape.SculptData.Length == 0)
|
if (primShape.SculptData.Length == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
if (primShape.SculptTexture != null)
|
||||||
|
{
|
||||||
|
decodedSculptFileName = System.IO.Path.Combine(decodedScultMapPath, "smap_" + primShape.SculptTexture.ToString());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(decodedSculptFileName))
|
||||||
|
{
|
||||||
|
idata = Image.FromFile(decodedSculptFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.Error("[SCULPT]: unable to load cached sculpt map " + decodedSculptFileName + " " + e.Message);
|
||||||
|
|
||||||
|
}
|
||||||
|
if (idata != null)
|
||||||
|
m_log.Debug("[SCULPT]: loaded cached map asset for map ID: " + primShape.SculptTexture.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (idata == null)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ManagedImage managedImage; // we never use this
|
ManagedImage managedImage; // we never use this
|
||||||
OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata);
|
OpenJPEG.DecodeToImage(primShape.SculptData, out managedImage, out idata);
|
||||||
|
|
||||||
|
//if (File.Exists(System.IO.Path.GetDirectoryName(decodedScultMapPath)))
|
||||||
|
try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); }
|
||||||
|
catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); }
|
||||||
}
|
}
|
||||||
catch (DllNotFoundException)
|
catch (DllNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -203,6 +231,9 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed!");
|
m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PrimMesher.SculptMesh.SculptType sculptType;
|
PrimMesher.SculptMesh.SculptType sculptType;
|
||||||
switch ((OpenMetaverse.SculptType)primShape.SculptType)
|
switch ((OpenMetaverse.SculptType)primShape.SculptType)
|
||||||
|
|
Loading…
Reference in New Issue