public static void PartCollisionSound(SceneObjectPart part, List <CollisionForSoundInfo> collidersinfolist) { if (part.CollisionSoundType < 0) { return; } if (collidersinfolist.Count == 0 || part == null) { return; } if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) { return; } SceneObjectGroup sog = part.ParentGroup; if (sog == null || sog.IsDeleted || sog.inTransit) { return; } if (sog.CollisionSoundThrottled(part.CollisionSoundType)) { return; } float volume = part.CollisionSoundVolume; UUID soundID = part.CollisionSound; bool HaveSound = false; switch (part.CollisionSoundType) { case 0: // default sounds volume = 1.0f; break; case 1: // selected sound if (soundID == part.invalidCollisionSoundUUID) { return; } HaveSound = true; break; case 2: // default sounds with volume set by script default: break; } if (volume == 0.0f) { return; } bool doneownsound = false; int thisMaterial = (int)part.Material; if (thisMaterial >= MaxMaterials) { thisMaterial = 3; } int thisMatScaled = thisMaterial * MaxMaterials; CollisionForSoundInfo colInfo; uint id; for (int i = 0; i < collidersinfolist.Count; i++) { colInfo = collidersinfolist[i]; id = colInfo.colliderID; if (id == 0) // terrain collision { if (!doneownsound) { if (!HaveSound) { float vol = Math.Abs(colInfo.relativeVel); if (vol < 0.2f) { continue; } vol *= vol * .0625f; // 4m/s == full volume if (vol > 1.0f) { vol = 1.0f; } soundID = m_TerrainPart[thisMaterial]; volume *= vol; } part.SendCollisionSound(soundID, volume, colInfo.position); doneownsound = true; } continue; } SceneObjectPart otherPart = sog.Scene.GetSceneObjectPart(id); if (otherPart != null) { SceneObjectGroup othersog = otherPart.ParentGroup; if (othersog == null || othersog.IsDeleted || othersog.inTransit) { continue; } int otherType = otherPart.CollisionSoundType; if (otherType < 0 || otherPart.VolumeDetectActive) { continue; } if (!HaveSound) { if (othersog.CollisionSoundThrottled(otherType)) { continue; } if (otherType == 1) { soundID = otherPart.CollisionSound; volume = otherPart.CollisionSoundVolume; if (volume == 0.0f) { continue; } } else { if (otherType == 2) { volume = otherPart.CollisionSoundVolume; if (volume == 0.0f) { continue; } } float vol = Math.Abs(colInfo.relativeVel); if (vol < 0.2f) { continue; } vol *= vol * .0625f; // 4m/s == full volume if (vol > 1.0f) { vol = 1.0f; } int otherMaterial = (int)otherPart.Material; if (otherMaterial >= MaxMaterials) { otherMaterial = 3; } soundID = m_PartPart[thisMatScaled + otherMaterial]; volume *= vol; } } if (doneownsound) { otherPart.SendCollisionSound(soundID, volume, colInfo.position); } else { part.SendCollisionSound(soundID, volume, colInfo.position); doneownsound = true; } } } }
public static void AvatarCollisionSound(ScenePresence av, List <CollisionForSoundInfo> collidersinfolist) { if (collidersinfolist.Count == 0 || av == null) { return; } UUID soundID; int otherMaterial; int thisMaterial = 4; // flesh int thisMatScaled = thisMaterial * MaxMaterials; // bool doneownsound = false; CollisionForSoundInfo colInfo; uint id; float volume; for (int i = 0; i < collidersinfolist.Count; i++) { colInfo = collidersinfolist[i]; id = colInfo.colliderID; if (id == 0) // no terrain collision sounds for now { continue; // volume = Math.Abs(colInfo.relativeVel); // if (volume < 0.2f) // continue; } SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); if (otherPart != null) { if (otherPart.CollisionSoundType < 0) { continue; } if (otherPart.CollisionSoundType == 1 && otherPart.CollisionSoundVolume > 0f) { otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); } else { float volmod = 1.0f; if (otherPart.CollisionSoundType == 2) { volmod = otherPart.CollisionSoundVolume; if (volmod == 0.0) { continue; } } volume = Math.Abs(colInfo.relativeVel); // Most noral collisions (running into walls, stairs) // should never be heard. if (volume < 3.2f) { continue; } // m_log.DebugFormat("Collision speed was {0}", volume); // Cap to 0.2 times volume because climbing stairs should not be noisy // Also changed scaling volume *= volume * .0125f; // 4m/s == volume 0.2 if (volume > 0.2f) { volume = 0.2f; } otherMaterial = (int)otherPart.Material; if (otherMaterial >= MaxMaterials) { otherMaterial = 3; } volume *= volmod; soundID = m_PartPart[thisMatScaled + otherMaterial]; otherPart.SendCollisionSound(soundID, volume, colInfo.position); } continue; } /* * else if (!doneownsound) * { * ScenePresence otherav = av.Scene.GetScenePresence(Id); * if (otherav != null && (!otherav.IsChildAgent)) * { * soundID = snd_FleshFlesh; * av.SendCollisionSound(soundID, 1.0); * doneownsound = true; * } * } */ } }
public static void PartCollisionSound(SceneObjectPart part, List <CollisionForSoundInfo> collidersinfolist) { if (collidersinfolist.Count == 0 || part == null) { return; } if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) { return; } if (part.ParentGroup == null) { return; } if (part.CollisionSoundType < 0) { return; } float volume = 0.0f; bool HaveSound = false; UUID soundID = part.CollisionSound; if (part.CollisionSoundType > 0) { // soundID = part.CollisionSound; volume = part.CollisionSoundVolume; if (volume == 0.0f) { return; } HaveSound = true; } bool doneownsound = false; int thisMaterial = (int)part.Material; if (thisMaterial >= MaxMaterials) { thisMaterial = 3; } int thisMatScaled = thisMaterial * MaxMaterials; CollisionForSoundInfo colInfo; uint id; for (int i = 0; i < collidersinfolist.Count; i++) { colInfo = collidersinfolist[i]; id = colInfo.colliderID; if (id == 0) // terrain collision { if (!doneownsound) { if (!HaveSound) { volume = Math.Abs(colInfo.relativeVel); if (volume < 0.2f) { continue; } volume *= volume * .0625f; // 4m/s == full volume if (volume > 1.0f) { volume = 1.0f; } soundID = m_TerrainPart[thisMaterial]; } part.SendCollisionSound(soundID, volume, colInfo.position); doneownsound = true; } continue; } SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); if (otherPart != null) { if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive) { continue; } if (!HaveSound) { if (otherPart.CollisionSoundType > 0) { soundID = otherPart.CollisionSound; volume = otherPart.CollisionSoundVolume; if (volume == 0.0f) { continue; } } else { volume = Math.Abs(colInfo.relativeVel); if (volume < 0.2f) { continue; } volume *= volume * .0625f; // 4m/s == full volume if (volume > 1.0f) { volume = 1.0f; } int otherMaterial = (int)otherPart.Material; if (otherMaterial >= MaxMaterials) { otherMaterial = 3; } soundID = m_PartPart[thisMatScaled + otherMaterial]; } } if (doneownsound) { otherPart.SendCollisionSound(soundID, volume, colInfo.position); } else { part.SendCollisionSound(soundID, volume, colInfo.position); doneownsound = true; } } } }