From 0badf3718d98f579e0942e7c888986820d1250a7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Jul 2011 03:35:29 +0100 Subject: refactor: push the part of SceneObjectGroup.CheckSculptAndLoad() that actually deals with the part into a SceneObjectPart.CheckSculptAndLoad() method --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 32 ++++++++++---------- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 34 ++++++++++++++++++++++ 2 files changed, 49 insertions(+), 17 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a184445..fa23fcd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3288,7 +3288,14 @@ namespace OpenSim.Region.Framework.Scenes return retmass; } - + + /// + /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that + /// the physics engine can use it. + /// + /// + /// When the physics engine has finished with it, the sculpt data is discarded to save memory. + /// public void CheckSculptAndLoad() { if (IsDeleted) @@ -3302,24 +3309,15 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) - { - SceneObjectPart part = parts[i]; - 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( - part.Shape.SculptTexture.ToString(), part, AssetReceived); - } - } - } + parts[i].CheckSculptAndLoad(); } + /// + /// Handle an asset received asynchronously from the asset service. + /// + /// + /// + /// protected void AssetReceived(string id, Object sender, AssetBase asset) { SceneObjectPart sop = (SceneObjectPart)sender; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5b203e9..ce7c53a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.IO; using System.Reflection; using System.Runtime.Serialization; using System.Security.Permissions; @@ -4563,6 +4564,7 @@ namespace OpenSim.Region.Framework.Scenes m_shape.PathTaperY = shapeBlock.PathTaperY; m_shape.PathTwist = shapeBlock.PathTwist; m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; + if (PhysActor != null) { PhysActor.Shape = m_shape; @@ -4584,6 +4586,37 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// If the part is a sculpt/mesh, retrieve the mesh data and reinsert it into the shape so that the physics + /// engine can use it. + /// + /// + /// When the physics engine has finished with it, the sculpt data is discarded to save memory. + /// + public void CheckSculptAndLoad() + { +// m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); + + if (ParentGroup.IsDeleted) + return; + + if ((ParentGroup.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0) + return; + + if (Shape.SculptEntry && Shape.SculptTexture != UUID.Zero) + { + // check if a previously decoded sculpt map has been cached + if (File.Exists(System.IO.Path.Combine("j2kDecodeCache", "smap_" + Shape.SculptTexture.ToString()))) + { + SculptTextureCallback(Shape.SculptTexture, null); + } + else + { + ParentGroup.Scene.AssetService.Get(Shape.SculptTexture.ToString(), this, AssetReceived); + } + } + } + + /// /// Update the textures on the part. /// /// Added to handle bug in libsecondlife's TextureEntry.ToBytes() @@ -4819,6 +4852,7 @@ namespace OpenSim.Region.Framework.Scenes Inventory.ApplyNextOwnerPermissions(); } + public void UpdateLookAt() { try -- cgit v1.1