Import plumbing from Halcyon for camera data to physics engine.

Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
LSLKeyTest
Vegaslon 2016-08-26 12:44:14 -04:00 committed by UbitUmarov
parent 78fa544f0d
commit c918dd74da
2 changed files with 70 additions and 7 deletions

View File

@ -5429,10 +5429,23 @@ namespace OpenSim.Region.Framework.Scenes
}
}
CameraData physActor_OnPhysicsRequestingCameraData()
{
return new CameraData
{
Valid = true,
CameraPosition = this.CameraPosition,
CameraRotation = this.CameraRotation,
MouseLook = this.m_mouseLook,
HeadRotation = this.m_headrotation,
BodyRotation = this.m_bodyRot
};
}
public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID)
{
SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID);
if (p == null)
SceneObjectPart part = m_scene.GetSceneObjectPart(Obj_localID);
if (part == null)
return;
ControllingClient.SendTakeControls(controls, false, false);
@ -5442,7 +5455,7 @@ namespace OpenSim.Region.Framework.Scenes
obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
obj.eventControls = ScriptControlled.CONTROL_ZERO;
obj.objectID = p.ParentGroup.UUID;
obj.objectID = part.ParentGroup.UUID;
obj.itemID = Script_item_UUID;
if (pass_on == 0 && accept == 0)
{
@ -5470,17 +5483,43 @@ namespace OpenSim.Region.Framework.Scenes
{
IgnoredControls &= ~(ScriptControlled)controls;
if (scriptedcontrols.ContainsKey(Script_item_UUID))
scriptedcontrols.Remove(Script_item_UUID);
RemoveScriptFromControlNotifications(Script_item_UUID, part);
}
else
{
scriptedcontrols[Script_item_UUID] = obj;
AddScriptToControlNotifications(Script_item_UUID, part, ref obj);
}
}
ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true);
}
private void AddScriptToControlNotifications(OpenMetaverse.UUID Script_item_UUID, SceneObjectPart part, ref ScriptControllers obj)
{
scriptedcontrols[Script_item_UUID] = obj;
PhysicsActor physActor = part.ParentGroup.RootPart.PhysActor;
if (physActor != null)
{
physActor.OnPhysicsRequestingCameraData -= physActor_OnPhysicsRequestingCameraData;
physActor.OnPhysicsRequestingCameraData += physActor_OnPhysicsRequestingCameraData;
}
}
private void RemoveScriptFromControlNotifications(OpenMetaverse.UUID Script_item_UUID, SceneObjectPart part)
{
scriptedcontrols.Remove(Script_item_UUID);
if (part != null)
{
PhysicsActor physActor = part.ParentGroup.RootPart.PhysActor;
if (physActor != null)
{
physActor.OnPhysicsRequestingCameraData -= physActor_OnPhysicsRequestingCameraData;
}
}
}
public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID)
{
IgnoredControls = ScriptControlled.CONTROL_ZERO;
@ -5518,6 +5557,7 @@ namespace OpenSim.Region.Framework.Scenes
public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID)
{
ScriptControllers takecontrols;
SceneObjectPart part = m_scene.GetSceneObjectPart(Obj_localID);
lock (scriptedcontrols)
{
@ -5528,7 +5568,7 @@ namespace OpenSim.Region.Framework.Scenes
ControllingClient.SendTakeControls((int)sctc, false, false);
ControllingClient.SendTakeControls((int)sctc, true, false);
scriptedcontrols.Remove(Script_item_UUID);
RemoveScriptFromControlNotifications(Script_item_UUID, part);
IgnoredControls = ScriptControlled.CONTROL_ZERO;
foreach (ScriptControllers scData in scriptedcontrols.Values)
{

View File

@ -55,6 +55,16 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
Absolute
}
public struct CameraData
{
public Quaternion CameraRotation;
public Vector3 CameraPosition;
public bool MouseLook;
public bool Valid;
public Quaternion HeadRotation;
public Quaternion BodyRotation;
}
public struct ContactPoint
{
public Vector3 Position;
@ -159,13 +169,15 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
public delegate void RequestTerseUpdate();
public delegate void CollisionUpdate(EventArgs e);
public delegate void OutOfBounds(Vector3 pos);
public delegate CameraData GetCameraData();
// disable warning: public events
// disable warning: public events
#pragma warning disable 67
public event PositionUpdate OnPositionUpdate;
public event VelocityUpdate OnVelocityUpdate;
public event OrientationUpdate OnOrientationUpdate;
public event RequestTerseUpdate OnRequestTerseUpdate;
public event GetCameraData OnPhysicsRequestingCameraData;
/// <summary>
/// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event
@ -176,6 +188,17 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
public event OutOfBounds OnOutOfBounds;
#pragma warning restore 67
public CameraData TryGetCameraData()
{
GetCameraData handler = OnPhysicsRequestingCameraData;
if (handler != null)
{
return handler();
}
return new CameraData { Valid = false };
}
public static PhysicsActor Null
{
get { return new NullPhysicsActor(); }