Added code to propagate ScriptLandCollidingStart, ScriptLandColliding, and

ScriptLandCollidingEnd events.
dsg
Huaiyu (Kitty) Liu 2011-06-14 16:48:21 -07:00
parent 57a42508ec
commit 941cec5548
3 changed files with 223 additions and 117 deletions

View File

@ -287,6 +287,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
case EventManager.EventNames.ScriptCollidingStart: case EventManager.EventNames.ScriptCollidingStart:
case EventManager.EventNames.ScriptColliding: case EventManager.EventNames.ScriptColliding:
case EventManager.EventNames.ScriptCollidingEnd: case EventManager.EventNames.ScriptCollidingEnd:
case EventManager.EventNames.ScriptLandCollidingStart:
case EventManager.EventNames.ScriptLandColliding:
case EventManager.EventNames.ScriptLandCollidingEnd:
if (evArgs.Length < 2) if (evArgs.Length < 2)
{ {
m_log.Error(LogHeader + " not enough event args for ScriptCollidingEvents"); m_log.Error(LogHeader + " not enough event args for ScriptCollidingEvents");
@ -294,16 +297,6 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
OnLocalScriptCollidingEvents(ev, (uint)evArgs[0], (ColliderArgs)evArgs[1]); OnLocalScriptCollidingEvents(ev, (uint)evArgs[0], (ColliderArgs)evArgs[1]);
return; return;
/*
OnLocalScriptCollidingStart((uint)evArgs[0], (ColliderArgs)evArgs[1]);
return;
case EventManager.EventNames.ScriptColliding:
OnLocalScriptColliding((uint)evArgs[0], (ColliderArgs)evArgs[1]);
return;
case EventManager.EventNames.ScriptCollidingEnd:
OnLocalScriptCollidingEnd((uint)evArgs[0], (ColliderArgs)evArgs[1]);
return;
* */
default: default:
return; return;
} }
@ -759,7 +752,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
//special fix for R@I demo, need better optimization later //special fix for R@I demo, need better optimization later
if ((rsm.Type == SymmetricSyncMessage.MsgType.PhysicsCollision || rsm.Type == SymmetricSyncMessage.MsgType.ScriptCollidingStart if ((rsm.Type == SymmetricSyncMessage.MsgType.PhysicsCollision || rsm.Type == SymmetricSyncMessage.MsgType.ScriptCollidingStart
|| rsm.Type == SymmetricSyncMessage.MsgType.ScriptColliding || rsm.Type == SymmetricSyncMessage.MsgType.ScriptCollidingEnd) || rsm.Type == SymmetricSyncMessage.MsgType.ScriptColliding || rsm.Type == SymmetricSyncMessage.MsgType.ScriptCollidingEnd
|| rsm.Type == SymmetricSyncMessage.MsgType.ScriptLandCollidingStart
|| rsm.Type == SymmetricSyncMessage.MsgType.ScriptLandColliding || rsm.Type == SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd)
&& m_isSyncRelay) && m_isSyncRelay)
{ {
//for persistence actor, only forward collision events to script engines //for persistence actor, only forward collision events to script engines
@ -1771,6 +1766,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
case SymmetricSyncMessage.MsgType.ScriptCollidingStart: case SymmetricSyncMessage.MsgType.ScriptCollidingStart:
case SymmetricSyncMessage.MsgType.ScriptColliding: case SymmetricSyncMessage.MsgType.ScriptColliding:
case SymmetricSyncMessage.MsgType.ScriptCollidingEnd: case SymmetricSyncMessage.MsgType.ScriptCollidingEnd:
case SymmetricSyncMessage.MsgType.ScriptLandCollidingStart:
case SymmetricSyncMessage.MsgType.ScriptLandColliding:
case SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd:
{ {
HandleRemoteEvent(msg, senderActorID); HandleRemoteEvent(msg, senderActorID);
return; return;
@ -2241,6 +2239,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
case SymmetricSyncMessage.MsgType.ScriptCollidingStart: case SymmetricSyncMessage.MsgType.ScriptCollidingStart:
case SymmetricSyncMessage.MsgType.ScriptColliding: case SymmetricSyncMessage.MsgType.ScriptColliding:
case SymmetricSyncMessage.MsgType.ScriptCollidingEnd: case SymmetricSyncMessage.MsgType.ScriptCollidingEnd:
case SymmetricSyncMessage.MsgType.ScriptLandCollidingStart:
case SymmetricSyncMessage.MsgType.ScriptLandColliding:
case SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd:
//HandleRemoteEvent_ScriptCollidingStart(init_actorID, evSeqNum, data, DateTime.Now.Ticks); //HandleRemoteEvent_ScriptCollidingStart(init_actorID, evSeqNum, data, DateTime.Now.Ticks);
HandleRemoteEvent_ScriptCollidingEvents(msg.Type, init_actorID, evSeqNum, data, DateTime.Now.Ticks); HandleRemoteEvent_ScriptCollidingEvents(msg.Type, init_actorID, evSeqNum, data, DateTime.Now.Ticks);
break; break;
@ -2502,7 +2503,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
ColliderArgs StartCollidingMessage = new ColliderArgs(); ColliderArgs StartCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>(); List<DetectedObject> colliding = new List<DetectedObject>();
SceneObjectPart part = null; SceneObjectPart collisionPart = null;
OSDArray collidersNotFound = new OSDArray(); OSDArray collidersNotFound = new OSDArray();
try try
@ -2511,8 +2512,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//OSDArray collisionLocalIDs = (OSDArray)data["collisionLocalIDs"]; //OSDArray collisionLocalIDs = (OSDArray)data["collisionLocalIDs"];
OSDArray collisionUUIDs = (OSDArray)data["collisionUUIDs"]; OSDArray collisionUUIDs = (OSDArray)data["collisionUUIDs"];
part = m_scene.GetSceneObjectPart(primUUID); collisionPart = m_scene.GetSceneObjectPart(primUUID);
if (part == null) if (collisionPart == null)
{ {
m_log.WarnFormat("{0}: HandleRemoteEvent_PhysicsCollision: no part with UUID {1} found, event initiator {2}", LogHeader, primUUID, actorID); m_log.WarnFormat("{0}: HandleRemoteEvent_PhysicsCollision: no part with UUID {1} found, event initiator {2}", LogHeader, primUUID, actorID);
return; return;
@ -2522,10 +2523,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_log.WarnFormat("{0}: HandleRemoteEvent_PhysicsCollision: no collisionLocalIDs", LogHeader); m_log.WarnFormat("{0}: HandleRemoteEvent_PhysicsCollision: no collisionLocalIDs", LogHeader);
return; return;
} }
if (part.ParentGroup.IsDeleted == true) if (collisionPart.ParentGroup.IsDeleted == true)
return; return;
switch (msgType)
{
case SymmetricSyncMessage.MsgType.ScriptCollidingStart:
case SymmetricSyncMessage.MsgType.ScriptColliding:
case SymmetricSyncMessage.MsgType.ScriptCollidingEnd:
{
for (int i = 0; i < collisionUUIDs.Count; i++) for (int i = 0; i < collisionUUIDs.Count; i++)
{ {
OSD arg = collisionUUIDs[i]; OSD arg = collisionUUIDs[i];
@ -2565,17 +2571,11 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
else else
{ {
m_log.WarnFormat("HandleRemoteEvent_ScriptCollidingStart for SOP {0},{1} with SOP/SP {2}, but the latter is not found in local Scene. Saved for later processing", m_log.WarnFormat("HandleRemoteEvent_ScriptCollidingStart for SOP {0},{1} with SOP/SP {2}, but the latter is not found in local Scene. Saved for later processing",
part.Name, part.UUID, collidingUUID); collisionPart.Name, collisionPart.UUID, collidingUUID);
collidersNotFound.Add(OSD.FromUUID(collidingUUID)); collidersNotFound.Add(OSD.FromUUID(collidingUUID));
} }
} }
} }
}
catch (Exception e)
{
m_log.ErrorFormat("HandleRemoteEvent_ScriptCollidingStart Error: {0}", e.Message);
}
if (collidersNotFound.Count > 0) if (collidersNotFound.Count > 0)
{ {
@ -2585,18 +2585,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
if (msgSavedTime < msgExpireTime) if (msgSavedTime < msgExpireTime)
{ {
//for testing only, need to remove after testing
/*
TimeSpan testTime = new TimeSpan(0, 0, 5);
if (msgSavedTime > testTime)
{
collidersNotFound.Clear();
collidersNotFound.Add(OSD.FromUUID(new UUID("fe3bc3cc-3ec5-423d-bd2b-d19386210368")));
}
*/
OSDMap newdata = new OSDMap(); OSDMap newdata = new OSDMap();
newdata["primUUID"] = OSD.FromUUID(part.UUID); newdata["primUUID"] = OSD.FromUUID(collisionPart.UUID);
newdata["collisionUUIDs"] = collidersNotFound; newdata["collisionUUIDs"] = collidersNotFound;
newdata["actorID"] = OSD.FromString(actorID); newdata["actorID"] = OSD.FromString(actorID);
@ -2624,6 +2615,39 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
} }
} }
} }
}
break;
case SymmetricSyncMessage.MsgType.ScriptLandCollidingStart:
case SymmetricSyncMessage.MsgType.ScriptLandColliding:
case SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd:
{
for (int i = 0; i < collisionUUIDs.Count; i++)
{
OSD arg = collisionUUIDs[i];
UUID collidingUUID = arg.AsUUID();
if (collidingUUID.Equals(UUID.Zero))
{
//Hope that all is left is ground!
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = UUID.Zero;
detobj.nameStr = "";
detobj.ownerUUID = UUID.Zero;
detobj.posVector = collisionPart.ParentGroup.RootPart.AbsolutePosition;
detobj.rotQuat = Quaternion.Identity;
detobj.velVector = Vector3.Zero;
detobj.colliderType = 0;
detobj.groupUUID = UUID.Zero;
colliding.Add(detobj);
}
}
}
break;
}
}
catch (Exception e)
{
m_log.ErrorFormat("HandleRemoteEvent_ScriptCollidingStart Error: {0}", e.Message);
}
if (colliding.Count > 0) if (colliding.Count > 0)
@ -2634,16 +2658,28 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
switch (msgType) switch (msgType)
{ {
case SymmetricSyncMessage.MsgType.ScriptCollidingStart: case SymmetricSyncMessage.MsgType.ScriptCollidingStart:
m_log.DebugFormat("ScriptCollidingStart received for {0}", part.Name); m_log.DebugFormat("ScriptCollidingStart received for {0}", collisionPart.Name);
LocalScene.EventManager.TriggerScriptCollidingStartLocally(part.LocalId, StartCollidingMessage); LocalScene.EventManager.TriggerScriptCollidingStartLocally(collisionPart.LocalId, StartCollidingMessage);
break; break;
case SymmetricSyncMessage.MsgType.ScriptColliding: case SymmetricSyncMessage.MsgType.ScriptColliding:
m_log.DebugFormat("ScriptColliding received for {0}", part.Name); m_log.DebugFormat("ScriptColliding received for {0}", collisionPart.Name);
LocalScene.EventManager.TriggerScriptCollidingLocally(part.LocalId, StartCollidingMessage); LocalScene.EventManager.TriggerScriptCollidingLocally(collisionPart.LocalId, StartCollidingMessage);
break; break;
case SymmetricSyncMessage.MsgType.ScriptCollidingEnd: case SymmetricSyncMessage.MsgType.ScriptCollidingEnd:
m_log.DebugFormat("ScriptCollidingEnd received for {0}", part.Name); m_log.DebugFormat("ScriptCollidingEnd received for {0}", collisionPart.Name);
LocalScene.EventManager.TriggerScriptCollidingEndLocally(part.LocalId, StartCollidingMessage); LocalScene.EventManager.TriggerScriptCollidingEndLocally(collisionPart.LocalId, StartCollidingMessage);
break;
case SymmetricSyncMessage.MsgType.ScriptLandCollidingStart:
m_log.DebugFormat("ScriptLandCollidingStart received for {0}", collisionPart.Name);
LocalScene.EventManager.TriggerScriptLandCollidingStartLocally(collisionPart.LocalId, StartCollidingMessage);
break;
case SymmetricSyncMessage.MsgType.ScriptLandColliding:
m_log.DebugFormat("ScriptLandColliding received for {0}", collisionPart.Name);
LocalScene.EventManager.TriggerScriptLandCollidingLocally(collisionPart.LocalId, StartCollidingMessage);
break;
case SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd:
m_log.DebugFormat("ScriptLandCollidingEnd received for {0}", collisionPart.Name);
LocalScene.EventManager.TriggerScriptLandCollidingEndLocally(collisionPart.LocalId, StartCollidingMessage);
break; break;
} }
} }
@ -2982,6 +3018,16 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
case EventManager.EventNames.ScriptCollidingEnd: case EventManager.EventNames.ScriptCollidingEnd:
SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptCollidingEnd, data); SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptCollidingEnd, data);
break; break;
case EventManager.EventNames.ScriptLandCollidingStart:
SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptLandCollidingStart, data);
break;
case EventManager.EventNames.ScriptLandColliding:
SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptLandColliding, data);
break;
case EventManager.EventNames.ScriptLandCollidingEnd:
SendSceneEvent(SymmetricSyncMessage.MsgType.ScriptLandCollidingEnd, data);
break;
} }
} }

