diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 127 |
1 files changed, 78 insertions, 49 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index ebddf21..06dec8f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -4112,71 +4112,100 @@ namespace OpenSim.Region.Framework.Scenes | |||
4112 | List<uint> thisHitColliders = new List<uint>(); | 4112 | List<uint> thisHitColliders = new List<uint>(); |
4113 | List<uint> endedColliders = new List<uint>(); | 4113 | List<uint> endedColliders = new List<uint>(); |
4114 | List<uint> startedColliders = new List<uint>(); | 4114 | List<uint> startedColliders = new List<uint>(); |
4115 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4116 | CollisionForSoundInfo soundinfo; | ||
4117 | ContactPoint curcontact; | ||
4115 | 4118 | ||
4116 | foreach (uint localid in coldata.Keys) | 4119 | if (coldata.Count == 0) |
4117 | { | 4120 | { |
4118 | thisHitColliders.Add(localid); | 4121 | if (m_lastColliders.Count == 0) |
4119 | if (!m_lastColliders.Contains(localid)) | 4122 | return; // nothing to do |
4120 | { | 4123 | |
4121 | startedColliders.Add(localid); | 4124 | foreach (uint localID in m_lastColliders) |
4122 | } | ||
4123 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4124 | } | ||
4125 | |||
4126 | // calculate things that ended colliding | ||
4127 | foreach (uint localID in m_lastColliders) | ||
4128 | { | ||
4129 | if (!thisHitColliders.Contains(localID)) | ||
4130 | { | 4125 | { |
4131 | endedColliders.Add(localID); | 4126 | endedColliders.Add(localID); |
4132 | } | 4127 | } |
4133 | } | 4128 | m_lastColliders.Clear(); |
4134 | //add the items that started colliding this time to the last colliders list. | ||
4135 | foreach (uint localID in startedColliders) | ||
4136 | { | ||
4137 | m_lastColliders.Add(localID); | ||
4138 | } | ||
4139 | // remove things that ended colliding from the last colliders list | ||
4140 | foreach (uint localID in endedColliders) | ||
4141 | { | ||
4142 | m_lastColliders.Remove(localID); | ||
4143 | } | 4129 | } |
4144 | 4130 | ||
4145 | // do event notification | 4131 | else |
4146 | if (startedColliders.Count > 0) | ||
4147 | { | 4132 | { |
4148 | CollisionSounds.AvatarCollisionSound(this, startedColliders); | 4133 | foreach (uint id in coldata.Keys) |
4149 | |||
4150 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
4151 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4152 | foreach (uint localId in startedColliders) | ||
4153 | { | 4134 | { |
4154 | if (localId == 0) | 4135 | thisHitColliders.Add(id); |
4155 | continue; | 4136 | if (!m_lastColliders.Contains(id)) |
4137 | { | ||
4138 | startedColliders.Add(id); | ||
4139 | curcontact = coldata[id]; | ||
4140 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4141 | { | ||
4142 | soundinfo = new CollisionForSoundInfo(); | ||
4143 | soundinfo.colliderID = id; | ||
4144 | soundinfo.position = curcontact.Position; | ||
4145 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4146 | soundinfolist.Add(soundinfo); | ||
4147 | } | ||
4148 | } | ||
4149 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4150 | } | ||
4156 | 4151 | ||
4157 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | 4152 | // calculate things that ended colliding |
4158 | string data = ""; | 4153 | foreach (uint localID in m_lastColliders) |
4159 | if (obj != null) | 4154 | { |
4155 | if (!thisHitColliders.Contains(localID)) | ||
4160 | { | 4156 | { |
4161 | DetectedObject detobj = new DetectedObject(); | 4157 | endedColliders.Add(localID); |
4162 | detobj.keyUUID = obj.UUID; | ||
4163 | detobj.nameStr = obj.Name; | ||
4164 | detobj.ownerUUID = obj.OwnerID; | ||
4165 | detobj.posVector = obj.AbsolutePosition; | ||
4166 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4167 | detobj.velVector = obj.Velocity; | ||
4168 | detobj.colliderType = 0; | ||
4169 | detobj.groupUUID = obj.GroupID; | ||
4170 | colliding.Add(detobj); | ||
4171 | } | 4158 | } |
4172 | } | 4159 | } |
4160 | //add the items that started colliding this time to the last colliders list. | ||
4161 | foreach (uint localID in startedColliders) | ||
4162 | { | ||
4163 | m_lastColliders.Add(localID); | ||
4164 | } | ||
4165 | // remove things that ended colliding from the last colliders list | ||
4166 | foreach (uint localID in endedColliders) | ||
4167 | { | ||
4168 | m_lastColliders.Remove(localID); | ||
4169 | } | ||
4173 | 4170 | ||
4174 | if (colliding.Count > 0) | 4171 | if (soundinfolist.Count > 0) |
4172 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4173 | |||
4174 | // do event notification | ||
4175 | if (startedColliders.Count > 0) | ||
4175 | { | 4176 | { |
4176 | StartCollidingMessage.Colliders = colliding; | ||
4177 | 4177 | ||
4178 | foreach (SceneObjectGroup att in GetAttachments()) | 4178 | ColliderArgs StartCollidingMessage = new ColliderArgs(); |
4179 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | 4179 | List<DetectedObject> colliding = new List<DetectedObject>(); |
4180 | foreach (uint localId in startedColliders) | ||
4181 | { | ||
4182 | if (localId == 0) | ||
4183 | continue; | ||
4184 | |||
4185 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
4186 | string data = ""; | ||
4187 | if (obj != null) | ||
4188 | { | ||
4189 | DetectedObject detobj = new DetectedObject(); | ||
4190 | detobj.keyUUID = obj.UUID; | ||
4191 | detobj.nameStr = obj.Name; | ||
4192 | detobj.ownerUUID = obj.OwnerID; | ||
4193 | detobj.posVector = obj.AbsolutePosition; | ||
4194 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4195 | detobj.velVector = obj.Velocity; | ||
4196 | detobj.colliderType = 0; | ||
4197 | detobj.groupUUID = obj.GroupID; | ||
4198 | colliding.Add(detobj); | ||
4199 | } | ||
4200 | } | ||
4201 | |||
4202 | if (colliding.Count > 0) | ||
4203 | { | ||
4204 | StartCollidingMessage.Colliders = colliding; | ||
4205 | |||
4206 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4207 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
4208 | } | ||
4180 | } | 4209 | } |
4181 | } | 4210 | } |
4182 | 4211 | ||