From e1b5f3ad8146c6e0b02dcdbf3093bb1340bc83ee Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 20 Jun 2025 04:38:51 +0100 Subject: [PATCH] cosmetics --- OpenSim/Region/Framework/Scenes/Scene.cs | 9 +++++---- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- .../PhysicsModules/BulletS/BSActorAvatarMove.cs | 4 +++- OpenSim/Region/PhysicsModules/BulletS/BSDynamics.cs | 11 +++++++---- .../PhysicsModules/BulletS/BSLinksetCompound.cs | 6 +++++- OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs | 4 ++-- OpenSim/Region/PhysicsModules/BulletS/BSScene.cs | 3 ++- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 733eac40cd..52550d25c3 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3631,7 +3631,8 @@ namespace OpenSim.Region.Framework.Scenes if (target is not null && target2 is not null) { - Vector3 direction = Vector3.Normalize(RayEnd - RayStart); + Vector3 direction = RayEnd - RayStart; + direction.Normalize(); //pos = target2.AbsolutePosition; //m_log.Info("[OBJECT_REZ]: TargetPos: " + pos.ToString() + ", RayStart: " + RayStart.ToString() + ", RayEnd: " + RayEnd.ToString() + ", Volume: " + Util.GetDistanceTo(RayStart,RayEnd).ToString() + ", mag1: " + Util.GetMagnitude(RayStart).ToString() + ", mag2: " + Util.GetMagnitude(RayEnd).ToString()); @@ -3639,7 +3640,7 @@ namespace OpenSim.Region.Framework.Scenes // TODO: Raytrace better here //EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection)); - Ray NewRay = new(RayStart,direction); + Ray NewRay = new(RayStart, direction); // Ray Trace against target here EntityIntersection ei = target2.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, CopyCenters); @@ -4798,7 +4799,7 @@ Label_GroupsDone: { sp = GetScenePresence(agentID); - if (sp is null) + if (sp is null || sp.IsDeleted) { // If there is no scene presence, we may be handling a dead // client. These can keep an avatar from reentering a region @@ -4815,7 +4816,7 @@ Label_GroupsDone: // need to try this again, bc client close may had not done it m_authenticateHandler?.RemoveCircuit(agentID); - m_clientManager.Remove(agentID); + m_clientManager?.Remove(agentID); m_capsModule?.RemoveCaps(agentID, 0); return ret; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2e0f759182..0afa9f89ad 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4771,7 +4771,7 @@ namespace OpenSim.Region.Framework.Scenes return; CopyFrom(cAgentData); - m_updateAgentReceivedAfterTransferEvent.Set(); + m_updateAgentReceivedAfterTransferEvent?.Set(); } private static Vector3 marker = new(-1f, -1f, -1f); diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs index 925f526f2b..c45c551334 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSActorAvatarMove.cs @@ -368,7 +368,9 @@ namespace OpenSim.Region.PhysicsModule.BulletS // The step is presumed to be more or less vertical. Thus the Z component should // be nearly horizontal. OMV.Vector3 directionFacing = OMV.Vector3.UnitX * m_controllingPrim.RawOrientation; - OMV.Vector3 touchNormal = OMV.Vector3.Normalize(kvp.Value.SurfaceNormal); + OMV.Vector3 touchNormal = kvp.Value.SurfaceNormal; + touchNormal.Normalize(); + const float PIOver2 = 1.571f; // Used to make unit vector axis into approx radian angles // m_physicsScene.DetailLog("{0},BSCharacter.WalkUpStairs,avNormal={1},colNormal={2},diff={3}", // m_controllingPrim.LocalID, directionFacing, touchNormal, diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSDynamics.cs b/OpenSim/Region/PhysicsModules/BulletS/BSDynamics.cs index c4ccdbeade..bd13f65971 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/BSDynamics.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSDynamics.cs @@ -945,7 +945,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS { get { - return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleFrameOrientation)); + return VehicleVelocity * Quaternion.Inverse(VehicleFrameOrientation); } } @@ -1502,9 +1502,11 @@ namespace OpenSim.Region.PhysicsModule.BulletS Quaternion justZOrientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, currentEulerW.Z); // Create the axis that is perpendicular to the up vector and the rotated up vector. - Vector3 differenceAxisW = Vector3.Cross(Vector3.UnitZ * justZOrientation, Vector3.UnitZ * VehicleFrameOrientation); + Vector3 UnitZInFrame = Vector3.UnitZ * VehicleFrameOrientation; + Vector3 differenceAxisW = Vector3.Cross(Vector3.UnitZ * justZOrientation, UnitZInFrame); // Compute the angle between those to vectors. - double differenceAngle = Math.Acos((double)Vector3.Dot(Vector3.UnitZ, Vector3.Normalize(Vector3.UnitZ * VehicleFrameOrientation))); + UnitZInFrame.Normalize(); + double differenceAngle = Math.Acos((double)Vector3.Dot(Vector3.UnitZ, UnitZInFrame)); // 'differenceAngle' is the angle to rotate and 'differenceAxis' is the plane to rotate in to get the vehicle vertical // Reduce the change by the time period it is to change in. Timestep is handled when velocity is applied. @@ -1537,7 +1539,8 @@ namespace OpenSim.Region.PhysicsModule.BulletS Vector3 origRotVelW = VehicleRotationalVelocity; // DEBUG DEBUG // Take a vector pointing up and convert it from world to vehicle relative coords. - Vector3 verticalError = Vector3.Normalize(Vector3.UnitZ * VehicleFrameOrientation); + Vector3 verticalError = Vector3.UnitZ * VehicleFrameOrientation; + verticalError.Normalize(); // If vertical attraction correction is needed, the vector that was pointing up (UnitZ) // is now: diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSLinksetCompound.cs b/OpenSim/Region/PhysicsModules/BulletS/BSLinksetCompound.cs index 924d1c8750..fdd332704e 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSLinksetCompound.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSLinksetCompound.cs @@ -358,6 +358,8 @@ namespace OpenSim.Region.PhysicsModule.BulletS OMV.Quaternion invRootOrientation = OMV.Quaternion.Normalize(OMV.Quaternion.Inverse(LinksetRoot.RawOrientation)); OMV.Vector3 origRootPosition = LinksetRoot.RawPosition; + OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(LinksetRoot.RawOrientation); + invRootOrientation.Normalize(); // 'centerDisplacementV' is the vehicle relative distance from the simulator root position to the center-of-mass OMV.Vector3 centerDisplacementV = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation; @@ -396,7 +398,9 @@ namespace OpenSim.Region.PhysicsModule.BulletS // Offset the child shape from the center-of-mass and rotate it to root relative. OMV.Vector3 offsetPos = (cPrim.RawPosition - origRootPosition) * invRootOrientation - centerDisplacementV; - OMV.Quaternion offsetRot = OMV.Quaternion.Normalize(cPrim.RawOrientation) * invRootOrientation; + OMV.Quaternion offsetRot = cPrim.RawOrientation; + offsetRot.Normalize(); + offsetRot *= invRootOrientation; // Add the child shape to the compound shape being built if (childShape.physShapeInfo.HasPhysicalShape) diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs index fbc853a071..02ff0252a2 100755 --- a/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSPhysObject.cs @@ -354,7 +354,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS { get { - OMV.Vector3 characterOrientedVelocity = RawVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation)); + OMV.Vector3 characterOrientedVelocity = RawVelocity * OMV.Quaternion.Inverse(RawOrientation); return characterOrientedVelocity.X; } } @@ -363,7 +363,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS { get { - OMV.Vector3 characterOrientedVelocity = TargetVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation)); + OMV.Vector3 characterOrientedVelocity = TargetVelocity * OMV.Quaternion.Inverse(RawOrientation); return characterOrientedVelocity.X; } } diff --git a/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs index 48828b1a67..9e0e5d6fdf 100644 --- a/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs +++ b/OpenSim/Region/PhysicsModules/BulletS/BSScene.cs @@ -1000,7 +1000,8 @@ namespace OpenSim.Region.PhysicsModule.BulletS if (BSParam.UseBulletRaycast) { Vector3 posFrom = position; - Vector3 posTo = Vector3.Normalize(direction) * length + position; + direction.Normalize(); + Vector3 posTo = direction * length + position; TaintedObject(DetailLogZero, "BSScene.RaycastWorld1", delegate () {