aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs57
1 files changed, 34 insertions, 23 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 2ca218c..3378ead 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2313,25 +2313,23 @@ namespace OpenSim.Region.Framework.Scenes
2313 { 2313 {
2314 Vector3 posAdjusted = AbsolutePosition; 2314 Vector3 posAdjusted = AbsolutePosition;
2315// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; 2315// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f;
2316 // not good for tiny or huge avatars
2316 posAdjusted.Z += 1.0f; // viewer current camera focus point 2317 posAdjusted.Z += 1.0f; // viewer current camera focus point
2317 Vector3 tocam = CameraPosition - posAdjusted; 2318 Vector3 tocam = CameraPosition - posAdjusted;
2318 tocam.X = (float)Math.Round(tocam.X, 1);
2319 tocam.Y = (float)Math.Round(tocam.Y, 1);
2320 tocam.Z = (float)Math.Round(tocam.Z, 1);
2321 2319
2322 float distTocamlen = tocam.Length(); 2320 float distTocamlen = tocam.LengthSquared();
2323 if (distTocamlen > 0.3f) 2321 if (distTocamlen > 0.08f && distTocamlen < 400)
2324 { 2322 {
2323 distTocamlen = (float)Math.Sqrt(distTocamlen);
2325 tocam *= (1.0f / distTocamlen); 2324 tocam *= (1.0f / distTocamlen);
2326 posAdjusted.X = (float)Math.Round(posAdjusted.X, 1);
2327 posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1);
2328 posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1);
2329 2325
2330 m_doingCamRayCast = true; 2326 m_doingCamRayCast = true;
2331 m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); 2327 m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback);
2328 return;
2332 } 2329 }
2333 } 2330 }
2334 else if (CameraConstraintActive) 2331
2332 if (CameraConstraintActive)
2335 { 2333 {
2336 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... 2334 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right...
2337 UpdateCameraCollisionPlane(plane); 2335 UpdateCameraCollisionPlane(plane);
@@ -2350,17 +2348,14 @@ namespace OpenSim.Region.Framework.Scenes
2350 2348
2351 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) 2349 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal)
2352 { 2350 {
2353 const float POSITION_TOLERANCE = 0.02f; 2351// const float POSITION_TOLERANCE = 0.02f;
2354 const float ROTATION_TOLERANCE = 0.02f; 2352// const float ROTATION_TOLERANCE = 0.02f;
2355 2353
2356 m_doingCamRayCast = false;
2357 if (hitYN && localid != LocalId) 2354 if (hitYN && localid != LocalId)
2358 { 2355 {
2359 SceneObjectGroup group = m_scene.GetGroupByPrim(localid); 2356 if (localid != 0)
2360 bool IsPrim = group != null;
2361 if (IsPrim)
2362 { 2357 {
2363 SceneObjectPart part = group.GetPart(localid); 2358 SceneObjectPart part = m_scene.GetSceneObjectPart(localid);
2364 if (part != null && !part.VolumeDetectActive) 2359 if (part != null && !part.VolumeDetectActive)
2365 { 2360 {
2366 CameraConstraintActive = true; 2361 CameraConstraintActive = true;
@@ -2393,13 +2388,16 @@ namespace OpenSim.Region.Framework.Scenes
2393 UpdateCameraCollisionPlane(plane); 2388 UpdateCameraCollisionPlane(plane);
2394 } 2389 }
2395 } 2390 }
2396 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 2391// else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
2397 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) 2392// !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
2393 else if(CameraConstraintActive)
2398 { 2394 {
2399 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... 2395 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right...
2400 UpdateCameraCollisionPlane(plane); 2396 UpdateCameraCollisionPlane(plane);
2401 CameraConstraintActive = false; 2397 CameraConstraintActive = false;
2402 } 2398 }
2399
2400 m_doingCamRayCast = false;
2403 } 2401 }
2404 2402
2405 /// <summary> 2403 /// <summary>
@@ -2767,7 +2765,7 @@ namespace OpenSim.Region.Framework.Scenes
2767 // Use these three vectors to figure out what the agent is looking at 2765 // Use these three vectors to figure out what the agent is looking at
2768 // Convert it to a Matrix and/or Quaternion 2766 // Convert it to a Matrix and/or Quaternion
2769 2767
2770 // this my need lock 2768 // this may need lock
2771 CameraAtAxis = agentData.CameraAtAxis; 2769 CameraAtAxis = agentData.CameraAtAxis;
2772 CameraLeftAxis = agentData.CameraLeftAxis; 2770 CameraLeftAxis = agentData.CameraLeftAxis;
2773 CameraUpAxis = agentData.CameraUpAxis; 2771 CameraUpAxis = agentData.CameraUpAxis;
@@ -2781,11 +2779,24 @@ namespace OpenSim.Region.Framework.Scenes
2781 2779
2782 DrawDistance = agentData.Far; 2780 DrawDistance = agentData.Far;
2783 2781
2784 // Check if Client has camera in 'follow cam' or 'build' mode.
2785 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
2786 2782
2787 m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) 2783 // Check if Client has camera in 'follow cam' or 'build' mode.
2788 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; 2784// Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
2785 m_followCamAuto = false;
2786 if(!m_mouseLook)
2787 {
2788 if((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f))
2789 {
2790 Vector3 camdif = new Vector3(1f, 0f, 0f) * Rotation;
2791 float ftmp = camdif.X - CameraAtAxis.X;
2792 if(Math.Abs(ftmp) < 0.1f)
2793 {
2794 ftmp = camdif.Y - CameraAtAxis.Y;
2795 if(Math.Abs(ftmp) < 0.1f)
2796 m_followCamAuto = true;
2797 }
2798 }
2799 }
2789 2800
2790 if(agentData.NeedsCameraCollision) 2801 if(agentData.NeedsCameraCollision)
2791 checkCameraCollision(); 2802 checkCameraCollision();