fix llCollisionSound("",0.0) not disabling sounds BUT let llCollisionSound("",value [<=1.0]) play default sounds with selected volume. I really don't care if last part is not like SL

LSLKeyTest
UbitUmarov 2016-08-20 23:41:32 +01:00
parent 0517e3d439
commit 04dd2a9795
2 changed files with 50 additions and 22 deletions

View File

@ -128,18 +128,26 @@ namespace OpenSim.Region.Framework.Scenes
if (part.CollisionSoundType < 0) if (part.CollisionSoundType < 0)
return; return;
float volume = 0.0f; float volume = part.CollisionSoundVolume;
bool HaveSound = false; if (volume == 0.0f)
return;
UUID soundID = part.CollisionSound; UUID soundID = part.CollisionSound;
if (part.CollisionSoundType > 0) bool HaveSound = false;
switch (part.CollisionSoundType)
{ {
// soundID = part.CollisionSound; case 0: // default sounds
volume = part.CollisionSoundVolume; volume = 1.0f;
if (volume == 0.0f) break;
case 1: // selected sound
if(soundID == part.invalidCollisionSoundUUID)
return; return;
HaveSound = true; HaveSound = true;
break;
case 2: // default sounds with volume set by script
default:
break;
} }
bool doneownsound = false; bool doneownsound = false;
@ -163,15 +171,16 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (!HaveSound) if (!HaveSound)
{ {
volume = Math.Abs(colInfo.relativeVel); float vol = Math.Abs(colInfo.relativeVel);
if (volume < 0.2f) if (vol < 0.2f)
continue; continue;
volume *= volume * .0625f; // 4m/s == full volume vol *= vol * .0625f; // 4m/s == full volume
if (volume > 1.0f) if (vol > 1.0f)
volume = 1.0f; vol = 1.0f;
soundID = m_TerrainPart[thisMaterial]; soundID = m_TerrainPart[thisMaterial];
volume *= vol;
} }
part.SendCollisionSound(soundID, volume, colInfo.position); part.SendCollisionSound(soundID, volume, colInfo.position);
doneownsound = true; doneownsound = true;
@ -187,7 +196,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!HaveSound) if (!HaveSound)
{ {
if (otherPart.CollisionSoundType > 0) if (otherPart.CollisionSoundType == 1)
{ {
soundID = otherPart.CollisionSound; soundID = otherPart.CollisionSound;
volume = otherPart.CollisionSoundVolume; volume = otherPart.CollisionSoundVolume;
@ -196,19 +205,27 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
volume = Math.Abs(colInfo.relativeVel); if (otherPart.CollisionSoundType == 2)
if (volume < 0.2f) {
volume = otherPart.CollisionSoundVolume;
if (volume == 0.0f)
continue;
}
float vol = Math.Abs(colInfo.relativeVel);
if (vol < 0.2f)
continue; continue;
volume *= volume * .0625f; // 4m/s == full volume vol *= vol * .0625f; // 4m/s == full volume
if (volume > 1.0f) if (vol > 1.0f)
volume = 1.0f; vol = 1.0f;
int otherMaterial = (int)otherPart.Material; int otherMaterial = (int)otherPart.Material;
if (otherMaterial >= MaxMaterials) if (otherMaterial >= MaxMaterials)
otherMaterial = 3; otherMaterial = 3;
soundID = m_PartPart[thisMatScaled + otherMaterial]; soundID = m_PartPart[thisMatScaled + otherMaterial];
volume *= vol;
} }
} }
@ -261,10 +278,17 @@ namespace OpenSim.Region.Framework.Scenes
{ {
if (otherPart.CollisionSoundType < 0) if (otherPart.CollisionSoundType < 0)
continue; continue;
if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) if (otherPart.CollisionSoundType == 1 && otherPart.CollisionSoundVolume > 0f)
otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position);
else else
{ {
float volmod = 1.0f;
if (otherPart.CollisionSoundType == 2)
{
volmod = otherPart.CollisionSoundVolume;
if(volmod == 0.0)
continue;
}
volume = Math.Abs(colInfo.relativeVel); volume = Math.Abs(colInfo.relativeVel);
// Most noral collisions (running into walls, stairs) // Most noral collisions (running into walls, stairs)
// should never be heard. // should never be heard.
@ -281,6 +305,7 @@ namespace OpenSim.Region.Framework.Scenes
if (otherMaterial >= MaxMaterials) if (otherMaterial >= MaxMaterials)
otherMaterial = 3; otherMaterial = 3;
volume *= volmod;
soundID = m_PartPart[thisMatScaled + otherMaterial]; soundID = m_PartPart[thisMatScaled + otherMaterial];
otherPart.SendCollisionSound(soundID, volume, colInfo.position); otherPart.SendCollisionSound(soundID, volume, colInfo.position);
} }

View File

@ -5118,7 +5118,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.CollisionSoundVolume = (float)impact_volume; m_host.CollisionSoundVolume = (float)impact_volume;
m_host.CollisionSound = m_host.invalidCollisionSoundUUID; m_host.CollisionSound = m_host.invalidCollisionSoundUUID;
m_host.CollisionSoundType = 0; if(impact_volume == 0.0)
m_host.CollisionSoundType = -1; // disable all sounds
else
m_host.CollisionSoundType = 2; // allow change of default sounds volume
return; return;
} }
// TODO: Parameter check logic required. // TODO: Parameter check logic required.