public void PhysicsCollision(EventArgs e) { // m_log.DebugFormat("Invoking PhysicsCollision on {0} {1} {2}", Name, LocalId, UUID); // single threaded here CollisionEventUpdate a = (CollisionEventUpdate)e; Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList; List<uint> thisHitColliders = new List<uint>(); List<uint> endedColliders = new List<uint>(); List<uint> startedColliders = new List<uint>(); // calculate things that started colliding this time // and build up list of colliders this time foreach (uint localid in collissionswith.Keys) { 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()); } // calculate things that ended colliding foreach (uint localID in m_lastColliders) { if (!thisHitColliders.Contains(localID)) { endedColliders.Add(localID); } } //add the items that started colliding this time to the last colliders list. foreach (uint localID in startedColliders) { m_lastColliders.Add(localID); } // remove things that ended colliding from the last colliders list foreach (uint localID in endedColliders) { m_lastColliders.Remove(localID); } if (ParentGroup.IsDeleted) return; // play the sound. if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) { SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); } if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) { // do event notification if (startedColliders.Count > 0) { ColliderArgs StartCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); foreach (uint localId in startedColliders) { if (localId == 0) continue; if (ParentGroup.Scene == null) return; SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); string data = ""; if (obj != null) { if (ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) || ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name)) { bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this object 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 0, it is to not accept collisions from this object else { } } else { bool found = 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); } } } else { ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) { if (av.LocalId == localId) { if (ParentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || ParentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) { bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this avatar 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 0, it is to not accept collisions from this avatar else { } } else { bool found = 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 (colliding.Count > 0) { StartCollidingMessage.Colliders = colliding; if (ParentGroup.Scene == null) return; // if (m_parentGroup.PassCollision == true) // { // //TODO: Add pass to root prim! // } ParentGroup.Scene.EventManager.TriggerScriptCollidingStart(LocalId, StartCollidingMessage); } } } if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision) != 0) { if (m_lastColliders.Count > 0) { ColliderArgs CollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); foreach (uint localId in m_lastColliders) { // always running this check because if the user deletes the object it would return a null reference. if (localId == 0) continue; if (ParentGroup.Scene == null) return; SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); string data = ""; if (obj != null) { if (ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) || ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name)) { bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); //If it is 1, it is to accept ONLY collisions from this object 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 0, it is to not accept collisions from this object else { } } else { bool found = 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); } } } else { ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) { if (av.LocalId == localId) { if (ParentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || ParentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) { bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this avatar 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 0, it is to not accept collisions from this avatar else { } } else { bool found = 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 (colliding.Count > 0) { CollidingMessage.Colliders = colliding; if (ParentGroup.Scene == null) return; ParentGroup.Scene.EventManager.TriggerScriptColliding(LocalId, CollidingMessage); } } } if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.collision_end) != 0) { if (endedColliders.Count > 0) { ColliderArgs EndCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); foreach (uint localId in endedColliders) { if (localId == 0) continue; if (ParentGroup.Scene == null) return; SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); string data = ""; if (obj != null) { if (ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) || ParentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name)) { bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1,out data); //If it is 1, it is to accept ONLY collisions from this object 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 0, it is to not accept collisions from this object else { } } else { bool found = 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); } } } else { ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence av) { if (av.LocalId == localId) { if (ParentGroup.RootPart.CollisionFilter.ContainsValue(av.UUID.ToString()) || ParentGroup.RootPart.CollisionFilter.ContainsValue(av.Name)) { bool found = ParentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this avatar 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 0, it is to not accept collisions from this avatar else { } } else { bool found = 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 (colliding.Count > 0) { EndCollidingMessage.Colliders = colliding; if (ParentGroup.Scene == null) return; ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd(LocalId, EndCollidingMessage); } } } if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_start) != 0) { if (startedColliders.Count > 0) { ColliderArgs LandStartCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); 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 = 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; if (ParentGroup.Scene == null) return; ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart(LocalId, LandStartCollidingMessage); } } } if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.land_collision) != 0) { if (m_lastColliders.Count > 0) { ColliderArgs LandCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); 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 = 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; if (ParentGroup.Scene == null) return; ParentGroup.Scene.EventManager.TriggerScriptLandColliding(LocalId, LandCollidingMessage); } } } if ((ParentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_end) != 0) { if (endedColliders.Count > 0) { ColliderArgs LandEndCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); 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 = 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; if (ParentGroup.Scene == null) return; ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd(LocalId, LandEndCollidingMessage); } } } }
private DetectedObject CreateDetObject(ScenePresence av) { 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; detobj.linkNumber = 0; return detobj; }
private DetectedObject CreateDetObjectForGround() { DetectedObject detobj = new DetectedObject(); detobj.keyUUID = UUID.Zero; detobj.nameStr = ""; detobj.ownerUUID = UUID.Zero; detobj.posVector = AbsolutePosition; detobj.rotQuat = Quaternion.Identity; detobj.velVector = Vector3.Zero; detobj.colliderType = 0; detobj.groupUUID = UUID.Zero; detobj.linkNumber = 0; return detobj; }
public void PhysicsCollision(EventArgs e) { // single threaded here if (e == null) { return; } CollisionEventUpdate a = (CollisionEventUpdate)e; Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList; List<uint> thisHitColliders = new List<uint>(); List<uint> endedColliders = new List<uint>(); List<uint> startedColliders = new List<uint>(); // calculate things that started colliding this time // 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)) { startedColliders.Add(localid); } //m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); } } // calculate things that ended colliding foreach (uint localID in m_lastColliders) { if (!thisHitColliders.Contains(localID)) { endedColliders.Add(localID); } } //add the items that started colliding this time to the last colliders list. foreach (uint localID in startedColliders) { m_lastColliders.Add(localID); } // remove things that ended colliding from the last colliders list foreach (uint localID in endedColliders) { m_lastColliders.Remove(localID); } if (m_parentGroup == null) return; if (m_parentGroup.IsDeleted) return; // play the sound. if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) { SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0); } if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) { // do event notification if (startedColliders.Count > 0) { ColliderArgs StartCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); foreach (uint localId in startedColliders) { // 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; SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); if (obj != null) { 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 { ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); for (int i = 0; i < avlist.Length; i++) { ScenePresence av = avlist[i]; if (av.LocalId == localId) { 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 (colliding.Count > 0) { StartCollidingMessage.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.TriggerScriptCollidingStart(LocalId, StartCollidingMessage); } } } if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision) != 0) { if (m_lastColliders.Count > 0) { ColliderArgs CollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); foreach (uint localId in m_lastColliders) { // always running this check because if the user deletes the object it would return a null reference. if (localId == 0) continue; if (m_parentGroup == null) return; if (m_parentGroup.Scene == null) return; SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); if (obj != null) { 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 { ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); for (int i = 0; i < avlist.Length; i++) { ScenePresence av = avlist[i]; if (av.LocalId == localId) { DetectedObject detobj = new DetectedObject(); detobj.keyUUID = av.UUID; detobj.nameStr = av.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 (colliding.Count > 0) { CollidingMessage.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.TriggerScriptColliding(LocalId, CollidingMessage); } } } if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_end) != 0) { if (endedColliders.Count > 0) { ColliderArgs EndCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); foreach (uint localId in endedColliders) { if (localId == 0) continue; // 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; SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); if (obj != null) { 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 { ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); for (int i = 0; i < avlist.Length; i++) { ScenePresence av = avlist[i]; if (av.LocalId == localId) { DetectedObject detobj = new DetectedObject(); detobj.keyUUID = av.UUID; detobj.nameStr = av.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 (colliding.Count > 0) { EndCollidingMessage.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.TriggerScriptCollidingEnd(LocalId, EndCollidingMessage); } } } }
private DetectedObject CreateDetObject(SceneObjectPart obj) { 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; detobj.linkNumber = 0; return detobj; }
private DetectedObject CreateDetObjectForGround() { DetectedObject detobj = new DetectedObject(); detobj.keyUUID = UUID.Zero; detobj.nameStr = ""; detobj.ownerUUID = UUID.Zero; detobj.posVector = ParentGroup.RootPart.AbsolutePosition; detobj.rotQuat = Quaternion.Identity; detobj.velVector = Vector3.Zero; detobj.colliderType = 0; detobj.groupUUID = UUID.Zero; detobj.linkNumber = LinkNum; // pass my link number not sure needed.. but no harm return detobj; }
private void TryExtractCollider(uint localId, List<DetectedObject> colliding, bool isPrim, UUID fallbackUuid) { //TODO: this extracts a DetectedObject from the collision, BUT this is then further changed into a //detectparams later making most of this information useless since the change will rediscover //the colliding object again. I have no idea why opensim did it this way. if (isPrim) { // always running this check because if the user deletes the object it would return a null reference. SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); if (obj != null) { 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.groupUUID = obj._groupID; detobj.colliderType = (int)DetermineColliderType(obj); detobj.linkNum = this.LinkNum; colliding.Add(detobj); } else { DetectedObject detobj = new DetectedObject(); detobj.keyUUID = fallbackUuid; colliding.Add(detobj); } } else { ScenePresence presence = m_parentGroup.Scene.GetScenePresence(localId); if (presence != null) { DetectedObject detobj = new DetectedObject(); detobj.keyUUID = presence.UUID; detobj.nameStr = presence.Firstname + " " + presence.Lastname; detobj.ownerUUID = presence.UUID; detobj.posVector = presence.AbsolutePosition; detobj.rotQuat = presence.Rotation; detobj.velVector = presence.Velocity; detobj.linkNum = this.LinkNum; detobj.colliderType = (int)DetectedType.Agent | (int)(presence.Velocity != OpenMetaverse.Vector3.Zero ? DetectedType.Active : DetectedType.Passive); colliding.Add(detobj); } } }
public static DetectParams FromDetectedObject(DetectedObject detobj) { DetectParams parms = new DetectParams(); parms.Key = detobj.keyUUID; parms.Group = detobj.groupUUID; parms.LinkNum = detobj.linkNum; parms.Name = detobj.nameStr; parms.Owner = detobj.ownerUUID; parms.Position = detobj.posVector; parms.Rotation = detobj.rotQuat; parms.Type = detobj.colliderType; parms.Velocity = detobj.velVector; return parms; }
public void PhysicsCollision(EventArgs e) { // single threaded here if (e == null) { return; } CollisionEventUpdate a = (CollisionEventUpdate)e; Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList; List<uint> thisHitColliders = new List<uint>(); List<uint> endedColliders = new List<uint>(); List<uint> startedColliders = new List<uint>(); // calculate things that started colliding this time // and build up list of colliders this time foreach (uint localID in collissionswith.Keys) { 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()); } // calculate things that ended colliding foreach (uint localID in m_lastColliders) { if (!thisHitColliders.Contains(localID)) { endedColliders.Add(localID); } } //add the items that started colliding this time to the last colliders list. m_lastColliders.AddRange(startedColliders); // remove things that ended colliding from the last colliders list foreach (uint localID in endedColliders) { m_lastColliders.Remove(localID); } if (m_parentGroup == null) return; if (m_parentGroup.IsDeleted) return; const string SoundGlassCollision = "6a45ba0b-5775-4ea8-8513-26008a17f873"; const string SoundMetalCollision = "9e5c1297-6eed-40c0-825a-d9bcd86e3193"; const string SoundStoneCollision = "9538f37c-456e-4047-81be-6435045608d4"; const string SoundFleshCollision = "dce5fdd4-afe4-4ea1-822f-dd52cac46b08"; const string SoundPlasticCollision = "0e24a717-b97e-4b77-9c94-b59a5a88b2da"; const string SoundRubberCollision = "153c8bf7-fb89-4d89-b263-47e58b1b4774"; const string SoundWoodCollision = "063c97d3-033a-4e9b-98d8-05c8074922cb"; // play the sound. if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) { SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); } else if (startedColliders.Count > 0) { switch (a.collidertype) { case (int)ActorTypes.Agent: break; // Agents will play the sound so we don't case (int)ActorTypes.Ground: if (collissionswith[startedColliders[0]].PenetrationDepth < 0.17) SendSound(SoundWoodCollision, 1, true, 0, 0, false, false); else SendSound(Sounds.OBJECT_COLLISION.ToString(), 1, true, 0, 0, false, false); break; //Always play the click or thump sound when hitting ground case (int)ActorTypes.Prim: if (m_material == OpenMetaverse.Material.Flesh) SendSound(SoundFleshCollision.ToString(), 1, true, 0, 0, false, false); else if (m_material == OpenMetaverse.Material.Glass) SendSound(SoundGlassCollision, 1, true, 0, 0, false, false); else if (m_material == OpenMetaverse.Material.Metal) SendSound(SoundMetalCollision, 1, true, 0, 0, false, false); else if (m_material == OpenMetaverse.Material.Plastic) SendSound(SoundPlasticCollision, 1, true, 0, 0, false, false); else if (m_material == OpenMetaverse.Material.Rubber) SendSound(SoundRubberCollision, 1, true, 0, 0, false, false); else if (m_material == OpenMetaverse.Material.Stone) SendSound(SoundStoneCollision, 1, true, 0, 0, false, false); else if (m_material == OpenMetaverse.Material.Wood) SendSound(SoundWoodCollision, 1, true, 0, 0, false, false); break; //Play based on material type in prim2prim collisions default: break; //Unclear of what this object is, no sounds } } if (CollisionSprite != UUID.Zero && CollisionSoundVolume > 0.0f) // The collision volume isn't a mistake, its an SL feature/bug { // TODO: make a sprite! } if (((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) || PassCollisions != 2) { if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) { // do event notification if (startedColliders.Count > 0) { ColliderArgs StartCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); foreach (uint localId in startedColliders) { if (localId == 0) continue; // 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; SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); string data = ""; if (obj != null) { if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name)) { bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this object 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 0, it is to not accept collisions from this object 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); } } } else { ScenePresence av = ParentGroup.Scene.GetScenePresence(localId); if(av != null) { 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); //If it is 1, it is to accept ONLY collisions from this avatar 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 0, it is to not accept collisions from this avatar 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 (colliding.Count > 0) { StartCollidingMessage.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; //Always send to the prim it is occuring to m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(this, StartCollidingMessage); if ((this.UUID != this.ParentGroup.RootPart.UUID)) { const int PASS_IF_NOT_HANDLED = 0; const int PASS_ALWAYS = 1; const int PASS_NEVER = 2; if (this.PassCollisions == PASS_NEVER) { } if (this.PassCollisions == PASS_ALWAYS) { m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(this.ParentGroup.RootPart, StartCollidingMessage); } else if (((this.ScriptEvents & scriptEvents.collision_start) == 0) && this.PassCollisions == PASS_IF_NOT_HANDLED) //If no event in this prim, pass to parent { m_parentGroup.Scene.EventManager.TriggerScriptCollidingStart(this.ParentGroup.RootPart, StartCollidingMessage); } } } } } if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision) != 0) { if (m_lastColliders.Count > 0) { ColliderArgs CollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); foreach (uint localId in m_lastColliders) { // always running this check because if the user deletes the object it would return a null reference. if (localId == 0) continue; if (m_parentGroup == null) return; if (m_parentGroup.Scene == null) return; SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); string data = ""; if (obj != null) { if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name)) { bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this object 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 0, it is to not accept collisions from this object 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); } } } else { ScenePresence av = ParentGroup.Scene.GetScenePresence(localId); 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); //If it is 1, it is to accept ONLY collisions from this avatar 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 0, it is to not accept collisions from this avatar 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 (colliding.Count > 0) { CollidingMessage.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.TriggerScriptColliding(this, CollidingMessage); if ((this.UUID != this.ParentGroup.RootPart.UUID)) { const int PASS_IF_NOT_HANDLED = 0; const int PASS_ALWAYS = 1; const int PASS_NEVER = 2; if (this.PassCollisions == PASS_NEVER) { } if (this.PassCollisions == PASS_ALWAYS) { m_parentGroup.Scene.EventManager.TriggerScriptColliding(this.ParentGroup.RootPart, CollidingMessage); } else if (((this.ScriptEvents & scriptEvents.collision) == 0) && this.PassCollisions == PASS_IF_NOT_HANDLED) //If no event in this prim, pass to parent { m_parentGroup.Scene.EventManager.TriggerScriptColliding(this.ParentGroup.RootPart, CollidingMessage); } } } } } if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_end) != 0) { if (endedColliders.Count > 0) { ColliderArgs EndCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); foreach (uint localId in endedColliders) { if (localId == 0) continue; // 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; SceneObjectPart obj = m_parentGroup.Scene.GetSceneObjectPart(localId); string data = ""; if (obj != null) { if (m_parentGroup.RootPart.CollisionFilter.ContainsValue(obj.UUID.ToString()) || m_parentGroup.RootPart.CollisionFilter.ContainsValue(obj.Name)) { bool found = m_parentGroup.RootPart.CollisionFilter.TryGetValue(1, out data); //If it is 1, it is to accept ONLY collisions from this object 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 0, it is to not accept collisions from this object 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); } } } else { ScenePresence av = ParentGroup.Scene.GetScenePresence(localId); if(av != null) { 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); //If it is 1, it is to accept ONLY collisions from this avatar 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 0, it is to not accept collisions from this avatar 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 (colliding.Count > 0) { EndCollidingMessage.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.TriggerScriptCollidingEnd(this, EndCollidingMessage); if ((this.UUID != this.ParentGroup.RootPart.UUID)) { const int PASS_IF_NOT_HANDLED = 0; const int PASS_ALWAYS = 1; const int PASS_NEVER = 2; if (this.PassCollisions == PASS_NEVER) { } if (this.PassCollisions == PASS_ALWAYS) { m_parentGroup.Scene.EventManager.TriggerScriptCollidingEnd(this.ParentGroup.RootPart, EndCollidingMessage); } else if (((this.ScriptEvents & scriptEvents.collision_end) == 0) && this.PassCollisions == PASS_IF_NOT_HANDLED) //If no event in this prim, pass to parent { m_parentGroup.Scene.EventManager.TriggerScriptCollidingEnd(this.ParentGroup.RootPart, EndCollidingMessage); } } } } } if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_start) != 0) { if (startedColliders.Count > 0) { ColliderArgs LandStartCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); 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(this, LandStartCollidingMessage); if ((this.UUID != this.ParentGroup.RootPart.UUID)) { const int PASS_IF_NOT_HANDLED = 0; const int PASS_ALWAYS = 1; const int PASS_NEVER = 2; if (this.PassCollisions == PASS_NEVER) { } if (this.PassCollisions == PASS_ALWAYS) { m_parentGroup.Scene.EventManager.TriggerScriptLandCollidingStart(this.ParentGroup.RootPart, LandStartCollidingMessage); } else if (((this.ScriptEvents & scriptEvents.land_collision_start) == 0) && this.PassCollisions == PASS_IF_NOT_HANDLED) //If no event in this prim, pass to parent { m_parentGroup.Scene.EventManager.TriggerScriptLandCollidingStart(this.ParentGroup.RootPart, LandStartCollidingMessage); } } } } } if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision) != 0) { if (m_lastColliders.Count > 0) { ColliderArgs LandCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); 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(this, LandCollidingMessage); if ((this.UUID != this.ParentGroup.RootPart.UUID)) { const int PASS_IF_NOT_HANDLED = 0; const int PASS_ALWAYS = 1; const int PASS_NEVER = 2; if (this.PassCollisions == PASS_NEVER) { } if (this.PassCollisions == PASS_ALWAYS) { m_parentGroup.Scene.EventManager.TriggerScriptColliding(this.ParentGroup.RootPart, LandCollidingMessage); } else if (((this.ScriptEvents & scriptEvents.land_collision) == 0) && this.PassCollisions == PASS_IF_NOT_HANDLED) //If no event in this prim, pass to parent { m_parentGroup.Scene.EventManager.TriggerScriptColliding(this.ParentGroup.RootPart, LandCollidingMessage); } } } } } if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_end) != 0) { if (endedColliders.Count > 0) { ColliderArgs LandEndCollidingMessage = new ColliderArgs(); List<DetectedObject> colliding = new List<DetectedObject>(); 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(this, LandEndCollidingMessage); if ((this.UUID != this.ParentGroup.RootPart.UUID)) { const int PASS_IF_NOT_HANDLED = 0; const int PASS_ALWAYS = 1; const int PASS_NEVER = 2; if (this.PassCollisions == PASS_NEVER) { } if (this.PassCollisions == PASS_ALWAYS) { m_parentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd(this.ParentGroup.RootPart, LandEndCollidingMessage); } else if (((this.ScriptEvents & scriptEvents.land_collision_end) == 0) && this.PassCollisions == PASS_IF_NOT_HANDLED) //If no event in this prim, pass to parent { m_parentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd(this.ParentGroup.RootPart, LandEndCollidingMessage); } } } } } } }
private void BuildLandColliders(SceneObjectPart collisionPart, OSDArray collisionUUIDs, RegionSyncModule pRegionContext) { for (int i = 0; i < collisionUUIDs.Count; i++) { OSD arg = collisionUUIDs[i]; UUID collidingUUID = arg.AsUUID(); if (collidingUUID.Equals(UUID.Zero)) { //Hope that all is left is ground! DetectedObject detobj = new DetectedObject(); detobj.keyUUID = UUID.Zero; detobj.nameStr = ""; detobj.ownerUUID = UUID.Zero; detobj.posVector = collisionPart.ParentGroup.RootPart.AbsolutePosition; detobj.rotQuat = Quaternion.Identity; detobj.velVector = Vector3.Zero; detobj.colliderType = 0; detobj.groupUUID = UUID.Zero; Colliders.Add(detobj); } } }
private void BuildColliders(OSDArray collisionUUIDs, RegionSyncModule pRegionContext) { for (int i = 0; i < collisionUUIDs.Count; i++) { OSD arg = collisionUUIDs[i]; UUID collidingUUID = arg.AsUUID(); SceneObjectPart obj = pRegionContext.Scene.GetSceneObjectPart(collidingUUID); if (obj != null) { 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; Colliders.Add(detobj); } else { //collision object is not a prim, check if it's an avatar ScenePresence av = pRegionContext.Scene.GetScenePresence(collidingUUID); if (av != null) { 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; Colliders.Add(detobj); } else { // m_log.WarnFormat("HandleRemoteEvent_ScriptCollidingStart for SOP {0},{1} with SOP/SP {2}, but the latter is not found in local Scene. Saved for later processing", // collisionPart.Name, collisionPart.UUID, collidingUUID); CollidersNotFound.Add(collidingUUID); } } } }