a few changes on check targets for lsl
parent
b3db90db92
commit
5c5e4bd830
|
@ -410,7 +410,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
|
||||
private volatile bool m_backingup;
|
||||
private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>();
|
||||
private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>();
|
||||
private HashSet<UUID> m_groupsWithTargets = new HashSet<UUID>();
|
||||
|
||||
private string m_defaultScriptEngine;
|
||||
|
||||
|
@ -837,7 +837,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
Random random = new Random();
|
||||
|
||||
m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4);
|
||||
m_lastAllocatedLocalId = (int)(random.NextDouble() * (uint.MaxValue / 4));
|
||||
m_lastAllocatedIntId = (int)(random.NextDouble() * (int.MaxValue / 4));
|
||||
m_authenticateHandler = authen;
|
||||
m_sceneGridService = new SceneCommunicationService();
|
||||
m_SimulationDataService = simDataService;
|
||||
|
@ -1633,7 +1634,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
// m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName);
|
||||
|
||||
agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0f;
|
||||
otherMS = agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0f;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -1713,6 +1714,10 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (Frame % m_update_objects == 0)
|
||||
m_sceneGraph.UpdateObjectGroups();
|
||||
|
||||
tmpMS2 = Util.GetTimeStampMS();
|
||||
otherMS = (float)(tmpMS2 - tmpMS);
|
||||
tmpMS = tmpMS2;
|
||||
|
||||
// Run through all ScenePresences looking for updates
|
||||
// Presence updates and queued object updates for each presence are sent to clients
|
||||
if (Frame % m_update_presences == 0)
|
||||
|
@ -1828,7 +1833,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
m_firstHeartbeat = false;
|
||||
Watchdog.UpdateThread();
|
||||
|
||||
otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
|
||||
otherMS += tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
|
||||
|
||||
tmpMS = Util.GetTimeStampMS();
|
||||
|
||||
|
@ -1912,7 +1917,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
public void AddGroupTarget(SceneObjectGroup grp)
|
||||
{
|
||||
lock (m_groupsWithTargets)
|
||||
m_groupsWithTargets[grp.UUID] = 0;
|
||||
m_groupsWithTargets.Add(grp.UUID);
|
||||
}
|
||||
|
||||
public void RemoveGroupTarget(SceneObjectGroup grp)
|
||||
|
@ -1928,13 +1933,14 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
lock (m_groupsWithTargets)
|
||||
{
|
||||
if (m_groupsWithTargets.Count != 0)
|
||||
objs = new List<UUID>(m_groupsWithTargets.Keys);
|
||||
objs = new List<UUID>(m_groupsWithTargets);
|
||||
}
|
||||
|
||||
if (objs != null)
|
||||
{
|
||||
foreach (UUID entry in objs)
|
||||
for(int i = 0; i< objs.Count; ++i)
|
||||
{
|
||||
UUID entry = objs[i];
|
||||
SceneObjectGroup grp = GetSceneObjectGroup(entry);
|
||||
if (grp == null)
|
||||
m_groupsWithTargets.Remove(entry);
|
||||
|
|
|
@ -105,9 +105,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// The last allocated local prim id. When a new local id is requested, the next number in the sequence is
|
||||
/// dispensed.
|
||||
/// </summary>
|
||||
protected uint m_lastAllocatedLocalId = 720000;
|
||||
|
||||
private readonly Mutex _primAllocateMutex = new Mutex(false);
|
||||
protected int m_lastAllocatedLocalId = 720000;
|
||||
protected int m_lastAllocatedIntId = 7200;
|
||||
|
||||
protected readonly ClientManager m_clientManager = new ClientManager();
|
||||
|
||||
|
@ -299,15 +298,16 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <returns>A brand new local ID</returns>
|
||||
public uint AllocateLocalId()
|
||||
{
|
||||
uint myID;
|
||||
|
||||
_primAllocateMutex.WaitOne();
|
||||
myID = ++m_lastAllocatedLocalId;
|
||||
_primAllocateMutex.ReleaseMutex();
|
||||
|
||||
return myID;
|
||||
return (uint)Interlocked.Increment(ref m_lastAllocatedLocalId);
|
||||
}
|
||||
|
||||
public int AllocateIntId()
|
||||
{
|
||||
return Interlocked.Increment(ref m_lastAllocatedLocalId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Module Methods
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -87,14 +87,14 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
public Vector3 targetPos;
|
||||
public float tolerance;
|
||||
public uint handle;
|
||||
public int handle;
|
||||
}
|
||||
|
||||
public struct scriptRotTarget
|
||||
{
|
||||
public Quaternion targetRot;
|
||||
public float tolerance;
|
||||
public uint handle;
|
||||
public int handle;
|
||||
}
|
||||
|
||||
public delegate void PrimCountTaintedDelegate();
|
||||
|
@ -357,15 +357,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
protected SceneObjectPart m_rootPart;
|
||||
// private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
|
||||
|
||||
private SortedDictionary<uint, scriptPosTarget> m_targets = new SortedDictionary<uint, scriptPosTarget>();
|
||||
private SortedDictionary<uint, scriptRotTarget> m_rotTargets = new SortedDictionary<uint, scriptRotTarget>();
|
||||
private SortedDictionary<int, scriptPosTarget> m_targets = new SortedDictionary<int, scriptPosTarget>();
|
||||
private SortedDictionary<int, scriptRotTarget> m_rotTargets = new SortedDictionary<int, scriptRotTarget>();
|
||||
|
||||
public SortedDictionary<uint, scriptPosTarget> AtTargets
|
||||
public SortedDictionary<int, scriptPosTarget> AtTargets
|
||||
{
|
||||
get { return m_targets; }
|
||||
}
|
||||
|
||||
public SortedDictionary<uint, scriptRotTarget> RotTargets
|
||||
public SortedDictionary<int, scriptRotTarget> RotTargets
|
||||
{
|
||||
get { return m_rotTargets; }
|
||||
}
|
||||
|
@ -2906,7 +2906,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
// if (IsAttachment)
|
||||
// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId);
|
||||
checkAtTargets();
|
||||
if (Scene.GetNumberOfClients() == 0)
|
||||
return;
|
||||
|
||||
|
@ -2925,8 +2924,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
// if (IsAttachment)
|
||||
// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId);
|
||||
checkAtTargets();
|
||||
|
||||
if (Scene.GetNumberOfClients() == 0)
|
||||
return;
|
||||
|
||||
|
@ -4809,7 +4806,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
scriptRotTarget waypoint = new scriptRotTarget();
|
||||
waypoint.targetRot = target;
|
||||
waypoint.tolerance = tolerance;
|
||||
uint handle = m_scene.AllocateLocalId();
|
||||
int handle = m_scene.AllocateIntId();
|
||||
waypoint.handle = handle;
|
||||
lock (m_rotTargets)
|
||||
{
|
||||
|
@ -4818,14 +4815,14 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
m_rotTargets.Add(handle, waypoint);
|
||||
}
|
||||
m_scene.AddGroupTarget(this);
|
||||
return (int)handle;
|
||||
return handle;
|
||||
}
|
||||
|
||||
public void unregisterRotTargetWaypoint(int handle)
|
||||
{
|
||||
lock (m_targets)
|
||||
{
|
||||
m_rotTargets.Remove((uint)handle);
|
||||
m_rotTargets.Remove(handle);
|
||||
if (m_targets.Count == 0)
|
||||
m_scene.RemoveGroupTarget(this);
|
||||
}
|
||||
|
@ -4836,7 +4833,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
scriptPosTarget waypoint = new scriptPosTarget();
|
||||
waypoint.targetPos = target;
|
||||
waypoint.tolerance = tolerance;
|
||||
uint handle = m_scene.AllocateLocalId();
|
||||
int handle = m_scene.AllocateIntId();
|
||||
waypoint.handle = handle;
|
||||
lock (m_targets)
|
||||
{
|
||||
|
@ -4852,7 +4849,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
lock (m_targets)
|
||||
{
|
||||
m_targets.Remove((uint)handle);
|
||||
m_targets.Remove(handle);
|
||||
if (m_targets.Count == 0)
|
||||
m_scene.RemoveGroupTarget(this);
|
||||
}
|
||||
|
@ -4860,31 +4857,32 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public void checkAtTargets()
|
||||
{
|
||||
if (m_scriptListens_atTarget || m_scriptListens_notAtTarget)
|
||||
if (m_targets.Count > 0 && (m_scriptListens_atTarget || m_scriptListens_notAtTarget))
|
||||
{
|
||||
if (m_targets.Count > 0)
|
||||
{
|
||||
bool at_target = false;
|
||||
//Vector3 targetPos;
|
||||
//uint targetHandle;
|
||||
Dictionary<uint, scriptPosTarget> atTargets = new Dictionary<uint, scriptPosTarget>();
|
||||
bool not_target = true;
|
||||
|
||||
List<scriptPosTarget> atTargets = new List<scriptPosTarget>(m_targets.Count);
|
||||
lock (m_targets)
|
||||
{
|
||||
foreach (uint idx in m_targets.Keys)
|
||||
{
|
||||
scriptPosTarget target = m_targets[idx];
|
||||
if (Vector3.DistanceSquared(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance * target.tolerance)
|
||||
{
|
||||
at_target = true;
|
||||
|
||||
// trigger at_target
|
||||
if (m_scriptListens_atTarget)
|
||||
{
|
||||
scriptPosTarget att = new scriptPosTarget();
|
||||
att.targetPos = target.targetPos;
|
||||
att.tolerance = target.tolerance;
|
||||
att.handle = target.handle;
|
||||
atTargets.Add(idx, att);
|
||||
foreach (scriptPosTarget target in m_targets.Values)
|
||||
{
|
||||
if (Vector3.DistanceSquared(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance * target.tolerance)
|
||||
{
|
||||
not_target = false;
|
||||
atTargets.Add(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (scriptPosTarget target in m_targets.Values)
|
||||
{
|
||||
if (Vector3.DistanceSquared(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance * target.tolerance)
|
||||
{
|
||||
not_target = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4893,69 +4891,66 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (atTargets.Count > 0)
|
||||
{
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
uint[] localids = new uint[parts.Length];
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
localids[i] = parts[i].LocalId;
|
||||
|
||||
for (int ctr = 0; ctr < localids.Length; ctr++)
|
||||
for (int ctr = 0; ctr < parts.Length; ++ctr)
|
||||
{
|
||||
foreach (uint target in atTargets.Keys)
|
||||
uint pid = parts[ctr].LocalId;
|
||||
for(int target = 0; target < atTargets.Count; ++target)
|
||||
{
|
||||
scriptPosTarget att = atTargets[target];
|
||||
m_scene.EventManager.TriggerAtTargetEvent(
|
||||
localids[ctr], att.handle, att.targetPos, m_rootPart.GroupPosition);
|
||||
pid, (uint)att.handle, att.targetPos, m_rootPart.GroupPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_scriptListens_notAtTarget && !at_target)
|
||||
if (not_target && m_scriptListens_notAtTarget)
|
||||
{
|
||||
//trigger not_at_target
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
uint[] localids = new uint[parts.Length];
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
localids[i] = parts[i].LocalId;
|
||||
for (int ctr = 0; ctr < parts.Length; ctr++)
|
||||
{
|
||||
m_scene.EventManager.TriggerNotAtTargetEvent(parts[ctr].LocalId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int ctr = 0; ctr < localids.Length; ctr++)
|
||||
if (m_rotTargets.Count > 0 && (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget))
|
||||
{
|
||||
m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget)
|
||||
{
|
||||
if (m_rotTargets.Count > 0)
|
||||
{
|
||||
bool at_Rottarget = false;
|
||||
Dictionary<uint, scriptRotTarget> atRotTargets = new Dictionary<uint, scriptRotTarget>();
|
||||
bool not_Rottarget = true;
|
||||
|
||||
List<scriptRotTarget> atRotTargets = new List<scriptRotTarget>(m_rotTargets.Count);
|
||||
lock (m_rotTargets)
|
||||
{
|
||||
foreach (uint idx in m_rotTargets.Keys)
|
||||
if (m_scriptListens_atRotTarget)
|
||||
{
|
||||
scriptRotTarget target = m_rotTargets[idx];
|
||||
double angle
|
||||
= Math.Acos(
|
||||
target.targetRot.X * m_rootPart.RotationOffset.X
|
||||
+ target.targetRot.Y * m_rootPart.RotationOffset.Y
|
||||
+ target.targetRot.Z * m_rootPart.RotationOffset.Z
|
||||
+ target.targetRot.W * m_rootPart.RotationOffset.W)
|
||||
* 2;
|
||||
if (angle < 0) angle = -angle;
|
||||
if (angle > Math.PI) angle = (Math.PI * 2 - angle);
|
||||
foreach (scriptRotTarget target in m_rotTargets.Values)
|
||||
{
|
||||
double angle = 2 * Math.Acos(Quaternion.Dot(target.targetRot, m_rootPart.RotationOffset));
|
||||
if (angle < 0)
|
||||
angle = -angle;
|
||||
if (angle > Math.PI)
|
||||
angle = (2 * Math.PI - angle);
|
||||
if (angle <= target.tolerance)
|
||||
{
|
||||
// trigger at_rot_target
|
||||
if (m_scriptListens_atRotTarget)
|
||||
not_Rottarget = false;
|
||||
atRotTargets.Add(target);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
at_Rottarget = true;
|
||||
scriptRotTarget att = new scriptRotTarget();
|
||||
att.targetRot = target.targetRot;
|
||||
att.tolerance = target.tolerance;
|
||||
att.handle = target.handle;
|
||||
atRotTargets.Add(idx, att);
|
||||
foreach (scriptRotTarget target in m_rotTargets.Values)
|
||||
{
|
||||
double angle = 2 * Math.Acos(Quaternion.Dot(target.targetRot, m_rootPart.RotationOffset));
|
||||
if (angle < 0)
|
||||
angle = -angle;
|
||||
if (angle > Math.PI)
|
||||
angle = (2 * Math.PI - angle);
|
||||
if (angle <= target.tolerance)
|
||||
{
|
||||
not_Rottarget = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4964,36 +4959,24 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (atRotTargets.Count > 0)
|
||||
{
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
uint[] localids = new uint[parts.Length];
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
localids[i] = parts[i].LocalId;
|
||||
|
||||
for (int ctr = 0; ctr < localids.Length; ctr++)
|
||||
for (int ctr = 0; ctr < parts.Length; ++ctr)
|
||||
{
|
||||
foreach (uint target in atRotTargets.Keys)
|
||||
uint pid = parts[ctr].LocalId;
|
||||
for (int target = 0; target < atRotTargets.Count; ++target)
|
||||
{
|
||||
scriptRotTarget att = atRotTargets[target];
|
||||
m_scene.EventManager.TriggerAtRotTargetEvent(
|
||||
localids[ctr], att.handle, att.targetRot, m_rootPart.RotationOffset);
|
||||
pid, (uint)att.handle, att.targetRot, m_rootPart.RotationOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_scriptListens_notAtRotTarget && !at_Rottarget)
|
||||
if (not_Rottarget && m_scriptListens_notAtRotTarget)
|
||||
{
|
||||
//trigger not_at_target
|
||||
SceneObjectPart[] parts = m_parts.GetArray();
|
||||
uint[] localids = new uint[parts.Length];
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
localids[i] = parts[i].LocalId;
|
||||
|
||||
for (int ctr = 0; ctr < localids.Length; ctr++)
|
||||
{
|
||||
m_scene.EventManager.TriggerNotAtRotTargetEvent(localids[ctr]);
|
||||
}
|
||||
}
|
||||
for (int ctr = 0; ctr < parts.Length; ++ctr)
|
||||
m_scene.EventManager.TriggerNotAtRotTargetEvent(parts[ctr].LocalId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3344,7 +3344,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
private const float VELOCITY_TOLERANCE = 0.1f;
|
||||
private const float ANGVELOCITY_TOLERANCE = 0.005f;
|
||||
private const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
|
||||
private const double TIME_MS_TOLERANCE = 200.0; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
|
||||
private const double TIME_MS_TOLERANCE = 250.0; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
|
||||
|
||||
private Vector3 ClampVectorForTerseUpdate(Vector3 v, float max)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue