diff options
author | Melanie | 2009-10-02 19:53:42 +0100 |
---|---|---|
committer | Melanie | 2009-10-02 19:53:42 +0100 |
commit | 9eccea577716ee4331d30d519da389393b8606cd (patch) | |
tree | 2e3f1ad5892a7e1d1dc0155f1613adab8bcd2690 /OpenSim/Region/Framework | |
parent | Merge branch 'master' into vehicles (diff) | |
parent | Merge branch 'master' into diva-textures (diff) | |
download | opensim-SC_OLD-9eccea577716ee4331d30d519da389393b8606cd.zip opensim-SC_OLD-9eccea577716ee4331d30d519da389393b8606cd.tar.gz opensim-SC_OLD-9eccea577716ee4331d30d519da389393b8606cd.tar.bz2 opensim-SC_OLD-9eccea577716ee4331d30d519da389393b8606cd.tar.xz |
Merge branch 'master' into vehicles
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneManager.cs | 122 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 39 |
3 files changed, 34 insertions, 132 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs index b153997..856eb11 100644 --- a/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs +++ b/OpenSim/Region/Framework/Interfaces/IJ2KDecoder.cs | |||
@@ -30,12 +30,11 @@ using OpenMetaverse.Imaging; | |||
30 | 30 | ||
31 | namespace OpenSim.Region.Framework.Interfaces | 31 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 32 | { |
33 | |||
34 | public delegate void DecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers); | 33 | public delegate void DecodedCallback(UUID AssetId, OpenJPEG.J2KLayerInfo[] layers); |
35 | 34 | ||
36 | public interface IJ2KDecoder | 35 | public interface IJ2KDecoder |
37 | { | 36 | { |
38 | void decode(UUID AssetId, byte[] assetData, DecodedCallback decodedReturn); | 37 | void BeginDecode(UUID assetID, byte[] j2kData, DecodedCallback callback); |
39 | void syncdecode(UUID AssetId, byte[] j2kdata); | 38 | void Decode(UUID assetID, byte[] j2kData); |
40 | } | 39 | } |
41 | } | 40 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 1d4efd0..3097929 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -540,127 +540,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
540 | { | 540 | { |
541 | m_localScenes.ForEach(action); | 541 | m_localScenes.ForEach(action); |
542 | } | 542 | } |
543 | |||
544 | public void CacheJ2kDecode(int threads) | ||
545 | { | ||
546 | if (threads < 1) threads = 1; | ||
547 | |||
548 | IJ2KDecoder m_decoder = m_localScenes[0].RequestModuleInterface<IJ2KDecoder>(); | ||
549 | |||
550 | List<UUID> assetRequestList = new List<UUID>(); | ||
551 | |||
552 | #region AssetGathering! | ||
553 | foreach (Scene scene in m_localScenes) | ||
554 | { | ||
555 | List<EntityBase> entitles = scene.GetEntities(); | ||
556 | foreach (EntityBase entity in entitles) | ||
557 | { | ||
558 | if (entity is SceneObjectGroup) | ||
559 | { | ||
560 | SceneObjectGroup sog = (SceneObjectGroup) entity; | ||
561 | foreach (SceneObjectPart part in sog.Children.Values) | ||
562 | { | ||
563 | if (part.Shape != null) | ||
564 | { | ||
565 | if (part.Shape.TextureEntry.Length > 0) | ||
566 | { | ||
567 | OpenMetaverse.Primitive.TextureEntry te = | ||
568 | new Primitive.TextureEntry(part.Shape.TextureEntry, 0, | ||
569 | part.Shape.TextureEntry.Length); | ||
570 | if (te.DefaultTexture != null) // this has been null for some reason... | ||
571 | { | ||
572 | if (te.DefaultTexture.TextureID != UUID.Zero) | ||
573 | assetRequestList.Add(te.DefaultTexture.TextureID); | ||
574 | } | ||
575 | for (int i=0; i<te.FaceTextures.Length; i++) | ||
576 | { | ||
577 | if (te.FaceTextures[i] != null) | ||
578 | { | ||
579 | if (te.FaceTextures[i].TextureID != UUID.Zero) | ||
580 | { | ||
581 | assetRequestList.Add(te.FaceTextures[i].TextureID); | ||
582 | } | ||
583 | } | ||
584 | } | ||
585 | } | ||
586 | if (part.Shape.SculptTexture != UUID.Zero) | ||
587 | { | ||
588 | assetRequestList.Add(part.Shape.SculptTexture); | ||
589 | } | ||
590 | |||
591 | } | ||
592 | } | ||
593 | } | ||
594 | } | ||
595 | } | ||
596 | #endregion | ||
597 | |||
598 | int entries_per_thread = (assetRequestList.Count / threads) + 1; | ||
599 | |||
600 | UUID[] arrAssetRequestList = assetRequestList.ToArray(); | ||
601 | |||
602 | List<UUID[]> arrvalus = new List<UUID[]>(); | ||
603 | |||
604 | //split into separate arrays | ||
605 | for (int j = 0; j < threads; j++) | ||
606 | { | ||
607 | List<UUID> val = new List<UUID>(); | ||
608 | |||
609 | for (int k = j * entries_per_thread; k < ((j + 1) * entries_per_thread); k++) | ||
610 | { | ||
611 | if (k < arrAssetRequestList.Length) | ||
612 | { | ||
613 | val.Add(arrAssetRequestList[k]); | ||
614 | } | ||
615 | |||
616 | } | ||
617 | arrvalus.Add(val.ToArray()); | ||
618 | } | ||
619 | |||
620 | for (int l = 0; l < arrvalus.Count; l++) | ||
621 | { | ||
622 | DecodeThreadContents threadworkItem = new DecodeThreadContents(); | ||
623 | threadworkItem.sn = m_localScenes[0]; | ||
624 | threadworkItem.j2kdecode = m_decoder; | ||
625 | threadworkItem.arrassets = arrvalus[l]; | ||
626 | |||
627 | System.Threading.Thread decodethread = | ||
628 | new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(threadworkItem.run)); | ||
629 | |||
630 | threadworkItem.SetThread(decodethread); | ||
631 | |||
632 | decodethread.Priority = System.Threading.ThreadPriority.Lowest; | ||
633 | decodethread.Name = "J2kCacheDecodeThread_" + l + 1; | ||
634 | ThreadTracker.Add(decodethread); | ||
635 | decodethread.Start(); | ||
636 | |||
637 | } | ||
638 | } | ||
639 | } | ||
640 | |||
641 | public class DecodeThreadContents | ||
642 | { | ||
643 | public Scene sn; | ||
644 | public UUID[] arrassets; | ||
645 | public IJ2KDecoder j2kdecode; | ||
646 | private System.Threading.Thread thisthread; | ||
647 | |||
648 | public void run(object o) | ||
649 | { | ||
650 | for (int i=0;i<arrassets.Length;i++) | ||
651 | { | ||
652 | AssetBase ab = sn.AssetService.Get(arrassets[i].ToString()); | ||
653 | if (ab != null && ab.Data != null) | ||
654 | { | ||
655 | j2kdecode.syncdecode(arrassets[i], ab.Data); | ||
656 | } | ||
657 | } | ||
658 | ThreadTracker.Remove(thisthread); | ||
659 | } | ||
660 | |||
661 | public void SetThread(System.Threading.Thread thr) | ||
662 | { | ||
663 | thisthread = thr; | ||
664 | } | ||
665 | } | 543 | } |
666 | } | 544 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 66fefa3..3996cdc 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -74,6 +74,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
74 | 74 | ||
75 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 75 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
76 | 76 | ||
77 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; | ||
78 | |||
77 | public static byte[] DefaultTexture; | 79 | public static byte[] DefaultTexture; |
78 | 80 | ||
79 | public UUID currentParcelUUID = UUID.Zero; | 81 | public UUID currentParcelUUID = UUID.Zero; |
@@ -2686,7 +2688,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2686 | /// </summary> | 2688 | /// </summary> |
2687 | /// <param name="texture"></param> | 2689 | /// <param name="texture"></param> |
2688 | /// <param name="visualParam"></param> | 2690 | /// <param name="visualParam"></param> |
2689 | public void SetAppearance(byte[] texture, List<byte> visualParam) | 2691 | public void SetAppearance(Primitive.TextureEntry textureEntry, byte[] visualParams) |
2690 | { | 2692 | { |
2691 | if (m_physicsActor != null) | 2693 | if (m_physicsActor != null) |
2692 | { | 2694 | { |
@@ -2704,7 +2706,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
2704 | AddToPhysicalScene(flyingTemp); | 2706 | AddToPhysicalScene(flyingTemp); |
2705 | } | 2707 | } |
2706 | } | 2708 | } |
2707 | m_appearance.SetAppearance(texture, visualParam); | 2709 | |
2710 | #region Bake Cache Check | ||
2711 | |||
2712 | if (textureEntry != null) | ||
2713 | { | ||
2714 | for (int i = 0; i < BAKE_INDICES.Length; i++) | ||
2715 | { | ||
2716 | int j = BAKE_INDICES[i]; | ||
2717 | Primitive.TextureEntryFace face = textureEntry.FaceTextures[j]; | ||
2718 | |||
2719 | if (face != null && face.TextureID != AppearanceManager.DEFAULT_AVATAR_TEXTURE) | ||
2720 | { | ||
2721 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | ||
2722 | { | ||
2723 | m_log.Warn("[APPEARANCE]: Missing baked texture " + face.TextureID + " (" + (AppearanceManager.TextureIndex)j + ") for avatar " + this.Name); | ||
2724 | this.ControllingClient.SendRebakeAvatarTextures(face.TextureID); | ||
2725 | } | ||
2726 | } | ||
2727 | } | ||
2728 | } | ||
2729 | |||
2730 | #endregion Bake Cache Check | ||
2731 | |||
2732 | m_appearance.SetAppearance(textureEntry, visualParams); | ||
2708 | if (m_appearance.AvatarHeight > 0) | 2733 | if (m_appearance.AvatarHeight > 0) |
2709 | SetHeight(m_appearance.AvatarHeight); | 2734 | SetHeight(m_appearance.AvatarHeight); |
2710 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 2735 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); |
@@ -3255,14 +3280,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3255 | wears[i++] = new AvatarWearable(itemId, assetId); | 3280 | wears[i++] = new AvatarWearable(itemId, assetId); |
3256 | } | 3281 | } |
3257 | m_appearance.Wearables = wears; | 3282 | m_appearance.Wearables = wears; |
3258 | byte[] te = null; | 3283 | Primitive.TextureEntry te; |
3259 | if (cAgent.AgentTextures != null) | 3284 | if (cAgent.AgentTextures != null && cAgent.AgentTextures.Length > 1) |
3260 | te = cAgent.AgentTextures; | 3285 | te = new Primitive.TextureEntry(cAgent.AgentTextures, 0, cAgent.AgentTextures.Length); |
3261 | else | 3286 | else |
3262 | te = AvatarAppearance.GetDefaultTexture().GetBytes(); | 3287 | te = AvatarAppearance.GetDefaultTexture(); |
3263 | if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) | 3288 | if ((cAgent.VisualParams == null) || (cAgent.VisualParams.Length < AvatarAppearance.VISUALPARAM_COUNT)) |
3264 | cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); | 3289 | cAgent.VisualParams = AvatarAppearance.GetDefaultVisualParams(); |
3265 | m_appearance.SetAppearance(te, new List<byte>(cAgent.VisualParams)); | 3290 | m_appearance.SetAppearance(te, (byte[])cAgent.VisualParams.Clone()); |
3266 | } | 3291 | } |
3267 | catch (Exception e) | 3292 | catch (Exception e) |
3268 | { | 3293 | { |