Skip to content

Commit

Permalink
Updated Scene related classes (SceneGraph, Scene and SceneEntity and …
Browse files Browse the repository at this point in the history
…sublasses).
  • Loading branch information
mdickson committed Apr 3, 2024
1 parent 65b9ece commit bde2ad5
Show file tree
Hide file tree
Showing 20 changed files with 574 additions and 507 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,8 @@ public override bool HandleIncomingSceneObject(SceneObjectGroup so, Vector3 newP
// so.Name, so.AttachedAvatar, url);

IDictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>();
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, url, ids);
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.Logger, m_scene.AssetService);
uuidGatherer.Initialize(assetServerURL: url, collector: ids);
uuidGatherer.AddForInspection(defso);

while (!uuidGatherer.Complete)
Expand Down Expand Up @@ -807,7 +808,9 @@ public override bool HandleIncomingAttachments(ScenePresence sp, List<SceneObjec
{
string url = aCircuit.ServiceURLs["AssetServerURI"].ToString();
IDictionary<UUID, sbyte> ids = new Dictionary<UUID, sbyte>();
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, url, ids);

HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.Logger, m_scene.AssetService);
uuidGatherer.Initialize(assetServerURL: url, collector: ids);

foreach (SceneObjectGroup defso in deftatt)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Security.Policy;
using System.Text;

using log4net;
Expand All @@ -37,6 +38,7 @@

using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using Org.BouncyCastle.Crypto;

namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
{
Expand Down Expand Up @@ -194,8 +196,10 @@ protected string RewriteSOP(string xmlData)
public void Get(UUID assetID, UUID ownerID, string userAssetURL)
{
// The act of gathering UUIDs downloads some assets from the remote server
// but not all...
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, userAssetURL);
// but not all...
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.Logger, m_scene.AssetService);
uuidGatherer.Initialize(assetServerURL: userAssetURL);

uuidGatherer.AddForInspection(assetID);
uuidGatherer.GatherAll();

Expand Down Expand Up @@ -227,7 +231,9 @@ public void Post(UUID assetID, UUID ownerID, string userAssetURL)
m_log.DebugFormat("[HG ASSET MAPPER POST]: Starting to send asset {0} to asset server {1}", assetID, userAssetURL);

// Find all the embedded assets
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.AssetService, string.Empty);
HGUuidGatherer uuidGatherer = new HGUuidGatherer(m_scene.Logger, m_scene.AssetService);
uuidGatherer.Initialize(assetServerURL: string.Empty);

uuidGatherer.AddForInspection(asset.FullID);
uuidGatherer.GatherAll(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public class MovementAnimationOverrides
private object MAOLock = new object();
private Dictionary<string, UUID> m_overrides = new Dictionary<string, UUID>();

private readonly ILogger _logger;
private readonly ILogger? _logger;

public MovementAnimationOverrides(ILogger<MovementAnimationOverrides> logger)
public MovementAnimationOverrides(ILogger? logger)
{
_logger = logger;
}
Expand All @@ -53,7 +53,7 @@ public void SetOverride(string state, UUID animID)
return;
}

_logger.LogDebug($"Setting override for {state} to {animID}", state, animID);
_logger?.LogDebug($"Setting override for {state} to {animID}", state, animID);

lock (MAOLock)
m_overrides[state] = animID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
/// </summary>
public class ScenePresenceAnimator
{
private readonly ILogger<ScenePresenceAnimator> _logger;
private readonly ILogger? _logger;

private float m_lastFallVelocity;

Expand Down Expand Up @@ -73,7 +73,7 @@ public AnimationSet Animations
/// </summary>
public bool Falling { get; private set; }

public ScenePresenceAnimator(ILogger<ScenePresenceAnimator> logger, ScenePresence sp)
public ScenePresenceAnimator(ILogger? logger, ScenePresence sp)
{
_logger = logger;

Expand All @@ -88,7 +88,7 @@ public void AddAnimation(UUID animID, UUID objectID)

if (m_scenePresence.Scene.DebugAnimations)
{
_logger.LogDebug($"[SCENE PRESENCE ANIMATOR]: Adding animation {GetAnimName(animID)} {animID} for {m_scenePresence.Name}");
_logger?.LogDebug($"[SCENE PRESENCE ANIMATOR]: Adding animation {GetAnimName(animID)} {animID} for {m_scenePresence.Name}");
}

if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID))
Expand Down Expand Up @@ -128,7 +128,7 @@ public void RemoveAnimation(UUID animID, bool allowNoDefault)

