diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 34d8b49..ec41ac7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -57,6 +57,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
57 | land_collision_end = 4096, | 57 | land_collision_end = 4096, |
58 | land_collision_start = 8192, | 58 | land_collision_start = 8192, |
59 | at_target = 16384, | 59 | at_target = 16384, |
60 | at_rot_target = 16777216, | ||
60 | listen = 32768, | 61 | listen = 32768, |
61 | money = 65536, | 62 | money = 65536, |
62 | moving_end = 131072, | 63 | moving_end = 131072, |
@@ -81,6 +82,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
81 | public uint handle; | 82 | public uint handle; |
82 | } | 83 | } |
83 | 84 | ||
85 | struct scriptRotTarget | ||
86 | { | ||
87 | public Quaternion targetRot; | ||
88 | public float tolerance; | ||
89 | public uint handle; | ||
90 | } | ||
91 | |||
84 | public delegate void PrimCountTaintedDelegate(); | 92 | public delegate void PrimCountTaintedDelegate(); |
85 | 93 | ||
86 | /// <summary> | 94 | /// <summary> |
@@ -166,10 +174,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
166 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); | 174 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); |
167 | 175 | ||
168 | private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); | 176 | private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); |
177 | private Dictionary<uint, scriptRotTarget> m_rotTargets = new Dictionary<uint, scriptRotTarget>(); | ||
169 | 178 | ||
170 | private bool m_scriptListens_atTarget = false; | 179 | private bool m_scriptListens_atTarget = false; |
171 | private bool m_scriptListens_notAtTarget = false; | 180 | private bool m_scriptListens_notAtTarget = false; |
172 | 181 | ||
182 | private bool m_scriptListens_atRotTarget = false; | ||
183 | private bool m_scriptListens_notAtRotTarget = false; | ||
184 | |||
173 | internal Dictionary<UUID, string> m_savedScriptState = null; | 185 | internal Dictionary<UUID, string> m_savedScriptState = null; |
174 | 186 | ||
175 | #region Properties | 187 | #region Properties |
@@ -1262,6 +1274,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1262 | m_targets.Clear(); | 1274 | m_targets.Clear(); |
1263 | m_scene.RemoveGroupTarget(this); | 1275 | m_scene.RemoveGroupTarget(this); |
1264 | } | 1276 | } |
1277 | m_scriptListens_atRotTarget = ((aggregateScriptEvents & scriptEvents.at_rot_target) != 0); | ||
1278 | m_scriptListens_notAtRotTarget = ((aggregateScriptEvents & scriptEvents.not_at_rot_target) != 0); | ||
1279 | |||
1280 | if (!m_scriptListens_atRotTarget && !m_scriptListens_notAtRotTarget) | ||
1281 | { | ||
1282 | lock (m_rotTargets) | ||
1283 | m_rotTargets.Clear(); | ||
1284 | m_scene.RemoveGroupTarget(this); | ||
1285 | } | ||
1265 | 1286 | ||
1266 | ScheduleGroupForFullUpdate(); | 1287 | ScheduleGroupForFullUpdate(); |
1267 | } | 1288 | } |
@@ -3158,6 +3179,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3158 | 3179 | ||
3159 | } | 3180 | } |
3160 | } | 3181 | } |
3182 | public int registerRotTargetWaypoint(Quaternion target, float tolerance) | ||
3183 | { | ||
3184 | scriptRotTarget waypoint = new scriptRotTarget(); | ||
3185 | waypoint.targetRot = target; | ||
3186 | waypoint.tolerance = tolerance; | ||
3187 | uint handle = m_scene.AllocateLocalId(); | ||
3188 | waypoint.handle = handle; | ||
3189 | lock (m_rotTargets) | ||
3190 | { | ||
3191 | m_rotTargets.Add(handle, waypoint); | ||
3192 | } | ||
3193 | m_scene.AddGroupTarget(this); | ||
3194 | return (int)handle; | ||
3195 | } | ||
3196 | |||
3197 | public void unregisterRotTargetWaypoint(int handle) | ||
3198 | { | ||
3199 | lock (m_targets) | ||
3200 | { | ||
3201 | m_rotTargets.Remove((uint)handle); | ||
3202 | if (m_targets.Count == 0) | ||
3203 | m_scene.RemoveGroupTarget(this); | ||
3204 | } | ||
3205 | } | ||
3161 | 3206 | ||
3162 | public int registerTargetWaypoint(Vector3 target, float tolerance) | 3207 | public int registerTargetWaypoint(Vector3 target, float tolerance) |
3163 | { | 3208 | { |
@@ -3264,6 +3309,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
3264 | } | 3309 | } |
3265 | } | 3310 | } |
3266 | } | 3311 | } |
3312 | if (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget) | ||
3313 | { | ||
3314 | if (m_rotTargets.Count > 0) | ||
3315 | { | ||
3316 | bool at_Rottarget = false; | ||
3317 | Dictionary<uint, scriptRotTarget> atRotTargets = new Dictionary<uint, scriptRotTarget>(); | ||
3318 | lock (m_rotTargets) | ||
3319 | { | ||
3320 | foreach (uint idx in m_rotTargets.Keys) | ||
3321 | { | ||
3322 | scriptRotTarget target = m_rotTargets[idx]; | ||
3323 | 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; | ||
3324 | if (angle < 0) angle = -angle; | ||
3325 | if (angle > Math.PI) angle = (Math.PI * 2 - angle); | ||
3326 | if (angle <= target.tolerance) | ||
3327 | { | ||
3328 | // trigger at_rot_target | ||
3329 | if (m_scriptListens_atRotTarget) | ||
3330 | { | ||
3331 | at_Rottarget = true; | ||
3332 | scriptRotTarget att = new scriptRotTarget(); | ||
3333 | att.targetRot = target.targetRot; | ||
3334 | att.tolerance = target.tolerance; | ||
3335 | att.handle = target.handle; | ||
3336 | atRotTargets.Add(idx, att); | ||
3337 | } | ||
3338 | } | ||
3339 | } | ||
3340 | } | ||
3341 | |||
3342 | if (atRotTargets.Count > 0) | ||
3343 | { | ||
3344 | uint[] localids = new uint[0]; | ||
3345 | lock (m_parts) | ||
3346 | { | ||
3347 | localids = new uint[m_parts.Count]; | ||
3348 | int cntr = 0; | ||
3349 | foreach (SceneObjectPart part in m_parts.Values) | ||
3350 | { | ||
3351 | localids[cntr] = part.LocalId; | ||
3352 | cntr++; | ||
3353 | } | ||
3354 | } | ||
3355 | |||
3356 | for (int ctr = 0; ctr < localids.Length; ctr++) | ||
3357 | { | ||
3358 | foreach (uint target in atRotTargets.Keys) | ||
3359 | { | ||
3360 | scriptRotTarget att = atRotTargets[target]; | ||
3361 | m_scene.EventManager.TriggerAtRotTargetEvent( | ||
3362 | localids[ctr], att.handle, att.targetRot, m_rootPart.RotationOffset); | ||
3363 | } | ||
3364 | } | ||
3365 | |||
3366 | return; | ||
3367 | } | ||
3368 | |||
3369 | if (m_scriptListens_notAtRotTarget && !at_Rottarget) | ||
3370 | { | ||
3371 | //trigger not_at_target | ||
3372 | uint[] localids = new uint[0]; | ||
3373 | lock (m_parts) | ||
3374 | { | ||
3375 | localids = new uint[m_parts.Count]; | ||
3376 | int cntr = 0; | ||
3377 | foreach (SceneObjectPart part in m_parts.Values) | ||
3378 | { | ||
3379 | localids[cntr] = part.LocalId; | ||
3380 | cntr++; | ||
3381 | } | ||
3382 | } | ||
3383 | |||
3384 | for (int ctr = 0; ctr < localids.Length; ctr++) | ||
3385 | { | ||
3386 | m_scene.EventManager.TriggerNotAtRotTargetEvent(localids[ctr]); | ||
3387 | } | ||
3388 | } | ||
3389 | } | ||
3390 | } | ||
3267 | } | 3391 | } |
3268 | 3392 | ||
3269 | public float GetMass() | 3393 | public float GetMass() |