From c02fe98b7da0ef62fe67fb45652878181e4a297d Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Wed, 6 Jul 2016 16:10:44 +0100
Subject: add test option ObjectsCullingByDistance. In future, if true, it may
prevent sending objects outside view range to viewers. DO NOT SET TRUE
unless testing it. Code still not completei!!!
---
OpenSim/Region/Framework/Scenes/Scene.cs | 23 ++++----
.../Region/Framework/Scenes/SceneObjectGroup.cs | 62 ++++++++++++----------
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 20 ++++---
3 files changed, 56 insertions(+), 49 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0d19e94..3c5630e 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -803,9 +803,9 @@ namespace OpenSim.Region.Framework.Scenes
public UpdatePrioritizationSchemes UpdatePrioritizationScheme { get; set; }
public bool IsReprioritizationEnabled { get; set; }
public float ReprioritizationInterval { get; set; }
- public float RootReprioritizationDistance { get; set; }
- public float ChildReprioritizationDistance { get; set; }
+ public float ReprioritizationDistance { get; set; }
private float m_minReprioritizationDistance = 32f;
+ public bool ObjectsCullingByDistance = false;
public AgentCircuitManager AuthenticateHandler
{
@@ -1185,15 +1185,15 @@ namespace OpenSim.Region.Framework.Scenes
= interestConfig.GetBoolean("ReprioritizationEnabled", IsReprioritizationEnabled);
ReprioritizationInterval
= interestConfig.GetFloat("ReprioritizationInterval", ReprioritizationInterval);
- RootReprioritizationDistance
- = interestConfig.GetFloat("RootReprioritizationDistance", RootReprioritizationDistance);
- ChildReprioritizationDistance
- = interestConfig.GetFloat("ChildReprioritizationDistance", ChildReprioritizationDistance);
+ ReprioritizationDistance
+ = interestConfig.GetFloat("RootReprioritizationDistance", ReprioritizationDistance);
+
+ if(ReprioritizationDistance < m_minReprioritizationDistance)
+ ReprioritizationDistance = m_minReprioritizationDistance;
+
+ ObjectsCullingByDistance
+ = interestConfig.GetBoolean("ObjectsCullingByDistance", ObjectsCullingByDistance);
- if(RootReprioritizationDistance < m_minReprioritizationDistance)
- RootReprioritizationDistance = m_minReprioritizationDistance;
- if(ChildReprioritizationDistance < m_minReprioritizationDistance)
- ChildReprioritizationDistance = m_minReprioritizationDistance;
RootTerseUpdatePeriod = interestConfig.GetInt("RootTerseUpdatePeriod", RootTerseUpdatePeriod);
ChildTerseUpdatePeriod = interestConfig.GetInt("ChildTerseUpdatePeriod", ChildTerseUpdatePeriod);
@@ -1252,8 +1252,7 @@ namespace OpenSim.Region.Framework.Scenes
RootRotationUpdateTolerance = 0.1f;
RootVelocityUpdateTolerance = 0.001f;
RootPositionUpdateTolerance = 0.05f;
- RootReprioritizationDistance = m_minReprioritizationDistance;
- ChildReprioritizationDistance = m_minReprioritizationDistance;
+ ReprioritizationDistance = m_minReprioritizationDistance;
m_eventManager = new EventManager();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index cb1bf55..4e87014 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1567,6 +1567,39 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
+ private float? m_boundsRadius = null;
+
+ public float GetBoundsRadius()
+ {
+ // this may need more threading work
+ if(m_boundsRadius == null)
+ {
+ float res = 0;
+ SceneObjectPart p;
+ SceneObjectPart[] parts;
+ float partR;
+ lock (m_parts)
+ {
+ parts = m_parts.GetArray();
+ }
+
+ int nparts = parts.Length;
+ for (int i = 0; i < nparts; i++)
+ {
+ p = parts[i];
+ partR = p.Scale.Length();
+ if(p != RootPart)
+ partR += p.OffsetPosition.Length();
+ if(partR > res)
+ res = partR;
+ }
+ m_boundsRadius = res;
+ return res;
+ }
+
+ return m_boundsRadius.Value;
+ }
+
public void GetResourcesCosts(SceneObjectPart apart,
out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost)
{
@@ -4596,14 +4629,11 @@ namespace OpenSim.Region.Framework.Scenes
if (nparts <= 1)
return gc;
- Quaternion parentRot = RootPart.RotationOffset;
Vector3 pPos;
// average all parts positions
for (int i = 0; i < nparts; i++)
{
- // do it directly
- // gc += parts[i].GetWorldPosition();
if (parts[i] != RootPart)
{
pPos = parts[i].OffsetPosition;
@@ -4613,8 +4643,6 @@ namespace OpenSim.Region.Framework.Scenes
}
gc /= nparts;
- // relative to root:
-// gc -= AbsolutePosition;
return gc;
}
@@ -4662,30 +4690,6 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that
- /// the physics engine can use it.
- ///
- ///
- /// When the physics engine has finished with it, the sculpt data is discarded to save memory.
- ///
-/*
- public void CheckSculptAndLoad()
- {
- if (IsDeleted)
- return;
-
- if ((RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Phantom) != 0)
- return;
-
-// m_log.Debug("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId);
-
- SceneObjectPart[] parts = m_parts.GetArray();
-
- for (int i = 0; i < parts.Length; i++)
- parts[i].CheckSculptAndLoad();
- }
-*/
- ///
/// Set the user group to which this scene object belongs.
///
///
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4775b1f..817ed43 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -350,6 +350,7 @@ namespace OpenSim.Region.Framework.Scenes
protected int m_reprioritizationLastTime;
protected bool m_reprioritizationBusy;
protected Vector3 m_reprioritizationLastPosition;
+ protected float m_reprioritizationLastDrawDistance;
private Quaternion m_headrotation = Quaternion.Identity;
@@ -1047,6 +1048,8 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition = posLastMove = posLastSignificantMove = CameraPosition =
m_reprioritizationLastPosition = ControllingClient.StartPos;
+ m_reprioritizationLastDrawDistance = DrawDistance;
+
// disable updates workjobs for now
childUpdatesBusy = true;
m_reprioritizationBusy = true;
@@ -2130,6 +2133,7 @@ namespace OpenSim.Region.Framework.Scenes
// priority uses avatar position only
m_reprioritizationLastPosition = AbsolutePosition;
+ m_reprioritizationLastDrawDistance = DrawDistance;
m_reprioritizationLastTime = Util.EnvironmentTickCount() + 15000; // delay it
m_reprioritizationBusy = false;
@@ -3986,24 +3990,24 @@ namespace OpenSim.Region.Framework.Scenes
if(m_reprioritizationBusy)
return;
+ float limit = Scene.ReprioritizationDistance;
+ bool byDrawdistance = Scene.ObjectsCullingByDistance;
+ if(byDrawdistance)
+ byDrawdistance = (Math.Abs(DrawDistance-m_reprioritizationLastDrawDistance) > 0.5f * limit);
+
int tdiff = Util.EnvironmentTickCountSubtract(m_reprioritizationLastTime);
- if(tdiff < Scene.ReprioritizationInterval)
+ if(!byDrawdistance && tdiff < Scene.ReprioritizationInterval)
return;
// priority uses avatar position
Vector3 pos = AbsolutePosition;
Vector3 diff = pos - m_reprioritizationLastPosition;
- float limit;
- if(IsChildAgent)
- limit = (float)Scene.ChildReprioritizationDistance;
- else
- limit = (float)Scene.RootReprioritizationDistance;
-
limit *= limit;
- if (diff.LengthSquared() < limit)
+ if (!byDrawdistance && diff.LengthSquared() < limit)
return;
m_reprioritizationBusy = true;
m_reprioritizationLastPosition = pos;
+ m_reprioritizationLastDrawDistance = DrawDistance;
Util.FireAndForget(
o =>
--
cgit v1.1