Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork

avinationmerge
ubit 2012-05-19 14:55:43 +02:00
commit 51f6456442
2 changed files with 100 additions and 53 deletions

View File

@ -197,30 +197,29 @@ namespace OpenSim.Region.Framework.Scenes
if (part.ParentGroup == null) if (part.ParentGroup == null)
return; return;
UUID soundID = part.CollisionSound; if (part.CollisionSoundType < 0)
if (soundID == part.invalidCollisionSoundUUID)
return; return;
float volume = 0.0f; float volume = 0.0f;
int otherMaterial;
bool HaveSound = false; bool HaveSound = false;
if (soundID != UUID.Zero) UUID soundID = part.CollisionSound;
if (part.CollisionSoundType > 0)
{ {
// soundID = part.CollisionSound;
volume = part.CollisionSoundVolume; volume = part.CollisionSoundVolume;
if (volume == 0.0f) if (volume == 0.0f)
return; return;
HaveSound = true; HaveSound = true;
} }
int thisMaterial = (int) part.Material; bool doneownsound = false;
int thisMaterial = (int)part.Material;
if (thisMaterial >= MaxMaterials) if (thisMaterial >= MaxMaterials)
thisMaterial = 3; thisMaterial = 3;
int thisMatScaled = thisMaterial * MaxMaterials; int thisMatScaled = thisMaterial * MaxMaterials;
int index;
bool doneownsound = false;
CollisionForSoundInfo colInfo; CollisionForSoundInfo colInfo;
uint id; uint id;
@ -229,23 +228,21 @@ namespace OpenSim.Region.Framework.Scenes
{ {
colInfo = collidersinfolist[i]; colInfo = collidersinfolist[i];
if (!HaveSound)
{
volume = Math.Abs(colInfo.relativeVel);
if (volume < 0.2f)
continue;
}
id = colInfo.colliderID; id = colInfo.colliderID;
if (id == 0) if (id == 0) // terrain collision
{ {
if (!doneownsound) if (!doneownsound)
{ {
if (!HaveSound) if (!HaveSound)
{ {
volume = Math.Abs(colInfo.relativeVel);
if (volume < 0.2f)
continue;
volume *= volume * .0625f; // 4m/s == full volume volume *= volume * .0625f; // 4m/s == full volume
if (volume > 1.0f) if (volume > 1.0f)
volume = 1.0f; volume = 1.0f;
soundID = m_TerrainPart[thisMaterial]; soundID = m_TerrainPart[thisMaterial];
} }
part.SendCollisionSound(soundID, volume, colInfo.position); part.SendCollisionSound(soundID, volume, colInfo.position);
@ -257,12 +254,12 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id);
if (otherPart != null) if (otherPart != null)
{ {
if (otherPart.CollisionSound == part.invalidCollisionSoundUUID || otherPart.VolumeDetectActive) if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive)
continue; continue;
if (!HaveSound) if (!HaveSound)
{ {
if (otherPart.CollisionSound != UUID.Zero) if (otherPart.CollisionSoundType > 0)
{ {
soundID = otherPart.CollisionSound; soundID = otherPart.CollisionSound;
volume = otherPart.CollisionSoundVolume; volume = otherPart.CollisionSoundVolume;
@ -271,14 +268,19 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
{ {
volume = Math.Abs(colInfo.relativeVel);
if (volume < 0.2f)
continue;
volume *= volume * .0625f; // 4m/s == full volume volume *= volume * .0625f; // 4m/s == full volume
if (volume > 1.0f) if (volume > 1.0f)
volume = 1.0f; volume = 1.0f;
otherMaterial = (int)otherPart.Material;
int otherMaterial = (int)otherPart.Material;
if (otherMaterial >= MaxMaterials) if (otherMaterial >= MaxMaterials)
otherMaterial = 3; otherMaterial = 3;
index = thisMatScaled + otherMaterial;
soundID = m_PartPart[index]; soundID = m_PartPart[thisMatScaled + otherMaterial];
} }
} }
@ -301,11 +303,11 @@ namespace OpenSim.Region.Framework.Scenes
UUID soundID; UUID soundID;
int otherMaterial; int otherMaterial;
int thisMaterial = 3; int thisMaterial = 4; // flesh
int thisMatScaled = thisMaterial * MaxMaterials; int thisMatScaled = thisMaterial * MaxMaterials;
int index;
// bool doneownsound = false; // bool doneownsound = false;
CollisionForSoundInfo colInfo; CollisionForSoundInfo colInfo;
uint id; uint id;
@ -315,36 +317,41 @@ namespace OpenSim.Region.Framework.Scenes
{ {
colInfo = collidersinfolist[i]; colInfo = collidersinfolist[i];
volume = Math.Abs(colInfo.relativeVel);
if(volume < 0.2f)
continue;
id = colInfo.colliderID; id = colInfo.colliderID;
if (id == 0) // no terrain collision sounds for now if (id == 0) // no terrain collision sounds for now
{ {
continue; continue;
// volume = Math.Abs(colInfo.relativeVel);
// if (volume < 0.2f)
// continue;
} }
SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id);
if (otherPart != null) if (otherPart != null)
{ {
if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID) if (otherPart.CollisionSoundType < 0)
continue; continue;
if (otherPart.CollisionSound != UUID.Zero) if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f)
otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position);
else else
{ {
volume = Math.Abs(colInfo.relativeVel);
if (volume < 0.2f)
continue;
volume *= volume * .0625f; // 4m/s == full volume volume *= volume * .0625f; // 4m/s == full volume
if (volume > 1.0f) if (volume > 1.0f)
volume = 1.0f; volume = 1.0f;
otherMaterial = (int)otherPart.Material; otherMaterial = (int)otherPart.Material;
if (otherMaterial >= MaxMaterials) if (otherMaterial >= MaxMaterials)
otherMaterial = 3; otherMaterial = 3;
index = thisMatScaled + otherMaterial;
soundID = m_PartPart[index]; soundID = m_PartPart[thisMatScaled + otherMaterial];
otherPart.SendCollisionSound(soundID, volume, colInfo.position); otherPart.SendCollisionSound(soundID, volume, colInfo.position);
} }
continue;
} }
/* /*
else if (!doneownsound) else if (!doneownsound)

View File

@ -329,7 +329,9 @@ namespace OpenSim.Region.Framework.Scenes
private Vector3 m_cameraAtOffset; private Vector3 m_cameraAtOffset;
private bool m_forceMouselook; private bool m_forceMouselook;
// TODO: Collision sound should have default.
// 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound
private sbyte m_collisionSoundType;
private UUID m_collisionSound; private UUID m_collisionSound;
private float m_collisionSoundVolume; private float m_collisionSoundVolume;
@ -1342,12 +1344,39 @@ namespace OpenSim.Region.Framework.Scenes
public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff");
// 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound
// runtime thing.. do not persist
[XmlIgnore]
public sbyte CollisionSoundType
{
get
{
return m_collisionSoundType;
}
set
{
m_collisionSoundType = value;
if (value == -1)
m_collisionSound = invalidCollisionSoundUUID;
else if (value == 0)
m_collisionSound = UUID.Zero;
}
}
public UUID CollisionSound public UUID CollisionSound
{ {
get { return m_collisionSound; } get { return m_collisionSound; }
set set
{ {
m_collisionSound = value; m_collisionSound = value;
if (value == invalidCollisionSoundUUID)
m_collisionSoundType = -1;
else if (value == UUID.Zero)
m_collisionSoundType = 0;
else
m_collisionSoundType = 1;
aggregateScriptEvents(); aggregateScriptEvents();
} }
} }
@ -2633,29 +2662,42 @@ namespace OpenSim.Region.Framework.Scenes
else else
{ {
List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
CollisionForSoundInfo soundinfo;
ContactPoint curcontact;
// calculate things that started colliding this time // calculate things that started colliding this time
// and build up list of colliders this time // and build up list of colliders this time
foreach (uint id in collissionswith.Keys) if (!VolumeDetectActive && CollisionSoundType >= 0)
{ {
thisHitColliders.Add(id); CollisionForSoundInfo soundinfo;
if (!m_lastColliders.Contains(id)) ContactPoint curcontact;
{
startedColliders.Add(id);
curcontact = collissionswith[id]; foreach (uint id in collissionswith.Keys)
if (Math.Abs(curcontact.RelativeSpeed) > 0.2) {
thisHitColliders.Add(id);
if (!m_lastColliders.Contains(id))
{ {
soundinfo = new CollisionForSoundInfo(); startedColliders.Add(id);
soundinfo.colliderID = id;
soundinfo.position = curcontact.Position; curcontact = collissionswith[id];
soundinfo.relativeVel = curcontact.RelativeSpeed; if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
soundinfolist.Add(soundinfo); {
soundinfo = new CollisionForSoundInfo();
soundinfo.colliderID = id;
soundinfo.position = curcontact.Position;
soundinfo.relativeVel = curcontact.RelativeSpeed;
soundinfolist.Add(soundinfo);
}
} }
} }
} }
else
{
foreach (uint id in collissionswith.Keys)
{
thisHitColliders.Add(id);
if (!m_lastColliders.Contains(id))
startedColliders.Add(id);
}
}
// calculate things that ended colliding // calculate things that ended colliding
foreach (uint localID in m_lastColliders) foreach (uint localID in m_lastColliders)
@ -2673,7 +2715,7 @@ namespace OpenSim.Region.Framework.Scenes
m_lastColliders.Remove(localID); m_lastColliders.Remove(localID);
// play sounds. // play sounds.
if (soundinfolist.Count > 0 && !VolumeDetectActive && CollisionSound != invalidCollisionSoundUUID) if (soundinfolist.Count > 0)
CollisionSounds.PartCollisionSound(this, soundinfolist); CollisionSounds.PartCollisionSound(this, soundinfolist);
} }
@ -4791,7 +4833,8 @@ namespace OpenSim.Region.Framework.Scenes
pa.OnCollisionUpdate -= PhysicsCollision; pa.OnCollisionUpdate -= PhysicsCollision;
bool hassound = ( CollisionSound != invalidCollisionSoundUUID); bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive);
scriptEvents CombinedEvents = AggregateScriptEvents; scriptEvents CombinedEvents = AggregateScriptEvents;
// merge with root part // merge with root part
@ -4800,10 +4843,7 @@ namespace OpenSim.Region.Framework.Scenes
// submit to this part case // submit to this part case
if (VolumeDetectActive) if (VolumeDetectActive)
{
CombinedEvents &= PhyscicsVolumeDtcSubsEvents; CombinedEvents &= PhyscicsVolumeDtcSubsEvents;
hassound = false;
}
else if ((Flags & PrimFlags.Phantom) != 0) else if ((Flags & PrimFlags.Phantom) != 0)
CombinedEvents &= PhyscicsPhantonSubsEvents; CombinedEvents &= PhyscicsPhantonSubsEvents;
else else