aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorVegaslon2016-08-26 12:44:14 -0400
committerUbitUmarov2016-08-27 22:02:03 +0100
commitc918dd74dad732619d9496d02a1cc8c5eb51d8d0 (patch)
treed4dab43a3b1d51111e5c7f25190d47d188a61ec5
parent experimental function. Results still too volatile to be usefull (diff)
downloadopensim-SC-c918dd74dad732619d9496d02a1cc8c5eb51d8d0.zip
opensim-SC-c918dd74dad732619d9496d02a1cc8c5eb51d8d0.tar.gz
opensim-SC-c918dd74dad732619d9496d02a1cc8c5eb51d8d0.tar.bz2
opensim-SC-c918dd74dad732619d9496d02a1cc8c5eb51d8d0.tar.xz
Import plumbing from Halcyon for camera data to physics engine.
Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs52
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs25
2 files changed, 70 insertions, 7 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index db21dba..878381d 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -5429,10 +5429,23 @@ namespace OpenSim.Region.Framework.Scenes
5429 } 5429 }
5430 } 5430 }
5431 5431
5432 CameraData physActor_OnPhysicsRequestingCameraData()
5433 {
5434 return new CameraData
5435 {
5436 Valid = true,
5437 CameraPosition = this.CameraPosition,
5438 CameraRotation = this.CameraRotation,
5439 MouseLook = this.m_mouseLook,
5440 HeadRotation = this.m_headrotation,
5441 BodyRotation = this.m_bodyRot
5442 };
5443 }
5444
5432 public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) 5445 public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID)
5433 { 5446 {
5434 SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); 5447 SceneObjectPart part = m_scene.GetSceneObjectPart(Obj_localID);
5435 if (p == null) 5448 if (part == null)
5436 return; 5449 return;
5437 5450
5438 ControllingClient.SendTakeControls(controls, false, false); 5451 ControllingClient.SendTakeControls(controls, false, false);
@@ -5442,7 +5455,7 @@ namespace OpenSim.Region.Framework.Scenes
5442 obj.ignoreControls = ScriptControlled.CONTROL_ZERO; 5455 obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
5443 obj.eventControls = ScriptControlled.CONTROL_ZERO; 5456 obj.eventControls = ScriptControlled.CONTROL_ZERO;
5444 5457
5445 obj.objectID = p.ParentGroup.UUID; 5458 obj.objectID = part.ParentGroup.UUID;
5446 obj.itemID = Script_item_UUID; 5459 obj.itemID = Script_item_UUID;
5447 if (pass_on == 0 && accept == 0) 5460 if (pass_on == 0 && accept == 0)
5448 { 5461 {
@@ -5470,17 +5483,43 @@ namespace OpenSim.Region.Framework.Scenes
5470 { 5483 {
5471 IgnoredControls &= ~(ScriptControlled)controls; 5484 IgnoredControls &= ~(ScriptControlled)controls;
5472 if (scriptedcontrols.ContainsKey(Script_item_UUID)) 5485 if (scriptedcontrols.ContainsKey(Script_item_UUID))
5473 scriptedcontrols.Remove(Script_item_UUID); 5486 RemoveScriptFromControlNotifications(Script_item_UUID, part);
5474 } 5487 }
5475 else 5488 else
5476 { 5489 {
5477 scriptedcontrols[Script_item_UUID] = obj; 5490 AddScriptToControlNotifications(Script_item_UUID, part, ref obj);
5478 } 5491 }
5479 } 5492 }
5480 5493
5481 ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); 5494 ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true);
5482 } 5495 }
5483 5496
5497 private void AddScriptToControlNotifications(OpenMetaverse.UUID Script_item_UUID, SceneObjectPart part, ref ScriptControllers obj)
5498 {
5499 scriptedcontrols[Script_item_UUID] = obj;
5500
5501 PhysicsActor physActor = part.ParentGroup.RootPart.PhysActor;
5502 if (physActor != null)
5503 {
5504 physActor.OnPhysicsRequestingCameraData -= physActor_OnPhysicsRequestingCameraData;
5505 physActor.OnPhysicsRequestingCameraData += physActor_OnPhysicsRequestingCameraData;
5506 }
5507 }
5508
5509 private void RemoveScriptFromControlNotifications(OpenMetaverse.UUID Script_item_UUID, SceneObjectPart part)
5510 {
5511 scriptedcontrols.Remove(Script_item_UUID);
5512
5513 if (part != null)
5514 {
5515 PhysicsActor physActor = part.ParentGroup.RootPart.PhysActor;
5516 if (physActor != null)
5517 {
5518 physActor.OnPhysicsRequestingCameraData -= physActor_OnPhysicsRequestingCameraData;
5519 }
5520 }
5521 }
5522
5484 public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID) 5523 public void HandleForceReleaseControls(IClientAPI remoteClient, UUID agentID)
5485 { 5524 {
5486 IgnoredControls = ScriptControlled.CONTROL_ZERO; 5525 IgnoredControls = ScriptControlled.CONTROL_ZERO;
@@ -5518,6 +5557,7 @@ namespace OpenSim.Region.Framework.Scenes
5518 public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) 5557 public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID)
5519 { 5558 {
5520 ScriptControllers takecontrols; 5559 ScriptControllers takecontrols;
5560 SceneObjectPart part = m_scene.GetSceneObjectPart(Obj_localID);
5521 5561
5522 lock (scriptedcontrols) 5562 lock (scriptedcontrols)
5523 { 5563 {
@@ -5528,7 +5568,7 @@ namespace OpenSim.Region.Framework.Scenes
5528 ControllingClient.SendTakeControls((int)sctc, false, false); 5568 ControllingClient.SendTakeControls((int)sctc, false, false);
5529 ControllingClient.SendTakeControls((int)sctc, true, false); 5569 ControllingClient.SendTakeControls((int)sctc, true, false);
5530 5570
5531 scriptedcontrols.Remove(Script_item_UUID); 5571 RemoveScriptFromControlNotifications(Script_item_UUID, part);
5532 IgnoredControls = ScriptControlled.CONTROL_ZERO; 5572 IgnoredControls = ScriptControlled.CONTROL_ZERO;
5533 foreach (ScriptControllers scData in scriptedcontrols.Values) 5573 foreach (ScriptControllers scData in scriptedcontrols.Values)
5534 { 5574 {
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
index 04ccbf0..f140e09 100644
--- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
@@ -55,6 +55,16 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
55 Absolute 55 Absolute
56 } 56 }
57 57
58 public struct CameraData
59 {
60 public Quaternion CameraRotation;
61 public Vector3 CameraPosition;
62 public bool MouseLook;
63 public bool Valid;
64 public Quaternion HeadRotation;
65 public Quaternion BodyRotation;
66 }
67
58 public struct ContactPoint 68 public struct ContactPoint
59 { 69 {
60 public Vector3 Position; 70 public Vector3 Position;
@@ -159,13 +169,15 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
159 public delegate void RequestTerseUpdate(); 169 public delegate void RequestTerseUpdate();
160 public delegate void CollisionUpdate(EventArgs e); 170 public delegate void CollisionUpdate(EventArgs e);
161 public delegate void OutOfBounds(Vector3 pos); 171 public delegate void OutOfBounds(Vector3 pos);
172 public delegate CameraData GetCameraData();
162 173
163// disable warning: public events 174 // disable warning: public events
164#pragma warning disable 67 175#pragma warning disable 67
165 public event PositionUpdate OnPositionUpdate; 176 public event PositionUpdate OnPositionUpdate;
166 public event VelocityUpdate OnVelocityUpdate; 177 public event VelocityUpdate OnVelocityUpdate;
167 public event OrientationUpdate OnOrientationUpdate; 178 public event OrientationUpdate OnOrientationUpdate;
168 public event RequestTerseUpdate OnRequestTerseUpdate; 179 public event RequestTerseUpdate OnRequestTerseUpdate;
180 public event GetCameraData OnPhysicsRequestingCameraData;
169 181
170 /// <summary> 182 /// <summary>
171 /// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event 183 /// Subscribers to this event must synchronously handle the dictionary of collisions received, since the event
@@ -176,6 +188,17 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
176 public event OutOfBounds OnOutOfBounds; 188 public event OutOfBounds OnOutOfBounds;
177#pragma warning restore 67 189#pragma warning restore 67
178 190
191 public CameraData TryGetCameraData()
192 {
193 GetCameraData handler = OnPhysicsRequestingCameraData;
194 if (handler != null)
195 {
196 return handler();
197 }
198
199 return new CameraData { Valid = false };
200 }
201
179 public static PhysicsActor Null 202 public static PhysicsActor Null
180 { 203 {
181 get { return new NullPhysicsActor(); } 204 get { return new NullPhysicsActor(); }