aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorUbitUmarov2012-05-19 13:53:49 +0100
committerUbitUmarov2012-05-19 13:53:49 +0100
commit2c498baf58005be487b4e457455a9896a96b90d3 (patch)
tree05976958d4499c7394000a44efa25f965535b0e8 /OpenSim/Region/Framework/Scenes
parenttemp work: sounds simetric acording to materials, still 'window close' test ... (diff)
downloadopensim-SC-2c498baf58005be487b4e457455a9896a96b90d3.zip
opensim-SC-2c498baf58005be487b4e457455a9896a96b90d3.tar.gz
opensim-SC-2c498baf58005be487b4e457455a9896a96b90d3.tar.bz2
opensim-SC-2c498baf58005be487b4e457455a9896a96b90d3.tar.xz
a bit faster collision sound type verification plus a few fixes/changes
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/CollisionSounds.cs73
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs80
2 files changed, 100 insertions, 53 deletions
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
index c593b63..476eccd 100644
--- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
+++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs
@@ -197,30 +197,29 @@ namespace OpenSim.Region.Framework.Scenes
197 if (part.ParentGroup == null) 197 if (part.ParentGroup == null)
198 return; 198 return;
199 199
200 UUID soundID = part.CollisionSound; 200 if (part.CollisionSoundType < 0)
201 if (soundID == part.invalidCollisionSoundUUID)
202 return; 201 return;
203 202
204 float volume = 0.0f; 203 float volume = 0.0f;
205 int otherMaterial;
206 bool HaveSound = false; 204 bool HaveSound = false;
207 205
208 if (soundID != UUID.Zero) 206 UUID soundID = part.CollisionSound;
207
208 if (part.CollisionSoundType > 0)
209 { 209 {
210 // soundID = part.CollisionSound;
210 volume = part.CollisionSoundVolume; 211 volume = part.CollisionSoundVolume;
211 if (volume == 0.0f) 212 if (volume == 0.0f)
212 return; 213 return;
213 HaveSound = true; 214 HaveSound = true;
214 } 215 }
215 216
216 int thisMaterial = (int) part.Material; 217 bool doneownsound = false;
218
219 int thisMaterial = (int)part.Material;
217 if (thisMaterial >= MaxMaterials) 220 if (thisMaterial >= MaxMaterials)
218 thisMaterial = 3; 221 thisMaterial = 3;
219
220 int thisMatScaled = thisMaterial * MaxMaterials; 222 int thisMatScaled = thisMaterial * MaxMaterials;
221 int index;
222
223 bool doneownsound = false;
224 223
225 CollisionForSoundInfo colInfo; 224 CollisionForSoundInfo colInfo;
226 uint id; 225 uint id;
@@ -229,23 +228,21 @@ namespace OpenSim.Region.Framework.Scenes
229 { 228 {
230 colInfo = collidersinfolist[i]; 229 colInfo = collidersinfolist[i];
231 230
232 if (!HaveSound)
233 {
234 volume = Math.Abs(colInfo.relativeVel);
235 if (volume < 0.2f)
236 continue;
237 }
238
239 id = colInfo.colliderID; 231 id = colInfo.colliderID;
240 if (id == 0) 232 if (id == 0) // terrain collision
241 { 233 {
242 if (!doneownsound) 234 if (!doneownsound)
243 { 235 {
244 if (!HaveSound) 236 if (!HaveSound)
245 { 237 {
238 volume = Math.Abs(colInfo.relativeVel);
239 if (volume < 0.2f)
240 continue;
241
246 volume *= volume * .0625f; // 4m/s == full volume 242 volume *= volume * .0625f; // 4m/s == full volume
247 if (volume > 1.0f) 243 if (volume > 1.0f)
248 volume = 1.0f; 244 volume = 1.0f;
245
249 soundID = m_TerrainPart[thisMaterial]; 246 soundID = m_TerrainPart[thisMaterial];
250 } 247 }
251 part.SendCollisionSound(soundID, volume, colInfo.position); 248 part.SendCollisionSound(soundID, volume, colInfo.position);
@@ -257,12 +254,12 @@ namespace OpenSim.Region.Framework.Scenes
257 SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); 254 SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id);
258 if (otherPart != null) 255 if (otherPart != null)
259 { 256 {
260 if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) 257 if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive)
261 continue; 258 continue;
262 259
263 if (!HaveSound) 260 if (!HaveSound)
264 { 261 {
265 if (otherPart.CollisionSound != UUID.Zero) 262 if (otherPart.CollisionSoundType > 0)
266 { 263 {
267 soundID = otherPart.CollisionSound; 264 soundID = otherPart.CollisionSound;
268 volume = otherPart.CollisionSoundVolume; 265 volume = otherPart.CollisionSoundVolume;
@@ -271,14 +268,19 @@ namespace OpenSim.Region.Framework.Scenes
271 } 268 }
272 else 269 else
273 { 270 {
271 volume = Math.Abs(colInfo.relativeVel);
272 if (volume < 0.2f)
273 continue;
274
274 volume *= volume * .0625f; // 4m/s == full volume 275 volume *= volume * .0625f; // 4m/s == full volume
275 if (volume > 1.0f) 276 if (volume > 1.0f)
276 volume = 1.0f; 277 volume = 1.0f;
277 otherMaterial = (int)otherPart.Material; 278
279 int otherMaterial = (int)otherPart.Material;
278 if (otherMaterial >= MaxMaterials) 280 if (otherMaterial >= MaxMaterials)
279 otherMaterial = 3; 281 otherMaterial = 3;
280 index = thisMatScaled + otherMaterial; 282
281 soundID = m_PartPart[index]; 283 soundID = m_PartPart[thisMatScaled + otherMaterial];
282 } 284 }
283 } 285 }
284 286
@@ -301,11 +303,11 @@ namespace OpenSim.Region.Framework.Scenes
301 UUID soundID; 303 UUID soundID;
302 int otherMaterial; 304 int otherMaterial;
303 305
304 int thisMaterial = 3; 306 int thisMaterial = 4; // flesh
305 307
306 int thisMatScaled = thisMaterial * MaxMaterials; 308 int thisMatScaled = thisMaterial * MaxMaterials;
307 int index; 309
308// bool doneownsound = false; 310 // bool doneownsound = false;
309 311
310 CollisionForSoundInfo colInfo; 312 CollisionForSoundInfo colInfo;
311 uint id; 313 uint id;
@@ -315,36 +317,41 @@ namespace OpenSim.Region.Framework.Scenes
315 { 317 {
316 colInfo = collidersinfolist[i]; 318 colInfo = collidersinfolist[i];
317 319
318 volume = Math.Abs(colInfo.relativeVel);
319 if(volume < 0.2f)
320 continue;
321
322 id = colInfo.colliderID; 320 id = colInfo.colliderID;
323 321
324 if (id == 0) // no terrain collision sounds for now 322 if (id == 0) // no terrain collision sounds for now
325 { 323 {
326 continue; 324 continue;
325// volume = Math.Abs(colInfo.relativeVel);
326// if (volume < 0.2f)
327// continue;
328
327 } 329 }
328 330
329 SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); 331 SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id);
330 if (otherPart != null) 332 if (otherPart != null)
331 { 333 {
332 if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) 334 if (otherPart.CollisionSoundType < 0)
333 continue; 335 continue;
334 if (otherPart.CollisionSound != UUID.Zero) 336 if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f)
335 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); 337 otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position);
336 else 338 else
337 { 339 {
340 volume = Math.Abs(colInfo.relativeVel);
341 if (volume < 0.2f)
342 continue;
343
338 volume *= volume * .0625f; // 4m/s == full volume 344 volume *= volume * .0625f; // 4m/s == full volume
339 if (volume > 1.0f) 345 if (volume > 1.0f)
340 volume = 1.0f; 346 volume = 1.0f;
341 otherMaterial = (int)otherPart.Material; 347 otherMaterial = (int)otherPart.Material;
342 if (otherMaterial >= MaxMaterials) 348 if (otherMaterial >= MaxMaterials)
343 otherMaterial = 3; 349 otherMaterial = 3;
344 index = thisMatScaled + otherMaterial; 350
345 soundID = m_PartPart[index]; 351 soundID = m_PartPart[thisMatScaled + otherMaterial];
346 otherPart.SendCollisionSound(soundID, volume, colInfo.position); 352 otherPart.SendCollisionSound(soundID, volume, colInfo.position);
347 } 353 }
354 continue;
348 } 355 }
349/* 356/*
350 else if (!doneownsound) 357 else if (!doneownsound)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 467b625..5fddaed 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -329,7 +329,9 @@ namespace OpenSim.Region.Framework.Scenes
329 private Vector3 m_cameraAtOffset; 329 private Vector3 m_cameraAtOffset;
330 private bool m_forceMouselook; 330 private bool m_forceMouselook;
331 331
332 // TODO: Collision sound should have default. 332
333 // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound
334 private sbyte m_collisionSoundType;
333 private UUID m_collisionSound; 335 private UUID m_collisionSound;
334 private float m_collisionSoundVolume; 336 private float m_collisionSoundVolume;
335 337
@@ -1342,12 +1344,39 @@ namespace OpenSim.Region.Framework.Scenes
1342 1344
1343 public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); 1345 public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff");
1344 1346
1347 // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound
1348 // runtime thing.. do not persist
1349 [XmlIgnore]
1350 public sbyte CollisionSoundType
1351 {
1352 get
1353 {
1354 return m_collisionSoundType;
1355 }
1356 set
1357 {
1358 m_collisionSoundType = value;
1359 if (value == -1)
1360 m_collisionSound = invalidCollisionSoundUUID;
1361 else if (value == 0)
1362 m_collisionSound = UUID.Zero;
1363 }
1364 }
1365
1345 public UUID CollisionSound 1366 public UUID CollisionSound
1346 { 1367 {
1347 get { return m_collisionSound; } 1368 get { return m_collisionSound; }
1348 set 1369 set
1349 { 1370 {
1350 m_collisionSound = value; 1371 m_collisionSound = value;
1372
1373 if (value == invalidCollisionSoundUUID)
1374 m_collisionSoundType = -1;
1375 else if (value == UUID.Zero)
1376 m_collisionSoundType = 0;
1377 else
1378 m_collisionSoundType = 1;
1379
1351 aggregateScriptEvents(); 1380 aggregateScriptEvents();
1352 } 1381 }
1353 } 1382 }
@@ -2633,29 +2662,42 @@ namespace OpenSim.Region.Framework.Scenes
2633 else 2662 else
2634 { 2663 {
2635 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); 2664 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
2636 CollisionForSoundInfo soundinfo;
2637 ContactPoint curcontact;
2638 2665
2639 // calculate things that started colliding this time 2666 // calculate things that started colliding this time
2640 // and build up list of colliders this time 2667 // and build up list of colliders this time
2641 foreach (uint id in collissionswith.Keys) 2668 if (!VolumeDetectActive && CollisionSoundType >= 0)
2642 { 2669 {
2643 thisHitColliders.Add(id); 2670 CollisionForSoundInfo soundinfo;
2644 if (!m_lastColliders.Contains(id)) 2671 ContactPoint curcontact;
2645 {
2646 startedColliders.Add(id);
2647 2672
2648 curcontact = collissionswith[id]; 2673 foreach (uint id in collissionswith.Keys)
2649 if (Math.Abs(curcontact.RelativeSpeed) > 0.2) 2674 {
2675 thisHitColliders.Add(id);
2676 if (!m_lastColliders.Contains(id))
2650 { 2677 {
2651 soundinfo = new CollisionForSoundInfo(); 2678 startedColliders.Add(id);
2652 soundinfo.colliderID = id; 2679
2653 soundinfo.position = curcontact.Position; 2680 curcontact = collissionswith[id];
2654 soundinfo.relativeVel = curcontact.RelativeSpeed; 2681 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
2655 soundinfolist.Add(soundinfo); 2682 {
2683 soundinfo = new CollisionForSoundInfo();
2684 soundinfo.colliderID = id;
2685 soundinfo.position = curcontact.Position;
2686 soundinfo.relativeVel = curcontact.RelativeSpeed;
2687 soundinfolist.Add(soundinfo);
2688 }
2656 } 2689 }
2657 } 2690 }
2658 } 2691 }
2692 else
2693 {
2694 foreach (uint id in collissionswith.Keys)
2695 {
2696 thisHitColliders.Add(id);
2697 if (!m_lastColliders.Contains(id))
2698 startedColliders.Add(id);
2699 }
2700 }
2659 2701
2660 // calculate things that ended colliding 2702 // calculate things that ended colliding
2661 foreach (uint localID in m_lastColliders) 2703 foreach (uint localID in m_lastColliders)
@@ -2673,7 +2715,7 @@ namespace OpenSim.Region.Framework.Scenes
2673 m_lastColliders.Remove(localID); 2715 m_lastColliders.Remove(localID);
2674 2716
2675 // play sounds. 2717 // play sounds.
2676 if (soundinfolist.Count > 0 && !VolumeDetectActive && CollisionSound != invalidCollisionSoundUUID) 2718 if (soundinfolist.Count > 0)
2677 CollisionSounds.PartCollisionSound(this, soundinfolist); 2719 CollisionSounds.PartCollisionSound(this, soundinfolist);
2678 } 2720 }
2679 2721
@@ -4791,7 +4833,8 @@ namespace OpenSim.Region.Framework.Scenes
4791 4833
4792 pa.OnCollisionUpdate -= PhysicsCollision; 4834 pa.OnCollisionUpdate -= PhysicsCollision;
4793 4835
4794 bool hassound = ( CollisionSound != invalidCollisionSoundUUID); 4836 bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive);
4837
4795 scriptEvents CombinedEvents = AggregateScriptEvents; 4838 scriptEvents CombinedEvents = AggregateScriptEvents;
4796 4839
4797 // merge with root part 4840 // merge with root part
@@ -4800,10 +4843,7 @@ namespace OpenSim.Region.Framework.Scenes
4800 4843
4801 // submit to this part case 4844 // submit to this part case
4802 if (VolumeDetectActive) 4845 if (VolumeDetectActive)
4803 {
4804 CombinedEvents &= PhyscicsVolumeDtcSubsEvents; 4846 CombinedEvents &= PhyscicsVolumeDtcSubsEvents;
4805 hassound = false;
4806 }
4807 else if ((Flags & PrimFlags.Phantom) != 0) 4847 else if ((Flags & PrimFlags.Phantom) != 0)
4808 CombinedEvents &= PhyscicsPhantonSubsEvents; 4848 CombinedEvents &= PhyscicsPhantonSubsEvents;
4809 else 4849 else