Implementation of the llDetectedTouch* functions
parent
c826570751
commit
7ae9ec217d
|
@ -92,7 +92,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
public event OnShutdownDelegate OnShutdown;
|
||||
|
||||
public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient);
|
||||
public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
|
||||
public delegate void ObjectDeGrabDelegate(uint localID, uint originalID, IClientAPI remoteClient);
|
||||
public delegate void ScriptResetDelegate(uint localID, UUID itemID);
|
||||
|
||||
|
@ -530,12 +530,12 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
handlerShutdown();
|
||||
}
|
||||
|
||||
public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient)
|
||||
public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
|
||||
{
|
||||
handlerObjectGrab = OnObjectGrab;
|
||||
if (handlerObjectGrab != null)
|
||||
{
|
||||
handlerObjectGrab(localID, originalID, offsetPos, remoteClient);
|
||||
handlerObjectGrab(localID, originalID, offsetPos, remoteClient, surfaceArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -217,6 +217,10 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
List<EntityBase> EntityList = GetEntities();
|
||||
|
||||
SurfaceTouchEventArgs surfaceArg = null;
|
||||
if (surfaceArgs != null && surfaceArgs.Count > 0)
|
||||
surfaceArg = surfaceArgs[0];
|
||||
|
||||
foreach (EntityBase ent in EntityList)
|
||||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
|
@ -236,9 +240,9 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
// If the touched prim handles touches, deliver it
|
||||
// If not, deliver to root prim
|
||||
if ((part.ScriptEvents & scriptEvents.touch_start) != 0)
|
||||
EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient);
|
||||
EventManager.TriggerObjectGrab(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
|
||||
else
|
||||
EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient);
|
||||
EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
}
|
||||
|
||||
public void touch_start(uint localID, uint originalID,
|
||||
Vector3 offsetPos, IClientAPI remoteClient)
|
||||
Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
|
||||
{
|
||||
// Add to queue for all scripts in ObjectID object
|
||||
DetectParams[] det = new DetectParams[1];
|
||||
|
@ -165,6 +165,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
myScriptEngine.World.GetSceneObjectPart(originalID);
|
||||
det[0].LinkNum = originalPart.LinkNum;
|
||||
}
|
||||
if (surfaceArgs != null)
|
||||
{
|
||||
det[0].SurfaceTouchArgs = surfaceArgs;
|
||||
}
|
||||
|
||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
||||
"touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
|
||||
|
|
|
@ -889,46 +889,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return new LSL_Integer(parms.LinkNum);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchBinormal for details
|
||||
/// </summary>
|
||||
public LSL_Vector llDetectedTouchBinormal(int index)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
NotImplemented("llDetectedTouchBinormal");
|
||||
return new LSL_Vector();
|
||||
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
|
||||
if (detectedParams == null || detectedParams.TouchBinormal == null)
|
||||
return new LSL_Vector();
|
||||
return detectedParams.TouchBinormal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchFace for details
|
||||
/// </summary>
|
||||
public LSL_Integer llDetectedTouchFace(int index)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
NotImplemented("llDetectedTouchFace");
|
||||
return new LSL_Integer(0);
|
||||
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
|
||||
if (detectedParams == null || detectedParams.TouchFace == null)
|
||||
return new LSL_Integer(-1);
|
||||
return new LSL_Integer(detectedParams.TouchFace);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchNormal for details
|
||||
/// </summary>
|
||||
public LSL_Vector llDetectedTouchNormal(int index)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
NotImplemented("llDetectedTouchNormal");
|
||||
return new LSL_Vector();
|
||||
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
|
||||
if (detectedParams == null || detectedParams.TouchNormal == null)
|
||||
return new LSL_Vector();
|
||||
return detectedParams.TouchNormal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchPos for details
|
||||
/// </summary>
|
||||
public LSL_Vector llDetectedTouchPos(int index)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
NotImplemented("llDetectedTouchPos");
|
||||
return new LSL_Vector();
|
||||
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
|
||||
if (detectedParams == null || detectedParams.TouchPos == null)
|
||||
return new LSL_Vector();
|
||||
return detectedParams.TouchPos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchST for details
|
||||
/// </summary>
|
||||
public LSL_Vector llDetectedTouchST(int index)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
NotImplemented("llDetectedTouchST");
|
||||
return new LSL_Vector();
|
||||
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
|
||||
if (detectedParams == null || detectedParams.TouchST == null)
|
||||
return new LSL_Vector(-1.0, -1.0, 0.0);
|
||||
return detectedParams.TouchST;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// See http://wiki.secondlife.com/wiki/LlDetectedTouchUV for details
|
||||
/// </summary>
|
||||
public LSL_Vector llDetectedTouchUV(int index)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
NotImplemented("llDetectedTouchUV");
|
||||
return new LSL_Vector();
|
||||
DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, index);
|
||||
if (detectedParams == null || detectedParams.TouchUV == null)
|
||||
return new LSL_Vector(-1.0, -1.0, 0.0);
|
||||
return detectedParams.TouchUV;
|
||||
}
|
||||
|
||||
public void llDie()
|
||||
|
|
|
@ -494,5 +494,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
public const int CLICK_ACTION_OPEN = 4;
|
||||
public const int CLICK_ACTION_PLAY = 5;
|
||||
public const int CLICK_ACTION_OPEN_MEDIA = 6;
|
||||
|
||||
// constants for the llDetectedTouch* functions
|
||||
public const int TOUCH_INVALID_FACE = -1;
|
||||
public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0);
|
||||
public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
|||
Rotation = new LSL_Types.Quaternion();
|
||||
Type = 0;
|
||||
Velocity = new LSL_Types.Vector3();
|
||||
initializeSurfaceTouch();
|
||||
}
|
||||
|
||||
public UUID Key;
|
||||
|
@ -93,6 +94,61 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
|||
public int Type;
|
||||
public LSL_Types.Vector3 Velocity;
|
||||
|
||||
private LSL_Types.Vector3 touchST;
|
||||
public LSL_Types.Vector3 TouchST { get { return touchST; } }
|
||||
|
||||
private LSL_Types.Vector3 touchNormal;
|
||||
public LSL_Types.Vector3 TouchNormal { get { return touchNormal; } }
|
||||
|
||||
private LSL_Types.Vector3 touchBinormal;
|
||||
public LSL_Types.Vector3 TouchBinormal { get { return touchBinormal; } }
|
||||
|
||||
private LSL_Types.Vector3 touchPos;
|
||||
public LSL_Types.Vector3 TouchPos { get { return touchPos; } }
|
||||
|
||||
private LSL_Types.Vector3 touchUV;
|
||||
public LSL_Types.Vector3 TouchUV { get { return touchUV; } }
|
||||
|
||||
private int touchFace;
|
||||
public int TouchFace { get { return touchFace; } }
|
||||
|
||||
// This can be done in two places including the constructor
|
||||
// so be carefull what gets added here
|
||||
private void initializeSurfaceTouch()
|
||||
{
|
||||
touchST = new LSL_Types.Vector3(-1.0, -1.0, 0.0);
|
||||
touchNormal = new LSL_Types.Vector3();
|
||||
touchBinormal = new LSL_Types.Vector3();
|
||||
touchPos = new LSL_Types.Vector3();
|
||||
touchUV = new LSL_Types.Vector3(-1.0, -1.0, 0.0);
|
||||
touchFace = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the surface touch detected values
|
||||
*/
|
||||
public SurfaceTouchEventArgs SurfaceTouchArgs
|
||||
{
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
// Initialise to defaults if no value
|
||||
initializeSurfaceTouch();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the values from the touch data provided by the client
|
||||
touchST = new LSL_Types.Vector3(value.STCoord.X, value.STCoord.Y, value.STCoord.Z);
|
||||
touchUV = new LSL_Types.Vector3(value.UVCoord.X, value.UVCoord.Y, value.UVCoord.Z);
|
||||
touchNormal = new LSL_Types.Vector3(value.Normal.X, value.Normal.Y, value.Normal.Z);
|
||||
touchBinormal = new LSL_Types.Vector3(value.Binormal.X, value.Binormal.Y, value.Binormal.Z);
|
||||
touchPos = new LSL_Types.Vector3(value.Position.X, value.Position.Y, value.Position.Z);
|
||||
touchFace = value.FaceIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Populate(Scene scene)
|
||||
{
|
||||
SceneObjectPart part = scene.GetSceneObjectPart(Key);
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
}
|
||||
|
||||
public void touch_start(uint localID, uint originalID, Vector3 offsetPos,
|
||||
IClientAPI remoteClient)
|
||||
IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
|
||||
{
|
||||
// Add to queue for all scripts in ObjectID object
|
||||
DetectParams[] det = new DetectParams[1];
|
||||
|
@ -102,6 +102,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
det[0].LinkNum = originalPart.LinkNum;
|
||||
}
|
||||
|
||||
if (surfaceArgs != null)
|
||||
{
|
||||
det[0].SurfaceTouchArgs = surfaceArgs;
|
||||
}
|
||||
|
||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
||||
"touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
|
||||
det));
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace OpenSim.ScriptEngine.Components.DotNetEngine.Events
|
|||
RezScript(localID, itemID, script, startParam, postOnRez, engine);
|
||||
}
|
||||
|
||||
private void OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient)
|
||||
private void OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
|
||||
{
|
||||
// Add to queue for all scripts in ObjectID object
|
||||
DetectParams[] det = new DetectParams[1];
|
||||
|
@ -108,7 +108,10 @@ namespace OpenSim.ScriptEngine.Components.DotNetEngine.Events
|
|||
CurrentRegion.Scene.GetSceneObjectPart(originalID);
|
||||
det[0].LinkNum = originalPart.LinkNum;
|
||||
}
|
||||
|
||||
if (surfaceArgs != null)
|
||||
{
|
||||
det[0].SurfaceTouchArgs = surfaceArgs;
|
||||
}
|
||||
Shared.EventParams ep =
|
||||
new Shared.EventParams(localID, "touch_start", new Object[] {new LSL_Types.LSLInteger(1)}, det);
|
||||
CurrentRegion.Executors_Execute(ep);
|
||||
|
|
Loading…
Reference in New Issue