Adds land collision events.

CRs cleaned from patch

Signed-off-by: Melanie <melanie@t-data.com>
mysql-performance
Revolution 2010-01-10 14:28:53 -06:00 committed by Melanie
parent 45b19e5e2d
commit 038ec133e6
3 changed files with 210 additions and 27 deletions

View File

@ -189,6 +189,10 @@ namespace OpenSim.Region.Framework.Scenes
public event ScriptColliding OnScriptColliding;
public event ScriptColliding OnScriptCollidingEnd;
public event ScriptColliding OnScriptLandColliderStart;
public event ScriptColliding OnScriptLandColliding;
public event ScriptColliding OnScriptLandColliderEnd;
public delegate void OnMakeChildAgentDelegate(ScenePresence presence);
public event OnMakeChildAgentDelegate OnMakeChildAgent;
@ -439,6 +443,9 @@ namespace OpenSim.Region.Framework.Scenes
private ScriptColliding handlerCollidingStart = null;
private ScriptColliding handlerColliding = null;
private ScriptColliding handlerCollidingEnd = null;
private ScriptColliding handlerLandCollidingStart = null;
private ScriptColliding handlerLandColliding = null;
private ScriptColliding handlerLandCollidingEnd = null;
private GetScriptRunning handlerGetScriptRunning = null;
private SunLindenHour handlerCurrentTimeAsLindenSunHour = null;
@ -1034,6 +1041,27 @@ namespace OpenSim.Region.Framework.Scenes
handlerCollidingEnd(localId, colliders);
}
public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders)
{
handlerLandCollidingStart = OnScriptLandColliderStart;
if (handlerLandCollidingStart != null)
handlerLandCollidingStart(localId, colliders);
}
public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders)
{
handlerLandColliding = OnScriptLandColliding;
if (handlerLandColliding != null)
handlerLandColliding(localId, colliders);
}
public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders)
{
handlerLandCollidingEnd = OnScriptLandColliderEnd;
if (handlerLandCollidingEnd != null)
handlerLandCollidingEnd(localId, colliders);
}
public void TriggerSetRootAgentScene(UUID agentID, Scene scene)
{
handlerSetRootAgentScene = OnSetRootAgentScene;

View File

@ -1853,16 +1853,12 @@ namespace OpenSim.Region.Framework.Scenes
// and build up list of colliders this time
foreach (uint localid in collissionswith.Keys)
{
if (localid != 0)
thisHitColliders.Add(localid);
if (!m_lastColliders.Contains(localid))
{
thisHitColliders.Add(localid);
if (!m_lastColliders.Contains(localid))
{
startedColliders.Add(localid);
}
//m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
startedColliders.Add(localid);
}
//m_log.Debug("[OBJECT]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
}
// calculate things that ended colliding
@ -1904,6 +1900,8 @@ namespace OpenSim.Region.Framework.Scenes
List<DetectedObject> colliding = new List<DetectedObject>();
foreach (uint localId in startedColliders)
{
if (localId == 0)
return;
// always running this check because if the user deletes the object it would return a null reference.
if (m_parentGroup == null)
return;
@ -2039,7 +2037,7 @@ namespace OpenSim.Region.Framework.Scenes
{
// always running this check because if the user deletes the object it would return a null reference.
if (localId == 0)
continue;
return;
if (m_parentGroup == null)
return;
@ -2171,7 +2169,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (uint localId in endedColliders)
{
if (localId == 0)
continue;
return;
// always running this check because if the user deletes the object it would return a null reference.
if (m_parentGroup == null)
@ -2293,6 +2291,120 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_start) != 0)
{
if (startedColliders.Count > 0)
{
ColliderArgs LandStartCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
foreach (uint localId in startedColliders)
{
if (localId == 0)
{
//Hope that all is left is ground!
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = UUID.Zero;
detobj.nameStr = "";
detobj.ownerUUID = UUID.Zero;
detobj.posVector = m_parentGroup.RootPart.AbsolutePosition;
detobj.rotQuat = Quaternion.Identity;
detobj.velVector = Vector3.Zero;
detobj.colliderType = 0;
detobj.groupUUID = UUID.Zero;
colliding.Add(detobj);
}
}
if (colliding.Count > 0)
{
LandStartCollidingMessage.Colliders = colliding;
// always running this check because if the user deletes the object it would return a null reference.
if (m_parentGroup == null)
return;
if (m_parentGroup.Scene == null)
return;
m_parentGroup.Scene.EventManager.TriggerScriptLandCollidingStart(LocalId, LandStartCollidingMessage);
}
}
}
if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision) != 0)
{
if (m_lastColliders.Count > 0)
{
ColliderArgs LandCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
foreach (uint localId in startedColliders)
{
if (localId == 0)
{
//Hope that all is left is ground!
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = UUID.Zero;
detobj.nameStr = "";
detobj.ownerUUID = UUID.Zero;
detobj.posVector = m_parentGroup.RootPart.AbsolutePosition;
detobj.rotQuat = Quaternion.Identity;
detobj.velVector = Vector3.Zero;
detobj.colliderType = 0;
detobj.groupUUID = UUID.Zero;
colliding.Add(detobj);
}
}
if (colliding.Count > 0)
{
LandCollidingMessage.Colliders = colliding;
// always running this check because if the user deletes the object it would return a null reference.
if (m_parentGroup == null)
return;
if (m_parentGroup.Scene == null)
return;
m_parentGroup.Scene.EventManager.TriggerScriptLandColliding(LocalId, LandCollidingMessage);
}
}
}
if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.land_collision_end) != 0)
{
if (endedColliders.Count > 0)
{
ColliderArgs LandEndCollidingMessage = new ColliderArgs();
List<DetectedObject> colliding = new List<DetectedObject>();
foreach (uint localId in startedColliders)
{
if (localId == 0)
{
//Hope that all is left is ground!
DetectedObject detobj = new DetectedObject();
detobj.keyUUID = UUID.Zero;
detobj.nameStr = "";
detobj.ownerUUID = UUID.Zero;
detobj.posVector = m_parentGroup.RootPart.AbsolutePosition;
detobj.rotQuat = Quaternion.Identity;
detobj.velVector = Vector3.Zero;
detobj.colliderType = 0;
detobj.groupUUID = UUID.Zero;
colliding.Add(detobj);
}
}
if (colliding.Count > 0)
{
LandEndCollidingMessage.Colliders = colliding;
// always running this check because if the user deletes the object it would return a null reference.
if (m_parentGroup == null)
return;
if (m_parentGroup.Scene == null)
return;
m_parentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd(LocalId, LandEndCollidingMessage);
}
}
}
}
public void PhysicsOutOfBounds(Vector3 pos)
@ -3698,6 +3810,9 @@ namespace OpenSim.Region.Framework.Scenes
((AggregateScriptEvents & scriptEvents.collision) != 0) ||
((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
(CollisionSound != UUID.Zero)
)
{
@ -3902,6 +4017,9 @@ namespace OpenSim.Region.Framework.Scenes
((AggregateScriptEvents & scriptEvents.collision) != 0) ||
((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
(CollisionSound != UUID.Zero)
)
{

View File

@ -63,6 +63,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
myScriptEngine.World.EventManager.OnScriptColliderStart += collision_start;
myScriptEngine.World.EventManager.OnScriptColliding += collision;
myScriptEngine.World.EventManager.OnScriptCollidingEnd += collision_end;
myScriptEngine.World.EventManager.OnScriptLandColliderStart += land_collision_start;
myScriptEngine.World.EventManager.OnScriptLandColliding += land_collision;
myScriptEngine.World.EventManager.OnScriptLandColliderEnd += land_collision_end;
IMoneyModule money=myScriptEngine.World.RequestModuleInterface<IMoneyModule>();
if (money != null)
{
@ -285,29 +288,63 @@ namespace OpenSim.Region.ScriptEngine.XEngine
det.ToArray()));
}
public void land_collision_start(uint localID, UUID itemID)
{
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision_start",
new object[0],
new DetectParams[0]));
public void land_collision_start(uint localID, ColliderArgs col)
{
List<DetectParams> det = new List<DetectParams>();
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Position = new LSL_Types.Vector3(detobj.posVector.X,
detobj.posVector.Y,
detobj.posVector.Z);
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision_start",
new Object[] { new LSL_Types.Vector3(d.Position) },
det.ToArray()));
}
}
public void land_collision(uint localID, UUID itemID)
public void land_collision(uint localID, ColliderArgs col)
{
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision",
new object[0],
new DetectParams[0]));
List<DetectParams> det = new List<DetectParams>();
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Position = new LSL_Types.Vector3(detobj.posVector.X,
detobj.posVector.Y,
detobj.posVector.Z);
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision",
new Object[] { new LSL_Types.Vector3(d.Position) },
det.ToArray()));
}
}
public void land_collision_end(uint localID, UUID itemID)
public void land_collision_end(uint localID, ColliderArgs col)
{
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision_end",
new object[0],
new DetectParams[0]));
}
List<DetectParams> det = new List<DetectParams>();
foreach (DetectedObject detobj in col.Colliders)
{
DetectParams d = new DetectParams();
d.Position = new LSL_Types.Vector3(detobj.posVector.X,
detobj.posVector.Y,
detobj.posVector.Z);
d.Populate(myScriptEngine.World);
det.Add(d);
myScriptEngine.PostObjectEvent(localID, new EventParams(
"land_collision_end",
new Object[] { new LSL_Types.Vector3(d.Position) },
det.ToArray()));
}
}
// timer: not handled here
// listen: not handled here