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

avinationmerge
ubit 2012-05-29 20:14:39 +02:00
commit 927e026b6d
3 changed files with 184 additions and 183 deletions

View File

@ -2495,21 +2495,21 @@ namespace OpenSim.Region.Framework.Scenes
{ {
} }
private bool CollisionFilteredOut(SceneObjectPart dest, UUID objectID, string objectName) public bool CollisionFilteredOut(UUID objectID, string objectName)
{ {
if(dest.CollisionFilter.Count == 0) if(CollisionFilter.Count == 0)
return false; return false;
if (dest.CollisionFilter.ContainsValue(objectID.ToString()) || if (CollisionFilter.ContainsValue(objectID.ToString()) ||
dest.CollisionFilter.ContainsValue(objectID.ToString() + objectName) || CollisionFilter.ContainsValue(objectID.ToString() + objectName) ||
dest.CollisionFilter.ContainsValue(UUID.Zero.ToString() + objectName)) CollisionFilter.ContainsValue(UUID.Zero.ToString() + objectName))
{ {
if (dest.CollisionFilter.ContainsKey(1)) if (CollisionFilter.ContainsKey(1))
return false; return false;
return true; return true;
} }
if (dest.CollisionFilter.ContainsKey(1)) if (CollisionFilter.ContainsKey(1))
return true; return true;
return false; return false;
@ -2572,7 +2572,7 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId);
if (obj != null) if (obj != null)
{ {
if (!dest.CollisionFilteredOut(this, obj.UUID, obj.Name)) if (!dest.CollisionFilteredOut(obj.UUID, obj.Name))
colliding.Add(CreateDetObject(obj)); colliding.Add(CreateDetObject(obj));
} }
else else
@ -2580,7 +2580,7 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence av = ParentGroup.Scene.GetScenePresence(localId); ScenePresence av = ParentGroup.Scene.GetScenePresence(localId);
if (av != null && (!av.IsChildAgent)) if (av != null && (!av.IsChildAgent))
{ {
if (!dest.CollisionFilteredOut(this, av.UUID, av.Name)) if (!dest.CollisionFilteredOut(av.UUID, av.Name))
colliding.Add(CreateDetObject(av)); colliding.Add(CreateDetObject(av));
} }
} }

View File

