diff options
-rw-r--r-- | OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 67 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 5 |
2 files changed, 50 insertions, 22 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 075724e..078449b 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs | |||
@@ -128,18 +128,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
128 | if (part.CollisionSoundType < 0) | 128 | if (part.CollisionSoundType < 0) |
129 | return; | 129 | return; |
130 | 130 | ||
131 | float volume = 0.0f; | 131 | float volume = part.CollisionSoundVolume; |
132 | bool HaveSound = false; | 132 | if (volume == 0.0f) |
133 | return; | ||
133 | 134 | ||
134 | UUID soundID = part.CollisionSound; | 135 | UUID soundID = part.CollisionSound; |
135 | 136 | ||
136 | if (part.CollisionSoundType > 0) | 137 | bool HaveSound = false; |
138 | switch (part.CollisionSoundType) | ||
137 | { | 139 | { |
138 | // soundID = part.CollisionSound; | 140 | case 0: // default sounds |
139 | volume = part.CollisionSoundVolume; | 141 | volume = 1.0f; |
140 | if (volume == 0.0f) | 142 | break; |
141 | return; | 143 | case 1: // selected sound |
142 | HaveSound = true; | 144 | if(soundID == part.invalidCollisionSoundUUID) |
145 | return; | ||
146 | HaveSound = true; | ||
147 | break; | ||
148 | case 2: // default sounds with volume set by script | ||
149 | default: | ||
150 | break; | ||
143 | } | 151 | } |
144 | 152 | ||
145 | bool doneownsound = false; | 153 | bool doneownsound = false; |
@@ -152,7 +160,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
152 | CollisionForSoundInfo colInfo; | 160 | CollisionForSoundInfo colInfo; |
153 | uint id; | 161 | uint id; |
154 | 162 | ||
155 | for(int i = 0; i< collidersinfolist.Count; i++) | 163 | for(int i = 0; i < collidersinfolist.Count; i++) |
156 | { | 164 | { |
157 | colInfo = collidersinfolist[i]; | 165 | colInfo = collidersinfolist[i]; |
158 | 166 | ||
@@ -163,15 +171,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
163 | { | 171 | { |
164 | if (!HaveSound) | 172 | if (!HaveSound) |
165 | { | 173 | { |
166 | volume = Math.Abs(colInfo.relativeVel); | 174 | float vol = Math.Abs(colInfo.relativeVel); |
167 | if (volume < 0.2f) | 175 | if (vol < 0.2f) |
168 | continue; | 176 | continue; |
169 | 177 | ||
170 | volume *= volume * .0625f; // 4m/s == full volume | 178 | vol *= vol * .0625f; // 4m/s == full volume |
171 | if (volume > 1.0f) | 179 | if (vol > 1.0f) |
172 | volume = 1.0f; | 180 | vol = 1.0f; |
173 | 181 | ||
174 | soundID = m_TerrainPart[thisMaterial]; | 182 | soundID = m_TerrainPart[thisMaterial]; |
183 | volume *= vol; | ||
175 | } | 184 | } |
176 | part.SendCollisionSound(soundID, volume, colInfo.position); | 185 | part.SendCollisionSound(soundID, volume, colInfo.position); |
177 | doneownsound = true; | 186 | doneownsound = true; |
@@ -187,7 +196,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
187 | 196 | ||
188 | if (!HaveSound) | 197 | if (!HaveSound) |
189 | { | 198 | { |
190 | if (otherPart.CollisionSoundType > 0) | 199 | if (otherPart.CollisionSoundType == 1) |
191 | { | 200 | { |
192 | soundID = otherPart.CollisionSound; | 201 | soundID = otherPart.CollisionSound; |
193 | volume = otherPart.CollisionSoundVolume; | 202 | volume = otherPart.CollisionSoundVolume; |
@@ -196,19 +205,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
196 | } | 205 | } |
197 | else | 206 | else |
198 | { | 207 | { |
199 | volume = Math.Abs(colInfo.relativeVel); | 208 | if (otherPart.CollisionSoundType == 2) |
200 | if (volume < 0.2f) | 209 | { |
210 | volume = otherPart.CollisionSoundVolume; | ||
211 | if (volume == 0.0f) | ||
212 | continue; | ||
213 | } | ||
214 | |||
215 | float vol = Math.Abs(colInfo.relativeVel); | ||
216 | if (vol < 0.2f) | ||
201 | continue; | 217 | continue; |
202 | 218 | ||
203 | volume *= volume * .0625f; // 4m/s == full volume | 219 | vol *= vol * .0625f; // 4m/s == full volume |
204 | if (volume > 1.0f) | 220 | if (vol > 1.0f) |
205 | volume = 1.0f; | 221 | vol = 1.0f; |
206 | 222 | ||
207 | int otherMaterial = (int)otherPart.Material; | 223 | int otherMaterial = (int)otherPart.Material; |
208 | if (otherMaterial >= MaxMaterials) | 224 | if (otherMaterial >= MaxMaterials) |
209 | otherMaterial = 3; | 225 | otherMaterial = 3; |
210 | 226 | ||
211 | soundID = m_PartPart[thisMatScaled + otherMaterial]; | 227 | soundID = m_PartPart[thisMatScaled + otherMaterial]; |
228 | volume *= vol; | ||
212 | } | 229 | } |
213 | } | 230 | } |
214 | 231 | ||
@@ -261,10 +278,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
261 | { | 278 | { |
262 | if (otherPart.CollisionSoundType < 0) | 279 | if (otherPart.CollisionSoundType < 0) |
263 | continue; | 280 | continue; |
264 | if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) | 281 | if (otherPart.CollisionSoundType == 1 && otherPart.CollisionSoundVolume > 0f) |
265 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); | 282 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); |
266 | else | 283 | else |
267 | { | 284 | { |
285 | float volmod = 1.0f; | ||
286 | if (otherPart.CollisionSoundType == 2) | ||
287 | { | ||
288 | volmod = otherPart.CollisionSoundVolume; | ||
289 | if(volmod == 0.0) | ||
290 | continue; | ||
291 | } | ||
268 | volume = Math.Abs(colInfo.relativeVel); | 292 | volume = Math.Abs(colInfo.relativeVel); |
269 | // Most noral collisions (running into walls, stairs) | 293 | // Most noral collisions (running into walls, stairs) |
270 | // should never be heard. | 294 | // should never be heard. |
@@ -281,6 +305,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
281 | if (otherMaterial >= MaxMaterials) | 305 | if (otherMaterial >= MaxMaterials) |
282 | otherMaterial = 3; | 306 | otherMaterial = 3; |
283 | 307 | ||
308 | volume *= volmod; | ||
284 | soundID = m_PartPart[thisMatScaled + otherMaterial]; | 309 | soundID = m_PartPart[thisMatScaled + otherMaterial]; |
285 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); | 310 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); |
286 | } | 311 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ce0e59c..fc9b5d9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -5118,7 +5118,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5118 | { | 5118 | { |
5119 | m_host.CollisionSoundVolume = (float)impact_volume; | 5119 | m_host.CollisionSoundVolume = (float)impact_volume; |
5120 | m_host.CollisionSound = m_host.invalidCollisionSoundUUID; | 5120 | m_host.CollisionSound = m_host.invalidCollisionSoundUUID; |
5121 | m_host.CollisionSoundType = 0; | 5121 | if(impact_volume == 0.0) |
5122 | m_host.CollisionSoundType = -1; // disable all sounds | ||
5123 | else | ||
5124 | m_host.CollisionSoundType = 2; // allow change of default sounds volume | ||
5122 | return; | 5125 | return; |
5123 | } | 5126 | } |
5124 | // TODO: Parameter check logic required. | 5127 | // TODO: Parameter check logic required. |