* Performance Changes:
* Moves Entity Updates into a seperate thread, allowing for OpenSim to utilize a computers CPU more effectively in return for potentially greater user and prim capacity. * Removes an expensive Sqrt call performed during Update on each object. This should lower CPU requirements for high-prim regions with physics enabled. * MXP Changes: Centers the region around 0,0 for primitives instead of 128,128. Prim display should now look more correct for MXP viewers.GenericGridServerConcept
parent
dba8c90611
commit
c2f3ff872d
|
@ -577,7 +577,9 @@ namespace OpenSim.Client.MXP.ClientStack
|
||||||
pe.ObjectFragment.AngularAcceleration = new float[4];
|
pe.ObjectFragment.AngularAcceleration = new float[4];
|
||||||
pe.ObjectFragment.AngularVelocity = new float[] { rvel.X, rvel.Y, rvel.Z, 0.0f };
|
pe.ObjectFragment.AngularVelocity = new float[] { rvel.X, rvel.Y, rvel.Z, 0.0f };
|
||||||
pe.ObjectFragment.BoundingSphereRadius = primShape.Scale.Length()/2.0f;
|
pe.ObjectFragment.BoundingSphereRadius = primShape.Scale.Length()/2.0f;
|
||||||
pe.ObjectFragment.Location = new float[] { pos.X, pos.Y, pos.Z };
|
|
||||||
|
pe.ObjectFragment.Location = new float[] { pos.X - 120.0f, pos.Z, pos.Y - 128.0f };
|
||||||
|
|
||||||
pe.ObjectFragment.Mass = 1.0f;
|
pe.ObjectFragment.Mass = 1.0f;
|
||||||
pe.ObjectFragment.ObjectId = objectID.Guid;
|
pe.ObjectFragment.ObjectId = objectID.Guid;
|
||||||
pe.ObjectFragment.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W };
|
pe.ObjectFragment.Orientation = new float[] { rotation.X, rotation.Y, rotation.Z, rotation.W };
|
||||||
|
|
|
@ -88,6 +88,21 @@ namespace OpenSim.Framework
|
||||||
return Math.Sqrt(dx * dx + dy * dy + dz * dz);
|
return Math.Sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if the distance beween A and B is less than amount. Significantly faster than GetDistanceTo since it eliminates the Sqrt.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="a"></param>
|
||||||
|
/// <param name="b"></param>
|
||||||
|
/// <param name="amount"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool DistanceLessThan(Vector3 a, Vector3 b, double amount)
|
||||||
|
{
|
||||||
|
float dx = a.X - b.X;
|
||||||
|
float dy = a.Y - b.Y;
|
||||||
|
float dz = a.Z - b.Z;
|
||||||
|
return (dx*dx + dy*dy + dz*dz) < (amount*amount);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the magnitude of a 3d vector
|
/// Get the magnitude of a 3d vector
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -64,6 +64,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
protected Timer m_restartWaitTimer = new Timer();
|
protected Timer m_restartWaitTimer = new Timer();
|
||||||
|
|
||||||
|
protected Thread m_updateEntitiesThread;
|
||||||
|
|
||||||
public SimStatsReporter StatsReporter;
|
public SimStatsReporter StatsReporter;
|
||||||
|
|
||||||
protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
|
protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
|
||||||
|
@ -852,7 +854,19 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
otherMS = Environment.TickCount;
|
otherMS = Environment.TickCount;
|
||||||
// run through all entities looking for updates (slow)
|
// run through all entities looking for updates (slow)
|
||||||
if (m_frame % m_update_entities == 0)
|
if (m_frame % m_update_entities == 0)
|
||||||
m_sceneGraph.UpdateEntities();
|
{
|
||||||
|
if (m_updateEntitiesThread == null)
|
||||||
|
{
|
||||||
|
m_updateEntitiesThread = new Thread(m_sceneGraph.UpdateEntities);
|
||||||
|
ThreadTracker.Add(m_updateEntitiesThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!m_updateEntitiesThread.IsAlive)
|
||||||
|
m_updateEntitiesThread.Start();
|
||||||
|
|
||||||
|
//m_sceneGraph.UpdateEntities();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// run through entities that have scheduled themselves for
|
// run through entities that have scheduled themselves for
|
||||||
// updates looking for updates(faster)
|
// updates looking for updates(faster)
|
||||||
|
|
|
@ -1733,7 +1733,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
//return;
|
//return;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if ((Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) && UsePhysics)
|
if (Util.DistanceLessThan(lastPhysGroupPos, AbsolutePosition, 0.02) && UsePhysics)
|
||||||
{
|
{
|
||||||
m_rootPart.UpdateFlag = 1;
|
m_rootPart.UpdateFlag = 1;
|
||||||
lastPhysGroupPos = AbsolutePosition;
|
lastPhysGroupPos = AbsolutePosition;
|
||||||
|
|
Loading…
Reference in New Issue