Implemented a "FrontBack" prioritizer, using distance plus the plane equation to give double weight to prims/avatars in front of you

0.6.8-post-fixes
John Hurliman 2009-10-23 02:38:59 -07:00
parent 37f7277378
commit 62f1a5e36d
4 changed files with 80 additions and 5 deletions

View File

@ -61,6 +61,7 @@ namespace OpenSim.Region.Framework.Scenes
Time = 0,
Distance = 1,
SimpleAngularDistance = 2,
FrontBack = 3,
}
public delegate void SynchronizeSceneHandler(Scene scene);
@ -540,6 +541,9 @@ namespace OpenSim.Region.Framework.Scenes
case "simpleangulardistance":
m_update_prioritization_scheme = UpdatePrioritizationSchemes.SimpleAngularDistance;
break;
case "frontback":
m_update_prioritization_scheme = UpdatePrioritizationSchemes.FrontBack;
break;
default:
m_log.Warn("[SCENE]: UpdatePrioritizationScheme was not recognized, setting to default settomg of Time");
m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;

View File

@ -493,8 +493,8 @@ namespace OpenSim.Region.Framework.Scenes
public Vector3 GroupScale()
{
Vector3 minScale = new Vector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize);
Vector3 maxScale = new Vector3(0f,0f,0f);
Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
Vector3 maxScale = Vector3.Zero;
Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);
lock (m_parts)
@ -577,7 +577,6 @@ namespace OpenSim.Region.Framework.Scenes
{
foreach (SceneObjectPart part in m_parts.Values)
{
Vector3 worldPos = part.GetWorldPosition();
Vector3 offset = worldPos - AbsolutePosition;
Quaternion worldRot;
@ -3366,6 +3365,8 @@ namespace OpenSim.Region.Framework.Scenes
return GetPriorityByDistance(client);
case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
return GetPriorityBySimpleAngularDistance(client);
case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
return GetPriorityByFrontBack(client);
default:
throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
}
@ -3398,6 +3399,16 @@ namespace OpenSim.Region.Framework.Scenes
return double.NaN;
}
private double GetPriorityByFrontBack(IClientAPI client)
{
ScenePresence presence = Scene.GetScenePresence(client.AgentId);
if (presence != null)
{
return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis);
}
return double.NaN;
}
public double GetPriorityByDistance(Vector3 position)
{
return Vector3.Distance(AbsolutePosition, position);
@ -3427,5 +3438,21 @@ namespace OpenSim.Region.Framework.Scenes
else
return double.MinValue;
}
public double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis)
{
// Distance
double priority = Vector3.Distance(camPosition, AbsolutePosition);
// Scale
//priority -= GroupScale().Length();
// Plane equation
float d = -Vector3.Dot(camPosition, camAtAxis);
float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d;
if (p < 0.0f) priority *= 2.0f;
return priority;
}
}
}

View File

@ -297,6 +297,21 @@ namespace OpenSim.Region.Framework.Scenes
get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); }
}
public Vector3 CameraAtAxis
{
get { return m_CameraAtAxis; }
}
public Vector3 CameraLeftAxis
{
get { return m_CameraLeftAxis; }
}
public Vector3 CameraUpAxis
{
get { return m_CameraUpAxis; }
}
public Vector3 Lookat
{
get
@ -3867,6 +3882,8 @@ namespace OpenSim.Region.Framework.Scenes
return GetPriorityByDistance(client);
case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
return GetPriorityByDistance(client);
case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
return GetPriorityByFrontBack(client);
default:
throw new InvalidOperationException("UpdatePrioritizationScheme not defined.");
}
@ -3888,11 +3905,34 @@ namespace OpenSim.Region.Framework.Scenes
return double.NaN;
}
private double GetPriorityByFrontBack(IClientAPI client)
{
ScenePresence presence = Scene.GetScenePresence(client.AgentId);
if (presence != null)
{
return GetPriorityByFrontBack(presence.CameraPosition, presence.CameraAtAxis);
}
return double.NaN;
}
private double GetPriorityByDistance(Vector3 position)
{
return Vector3.Distance(AbsolutePosition, position);
}
private double GetPriorityByFrontBack(Vector3 camPosition, Vector3 camAtAxis)
{
// Distance
double priority = Vector3.Distance(camPosition, AbsolutePosition);
// Plane equation
float d = -Vector3.Dot(camPosition, camAtAxis);
float p = Vector3.Dot(camAtAxis, AbsolutePosition) + d;
if (p < 0.0f) priority *= 2.0f;
return priority;
}
private double GetSOGUpdatePriority(SceneObjectGroup sog)
{
switch (Scene.UpdatePrioritizationScheme)
@ -3903,6 +3943,8 @@ namespace OpenSim.Region.Framework.Scenes
return sog.GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
return sog.GetPriorityBySimpleAngularDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
return sog.GetPriorityByFrontBack(CameraPosition, CameraAtAxis);
default:
throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
}
@ -3929,6 +3971,8 @@ namespace OpenSim.Region.Framework.Scenes
case Scene.UpdatePrioritizationSchemes.Distance:
case Scene.UpdatePrioritizationSchemes.SimpleAngularDistance:
return GetPriorityByDistance((IsChildAgent) ? AbsolutePosition : CameraPosition);
case Scenes.Scene.UpdatePrioritizationSchemes.FrontBack:
return GetPriorityByFrontBack(CameraPosition, CameraAtAxis);
default:
throw new InvalidOperationException("UpdatePrioritizationScheme not defined");
}

View File

@ -1397,8 +1397,8 @@
[InterestManagement]
; This section controls how state updates are prioritized for each client
; Valid values are Time, Distance, and SimpleAngularDistance
UpdatePrioritizationScheme = Distance;
; Valid values are Time, Distance, SimpleAngularDistance, and FrontBack
UpdatePrioritizationScheme = FrontBack;
ReprioritizationEnabled = true;
ReprioritizationInterval = 2000.0;
RootReprioritizationDistance = 10.0;