@ -3499,7 +3499,7 @@ namespace OpenSim.Region.Framework.Scenes
RaiseCollisionScriptEvents(coldata); RaiseCollisionScriptEvents(coldata);
if (Invulnerable) if (Invulnerable || GodLevel >= 200)
return; return;
float starthealth = Health; float starthealth = Health;
@ -4096,19 +4096,116 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) private DetectedObject CreateDetObject(SceneObjectPart obj)
{ {
/* DetectedObject detobj = new DetectedObject();
lock(m_collisionEventLock) detobj.keyUUID = obj.UUID;
{ detobj.nameStr = obj.Name;
if (m_collisionEventFlag) detobj.ownerUUID = obj.OwnerID;
return; detobj.posVector = obj.AbsolutePosition;
m_collisionEventFlag = true; detobj.rotQuat = obj.GetWorldRotation();
detobj.velVector = obj.Velocity;
detobj.colliderType = 0;
detobj.groupUUID = obj.GroupID;
return detobj;
} }
Util.FireAndForget(delegate(object x) private DetectedObject CreateDetObject(ScenePresence av)
{
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = av.UUID;
detobj.nameStr = av.ControllingClient.Name;
detobj.ownerUUID = av.UUID;
detobj.posVector = av.AbsolutePosition;
detobj.rotQuat = av.Rotation;
detobj.velVector = av.Velocity;
detobj.colliderType = 0;
detobj.groupUUID = av.ControllingClient.ActiveGroupId;
return detobj;
}
private DetectedObject CreateDetObjectForGround()
{
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = UUID.Zero;
detobj.nameStr = "";
detobj.ownerUUID = UUID.Zero;
detobj.posVector = AbsolutePosition;
detobj.rotQuat = Quaternion.Identity;
detobj.velVector = Vector3.Zero;
detobj.colliderType = 0;
detobj.groupUUID = UUID.Zero;
return detobj;
}
private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders)
{
ColliderArgs colliderArgs = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
foreach (uint localId in colliders)
{
if (localId == 0)
continue;
SceneObjectPart obj = m_scene.GetSceneObjectPart(localId);
if (obj != null)
{
if (!dest.CollisionFilteredOut(obj.UUID, obj.Name))
colliding.Add(CreateDetObject(obj));
}
else
{
ScenePresence av = m_scene.GetScenePresence(localId);
if (av != null && (!av.IsChildAgent))
{
if (!dest.CollisionFilteredOut(av.UUID, av.Name))
colliding.Add(CreateDetObject(av));
}
}
}
colliderArgs.Colliders = colliding;
return colliderArgs;
}
private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message);
private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify)
{
ColliderArgs CollidingMessage;
if (colliders.Count > 0)
{
if ((dest.RootPart.ScriptEvents & ev) != 0)
{
CollidingMessage = CreateColliderArgs(dest.RootPart, colliders);
if (CollidingMessage.Colliders.Count > 0)
notify(dest.RootPart.LocalId, CollidingMessage);
}
}
}
private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify)
{
if ((dest.RootPart.ScriptEvents & ev) != 0)
{
ColliderArgs LandCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
colliding.Add(CreateDetObjectForGround());
LandCollidingMessage.Colliders = colliding;
notify(dest.RootPart.LocalId, LandCollidingMessage);
}
}
private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
{ {
*/
try try
{ {
List<uint> thisHitColliders = new List<uint>(); List<uint> thisHitColliders = new List<uint>();
@ -4172,123 +4269,26 @@ namespace OpenSim.Region.Framework.Scenes
if (soundinfolist.Count > 0) if (soundinfolist.Count > 0)
CollisionSounds.AvatarCollisionSound(this, soundinfolist); CollisionSounds.AvatarCollisionSound(this, soundinfolist);
// do event notification
if (startedColliders.Count > 0)
{
ColliderArgs StartCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
foreach (uint localId in startedColliders)
{
if (localId == 0)
continue;
SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
string data = "";
if (obj != null)
{
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = obj.UUID;
detobj.nameStr = obj.Name;
detobj.ownerUUID = obj.OwnerID;
detobj.posVector = obj.AbsolutePosition;
detobj.rotQuat = obj.GetWorldRotation();
detobj.velVector = obj.Velocity;
detobj.colliderType = 0;
detobj.groupUUID = obj.GroupID;
colliding.Add(detobj);
} }
}
if (colliding.Count > 0)
{
StartCollidingMessage.Colliders = colliding;
foreach (SceneObjectGroup att in GetAttachments()) foreach (SceneObjectGroup att in GetAttachments())
Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); {
} SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart);
} SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding);
} SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd);
if (endedColliders.Count > 0) if (startedColliders.Contains(0))
{ SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart);
ColliderArgs EndCollidingMessage = new ColliderArgs(); if (m_lastColliders.Contains(0))
List<DetectedObject> colliding = new List<DetectedObject>(); SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding);
foreach (uint localId in endedColliders) if (endedColliders.Contains(0))
{ SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd);
if (localId == 0)
continue;
SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
string data = "";
if (obj != null)
{
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = obj.UUID;
detobj.nameStr = obj.Name;
detobj.ownerUUID = obj.OwnerID;
detobj.posVector = obj.AbsolutePosition;
detobj.rotQuat = obj.GetWorldRotation();
detobj.velVector = obj.Velocity;
detobj.colliderType = 0;
detobj.groupUUID = obj.GroupID;
colliding.Add(detobj);
}
}
if (colliding.Count > 0)
{
EndCollidingMessage.Colliders = colliding;
foreach (SceneObjectGroup att in GetAttachments())
Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
}
}
if (thisHitColliders.Count > 0)
{
ColliderArgs CollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
foreach (uint localId in thisHitColliders)
{
if (localId == 0)
continue;
SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
string data = "";
if (obj != null)
{
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = obj.UUID;
detobj.nameStr = obj.Name;
detobj.ownerUUID = obj.OwnerID;
detobj.posVector = obj.AbsolutePosition;
detobj.rotQuat = obj.GetWorldRotation();
detobj.velVector = obj.Velocity;
detobj.colliderType = 0;
detobj.groupUUID = obj.GroupID;
colliding.Add(detobj);
}
}
if (colliding.Count > 0)
{
CollidingMessage.Colliders = colliding;
lock (m_attachments)
{
foreach (SceneObjectGroup att in m_attachments)
Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
}
}
} }
} }
finally finally
{ {
m_collisionEventFlag = false; m_collisionEventFlag = false;
} }
// });
} }
private void TeleportFlagsDebug() { private void TeleportFlagsDebug() {

View File

@ -1118,6 +1118,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (CollisionEventsThisFrame == null) if (CollisionEventsThisFrame == null)
CollisionEventsThisFrame = new CollisionEventUpdate(); CollisionEventsThisFrame = new CollisionEventUpdate();
CollisionEventsThisFrame.AddCollider(CollidedWith, contact); CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
_parent_scene.AddCollisionEventReporting(this);
} }
public void SendCollisions() public void SendCollisions()