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

avinationmerge
ubit 2012-05-19 02:11:56 +02:00
commit 3a07220111
3 changed files with 122 additions and 83 deletions

View File

@ -33,8 +33,18 @@ using OpenSim.Framework;
namespace OpenSim.Region.Framework.Scenes
{
public struct CollisionForSoundInfo
{
public uint colliderID;
public Vector3 position;
public float relativeVel;
}
public static class CollisionSounds
{
// defines for cases
// only know one UUID for now (woodflesh)
@ -107,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes
public static void PartCollisionSound(SceneObjectPart part,List<uint> Colliders)
{
// temporary mute sounds
return;
// return;
if(Colliders.Count == 0 || part == null)
return;
@ -178,28 +188,15 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
/* avatars get notification let them trigger the sound
else if (!doneownsound)
{
ScenePresence av = part.ParentGroup.Scene.GetScenePresence(Id);
if (av != null && (!av.IsChildAgent))
{
index = thisMatScaled + 4; // flesh
soundID = m_PartPart[index];
part.SendCollisionSound(soundID, 1.0);
doneownsound = true;
}
}
*/
}
}
public static void AvatarCollisionSound(ScenePresence av, List<uint> Colliders)
public static void AvatarCollisionSound(ScenePresence av, List<CollisionForSoundInfo> collidersinfolist)
{
// temporary mute sounds
return;
// return;
if (Colliders.Count == 0 || av == null)
if (collidersinfolist.Count == 0 || av == null)
return;
UUID soundID;
@ -211,30 +208,43 @@ namespace OpenSim.Region.Framework.Scenes
int index;
// bool doneownsound = false;
Vector3 position = av.AbsolutePosition;
CollisionForSoundInfo colInfo;
uint id;
float volume;
foreach (uint Id in Colliders)
for(int i = 0; i< collidersinfolist.Count; i++)
{
if (Id == 0)
colInfo = collidersinfolist[i];
volume = Math.Abs(colInfo.relativeVel);
if(volume < 0.2f)
continue;
id = colInfo.colliderID;
if (id == 0) // no terrain collision sounds for now
{
continue;
}
SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(Id);
SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id);
if (otherPart != null)
{
if (otherPart.CollisionSound == otherPart.invalidCollisionSoundUUID)
continue;
if (otherPart.CollisionSound != UUID.Zero)
otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, position);
otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position);
else
{
volume *= volume * .0625f; // 4m/s == full volume
if (volume > 1.0f)
volume = 1.0f;
otherMaterial = (int)otherPart.Material;
if (otherMaterial >= MaxMaterials)
otherMaterial = 3;
index = thisMatScaled + otherMaterial;
soundID = m_PartPart[index];
otherPart.SendCollisionSound(soundID, 1.0, position);
otherPart.SendCollisionSound(soundID, volume, colInfo.position);
}
}
/*

View File

@ -4112,13 +4112,39 @@ namespace OpenSim.Region.Framework.Scenes
List<uint> thisHitColliders = new List<uint>();
List<uint> endedColliders = new List<uint>();
List<uint> startedColliders = new List<uint>();
List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
CollisionForSoundInfo soundinfo;
ContactPoint curcontact;
foreach (uint localid in coldata.Keys)
if (coldata.Count == 0)
{
thisHitColliders.Add(localid);
if (!m_lastColliders.Contains(localid))
if (m_lastColliders.Count == 0)
return; // nothing to do
foreach (uint localID in m_lastColliders)
{
startedColliders.Add(localid);
endedColliders.Add(localID);
}
m_lastColliders.Clear();
}
else
{
foreach (uint id in coldata.Keys)
{
thisHitColliders.Add(id);
if (!m_lastColliders.Contains(id))
{
startedColliders.Add(id);
curcontact = coldata[id];
if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
{
soundinfo = new CollisionForSoundInfo();
soundinfo.colliderID = id;
soundinfo.position = curcontact.Position;
soundinfo.relativeVel = curcontact.RelativeSpeed;
soundinfolist.Add(soundinfo);
}
}
//m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
}
@ -4142,10 +4168,12 @@ namespace OpenSim.Region.Framework.Scenes
m_lastColliders.Remove(localID);
}
if (soundinfolist.Count > 0)
CollisionSounds.AvatarCollisionSound(this, soundinfolist);
// do event notification
if (startedColliders.Count > 0)
{
CollisionSounds.AvatarCollisionSound(this, startedColliders);
ColliderArgs StartCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
@ -4179,6 +4207,7 @@ namespace OpenSim.Region.Framework.Scenes
Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
}
}
}
if (endedColliders.Count > 0)
{

View File

@ -239,7 +239,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool IsPhysical
{
get { return false; }
get { return m_isPhysical; }
set { return; }
}