aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/CollisionSounds.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/CollisionSounds.cs90
1 files changed, 60 insertions, 30 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
index 724ecb6..1f43843 100644
--- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
+++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
@@ -114,12 +114,9 @@ namespace OpenSim.Region.Framework.Scenes
114 snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber 114 snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber
115 }; 115 };
116 116
117 public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders) 117 public static void PartCollisionSound(SceneObjectPart part, List<CollisionForSoundInfo> collidersinfolist)
118 { 118 {
119 // temporary mute sounds 119 if (collidersinfolist.Count == 0 || part == null)
120// return;
121
122 if(Colliders.Count == 0 || part == null)
123 return; 120 return;
124 121
125 if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) 122 if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0)
@@ -128,19 +125,20 @@ namespace OpenSim.Region.Framework.Scenes
128 if (part.ParentGroup == null) 125 if (part.ParentGroup == null)
129 return; 126 return;
130 127
131 if (part.CollisionSound == part.invalidCollisionSoundUUID) 128 UUID soundID = part.CollisionSound;
129 if (soundID == part.invalidCollisionSoundUUID)
132 return; 130 return;
133 131
134 UUID soundID; 132 float volume = 0.0f;
135 int otherMaterial; 133 int otherMaterial;
134 bool HaveSound = false;
136 135
137 Vector3 position = part.AbsolutePosition; 136 if (soundID != UUID.Zero)
138
139 if (part.CollisionSound != UUID.Zero)
140 { 137 {
141 if (part.CollisionSoundVolume > 0.0f) 138 volume = part.CollisionSoundVolume;
142 part.SendCollisionSound(part.CollisionSound, part.CollisionSoundVolume, position); 139 if (volume == 0.0f)
143 return; 140 return;
141 HaveSound = true;
144 } 142 }
145 143
146 int thisMaterial = (int) part.Material; 144 int thisMaterial = (int) part.Material;
@@ -152,41 +150,73 @@ namespace OpenSim.Region.Framework.Scenes
152 150
153 bool doneownsound = false; 151 bool doneownsound = false;
154 152
155 foreach (uint Id in Colliders) 153 CollisionForSoundInfo colInfo;
154 uint id;
155
156 for(int i = 0; i< collidersinfolist.Count; i++)
156 { 157 {
157 if (Id == 0) 158 colInfo = collidersinfolist[i];
159
160 if (!HaveSound)
161 {
162 volume = Math.Abs(colInfo.relativeVel);
163 if (volume < 0.2f)
164 continue;
165 }
166
167 id = colInfo.colliderID;
168 if (id == 0)
158 { 169 {
159 if (!doneownsound) 170 if (!doneownsound)
160 { 171 {
161 soundID = m_TerrainPart[thisMaterial]; 172 if (!HaveSound)
162 part.SendCollisionSound(soundID, 1.0, position); 173 {
174 volume *= volume * .0625f; // 4m/s == full volume
175 if (volume > 1.0f)
176 volume = 1.0f;
177 soundID = m_TerrainPart[thisMaterial];
178 }
179 part.SendCollisionSound(soundID, volume, colInfo.position);
163 doneownsound = true; 180 doneownsound = true;
164 } 181 }
165 continue; 182 continue;
166 } 183 }
167 184
168 SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(Id); 185 SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id);
169 if (otherPart != null) 186 if (otherPart != null)
170 { 187 {
171 if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) 188 if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive)
172 continue; 189 continue;
173 if (otherPart.CollisionSound != UUID.Zero) 190
174 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position); 191 if (!HaveSound)
175 else
176 { 192 {
177 otherMaterial = (int)otherPart.Material; 193 if (otherPart.CollisionSound != UUID.Zero)
178 if (otherMaterial >= MaxMaterials) 194 {
179 otherMaterial = 3; 195 soundID = otherPart.CollisionSound;
180 index = thisMatScaled + otherMaterial; 196 volume = otherPart.CollisionSoundVolume;
181 soundID = m_PartPart[index]; 197 if (volume == 0.0f)
182 if (doneownsound) 198 continue;
183 otherPart.SendCollisionSound(soundID, 1.0, position); 199 }
184 else 200 else
185 { 201 {
186 part.SendCollisionSound(soundID, 1.0, position); 202 volume *= volume * .0625f; // 4m/s == full volume
187 doneownsound = true; 203 if (volume > 1.0f)
204 volume = 1.0f;
205 otherMaterial = (int)otherPart.Material;
206 if (otherMaterial >= MaxMaterials)
207 otherMaterial = 3;
208 index = thisMatScaled + otherMaterial;
209 soundID = m_PartPart[index];
188 } 210 }
189 } 211 }
212
213 if (doneownsound)
214 otherPart.SendCollisionSound(soundID, volume, colInfo.position);
215 else
216 {
217 part.SendCollisionSound(soundID, volume, colInfo.position);
218 doneownsound = true;
219 }
190 } 220 }
191 } 221 }
192 } 222 }