if (m_scenePresence.Scene.DebugAnimations)
{
_logger.LogDebug($"[SCENE PRESENCE ANIMATOR]: Removing animation {GetAnimName(animID)} {animID} for {m_scenePresence.Name}");
_logger?.LogDebug($"[SCENE PRESENCE ANIMATOR]: Removing animation {GetAnimName(animID)} {animID} for {m_scenePresence.Name}");
}

if (m_animations.Remove(animID, allowNoDefault))
Expand Down Expand Up @@ -179,7 +179,7 @@ public void ResetAnimations()
{
if (m_scenePresence.Scene.DebugAnimations)
{
_logger.LogDebug(
_logger?.LogDebug(
$"[SCENE PRESENCE ANIMATOR]: Resetting animations for {m_scenePresence.Name} " +
$"in {m_scenePresence.Scene.RegionInfo.RegionName}");
}
Expand All @@ -200,7 +200,7 @@ public bool TrySetMovementAnimation(string anim)
{
if (m_scenePresence.IsChildAgent)
{
_logger.LogWarning($"[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {anim} on child presence {m_scenePresence.Name}");
_logger?.LogWarning($"[SCENE PRESENCE ANIMATOR]: Tried to set movement animation {anim} on child presence {m_scenePresence.Name}");

return false;
}
Expand Down
6 changes: 6 additions & 0 deletions Source/OpenSim.Region.Framework/Scenes/EntityBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

using OpenSim.Framework;
using OpenMetaverse;
using Microsoft.Extensions.Logging;

namespace OpenSim.Region.Framework.Scenes
{
Expand All @@ -41,6 +42,11 @@ public Scene Scene
get { return m_scene; }
}

/// <summary>
/// A Logger to use for this scene and related objects.
/// </summary>
public ILogger? Logger { get { return Scene?.Logger; } }

protected UUID m_uuid;
public virtual UUID UUID
{
Expand Down
48 changes: 26 additions & 22 deletions Source/OpenSim.Region.Framework/Scenes/Scene.PacketHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void SimChat(string message, ChatTypeEnum type, int channel, Vector3 from
args.SenderObject = obj;
}

//m_log.DebugFormat(
//Logger?.DebugFormat(
// "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}",
// args.Message.Replace("\n", "\\n"), args.Channel, args.Type, fromName, broadcast);

Expand Down Expand Up @@ -248,7 +248,7 @@ private void HandleObjectGroupUpdate(

if (gmd == null)
{
// m_log.WarnFormat(
// Logger?.WarnFormat(
// "[GROUPS]: User {0} is not a member of group {1} so they can't update {2} to this group",
// remoteClient.Name, GroupID, objectLocalID);

Expand Down Expand Up @@ -512,7 +512,7 @@ void ProcessViewerEffect(IClientAPI remoteClient, List<ViewerEffectEventHandlerA
if ((EffectType)effect.Type != EffectType.LookAt && (EffectType)effect.Type != EffectType.Beam)
discardableEffects = false;

//m_log.DebugFormat("[YYY]: VE {0} {1} {2}", effect.AgentID, effect.Duration, (EffectType)effect.Type);
//Logger?.DebugFormat("[YYY]: VE {0} {1} {2}", effect.AgentID, effect.Duration, (EffectType)effect.Type);
}

ForEachScenePresence(sp =>
Expand All @@ -522,11 +522,11 @@ void ProcessViewerEffect(IClientAPI remoteClient, List<ViewerEffectEventHandlerA
if (!discardableEffects ||
(discardableEffects && ShouldSendDiscardableEffect(remoteClient, sp)))
{
//m_log.DebugFormat("[YYY]: Sending to {0}", sp.UUID);
//Logger?.DebugFormat("[YYY]: Sending to {0}", sp.UUID);
sp.ControllingClient.SendViewerEffect(effectBlockArray);
}
//else
// m_log.DebugFormat("[YYY]: Not sending to {0}", sp.UUID);
// Logger?.DebugFormat("[YYY]: Not sending to {0}", sp.UUID);
}
});
}
Expand Down Expand Up @@ -562,7 +562,7 @@ private class DescendentsRequestData
public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID,
bool fetchFolders, bool fetchItems, int sortOrder)
{
// m_log.DebugFormat(
// Logger?.DebugFormat(
// "[USER INVENTORY]: HandleFetchInventoryDescendents() for {0}, folder={1}, fetchFolders={2}, fetchItems={3}, sortOrder={4}",
// remoteClient.Name, folderID, fetchFolders, fetchItems, sortOrder);

Expand Down Expand Up @@ -641,15 +641,17 @@ void SendInventoryAsync()
/// <param name="folderType"></param>
/// <param name="folderName"></param>
/// <param name="parentID"></param>
public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType,
string folderName, UUID parentID)
public void HandleCreateInventoryFolder(
IClientAPI remoteClient,
UUID folderID,
ushort folderType,
string folderName,
UUID parentID)
{
InventoryFolderBase folder = new InventoryFolderBase(folderID, folderName, remoteClient.AgentId, (short)folderType, parentID, 1);
if (!InventoryService.AddFolder(folder))
{
m_log.WarnFormat(
"[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
remoteClient.Name, remoteClient.AgentId);
Logger?.LogWarning($"[AGENT INVENTORY]: Failed to create folder for user {remoteClient.Name} {remoteClient.AgentId}");
}
}

Expand All @@ -665,7 +667,7 @@ public void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID,
public void HandleUpdateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort type, string name,
UUID parentID)
{
// m_log.DebugFormat(
// Logger?.DebugFormat(
// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId);

InventoryFolderBase folder = InventoryService.GetFolder(remoteClient.AgentId, folderID);
Expand All @@ -676,9 +678,7 @@ public void HandleUpdateInventoryFolder(IClientAPI remoteClient, UUID folderID,
folder.ParentID = parentID;
if (!InventoryService.UpdateFolder(folder))
{
m_log.ErrorFormat(
"[AGENT INVENTORY]: Failed to update folder for user {0} {1}",
remoteClient.Name, remoteClient.AgentId);
Logger?.LogError($"[AGENT INVENTORY]: Failed to update folder for user {remoteClient.Name} {remoteClient.AgentId}");
}
}
}
Expand All @@ -690,13 +690,17 @@ public void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UU
{
folder.ParentID = parentID;
if (!InventoryService.MoveFolder(folder))
m_log.WarnFormat("[AGENT INVENTORY]: could not move folder {0}", folderID);
{
Logger?.LogWarning($"[AGENT INVENTORY]: could not move folder {folderID}");
}
else
m_log.DebugFormat("[AGENT INVENTORY]: folder {0} moved to parent {1}", folderID, parentID);
{
Logger?.LogDebug($"[AGENT INVENTORY]: folder {folderID} moved to parent {parentID}", folderID, parentID);
}
}
else
{
m_log.WarnFormat("[AGENT INVENTORY]: request to move folder {0} but folder not found", folderID);
Logger?.LogWarning($"[AGENT INVENTORY]: request to move folder {folderID} but folder not found");
}
}

Expand All @@ -718,7 +722,7 @@ public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folder
}
catch (Exception e)
{
m_log.WarnFormat("[AGENT INVENTORY]: Exception on purge folder for user {0}: {1}", remoteClient.AgentId, e.Message);
Logger?.LogWarning(e, $"[AGENT INVENTORY]: Exception on purge folder for user {remoteClient.AgentId}.");
}
}

Expand All @@ -729,13 +733,13 @@ private void PurgeFolderAsync(UUID userID, UUID folderID)
try
{
if (InventoryService.PurgeFolder(folder))
m_log.DebugFormat("[AGENT INVENTORY]: folder {0} purged successfully", folderID);
Logger?.LogDebug($"[AGENT INVENTORY]: folder {folderID} purged successfully");
else
m_log.WarnFormat("[AGENT INVENTORY]: could not purge folder {0}", folderID);
Logger?.LogWarning($"[AGENT INVENTORY]: could not purge folder {folderID}");
}
catch (Exception e)
{
m_log.WarnFormat("[AGENT INVENTORY]: Exception on async purge folder for user {0}: {1}", userID, e.Message);
Logger?.LogWarning(e, $"[AGENT INVENTORY]: Exception on async purge folder for user {userID}.");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/OpenSim.Region.Framework/Scenes/SceneBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public virtual void Close()
}
catch (Exception e)
{
m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception {0}", e));
Logger?.LogError(e, $"[SCENE]: SceneBase.cs: Close() - Failed with exception");
}
}

Expand Down
Loading

0 comments on commit bde2ad5

Please sign in to comment.