aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorUbitUmarov2017-08-25 20:53:07 +0100
committerUbitUmarov2017-08-25 20:53:07 +0100
commitdfdc3e3adfc787c10a5235cf37be47ec8a3b7c7e (patch)
tree09bcb51e1d41236a585b720a818244cb7a789ec7 /OpenSim/Region/Framework
parentfrozen avatars should not do local teleports. Possible none should not be all... (diff)
downloadopensim-SC-dfdc3e3adfc787c10a5235cf37be47ec8a3b7c7e.zip
opensim-SC-dfdc3e3adfc787c10a5235cf37be47ec8a3b7c7e.tar.gz
opensim-SC-dfdc3e3adfc787c10a5235cf37be47ec8a3b7c7e.tar.bz2
opensim-SC-dfdc3e3adfc787c10a5235cf37be47ec8a3b7c7e.tar.xz
change camera view constraint. we need to do it a lot more :(
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs90
1 files changed, 40 insertions, 50 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index f9c7031..9cceb06 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -290,8 +290,6 @@ namespace OpenSim.Region.Framework.Scenes
290 private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); 290 private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f);
291 private bool SentInitialData = false; 291 private bool SentInitialData = false;
292 292
293 private bool m_followCamAuto = false;
294
295 private int m_userFlags; 293 private int m_userFlags;
296 public int UserFlags 294 public int UserFlags
297 { 295 {
@@ -344,6 +342,11 @@ namespace OpenSim.Region.Framework.Scenes
344 private Vector3 m_lastChildAgentUpdatePosition; 342 private Vector3 m_lastChildAgentUpdatePosition;
345// private Vector3 m_lastChildAgentUpdateCamPosition; 343// private Vector3 m_lastChildAgentUpdateCamPosition;
346 344
345 private Vector3 m_lastCameraRayCastCam;
346 private Vector3 m_lastCameraRayCastPos;
347
348 private float m_FOV = 1.04f;
349
347 private const int LAND_VELOCITYMAG_MAX = 12; 350 private const int LAND_VELOCITYMAG_MAX = 12;
348 351
349 private const float FLY_ROLL_MAX_RADIANS = 1.1f; 352 private const float FLY_ROLL_MAX_RADIANS = 1.1f;
@@ -374,9 +377,6 @@ namespace OpenSim.Region.Framework.Scenes
374 /// </summary> 377 /// </summary>
375 public bool LandAtTarget { get; private set; } 378 public bool LandAtTarget { get; private set; }
376 379
377 private int m_movementUpdateCount;
378 private const int NumMovementsBetweenRayCast = 5;
379
380 private bool CameraConstraintActive; 380 private bool CameraConstraintActive;
381 381
382 private object m_collisionEventLock = new Object(); 382 private object m_collisionEventLock = new Object();
@@ -1159,6 +1159,7 @@ namespace OpenSim.Region.Framework.Scenes
1159 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; 1159 ControllingClient.OnForceReleaseControls += HandleForceReleaseControls;
1160 ControllingClient.OnAutoPilotGo += MoveToTarget; 1160 ControllingClient.OnAutoPilotGo += MoveToTarget;
1161 ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; 1161 ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles;
1162// ControllingClient.OnAgentFOV += HandleAgentFOV;
1162 1163
1163 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 1164 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
1164 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 1165 // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
@@ -1178,6 +1179,7 @@ namespace OpenSim.Region.Framework.Scenes
1178 ControllingClient.OnForceReleaseControls -= HandleForceReleaseControls; 1179 ControllingClient.OnForceReleaseControls -= HandleForceReleaseControls;
1179 ControllingClient.OnAutoPilotGo -= MoveToTarget; 1180 ControllingClient.OnAutoPilotGo -= MoveToTarget;
1180 ControllingClient.OnUpdateThrottles -= RaiseUpdateThrottles; 1181 ControllingClient.OnUpdateThrottles -= RaiseUpdateThrottles;
1182// ControllingClient.OnAgentFOV += HandleAgentFOV;
1181 } 1183 }
1182 1184
1183 private void SetDirectionVectors() 1185 private void SetDirectionVectors()
@@ -2352,34 +2354,41 @@ namespace OpenSim.Region.Framework.Scenes
2352 2354
2353 private void checkCameraCollision() 2355 private void checkCameraCollision()
2354 { 2356 {
2355 if(!m_scene.PhysicsScene.SupportsRayCast()) 2357 if(m_doingCamRayCast || !m_scene.PhysicsScene.SupportsRayCast())
2356 return; 2358 return;
2357 2359
2358 ++m_movementUpdateCount; 2360 if(m_mouseLook || ParentID != 0)
2359 if (m_movementUpdateCount < 1) 2361 {
2360 m_movementUpdateCount = 1; 2362 if (CameraConstraintActive)
2363 {
2364 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right...
2365 UpdateCameraCollisionPlane(plane);
2366 CameraConstraintActive = false;
2367 }
2368 return;
2369 }
2370
2371 Vector3 posAdjusted = AbsolutePosition;
2372 posAdjusted.Z += 1.0f; // viewer current camera focus point
2361 2373
2362 if (m_doingCamRayCast || m_movementUpdateCount % NumMovementsBetweenRayCast != 0) 2374 if(posAdjusted.ApproxEquals(m_lastCameraRayCastPos, 0.2f) &&
2375 CameraPosition.ApproxEquals(m_lastCameraRayCastCam, 0.2f))
2363 return; 2376 return;
2364 2377
2365 if (m_followCamAuto && !m_mouseLook) 2378 m_lastCameraRayCastCam = CameraPosition;
2366 { 2379 m_lastCameraRayCastPos = posAdjusted;
2367 Vector3 posAdjusted = AbsolutePosition;
2368// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f;
2369 // not good for tiny or huge avatars
2370 posAdjusted.Z += 1.0f; // viewer current camera focus point
2371 Vector3 tocam = CameraPosition - posAdjusted;
2372 2380
2373 float distTocamlen = tocam.LengthSquared(); 2381 Vector3 tocam = CameraPosition - posAdjusted;
2374 if (distTocamlen > 0.01f && distTocamlen < 400)
2375 {
2376 distTocamlen = (float)Math.Sqrt(distTocamlen);
2377 tocam *= (1.0f / distTocamlen);
2378 2382
2379 m_doingCamRayCast = true; 2383 float distTocamlen = tocam.LengthSquared();
2380 m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); 2384 if (distTocamlen > 0.01f && distTocamlen < 400)
2381 return; 2385 {
2382 } 2386 distTocamlen = (float)Math.Sqrt(distTocamlen);
2387 tocam *= (1.0f / distTocamlen);
2388
2389 m_doingCamRayCast = true;
2390 m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback);
2391 return;
2383 } 2392 }
2384 2393
2385 if (CameraConstraintActive) 2394 if (CameraConstraintActive)
@@ -2401,9 +2410,6 @@ namespace OpenSim.Region.Framework.Scenes
2401 2410
2402 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) 2411 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal)
2403 { 2412 {
2404// const float POSITION_TOLERANCE = 0.02f;
2405// const float ROTATION_TOLERANCE = 0.02f;
2406
2407 if (hitYN && localid != LocalId) 2413 if (hitYN && localid != LocalId)
2408 { 2414 {
2409 if (localid != 0) 2415 if (localid != 0)
@@ -2441,8 +2447,6 @@ namespace OpenSim.Region.Framework.Scenes
2441 UpdateCameraCollisionPlane(plane); 2447 UpdateCameraCollisionPlane(plane);
2442 } 2448 }
2443 } 2449 }
2444// else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
2445// !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
2446 else if(CameraConstraintActive) 2450 else if(CameraConstraintActive)
2447 { 2451 {
2448 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... 2452 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right...
@@ -2538,7 +2542,7 @@ namespace OpenSim.Region.Framework.Scenes
2538 2542
2539 // Raycast from the avatar's head to the camera to see if there's anything blocking the view 2543 // Raycast from the avatar's head to the camera to see if there's anything blocking the view
2540 // this exclude checks may not be complete 2544 // this exclude checks may not be complete
2541 if(agentData.NeedsCameraCollision && ParentID == 0) // condition parentID may be wrong 2545 if(agentData.NeedsCameraCollision) // condition parentID may be wrong
2542 checkCameraCollision(); 2546 checkCameraCollision();
2543 2547
2544 uint flagsForScripts = (uint)flags; 2548 uint flagsForScripts = (uint)flags;
@@ -2807,6 +2811,10 @@ namespace OpenSim.Region.Framework.Scenes
2807// m_scene.EventManager.TriggerOnClientMovement(this); 2811// m_scene.EventManager.TriggerOnClientMovement(this);
2808 } 2812 }
2809 2813
2814 private void HandleAgentFOV(IClientAPI remoteClient, float _fov)
2815 {
2816 m_FOV = _fov;
2817 }
2810 2818
2811 /// <summary> 2819 /// <summary>
2812 /// This is the event handler for client cameras. If a client is moving, or moving the camera, this event is triggering. 2820 /// This is the event handler for client cameras. If a client is moving, or moving the camera, this event is triggering.
@@ -2843,24 +2851,6 @@ namespace OpenSim.Region.Framework.Scenes
2843 Quaternion camRot = Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis); 2851 Quaternion camRot = Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis);
2844 CameraRotation = camRot; 2852 CameraRotation = camRot;
2845 2853
2846 // Check if Client has camera in 'follow cam' or 'build' mode.
2847// Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
2848 m_followCamAuto = false;
2849 if(!m_mouseLook)
2850 {
2851 if((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.99f))
2852 {
2853 Vector3 camdif = new Vector3(1f, 0f, 0f) * Rotation;
2854 float ftmp = camdif.X - CameraAtAxis.X;
2855 if(Math.Abs(ftmp) < 0.1f)
2856 {
2857 ftmp = camdif.Y - CameraAtAxis.Y;
2858 if(Math.Abs(ftmp) < 0.1f)
2859 m_followCamAuto = true;
2860 }
2861 }
2862 }
2863
2864 if(agentData.NeedsCameraCollision) 2854 if(agentData.NeedsCameraCollision)
2865 checkCameraCollision(); 2855 checkCameraCollision();
2866 2856