diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index 660eafb2c1..ed33fd4a30 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -544,7 +544,7 @@ namespace OpenSim.Data.SQLite
{
foreach (SceneObjectPart prim in obj.Parts)
{
-// m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
+ //m_log.Info("[REGION DB]: Adding obj: " + obj.UUID + " to region: " + regionUUID);
addPrim(prim, obj.UUID, regionUUID);
}
primDa.Update(ds, "prims");
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 4feae9e9a3..36c7eb113f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -304,9 +304,7 @@ namespace OpenSim.Region.Framework.Scenes
if (timeLastChanged == 0) timeLastChanged = currentTime;
if (timeFirstChanged == 0) timeFirstChanged = currentTime;
- if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime)
- return true;
- return false;
+ return currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime;
}
///
@@ -1491,19 +1489,16 @@ namespace OpenSim.Region.Framework.Scenes
///
public virtual void AttachToBackup()
{
- if (IsAttachment) return;
- m_scene.SceneGraph.FireAttachToBackup(this);
+ if (IsAttachment)
+ return;
- //if (InSceneBackup)
- //{
- // m_log.DebugFormat(
- // "[SCENE OBJECT GROUP]: Attaching object {0} {1} to scene presistence sweep", Name, UUID);
+ if (!Backup)
+ {
+ m_scene.SceneGraph.FireAttachToBackup(this);
+ m_scene.EventManager.OnBackup += ProcessBackup;
+ }
- if (!Backup)
- m_scene.EventManager.OnBackup += ProcessBackup;
-
- Backup = true;
- //}
+ Backup = true;
}
///
@@ -2081,13 +2076,7 @@ namespace OpenSim.Region.Framework.Scenes
// Setting this SOG's absolute position also loops through and sets the positions
// of the SOP's in this SOG's linkset. This has the side affect of making sure
// the physics world matches the simulated world.
- // AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works?
- // teravus: AbsolutePosition is NOT a normal property!
- // the code in the getter of AbsolutePosition is significantly different then the code in the setter!
- // jhurliman: Then why is it a property instead of two methods?
-
- // do only what is supposed to do
Vector3 groupPosition = m_rootPart.GroupPosition;
SceneObjectPart[] parts = m_parts.GetArray();
@@ -4512,11 +4501,12 @@ namespace OpenSim.Region.Framework.Scenes
{
m_rootPart.UpdateRotation(rot);
- PhysicsActor actor = m_rootPart.PhysActor;
- if (actor is not null)
- {
- actor.Orientation = m_rootPart.RotationOffset;
- }
+ //already done above
+ //PhysicsActor actor = m_rootPart.PhysActor;
+ //if (actor is not null)
+ //{
+ // actor.Orientation = m_rootPart.RotationOffset;
+ //}
if (IsAttachment)
{
@@ -4542,7 +4532,7 @@ namespace OpenSim.Region.Framework.Scenes
if (m_rootPart.PhysActor is not null)
m_rootPart.PhysActor.Building = true;
- if (part.UUID == m_rootPart.UUID)
+ if (part == m_rootPart)
{
UpdateRootRotation(rot);
}
@@ -4592,17 +4582,15 @@ namespace OpenSim.Region.Framework.Scenes
public void UpdateRootRotation(Quaternion rot)
{
// needs to be called with phys building true
- Quaternion axRot = rot;
- Quaternion oldParentRot = m_rootPart.RotationOffset;
+
+ Quaternion transformRot = Quaternion.Inverse(rot) * m_rootPart.RotationOffset;
//Don't use UpdateRotation because it schedules an update prematurely
m_rootPart.RotationOffset = rot;
PhysicsActor pa = m_rootPart.PhysActor;
if (pa is not null)
- {
- pa.Orientation = m_rootPart.RotationOffset;
- }
+ pa.Orientation = rot;
SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++)
@@ -4610,15 +4598,8 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart prim = parts[i];
if (prim != m_rootPart)
{
- Quaternion NewRot = oldParentRot * prim.RotationOffset;
- NewRot = Quaternion.Inverse(axRot) * NewRot;
- prim.RotationOffset = NewRot;
-
- Vector3 axPos = prim.OffsetPosition;
-
- axPos *= oldParentRot;
- axPos *= Quaternion.Inverse(axRot);
- prim.OffsetPosition = axPos;
+ prim.RotationOffset = transformRot * prim.RotationOffset;
+ prim.OffsetPosition *= transformRot;
}
}
@@ -4642,9 +4623,8 @@ namespace OpenSim.Region.Framework.Scenes
if (part is not null && part.ParentGroup is not null)
{
ObjectChangeType change = data.change;
- bool togroup = ((change & ObjectChangeType.Group) != 0);
- // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use
-
+ bool togroup = (change & ObjectChangeType.Group) != 0;
+
SceneObjectGroup group = part.ParentGroup;
PhysicsActor pha = group.RootPart.PhysActor;
@@ -5029,12 +5009,11 @@ namespace OpenSim.Region.Framework.Scenes
// ignoring tortured prims details since sl also seems to ignore
// so no real use in doing it on physics
- Vector3 gc = Vector3.Zero;
-
SceneObjectPart[] parts = m_parts.GetArray();
if (parts.Length < 2)
- return gc;
+ return Vector3.Zero;
+ Vector3 gc = Vector3.Zero;
// average all parts positions
for (int i = 0; i < parts.Length; i++)
{
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4ae3be4839..2183f316f5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -769,8 +769,7 @@ namespace OpenSim.Region.Framework.Scenes
// If I'm an attachment, my position is reported as the position of who I'm attached to
if (ParentGroup.IsAttachment)
{
- ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar);
- if (sp != null)
+ if(ParentGroup.Scene.TryGetScenePresence(ParentGroup.AttachedAvatar, out ScenePresence sp))
return sp.AbsolutePosition;
}
@@ -2412,53 +2411,28 @@ namespace OpenSim.Region.Framework.Scenes
// http://wiki.secondlife.com/wiki/llGetGeometricCenter
// ignoring tortured prims details since sl also seems to ignore
// so no real use in doing it on physics
- if (ParentGroup.IsDeleted)
- return new Vector3(0, 0, 0);
-
- return ParentGroup.GetGeometricCenter();
+ return ParentGroup.IsDeleted ? Vector3.Zero : ParentGroup.GetGeometricCenter();
}
public float GetMass()
{
PhysicsActor pa = PhysActor;
-
- if (pa != null)
- return pa.Mass;
- else
- return 0;
+ return pa is null ? 0 : pa.Mass;
}
public Vector3 GetCenterOfMass()
{
if (ParentGroup.RootPart == this)
- {
- if (ParentGroup.IsDeleted)
- return AbsolutePosition;
- return ParentGroup.GetCenterOfMass();
- }
+ return ParentGroup.IsDeleted ? AbsolutePosition : ParentGroup.GetCenterOfMass();
PhysicsActor pa = PhysActor;
-
- if (pa != null)
- {
- Vector3 tmp = pa.CenterOfMass;
- return tmp;
- }
- else
- return AbsolutePosition;
+ return (pa is null) ? AbsolutePosition : pa.CenterOfMass;
}
public Vector3 GetPartCenterOfMass()
{
PhysicsActor pa = PhysActor;
-
- if (pa != null)
- {
- Vector3 tmp = pa.CenterOfMass;
- return tmp;
- }
- else
- return AbsolutePosition;
+ return pa is null ? AbsolutePosition : pa.CenterOfMass;
}
@@ -2476,13 +2450,10 @@ namespace OpenSim.Region.Framework.Scenes
/// A Linked Child Prim objects position in world
public Vector3 GetWorldPosition()
{
- if (_parentID == 0)
- return GroupPosition;
-
// If a child SOP, my position is relative to the root SOP so take
// my info and add the root's position and rotation to
// get my world position.
- return ParentGroup.AbsolutePosition + OffsetPosition * ParentGroup.RootPart.RotationOffset;
+ return _parentID == 0 ? GroupPosition : ParentGroup.AbsolutePosition + OffsetPosition * ParentGroup.RootPart.RotationOffset;
}
///
@@ -2491,12 +2462,9 @@ namespace OpenSim.Region.Framework.Scenes
///
public Quaternion GetWorldRotation()
{
- if (_parentID == 0)
- return RotationOffset;
-
// A child SOP's rotation is relative to the root SOP's rotation.
// Combine them to get my absolute rotation.
- return ParentGroup.RootPart.RotationOffset * RotationOffset;
+ return _parentID == 0 ? RotationOffset : ParentGroup.RootPart.RotationOffset * RotationOffset;
}
///
@@ -2925,14 +2893,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RemFlag(PrimFlags flag)
{
- // PrimFlags prevflag = Flags;
- if ((m_flags & flag) != 0)
- {
- //m_log.Debug("Removing flag: " + ((PrimFlags)flag).ToString());
- m_flags &= ~flag;
- }
- //m_log.Debug("prev: " + prevflag.ToString() + " curr: " + Flags.ToString());
- //ScheduleFullUpdate();
+ m_flags &= ~flag;
}
public void RemoveScriptEvents(UUID scriptid)
@@ -4847,11 +4808,10 @@ namespace OpenSim.Region.Framework.Scenes
///
public void UpdateRotation(Quaternion rot)
{
- if (rot != RotationOffset)
+ if (rot.NotEqual(RotationOffset))
{
RotationOffset = rot;
-
- if (ParentGroup != null)
+ if (ParentGroup is not null)
{
ParentGroup.HasGroupChanged = true;
ScheduleTerseUpdate();