From 038ec133e648ab99643f5738e4ab85e450e5aa45 Mon Sep 17 00:00:00 2001 From: Revolution Date: Sun, 10 Jan 2010 14:28:53 -0600 Subject: Adds land collision events. CRs cleaned from patch Signed-off-by: Melanie --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 138 +++++++++++++++++++-- 1 file changed, 128 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index cadb19f..a427f12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -1853,16 +1853,12 @@ namespace OpenSim.Region.Framework.Scenes // and build up list of colliders this time foreach (uint localid in collissionswith.Keys) { - if (localid != 0) + thisHitColliders.Add(localid); + if (!m_lastColliders.Contains(localid)) { - thisHitColliders.Add(localid); - if (!m_lastColliders.Contains(localid)) - { - startedColliders.Add(localid); - } - - //m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); + startedColliders.Add(localid); } + //m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); } // calculate things that ended colliding @@ -1904,6 +1900,8 @@ namespace OpenSim.Region.Framework.Scenes List colliding = new List(); foreach (uint localId in startedColliders) { + if (localId == 0) + return; // always running this check because if the user deletes the object it would return a null reference. if (m_parentGroup == null) return; @@ -2039,7 +2037,7 @@ namespace OpenSim.Region.Framework.Scenes { // always running this check because if the user deletes the object it would return a null reference. if (localId == 0) - continue; + return; if (m_parentGroup == null) return; @@ -2171,7 +2169,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (uint localId in endedColliders) { if (localId == 0) - continue; + return; // always running this check because if the user deletes the object it would return a null reference. if (m_parentGroup == null) @@ -2293,6 +2291,120 @@ namespace OpenSim.Region.Framework.Scenes } } } + if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_start) != 0) + { + if (startedColliders.Count > 0) + { + ColliderArgs LandStartCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + { + //Hope that all is left is ground! + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = UUID.Zero; + detobj.nameStr = ""; + detobj.ownerUUID = UUID.Zero; + detobj.posVector = m_parentGroup.RootPart.AbsolutePosition; + detobj.rotQuat = Quaternion.Identity; + detobj.velVector = Vector3.Zero; + detobj.colliderType = 0; + detobj.groupUUID = UUID.Zero; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + LandStartCollidingMessage.Colliders = colliding; + // always running this check because if the user deletes the object it would return a null reference. + if (m_parentGroup == null) + return; + + if (m_parentGroup.Scene == null) + return; + + m_parentGroup.Scene.EventManager.TriggerScriptLandCollidingStart(LocalId, LandStartCollidingMessage); + } + } + } + if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision) != 0) + { + if (m_lastColliders.Count > 0) + { + ColliderArgs LandCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + { + //Hope that all is left is ground! + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = UUID.Zero; + detobj.nameStr = ""; + detobj.ownerUUID = UUID.Zero; + detobj.posVector = m_parentGroup.RootPart.AbsolutePosition; + detobj.rotQuat = Quaternion.Identity; + detobj.velVector = Vector3.Zero; + detobj.colliderType = 0; + detobj.groupUUID = UUID.Zero; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + LandCollidingMessage.Colliders = colliding; + // always running this check because if the user deletes the object it would return a null reference. + if (m_parentGroup == null) + return; + + if (m_parentGroup.Scene == null) + return; + + m_parentGroup.Scene.EventManager.TriggerScriptLandColliding(LocalId, LandCollidingMessage); + } + } + } + if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_end) != 0) + { + if (endedColliders.Count > 0) + { + ColliderArgs LandEndCollidingMessage = new ColliderArgs(); + List colliding = new List(); + foreach (uint localId in startedColliders) + { + if (localId == 0) + { + //Hope that all is left is ground! + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = UUID.Zero; + detobj.nameStr = ""; + detobj.ownerUUID = UUID.Zero; + detobj.posVector = m_parentGroup.RootPart.AbsolutePosition; + detobj.rotQuat = Quaternion.Identity; + detobj.velVector = Vector3.Zero; + detobj.colliderType = 0; + detobj.groupUUID = UUID.Zero; + colliding.Add(detobj); + } + } + + if (colliding.Count > 0) + { + LandEndCollidingMessage.Colliders = colliding; + // always running this check because if the user deletes the object it would return a null reference. + if (m_parentGroup == null) + return; + + if (m_parentGroup.Scene == null) + return; + + m_parentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd(LocalId, LandEndCollidingMessage); + } + } + } } public void PhysicsOutOfBounds(Vector3 pos) @@ -3698,6 +3810,9 @@ namespace OpenSim.Region.Framework.Scenes ((AggregateScriptEvents & scriptEvents.collision) != 0) || ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || (CollisionSound != UUID.Zero) ) { @@ -3902,6 +4017,9 @@ namespace OpenSim.Region.Framework.Scenes ((AggregateScriptEvents & scriptEvents.collision) != 0) || ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || + ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || (CollisionSound != UUID.Zero) ) { -- cgit v1.1 From 2bf49cc1bb2d87877476f68daec2d515f475406d Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 10 Jan 2010 19:58:44 +0000 Subject: Clean CRs from previous patch --- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 134 ++++++++++----------- 1 file changed, 67 insertions(+), 67 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a427f12..73f79b3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -139,15 +139,15 @@ namespace OpenSim.Region.Framework.Scenes public uint TimeStampTerse; [XmlIgnore] - public UUID FromItemID; - - [XmlIgnore] - public int STATUS_ROTATE_X; - - [XmlIgnore] - public int STATUS_ROTATE_Y; - - [XmlIgnore] + public UUID FromItemID; + + [XmlIgnore] + public int STATUS_ROTATE_X; + + [XmlIgnore] + public int STATUS_ROTATE_Y; + + [XmlIgnore] public int STATUS_ROTATE_Z; [XmlIgnore] @@ -1680,19 +1680,19 @@ namespace OpenSim.Region.Framework.Scenes return false; return m_parentGroup.RootPart.DIE_AT_EDGE; - } - - public int GetAxisRotation(int axis) - { - //Cannot use ScriptBaseClass constants as no referance to it currently. - if (axis == 2)//STATUS_ROTATE_X - return STATUS_ROTATE_X; - if (axis == 4)//STATUS_ROTATE_Y - return STATUS_ROTATE_Y; - if (axis == 8)//STATUS_ROTATE_Z - return STATUS_ROTATE_Z; - - return 0; + } + + public int GetAxisRotation(int axis) + { + //Cannot use ScriptBaseClass constants as no referance to it currently. + if (axis == 2)//STATUS_ROTATE_X + return STATUS_ROTATE_X; + if (axis == 4)//STATUS_ROTATE_Y + return STATUS_ROTATE_Y; + if (axis == 8)//STATUS_ROTATE_Z + return STATUS_ROTATE_Z; + + return 0; } public double GetDistanceTo(Vector3 a, Vector3 b) @@ -1934,24 +1934,24 @@ namespace OpenSim.Region.Framework.Scenes else { } - } - else - { + } + else + { bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); - //If it is 1, it is to accept ONLY collisions from this object, so this other object will not work - if (!found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = obj.UUID; - detobj.nameStr = obj.Name; - detobj.ownerUUID = obj._ownerID; - detobj.posVector = obj.AbsolutePosition; - detobj.rotQuat = obj.GetWorldRotation(); - detobj.velVector = obj.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = obj._groupID; - colliding.Add(detobj); - } + //If it is 1, it is to accept ONLY collisions from this object, so this other object will not work + if (!found) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = obj.UUID; + detobj.nameStr = obj.Name; + detobj.ownerUUID = obj._ownerID; + detobj.posVector = obj.AbsolutePosition; + detobj.rotQuat = obj.GetWorldRotation(); + detobj.velVector = obj.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = obj._groupID; + colliding.Add(detobj); + } } } else @@ -1963,7 +1963,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence av = avlist[i]; if (av.LocalId == localId) - { + { if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) { bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); @@ -1985,24 +1985,24 @@ namespace OpenSim.Region.Framework.Scenes else { } - } - else - { + } + else + { bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); - //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work - if (!found) - { - DetectedObject detobj = new DetectedObject(); - detobj.keyUUID = av.UUID; - detobj.nameStr = av.ControllingClient.Name; - detobj.ownerUUID = av.UUID; - detobj.posVector = av.AbsolutePosition; - detobj.rotQuat = av.Rotation; - detobj.velVector = av.Velocity; - detobj.colliderType = 0; - detobj.groupUUID = av.ControllingClient.ActiveGroupId; - colliding.Add(detobj); - } + //If it is 1, it is to accept ONLY collisions from this avatar, so this other avatar will not work + if (!found) + { + DetectedObject detobj = new DetectedObject(); + detobj.keyUUID = av.UUID; + detobj.nameStr = av.ControllingClient.Name; + detobj.ownerUUID = av.UUID; + detobj.posVector = av.AbsolutePosition; + detobj.rotQuat = av.Rotation; + detobj.velVector = av.Velocity; + detobj.colliderType = 0; + detobj.groupUUID = av.ControllingClient.ActiveGroupId; + colliding.Add(detobj); + } } } @@ -2099,7 +2099,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence av = avlist[i]; if (av.LocalId == localId) - { + { if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) { bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); @@ -2230,7 +2230,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence av = avlist[i]; if (av.LocalId == localId) - { + { if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) { bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); @@ -2290,7 +2290,7 @@ namespace OpenSim.Region.Framework.Scenes m_parentGroup.Scene.EventManager.TriggerScriptCollidingEnd(LocalId, EndCollidingMessage); } } - } + } if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_start) != 0) { if (startedColliders.Count > 0) @@ -2870,13 +2870,13 @@ namespace OpenSim.Region.Framework.Scenes if (m_parentGroup != null) { m_parentGroup.SetAxisRotation(axis, rotate); - } - //Cannot use ScriptBaseClass constants as no referance to it currently. - if (axis == 2)//STATUS_ROTATE_X - STATUS_ROTATE_X = rotate; - if (axis == 4)//STATUS_ROTATE_Y - STATUS_ROTATE_Y = rotate; - if (axis == 8)//STATUS_ROTATE_Z + } + //Cannot use ScriptBaseClass constants as no referance to it currently. + if (axis == 2)//STATUS_ROTATE_X + STATUS_ROTATE_X = rotate; + if (axis == 4)//STATUS_ROTATE_Y + STATUS_ROTATE_Y = rotate; + if (axis == 8)//STATUS_ROTATE_Z STATUS_ROTATE_Z = rotate; } -- cgit v1.1