From a0859754c03324be9a4a2b9c9f26928e64cb5a6f Mon Sep 17 00:00:00 2001 From: Revolution Date: Sun, 10 Jan 2010 20:20:00 -0600 Subject: Adds llRotTarget and the events at_rot_target and not_at_rot_target. Signed-off-by: Melanie --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 130 ++++++++++++++++++++- 1 file changed, 127 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 34d8b49..8050bf6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -56,7 +56,8 @@ namespace OpenSim.Region.Framework.Scenes land_collision = 2048, land_collision_end = 4096, land_collision_start = 8192, - at_target = 16384, + at_target = 16384, + at_rot_target = 16777216, listen = 32768, money = 65536, moving_end = 131072, @@ -79,6 +80,13 @@ namespace OpenSim.Region.Framework.Scenes public Vector3 targetPos; public float tolerance; public uint handle; + } + + struct scriptRotTarget + { + public Quaternion targetRot; + public float tolerance; + public uint handle; } public delegate void PrimCountTaintedDelegate(); @@ -165,10 +173,14 @@ namespace OpenSim.Region.Framework.Scenes protected SceneObjectPart m_rootPart; // private Dictionary m_scriptEvents = new Dictionary(); - private Dictionary m_targets = new Dictionary(); + private Dictionary m_targets = new Dictionary(); + private Dictionary m_rotTargets = new Dictionary(); private bool m_scriptListens_atTarget = false; - private bool m_scriptListens_notAtTarget = false; + private bool m_scriptListens_notAtTarget = false; + + private bool m_scriptListens_atRotTarget = false; + private bool m_scriptListens_notAtRotTarget = false; internal Dictionary m_savedScriptState = null; @@ -1261,6 +1273,15 @@ namespace OpenSim.Region.Framework.Scenes lock (m_targets) m_targets.Clear(); m_scene.RemoveGroupTarget(this); + } + m_scriptListens_atRotTarget = ((aggregateScriptEvents & scriptEvents.at_rot_target) != 0); + m_scriptListens_notAtRotTarget = ((aggregateScriptEvents & scriptEvents.not_at_rot_target) != 0); + + if (!m_scriptListens_atRotTarget && !m_scriptListens_notAtRotTarget) + { + lock (m_rotTargets) + m_rotTargets.Clear(); + m_scene.RemoveGroupTarget(this); } ScheduleGroupForFullUpdate(); @@ -3157,6 +3178,30 @@ namespace OpenSim.Region.Framework.Scenes } } + } + public int registerRotTargetWaypoint(Quaternion target, float tolerance) + { + scriptRotTarget waypoint = new scriptRotTarget(); + waypoint.targetRot = target; + waypoint.tolerance = tolerance; + uint handle = m_scene.AllocateLocalId(); + waypoint.handle = handle; + lock (m_rotTargets) + { + m_rotTargets.Add(handle, waypoint); + } + m_scene.AddGroupTarget(this); + return (int)handle; + } + + public void unregisterRotTargetWaypoint(int handle) + { + lock (m_targets) + { + m_rotTargets.Remove((uint)handle); + if (m_targets.Count == 0) + m_scene.RemoveGroupTarget(this); + } } public int registerTargetWaypoint(Vector3 target, float tolerance) @@ -3263,6 +3308,85 @@ namespace OpenSim.Region.Framework.Scenes } } } + } + if (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget) + { + if (m_rotTargets.Count > 0) + { + bool at_Rottarget = false; + Dictionary atRotTargets = new Dictionary(); + lock (m_rotTargets) + { + foreach (uint idx in m_rotTargets.Keys) + { + 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); + if (angle <= target.tolerance) + { + // trigger at_rot_target + if (m_scriptListens_atRotTarget) + { + at_Rottarget = true; + scriptRotTarget att = new scriptRotTarget(); + att.targetRot = target.targetRot; + att.tolerance = target.tolerance; + att.handle = target.handle; + atRotTargets.Add(idx, att); + } + } + } + } + + if (atRotTargets.Count > 0) + { + uint[] localids = new uint[0]; + lock (m_parts) + { + localids = new uint[m_parts.Count]; + int cntr = 0; + foreach (SceneObjectPart part in m_parts.Values) + { + localids[cntr] = part.LocalId; + cntr++; + } + } + + for (int ctr = 0; ctr < localids.Length; ctr++) + { + foreach (uint target in atRotTargets.Keys) + { + scriptRotTarget att = atRotTargets[target]; + m_scene.EventManager.TriggerAtRotTargetEvent( + localids[ctr], att.handle, att.targetRot, m_rootPart.RotationOffset); + } + } + + return; + } + + if (m_scriptListens_notAtRotTarget && !at_Rottarget) + { + //trigger not_at_target + uint[] localids = new uint[0]; + lock (m_parts) + { + localids = new uint[m_parts.Count]; + int cntr = 0; + foreach (SceneObjectPart part in m_parts.Values) + { + localids[cntr] = part.LocalId; + cntr++; + } + } + + for (int ctr = 0; ctr < localids.Length; ctr++) + { + m_scene.EventManager.TriggerNotAtRotTargetEvent(localids[ctr]); + } + } + } } } -- cgit v1.1