View File

@ -72,6 +72,9 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
ScriptCollidingStart, ScriptCollidingStart,
ScriptColliding, ScriptColliding,
ScriptCollidingEnd, ScriptCollidingEnd,
ScriptLandCollidingStart,
ScriptLandColliding,
ScriptLandCollidingEnd,
//contorl command //contorl command
SyncStateReport, SyncStateReport,
} }

View File

@ -63,7 +63,10 @@ namespace OpenSim.Region.Framework.Scenes
PhysicsCollision, PhysicsCollision,
ScriptCollidingStart, ScriptCollidingStart,
ScriptColliding, ScriptColliding,
ScriptCollidingEnd ScriptCollidingEnd,
ScriptLandCollidingStart,
ScriptLandColliding,
ScriptLandCollidingEnd
} }
public EventManager(Scene scene) public EventManager(Scene scene)
@ -332,6 +335,57 @@ namespace OpenSim.Region.Framework.Scenes
base.TriggerScriptCollidingEnd(localId, colliders); base.TriggerScriptCollidingEnd(localId, colliders);
} }
public override void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders)
{
if (m_scene.RegionSyncModule != null)
{
Object[] eventArgs = new Object[4];
eventArgs[0] = (Object)localId;
eventArgs[1] = (Object)colliders;
m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ScriptLandCollidingStart, eventArgs);
}
TriggerScriptLandCollidingStartLocally(localId, colliders);
}
public void TriggerScriptLandCollidingStartLocally(uint localId, ColliderArgs colliders)
{
base.TriggerScriptLandCollidingStart(localId, colliders);
}
public override void TriggerScriptLandColliding(uint localId, ColliderArgs colliders)
{
if (m_scene.RegionSyncModule != null)
{
Object[] eventArgs = new Object[4];
eventArgs[0] = (Object)localId;
eventArgs[1] = (Object)colliders;
m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ScriptLandColliding, eventArgs);
}
TriggerScriptLandCollidingLocally(localId, colliders);
}
public void TriggerScriptLandCollidingLocally(uint localId, ColliderArgs colliders)
{
base.TriggerScriptLandColliding(localId, colliders);
}
public override void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders)
{
if (m_scene.RegionSyncModule != null)
{
Object[] eventArgs = new Object[4];
eventArgs[0] = (Object)localId;
eventArgs[1] = (Object)colliders;
m_scene.RegionSyncModule.PublishSceneEvent(EventNames.ScriptLandCollidingEnd, eventArgs);
}
TriggerScriptLandCollidingEndLocally(localId, colliders);
}
public void TriggerScriptLandCollidingEndLocally(uint localId, ColliderArgs colliders)
{
base.TriggerScriptLandCollidingEnd(localId, colliders);
}
#endregion #endregion
} }
@ -2317,7 +2371,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) //public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders)
public virtual void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders)
{ {
ScriptColliding handlerLandCollidingStart = OnScriptLandColliderStart; ScriptColliding handlerLandCollidingStart = OnScriptLandColliderStart;
if (handlerLandCollidingStart != null) if (handlerLandCollidingStart != null)
@ -2338,7 +2393,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) //public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders)
public virtual void TriggerScriptLandColliding(uint localId, ColliderArgs colliders)
{ {
ScriptColliding handlerLandColliding = OnScriptLandColliding; ScriptColliding handlerLandColliding = OnScriptLandColliding;
if (handlerLandColliding != null) if (handlerLandColliding != null)
@ -2359,7 +2415,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) //public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders)
public virtual void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders)
{ {
ScriptColliding handlerLandCollidingEnd = OnScriptLandColliderEnd; ScriptColliding handlerLandCollidingEnd = OnScriptLandColliderEnd;
if (handlerLandCollidingEnd != null) if (handlerLandCollidingEnd != null)