diff options
author | UbitUmarov | 2012-05-19 01:10:39 +0100 |
---|---|---|
committer | UbitUmarov | 2012-05-19 01:10:39 +0100 |
commit | 98a2c7bfeec6eda7cffbe5c84083ef3a736e306d (patch) | |
tree | 7d58fa500dd90dc7a2ae065b094f60503417dc78 /OpenSim/Region | |
parent | fix character IsPhysical (diff) | |
download | opensim-SC-98a2c7bfeec6eda7cffbe5c84083ef3a736e306d.zip opensim-SC-98a2c7bfeec6eda7cffbe5c84083ef3a736e306d.tar.gz opensim-SC-98a2c7bfeec6eda7cffbe5c84083ef3a736e306d.tar.bz2 opensim-SC-98a2c7bfeec6eda7cffbe5c84083ef3a736e306d.tar.xz |
modulate collision sounds intensity with relative collision speed
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 74 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 127 |
2 files changed, 120 insertions, 81 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 4522f9e..724ecb6 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs | |||
@@ -33,14 +33,24 @@ using OpenSim.Framework; | |||
33 | 33 | ||
34 | namespace OpenSim.Region.Framework.Scenes | 34 | namespace OpenSim.Region.Framework.Scenes |
35 | { | 35 | { |
36 | public struct CollisionForSoundInfo | ||
37 | { | ||
38 | public uint colliderID; | ||
39 | public Vector3 position; | ||
40 | public float relativeVel; | ||
41 | } | ||
42 | |||
36 | public static class CollisionSounds | 43 | public static class CollisionSounds |
37 | { | 44 | { |
45 | |||
46 | |||
47 | |||
38 | // defines for cases | 48 | // defines for cases |
39 | // only know one UUID for now (woodflesh) | 49 | // only know one UUID for now (woodflesh) |
40 | 50 | ||
41 | private const int MaxMaterials = 7; | 51 | private const int MaxMaterials = 7; |
42 | // part part | 52 | // part part |
43 | private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 53 | private static UUID snd_StoneStone = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
44 | private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 54 | private static UUID snd_StoneMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
45 | private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 55 | private static UUID snd_StoneGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
46 | private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 56 | private static UUID snd_StoneWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
@@ -48,29 +58,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
48 | private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 58 | private static UUID snd_StonePlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
49 | private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 59 | private static UUID snd_StoneRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
50 | 60 | ||
51 | private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 61 | private static UUID snd_MetalMetal = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
52 | private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 62 | private static UUID snd_MetalGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
53 | private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 63 | private static UUID snd_MetalWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
54 | private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 64 | private static UUID snd_MetalFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
55 | private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 65 | private static UUID snd_MetalPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
56 | private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 66 | private static UUID snd_MetalRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
57 | 67 | ||
58 | private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 68 | private static UUID snd_GlassGlass = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
59 | private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 69 | private static UUID snd_GlassWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
60 | private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 70 | private static UUID snd_GlassFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
61 | private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 71 | private static UUID snd_GlassPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
62 | private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 72 | private static UUID snd_GlassRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
63 | 73 | ||
64 | private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 74 | private static UUID snd_WoodWood = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
65 | private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 75 | private static UUID snd_WoodFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
66 | private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 76 | private static UUID snd_WoodPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
67 | private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 77 | private static UUID snd_WoodRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
68 | 78 | ||
69 | private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 79 | private static UUID snd_FleshFlesh = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
70 | private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 80 | private static UUID snd_FleshPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
71 | private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 81 | private static UUID snd_FleshRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
72 | 82 | ||
73 | private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 83 | private static UUID snd_PlasticPlastic = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
74 | private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 84 | private static UUID snd_PlasticRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
75 | 85 | ||
76 | private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); | 86 | private static UUID snd_RubberRubber = new UUID("c80260ba-41fd-8a46-768a-6bf236360e3a"); |
@@ -107,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
107 | public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders) | 117 | public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders) |
108 | { | 118 | { |
109 | // temporary mute sounds | 119 | // temporary mute sounds |
110 | return; | 120 | // return; |
111 | 121 | ||
112 | if(Colliders.Count == 0 || part == null) | 122 | if(Colliders.Count == 0 || part == null) |
113 | return; | 123 | return; |
@@ -178,28 +188,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
178 | } | 188 | } |
179 | } | 189 | } |
180 | } | 190 | } |
181 | /* avatars get notification let them trigger the sound | ||
182 | else if (!doneownsound) | ||
183 | { | ||
184 | ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id); | ||
185 | if (av != null && (!av.IsChildAgent)) | ||
186 | { | ||
187 | index = thisMatScaled + 4; // flesh | ||
188 | soundID = m_PartPart[index]; | ||
189 | part.SendCollisionSound(soundID, 1.0); | ||
190 | doneownsound = true; | ||
191 | } | ||
192 | } | ||
193 | */ | ||
194 | } | 191 | } |
195 | } | 192 | } |
196 | 193 | ||
197 | public static void AvatarCollisionSound(ScenePresence av, List<uint> Colliders) | 194 | public static void AvatarCollisionSound(ScenePresence av, List<CollisionForSoundInfo> collidersinfolist) |
198 | { | 195 | { |
199 | // temporary mute sounds | 196 | // temporary mute sounds |
200 | return; | 197 | // return; |
201 | 198 | ||
202 | if (Colliders.Count == 0 || av == null) | 199 | if (collidersinfolist.Count == 0 || av == null) |
203 | return; | 200 | return; |
204 | 201 | ||
205 | UUID soundID; | 202 | UUID soundID; |
@@ -211,30 +208,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
211 | int index; | 208 | int index; |
212 | // bool doneownsound = false; | 209 | // bool doneownsound = false; |
213 | 210 | ||
214 | Vector3 position = av.AbsolutePosition; | 211 | CollisionForSoundInfo colInfo; |
212 | uint id; | ||
213 | float volume; | ||
215 | 214 | ||
216 | foreach (uint Id in Colliders) | 215 | for(int i = 0; i< collidersinfolist.Count; i++) |
217 | { | 216 | { |
218 | if (Id == 0) | 217 | colInfo = collidersinfolist[i]; |
218 | |||
219 | volume = Math.Abs(colInfo.relativeVel); | ||
220 | if(volume < 0.2f) | ||
221 | continue; | ||
222 | |||
223 | id = colInfo.colliderID; | ||
224 | |||
225 | if (id == 0) // no terrain collision sounds for now | ||
219 | { | 226 | { |
220 | continue; | 227 | continue; |
221 | } | 228 | } |
222 | 229 | ||
223 | SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(Id); | 230 | SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); |
224 | if (otherPart != null) | 231 | if (otherPart != null) |
225 | { | 232 | { |
226 | if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) | 233 | if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) |
227 | continue; | 234 | continue; |
228 | if (otherPart.CollisionSound != UUID.Zero) | 235 | if (otherPart.CollisionSound != UUID.Zero) |
229 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); | 236 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); |
230 | else | 237 | else |
231 | { | 238 | { |
239 | volume *= volume * .0625f; // 4m/s == full volume | ||
240 | if (volume > 1.0f) | ||
241 | volume = 1.0f; | ||
232 | otherMaterial = (int)otherPart.Material; | 242 | otherMaterial = (int)otherPart.Material; |
233 | if (otherMaterial >= MaxMaterials) | 243 | if (otherMaterial >= MaxMaterials) |
234 | otherMaterial = 3; | 244 | otherMaterial = 3; |
235 | index = thisMatScaled + otherMaterial; | 245 | index = thisMatScaled + otherMaterial; |
236 | soundID = m_PartPart[index]; | 246 | soundID = m_PartPart[index]; |
237 | otherPart.SendCollisionSound(soundID, 1.0, position); | 247 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); |
238 | } | 248 | } |
239 | } | 249 | } |
240 | /* | 250 | /* |
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 | ||