From 75952d9bea49f17e60c256ebdaa668de808e2806 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 2 Jan 2024 23:14:38 +0000 Subject: [PATCH] cosmetics --- .../Framework/Scenes/SceneObjectPart.cs | 50 ++++-------- .../PhysicsModules/BulletS/BSCharacter.cs | 3 +- .../PhysicsModules/ubOde/ODECharacter.cs | 6 +- .../Region/PhysicsModules/ubOde/ODEPrim.cs | 77 +++++++++---------- .../Region/PhysicsModules/ubOde/ODEScene.cs | 16 ++-- 5 files changed, 67 insertions(+), 85 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f939c6deb3..c2ce4be367 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; using System.Reflection; +using System.Runtime.CompilerServices; using System.Threading; using System.Text; using System.Xml; @@ -1675,12 +1676,8 @@ namespace OpenSim.Region.Framework.Scenes { get { - float cost; - if (PhysActor != null) - cost = PhysActor.StreamCost; - else - cost = 1.0f; - return 1.0f; + //float cost = PhysActor is null ? 1.0f : PhysActor.StreamCost; + return 1.0f; // disabled ? } } @@ -1838,16 +1835,10 @@ namespace OpenSim.Region.Framework.Scenes #endregion Public Properties with only Get - private uint ApplyMask(uint val, bool set, uint mask) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static uint ApplyMask(uint val, bool set, uint mask) { - if (set) - { - return val |= mask; - } - else - { - return val &= ~mask; - } + return set ? val |= mask : val &= ~mask; } /// @@ -3349,7 +3340,7 @@ namespace OpenSim.Region.Framework.Scenes private const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary private const double TIME_MS_TOLERANCE = 250.0; //llSetPos has a 200ms delay. This should NOT be 3 seconds. - private Vector3 ClampVectorForTerseUpdate(Vector3 v, float max) + private static Vector3 ClampVectorForTerseUpdate(Vector3 v, float max) { float a, b; @@ -3941,11 +3932,7 @@ namespace OpenSim.Region.Framework.Scenes public void SetPhysicsAxisRotation() { - PhysicsActor pa = PhysActor; - if (pa is not null) - { - pa.LockAngularMotion(RotationAxisLocks); - } + PhysActor?.LockAngularMotion(RotationAxisLocks); } /// @@ -4524,19 +4511,15 @@ namespace OpenSim.Region.Framework.Scenes /// public void UpdatePermissions(UUID AgentID, byte field, uint localID, uint mask, byte addRemTF) { - bool set = addRemTF == 1; bool god = ParentGroup.Scene.Permissions.IsGod(AgentID); - uint baseMask = BaseMask; - if (god) - baseMask = 0x7ffffff0; - - bool canChange = (AgentID == OwnerID) || god; - if(!canChange) - canChange = ParentGroup.Scene.Permissions.CanEditObjectPermissions(ParentGroup, AgentID); + bool canChange = god || AgentID.Equals(OwnerID) || + ParentGroup.Scene.Permissions.CanEditObjectPermissions(ParentGroup, AgentID); if (canChange) { + bool set = addRemTF == 1; + uint baseMask = god ? 0x7ffffff0 : BaseMask; switch (field) { case 1: @@ -4548,12 +4531,10 @@ namespace OpenSim.Region.Framework.Scenes break; case 2: - OwnerMask = ApplyMask(OwnerMask, set, mask) & - baseMask; + OwnerMask = ApplyMask(OwnerMask, set, mask) & baseMask; break; case 4: - GroupMask = ApplyMask(GroupMask, set, mask) & - baseMask; + GroupMask = ApplyMask(GroupMask, set, mask) & baseMask; break; case 8: // Trying to set export permissions - extra checks @@ -5273,7 +5254,8 @@ namespace OpenSim.Region.Framework.Scenes ParentGroup.Scene.StatsReporter.AddObjectUpdates(1); } - public void AddScriptLPS(int count) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void AddScriptLPS(int count) { //legacy, do nothing //ParentGroup.AddScriptLPS(count); diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs index 9ce77b1d14..b659648a33 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSCharacter.cs @@ -147,8 +147,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS ForcePosition = RawPosition; // Set the velocity - if (m_moveActor != null) - m_moveActor.SetVelocityAndTarget(RawVelocity, RawVelocity, false); + m_moveActor?.SetVelocityAndTarget(RawVelocity, RawVelocity, false); ForceVelocity = RawVelocity; TargetVelocity = RawVelocity; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index 00a9d1e3ff..94b6f8b680 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs @@ -1607,7 +1607,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetSmooth(ref Vector3 dst, ref Vector3 value, int rounddigits) + public static void SetSmooth(ref Vector3 dst, ref Vector3 value, int rounddigits) { dst.X = 0.4f * dst.X + 0.6f * value.X; dst.X = MathF.Round(dst.X, rounddigits); @@ -1626,10 +1626,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde /// copy and outbounds now done in move(..) at ode rate /// /// + /* [MethodImpl(MethodImplOptions.AggressiveInlining)] public void UpdatePositionAndVelocity() { } + */ /// /// Cleanup the things we use in the scene. @@ -2107,10 +2109,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_useHoverPID = active; } + /* [MethodImpl(MethodImplOptions.AggressiveInlining)] private void donullchange() { } + */ [MethodImpl(MethodImplOptions.AggressiveInlining)] public void UpdateAABB2D() diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 2794f708d8..5c300f052d 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -58,13 +58,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde private byte m_angularlocks = 0; - private Quaternion m_lastorientation; + //private Quaternion m_lastorientation; private Quaternion m_orientation; private Vector3 m_position; private Vector3 _velocity; - private Vector3 m_lastVelocity; - private Vector3 m_lastposition; + //private Vector3 m_lastVelocity; + //private Vector3 m_lastposition; private Vector3 m_rotationalVelocity; private Vector3 m_size; private Vector3 m_acceleration; @@ -120,7 +120,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde private readonly object m_meshlock = new(); private PrimitiveBaseShape m_pbs; - private UUID? m_assetID; + //private UUID? m_assetID; private MeshState m_meshState; @@ -155,7 +155,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde public Vector3 m_OBB; public float primOOBradiusSQ; - private bool m_hasOBB = true; + //private bool m_hasOBB = true; private float m_physCost; private float m_streamCost; @@ -200,8 +200,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde // and also to stop imediatly some updates // but real change will only happen in taintprocessing - if (!value) // Zero the remembered last velocity - m_lastVelocity = Vector3.Zero; + //if (!value) // Zero the remembered last velocity + //m_lastVelocity = Vector3.Zero; AddChange(changes.Physical, value); } } @@ -547,8 +547,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if(childPrim) { - if(_parent != null) - _parent.SetInertiaData(inertia); + _parent?.SetInertiaData(inertia); return; } @@ -993,12 +992,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_position.Y = Utils.Clamp(m_position.Y, 0.5f, m_parentScene.WorldExtents.Y - 0.5f); m_position.Z = Utils.Clamp(m_position.Z + 0.2f, Constants.MinSimulationHeight, Constants.MaxSimulationHeight); - m_lastposition = m_position; + //m_lastposition = m_position; _velocity = Vector3.Zero; UBOdeNative.AllocateODEDataForThread(0); - m_lastVelocity = _velocity; + //m_lastVelocity = _velocity; if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) m_vehicle.Stop(); @@ -1023,8 +1022,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_outbounds = true; - m_lastposition = m_position; - m_lastorientation = m_orientation; + //m_lastposition = m_position; + //m_lastorientation = m_orientation; UBOdeNative.AllocateODEDataForThread(0); if(Body != IntPtr.Zero) @@ -1655,7 +1654,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_log.WarnFormat("[PHYSICS]: Invalid mesh data on OdePrim {0}, mesh {1} at {2}", Name, m_pbs.SculptEntry ? m_pbs.SculptTexture.ToString() : "primMesh", m_position.ToString()); - m_hasOBB = false; + //m_hasOBB = false; m_OBBOffset = Vector3.Zero; m_OBB = m_size * 0.5f; @@ -1701,7 +1700,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } _triMeshData = IntPtr.Zero; - m_hasOBB = false; + //m_hasOBB = false; m_OBBOffset = Vector3.Zero; m_OBB = m_size * 0.5f; m_physCost = 0.1f; @@ -1814,7 +1813,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } Body = IntPtr.Zero; - m_hasOBB = false; + //m_hasOBB = false; } //sets non physical prim m_targetSpace to right space in spaces grid for static prims @@ -2217,6 +2216,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_collisionscore = 0; } + /* private void FixInertia(Vector3 NewPos,Quaternion newrot) { UBOdeNative.BodyGetMass(Body, out UBOdeNative.Mass tmpdmass); @@ -2289,6 +2289,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde UBOdeNative.BodySetMass(Body, ref objdmass); m_mass = objdmass.mass; } + */ private void FixInertia(Vector3 NewPos) { @@ -2353,6 +2354,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_mass = objdmass.mass; } + /* private void FixInertia(Quaternion newrot) { UBOdeNative.Matrix3 mat; @@ -2416,7 +2418,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde UBOdeNative.BodySetMass(Body, ref objdmass); m_mass = objdmass.mass; } - + */ #region Mass Calculation @@ -2517,6 +2519,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } } + /* private void UpdateChildsfromgeom() { if (childrenPrim.Count > 0) @@ -2525,6 +2528,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde prm.UpdateDataFromGeom(); } } + */ private void UpdateDataFromGeom() { @@ -2692,10 +2696,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde (_parent as OdePrim).ChildDelink(this, false); // for now... childPrim = false; - if (NewParent != null) - { - NewParent.ParentPrim(this); - } + NewParent?.ParentPrim(this); } } } @@ -2985,6 +2986,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde resetCollisionAccounting(); } + /* [MethodImpl(MethodImplOptions.AggressiveInlining)] private void changePositionAndOrientation(Vector3 newPos, Quaternion newOri) { @@ -3062,6 +3064,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_givefakeori = 0; resetCollisionAccounting(); } + */ [MethodImpl(MethodImplOptions.AggressiveInlining)] private void changeDisable(bool disable) @@ -3106,12 +3109,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void changeSize(Vector3 newSize) + private static void changeSize(Vector3 newSize) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void changeShape(PrimitiveBaseShape newShape) + private static void changeShape(PrimitiveBaseShape newShape) { } @@ -3123,10 +3126,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_mesh = repData.mesh; - m_assetID = repData.assetID; + //m_assetID = repData.assetID; m_meshState = repData.meshState; - m_hasOBB = repData.hasOBB; + //m_hasOBB = repData.hasOBB; m_OBBOffset = repData.OBBOffset; m_OBB = repData.OBB; @@ -3185,10 +3188,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (chp) { - if (parent != null) - { - parent.DestroyBody(); - } + parent?.DestroyBody(); } else { @@ -3202,10 +3202,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde m_mesh = repData.mesh; - m_assetID = repData.assetID; + //m_assetID = repData.assetID; m_meshState = repData.meshState; - m_hasOBB = repData.hasOBB; + //m_hasOBB = repData.hasOBB; m_OBBOffset = repData.OBBOffset; m_OBB = repData.OBB; @@ -3230,10 +3230,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde { if (chp) { - if (parent != null) - { - parent.MakeBody(); - } + parent?.MakeBody(); } else MakeBody(); @@ -3816,8 +3813,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde UBOdeNative.BodySetLinearVel(Body, 0, 0, 0); // stop it UBOdeNative.BodySetAngularVel(Body, 0, 0, 0); // stop it UBOdeNative.BodySetPosition(Body, lpos.X, lpos.Y, lpos.Z); // put it somewhere - m_lastposition = m_position; - m_lastorientation = m_orientation; + //m_lastposition = m_position; + //m_lastorientation = m_orientation; base.RequestPhysicsterseUpdate(); @@ -3852,8 +3849,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde if (m_outbounds) { - m_lastposition = m_position; - m_lastorientation = m_orientation; + //m_lastposition = m_position; + //m_lastorientation = m_orientation; _velocity = UBOdeNative.BodyGetLinearVelOMV(Body); m_rotationalVelocity = UBOdeNative.BodyGetAngularVelOMV(Body); @@ -4007,7 +4004,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde theobj.I.M22 -= part.I.M22; } - private void donullchange() + private static void donullchange() { } diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index 656934e7be..b311804a79 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -2099,10 +2099,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde UBOdeNative.GeomSetCategoryBits(TerrainGeom, (uint)(CollisionCategories.Land)); UBOdeNative.GeomSetCollideBits(TerrainGeom, 0); - PhysicsActor pa = new NullPhysicsActor(); - pa.Name = "Terrain"; - pa.PhysicsActorType = (int)ActorTypes.Ground; - actor_name_map[TerrainGeom] = pa; + PhysicsActor pa = new NullPhysicsActor + { + Name = "Terrain", + PhysicsActorType = (int)ActorTypes.Ground + }; + actor_name_map[TerrainGeom] = pa; //geom_name_map[GroundGeom] = "Terrain"; @@ -2196,8 +2198,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde UBOdeNative.AllocateODEDataForThread(~0U); - if (m_meshWorker != null) - m_meshWorker.Stop(); + m_meshWorker?.Stop(); if (m_rayCastManager != null) { @@ -2444,8 +2445,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde Util.FireAndForget( delegate { ODESitAvatar sitAvatar = new(this, m_rayCastManager); - if(sitAvatar is not null) - sitAvatar.Sit(actor, AbsolutePosition, CameraPosition, offset, AvatarSize, PhysicsSitResponse); + sitAvatar?.Sit(actor, AbsolutePosition, CameraPosition, offset, AvatarSize, PhysicsSitResponse); }); return 1; }