Add advanced collision processing into ScenePresence
parent
10e9ad0086
commit
100d2968c4
|
@ -3499,7 +3499,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
RaiseCollisionScriptEvents(coldata);
|
||||
|
||||
if (Invulnerable)
|
||||
if (Invulnerable || GodLevel >= 200)
|
||||
return;
|
||||
|
||||
float starthealth = Health;
|
||||
|
@ -4096,19 +4096,116 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata)
|
||||
private DetectedObject CreateDetObject(SceneObjectPart obj)
|
||||
{
|
||||
/*
|
||||
lock(m_collisionEventLock)
|
||||
{
|
||||
if (m_collisionEventFlag)
|
||||
return;
|
||||
m_collisionEventFlag = true;
|
||||
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;
|
||||
|
||||
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
|
||||
{
|
||||
List<uint> thisHitColliders = new List<uint>();
|
||||
|
@ -4172,123 +4269,26 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
if (soundinfolist.Count > 0)
|
||||
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())
|
||||
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)
|
||||
{
|
||||
ColliderArgs EndCollidingMessage = new ColliderArgs();
|
||||
List<DetectedObject> colliding = new List<DetectedObject>();
|
||||
foreach (uint localId in endedColliders)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
if (startedColliders.Contains(0))
|
||||
SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart);
|
||||
if (m_lastColliders.Contains(0))
|
||||
SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding);
|
||||
if (endedColliders.Contains(0))
|
||||
SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_collisionEventFlag = false;
|
||||
}
|
||||
// });
|
||||
}
|
||||
|
||||
private void TeleportFlagsDebug() {
|
||||
|
|
Loading…
Reference in New Issue