From 67be0213d4dd0ccd95a297aacf739e7a546a9dde Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sat, 28 Mar 2009 02:41:51 +0000 Subject: * Remove redundancies in ScenePresence --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 122 +++++++++++------------ 1 file changed, 59 insertions(+), 63 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b059624..f7ea357 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -28,10 +28,7 @@ using System; using System.Collections.Generic; using System.Reflection; -using System.Runtime.Serialization; -using System.Security.Permissions; using OpenMetaverse; -using OpenMetaverse.Packets; using log4net; using OpenSim.Framework; using OpenSim.Framework.Client; @@ -39,7 +36,6 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes.Types; using OpenSim.Region.Physics.Manager; -using OSD = OpenMetaverse.StructuredData.OSD; namespace OpenSim.Region.Framework.Scenes { @@ -83,24 +79,24 @@ namespace OpenSim.Region.Framework.Scenes private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; private bool MouseDown = false; - private SceneObjectGroup proxyObjectGroup = null; + private SceneObjectGroup proxyObjectGroup; //private SceneObjectPart proxyObjectPart = null; - public Vector3 lastKnownAllowedPosition = new Vector3(); - public bool sentMessageAboutRestrictedParcelFlyingDown = false; + public Vector3 lastKnownAllowedPosition; + public bool sentMessageAboutRestrictedParcelFlyingDown; - private bool m_updateflag = false; - private byte m_movementflag = 0; + private bool m_updateflag; + private byte m_movementflag; private readonly List m_forcesList = new List(); - private short m_updateCount = 0; - private uint m_requestedSitTargetID = 0; + private short m_updateCount; + private uint m_requestedSitTargetID; private UUID m_requestedSitTargetUUID = UUID.Zero; - private bool m_startAnimationSet = false; + private bool m_startAnimationSet; //private Vector3 m_requestedSitOffset = new Vector3(); - private Vector3 m_LastFinitePos = new Vector3(); + private Vector3 m_LastFinitePos; private float m_sitAvatarHeight = 2.0f; @@ -111,26 +107,26 @@ namespace OpenSim.Region.Framework.Scenes // rotation, prim cut, prim twist, prim taper, and prim shear. See mantis // issue #1716 private static readonly Vector3 m_sitTargetCorrectionOffset = new Vector3(0.1f, 0.0f, 0.3f); - private float m_godlevel = 0; + private float m_godlevel; private bool m_invulnerable = true; - private Vector3 m_LastChildAgentUpdatePosition = new Vector3(); + private Vector3 m_LastChildAgentUpdatePosition; - private int m_perfMonMS = 0; + private int m_perfMonMS; - private bool m_sitStatus = false; + private bool m_sitStatus; - private bool m_setAlwaysRun = false; + private bool m_setAlwaysRun; private Quaternion m_bodyRot= Quaternion.Identity; - public bool IsRestrictedToRegion = false; + public bool IsRestrictedToRegion; public string JID = string.Empty; // Agent moves with a PID controller causing a force to be exerted. - private bool m_newForce = false; + private bool m_newForce; private bool m_newCoarseLocations = true; private float m_health = 100f; @@ -140,7 +136,7 @@ namespace OpenSim.Region.Framework.Scenes private float m_avHeight = 127.0f; protected RegionInfo m_regionInfo; - protected ulong crossingFromRegion = 0; + protected ulong crossingFromRegion; private readonly Vector3[] Dir_Vectors = new Vector3[6]; @@ -162,27 +158,27 @@ namespace OpenSim.Region.Framework.Scenes protected Vector3 m_CameraAtAxis = Vector3.Zero; protected Vector3 m_CameraLeftAxis = Vector3.Zero; protected Vector3 m_CameraUpAxis = Vector3.Zero; - private uint m_AgentControlFlags = 0; + private uint m_AgentControlFlags; private Quaternion m_headrotation = Quaternion.Identity; - private byte m_state = 0; + private byte m_state; //Reuse the Vector3 instead of creating a new one on the UpdateMovement method private Vector3 movementvector = Vector3.Zero; - private bool m_autopilotMoving = false; + private bool m_autopilotMoving; private Vector3 m_autoPilotTarget = Vector3.Zero; - private bool m_sitAtAutoTarget = false; + private bool m_sitAtAutoTarget; private string m_nextSitAnimation = String.Empty; //PauPaw:Proper PID Controler for autopilot************ - private bool m_moveToPositionInProgress = false; + private bool m_moveToPositionInProgress; private Vector3 m_moveToPositionTarget = Vector3.Zero; //private int m_moveToPositionStateStatus = 0; //***************************************************** // Agent's Draw distance. - protected float m_DrawDistance = 0f; + protected float m_DrawDistance; protected AvatarAppearance m_appearance; @@ -209,10 +205,10 @@ namespace OpenSim.Region.Framework.Scenes /// /// Position at which a significant movement was made /// - private Vector3 posLastSignificantMove = new Vector3(); + private Vector3 posLastSignificantMove; private UpdateQueue m_partsUpdateQueue = new UpdateQueue(); - private Queue m_pendingObjects = null; + private Queue m_pendingObjects; private Dictionary m_updateTimes = new Dictionary(); @@ -374,7 +370,7 @@ namespace OpenSim.Region.Framework.Scenes get { return (IClientCore) m_controllingClient; } } - protected Vector3 m_parentPosition = new Vector3(); + protected Vector3 m_parentPosition; public Vector3 ParentPosition { get { return m_parentPosition; } @@ -472,7 +468,7 @@ namespace OpenSim.Region.Framework.Scenes set { m_isChildAgent = value; } } - private uint m_parentID = 0; + private uint m_parentID; public uint ParentID { @@ -693,7 +689,7 @@ namespace OpenSim.Region.Framework.Scenes // this.UpdateQuadTreeNode(); //this.RefreshQuadObject(); //} - m_perfMonMS = System.Environment.TickCount; + m_perfMonMS = Environment.TickCount; if (m_pendingObjects == null) { @@ -811,7 +807,7 @@ namespace OpenSim.Region.Framework.Scenes break; } - m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentTime(Environment.TickCount - m_perfMonMS); } #region Status Methods @@ -1129,7 +1125,7 @@ namespace OpenSim.Region.Framework.Scenes //} //} - m_perfMonMS = System.Environment.TickCount; + m_perfMonMS = Environment.TickCount; uint flags = agentData.ControlFlags; Quaternion bodyRotation = agentData.BodyRotation; @@ -1167,7 +1163,7 @@ namespace OpenSim.Region.Framework.Scenes if (scriptedcontrols.Count > 0) { SendControlToScripts(flags); - flags = this.RemoveIgnoredControls(flags, IgnoredControls); + flags = RemoveIgnoredControls(flags, IgnoredControls); } } @@ -1394,7 +1390,7 @@ namespace OpenSim.Region.Framework.Scenes m_scene.EventManager.TriggerOnClientMovement(this); - m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentTime(Environment.TickCount - m_perfMonMS); } public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) @@ -1450,7 +1446,7 @@ namespace OpenSim.Region.Framework.Scenes catch (Exception ex) { //Why did I get this error? - m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex.ToString()); + m_log.Error("[SCENEPRESENCE]: DoMoveToPosition" + ex); } } @@ -1473,6 +1469,7 @@ namespace OpenSim.Region.Framework.Scenes //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); m_requestedSitTargetUUID = UUID.Zero; } + /* else { //ControllingClient.SendAlertMessage("Autopilot cancelled"); @@ -1489,7 +1486,7 @@ namespace OpenSim.Region.Framework.Scenes //m_scene.DeleteSceneObject(proxyObjectGroup); //} } - + */ m_autoPilotTarget = Vector3.Zero; m_autopilotMoving = false; } @@ -1724,7 +1721,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); + m_log.Warn("Sit requested on unknown object: " + targetID); } SendSitResponse(remoteClient, targetID, offset); @@ -1796,12 +1793,12 @@ namespace OpenSim.Region.Framework.Scenes /// Event handler for the 'Always run' setting on the client /// Tells the physics plugin to increase speed of movement. /// - public void HandleSetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun) + public void HandleSetAlwaysRun(IClientAPI remoteClient, bool pSetAlwaysRun) { - m_setAlwaysRun = SetAlwaysRun; + m_setAlwaysRun = pSetAlwaysRun; if (PhysicsActor != null) { - PhysicsActor.SetAlwaysRun = SetAlwaysRun; + PhysicsActor.SetAlwaysRun = pSetAlwaysRun; } } public BinBVHAnimation GenerateRandomAnimation() @@ -2036,7 +2033,7 @@ namespace OpenSim.Region.Framework.Scenes return; } - m_perfMonMS = System.Environment.TickCount; + m_perfMonMS = Environment.TickCount; m_rotation = rotation; NewForce newVelocity = new NewForce(); @@ -2079,7 +2076,7 @@ namespace OpenSim.Region.Framework.Scenes newVelocity.Z = direc.Z; m_forcesList.Add(newVelocity); - m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentTime(Environment.TickCount - m_perfMonMS); } #endregion @@ -2142,16 +2139,16 @@ namespace OpenSim.Region.Framework.Scenes // server. if (remoteClient.IsActive) { - m_perfMonMS = System.Environment.TickCount; + m_perfMonMS = Environment.TickCount; Vector3 pos = m_pos; Vector3 vel = Velocity; Quaternion rot = m_bodyRot; pos.Z -= m_appearance.HipOffset; - remoteClient.SendAvatarTerseUpdate(m_regionHandle, (ushort)(m_scene.TimeDilation * (float)ushort.MaxValue), LocalId, new Vector3(pos.X, pos.Y, pos.Z), + remoteClient.SendAvatarTerseUpdate(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, new Vector3(pos.X, pos.Y, pos.Z), new Vector3(vel.X, vel.Y, vel.Z), rot); - m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentTime(Environment.TickCount - m_perfMonMS); m_scene.AddAgentUpdates(1); } } @@ -2161,7 +2158,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendTerseUpdateToAllClients() { - m_perfMonMS = System.Environment.TickCount; + m_perfMonMS = Environment.TickCount; m_scene.Broadcast(SendTerseUpdateToClient); @@ -2169,13 +2166,13 @@ namespace OpenSim.Region.Framework.Scenes lastPhysPos = AbsolutePosition; lastPhysRot = m_bodyRot; - m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentTime(Environment.TickCount - m_perfMonMS); } public void SendCoarseLocations() { - m_perfMonMS = System.Environment.TickCount; + m_perfMonMS = Environment.TickCount; List CoarseLocations = new List(); List AvatarUUIDs = new List(); @@ -2210,7 +2207,7 @@ namespace OpenSim.Region.Framework.Scenes m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); - m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentTime(Environment.TickCount - m_perfMonMS); } public void CoarseLocationChange() @@ -2252,7 +2249,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendInitialFullUpdateToAllClients() { - m_perfMonMS = System.Environment.TickCount; + m_perfMonMS = Environment.TickCount; List avatars = m_scene.GetScenePresences(); foreach (ScenePresence avatar in avatars) @@ -2269,24 +2266,23 @@ namespace OpenSim.Region.Framework.Scenes { if (!avatar.IsChildAgent) { - m_log.Debug(DateTime.Now.ToString()); avatar.SendFullUpdateToOtherClient(this); avatar.SendAppearanceToOtherAgent(this); if (m_sitStatus) GenerateRandomAnimation(); - avatar.SendAnimPackToClient(this.ControllingClient); + avatar.SendAnimPackToClient(ControllingClient); } } } m_scene.AddAgentUpdates(avatars.Count); - m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentTime(Environment.TickCount - m_perfMonMS); //SendAnimPack(); } public void SendFullUpdateToAllClients() { - m_perfMonMS = System.Environment.TickCount; + m_perfMonMS = Environment.TickCount; if (m_sitStatus) GenerateRandomAnimation(); @@ -2298,7 +2294,7 @@ namespace OpenSim.Region.Framework.Scenes } m_scene.AddAgentUpdates(avatars.Count); - m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentTime(Environment.TickCount - m_perfMonMS); SendAnimPack(); } @@ -2333,7 +2329,6 @@ namespace OpenSim.Region.Framework.Scenes /// /// Tell the client for this scene presence what items it should be wearing now /// - /// public void SendWearables() { ControllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); @@ -2344,7 +2339,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void SendAppearanceToAllOtherAgents() { - m_perfMonMS = System.Environment.TickCount; + m_perfMonMS = Environment.TickCount; m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) { @@ -2354,7 +2349,7 @@ namespace OpenSim.Region.Framework.Scenes } }); - m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); + m_scene.AddAgentTime(Environment.TickCount - m_perfMonMS); } /// @@ -2421,6 +2416,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// /// + /// public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) { if (m_isChildAgent) @@ -2759,7 +2755,7 @@ namespace OpenSim.Region.Framework.Scenes int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); if (innacurateNeighbors != 0) { - multiplier = 1f / (float)innacurateNeighbors; + multiplier = 1f / innacurateNeighbors; } if (multiplier <= 0f) { @@ -3369,7 +3365,7 @@ namespace OpenSim.Region.Framework.Scenes LastCommands = allflags; } - internal uint RemoveIgnoredControls(uint flags, ScriptControlled Ignored) + internal static uint RemoveIgnoredControls(uint flags, ScriptControlled Ignored) { if (Ignored == ScriptControlled.CONTROL_ZERO) return flags; @@ -3460,7 +3456,7 @@ namespace OpenSim.Region.Framework.Scenes { // Attach from world, if not already attached if (att.ParentGroup != null && !att.IsAttachment) - m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, (uint)0, Quaternion.Identity, att.ParentGroup.AbsolutePosition, false); + m_scene.AttachObject(ControllingClient, att.ParentGroup.LocalId, 0, Quaternion.Identity, att.ParentGroup.AbsolutePosition, false); } catch (NullReferenceException) { -- cgit v1.1