Changes to support client-side image pre-caching in the region. This
  commit adds an additional calling sequence to the DynamicTexture data
  and URL calls. The new interface allows a dynamic image to be loaded
  into a specific object face (rather than the mandatory ALL_SIDES
  supported today.
  This is in part fulfilment of ticket #458.
This commit is contained in:
Dr Scofield
2009-05-22 16:22:49 +00:00
parent 6626937e9a
commit 3b689e506f
6 changed files with 178 additions and 50 deletions

View File

@@ -42,6 +42,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
{
public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private const int ALL_SIDES = -1;
private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>();
private Dictionary<string, IDynamicTextureRender> RenderPlugins =
@@ -105,6 +109,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
string extraParams, int updateTimer, bool SetBlending, byte AlphaValue)
{
return AddDynamicTextureURL(simID, primID, contentType, url, extraParams, updateTimer, SetBlending, AlphaValue, ALL_SIDES);
}
public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
string extraParams, int updateTimer, bool SetBlending, byte AlphaValue, int face)
{
if (RenderPlugins.ContainsKey(contentType))
{
@@ -120,6 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
updater.Params = extraParams;
updater.BlendWithOldTexture = SetBlending;
updater.FrontAlpha = AlphaValue;
updater.Face = face;
lock (Updaters)
{
@@ -143,6 +154,12 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
string extraParams, int updateTimer, bool SetBlending, byte AlphaValue)
{
return AddDynamicTextureData(simID, primID, contentType, data, extraParams, updateTimer, SetBlending, AlphaValue, ALL_SIDES);
}
public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
string extraParams, int updateTimer, bool SetBlending, byte AlphaValue, int face)
{
if (RenderPlugins.ContainsKey(contentType))
{
@@ -156,6 +173,8 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
updater.Params = extraParams;
updater.BlendWithOldTexture = SetBlending;
updater.FrontAlpha = AlphaValue;
updater.Face = face;
updater.Url = "Local image";
lock (Updaters)
{
@@ -232,6 +251,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public UUID SimUUID;
public UUID UpdaterID;
public int UpdateTimer;
public int Face;
public string Url;
public DynamicTextureUpdater()
@@ -249,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
if (data == null)
if (data == null || data.Length <= 1)
{
string msg =
String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url);
@@ -287,34 +307,51 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
asset.Data = assetData;
asset.Name = "DynamicImage" + Util.RandomClass.Next(1, 10000);
asset.Type = 0;
asset.Description = "dynamic image";
asset.Description = String.Format("URL image : {0}", Url);
asset.Local = false;
asset.Temporary = true;
scene.AssetService.Store(asset);
LastAssetID = asset.FullID;
IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>();
if (cacheLayerDecode != null)
{
cacheLayerDecode.syncdecode(asset.FullID, asset.Data);
cacheLayerDecode = null;
LastAssetID = asset.FullID;
}
cacheLayerDecode = null;
// mostly keep the values from before
Primitive.TextureEntry tmptex = part.Shape.Textures;
// remove the old asset from the cache
// UUID oldID = tmptex.DefaultTexture.TextureID;
// remove the old asset from the cache later
UUID oldID = tmptex.DefaultTexture.TextureID;
tmptex.DefaultTexture.TextureID = asset.FullID;
if (Face == ALL_SIDES)
{
tmptex.DefaultTexture.TextureID = asset.FullID;
}
else
{
try
{
Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face);
texface.TextureID = asset.FullID;
tmptex.FaceTextures[Face] = texface;
}
catch(Exception)
{
tmptex.DefaultTexture.TextureID = asset.FullID;
}
}
// I'm pretty sure we always want to force this to true
// I'm pretty sure noone whats to set fullbright true if it wasn't true before.
// tmptex.DefaultTexture.Fullbright = true;
part.Shape.Textures = tmptex;
part.ScheduleFullUpdate();
part.UpdateTexture(tmptex);
// scene.CommsManager.AssetCache.ExpireAsset(oldID);
scene.AssetService.Delete(oldID.ToString());
}
private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha)