aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs118
2 files changed, 69 insertions, 50 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c99e37e..23006f2 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2977,6 +2977,7 @@ namespace OpenSim.Region.Framework.Scenes
2977 // start the scripts again (since this is done in RezAttachments()). 2977 // start the scripts again (since this is done in RezAttachments()).
2978 // XXX: This is convoluted. 2978 // XXX: This is convoluted.
2979 sp.IsChildAgent = false; 2979 sp.IsChildAgent = false;
2980 sp.IsLoggingIn = true;
2980 2981
2981 if (AttachmentsModule != null) 2982 if (AttachmentsModule != null)
2982 Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); 2983 Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); });
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4504e18..a9195f7 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -227,8 +227,6 @@ namespace OpenSim.Region.Framework.Scenes
227 /// </summary> 227 /// </summary>
228 public bool LandAtTarget { get; private set; } 228 public bool LandAtTarget { get; private set; }
229 229
230 private bool m_followCamAuto;
231
232 private int m_movementUpdateCount; 230 private int m_movementUpdateCount;
233 private const int NumMovementsBetweenRayCast = 5; 231 private const int NumMovementsBetweenRayCast = 5;
234 232
@@ -357,6 +355,9 @@ namespace OpenSim.Region.Framework.Scenes
357 /// </summary> 355 /// </summary>
358 protected Vector3 m_lastCameraPosition; 356 protected Vector3 m_lastCameraPosition;
359 357
358 private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1);
359 private bool m_doingCamRayCast = false;
360
360 public Vector3 CameraPosition { get; set; } 361 public Vector3 CameraPosition { get; set; }
361 362
362 public Quaternion CameraRotation 363 public Quaternion CameraRotation
@@ -606,6 +607,7 @@ namespace OpenSim.Region.Framework.Scenes
606 } 607 }
607 608
608 public bool IsChildAgent { get; set; } 609 public bool IsChildAgent { get; set; }
610 public bool IsLoggingIn { get; set; }
609 611
610 /// <summary> 612 /// <summary>
611 /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. 613 /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero.
@@ -742,6 +744,7 @@ namespace OpenSim.Region.Framework.Scenes
742 AttachmentsSyncLock = new Object(); 744 AttachmentsSyncLock = new Object();
743 AllowMovement = true; 745 AllowMovement = true;
744 IsChildAgent = true; 746 IsChildAgent = true;
747 IsLoggingIn = false;
745 m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; 748 m_sendCoarseLocationsMethod = SendCoarseLocationsDefault;
746 Animator = new ScenePresenceAnimator(this); 749 Animator = new ScenePresenceAnimator(this);
747 PresenceType = type; 750 PresenceType = type;
@@ -914,6 +917,7 @@ namespace OpenSim.Region.Framework.Scenes
914 else 917 else
915 { 918 {
916 IsChildAgent = false; 919 IsChildAgent = false;
920 IsLoggingIn = false;
917 } 921 }
918 922
919 923
@@ -1407,36 +1411,43 @@ namespace OpenSim.Region.Framework.Scenes
1407 /// <param name="collisionPoint"></param> 1411 /// <param name="collisionPoint"></param>
1408 /// <param name="localid"></param> 1412 /// <param name="localid"></param>
1409 /// <param name="distance"></param> 1413 /// <param name="distance"></param>
1414 ///
1415
1416 private void UpdateCameraCollisionPlane(Vector4 plane)
1417 {
1418 if (m_lastCameraCollisionPlane != plane)
1419 {
1420 m_lastCameraCollisionPlane = plane;
1421 ControllingClient.SendCameraConstraint(plane);
1422 }
1423 }
1424
1410 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) 1425 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal)
1411 { 1426 {
1412 const float POSITION_TOLERANCE = 0.02f; 1427 const float POSITION_TOLERANCE = 0.02f;
1413 const float VELOCITY_TOLERANCE = 0.02f;
1414 const float ROTATION_TOLERANCE = 0.02f; 1428 const float ROTATION_TOLERANCE = 0.02f;
1415 1429
1416 if (m_followCamAuto) 1430 m_doingCamRayCast = false;
1431 if (hitYN && localid != LocalId)
1417 { 1432 {
1418 if (hitYN && localid != LocalId) 1433 CameraConstraintActive = true;
1419 { 1434 pNormal.X = (float)Math.Round(pNormal.X, 2);
1420 1435 pNormal.Y = (float)Math.Round(pNormal.Y, 2);
1421 CameraConstraintActive = true; 1436 pNormal.Z = (float)Math.Round(pNormal.Z, 2);
1422 //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); 1437 pNormal.Normalize();
1423 1438 collisionPoint.X = (float)Math.Round(collisionPoint.X, 1);
1424 Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); 1439 collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1);
1425 ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); 1440 collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1);
1426 } 1441
1427 else 1442 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal));
1428 { 1443 UpdateCameraCollisionPlane(plane);
1429 if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 1444 }
1430 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || 1445 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
1431 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) 1446 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
1432 { 1447 {
1433 if (CameraConstraintActive) 1448 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right...
1434 { 1449 UpdateCameraCollisionPlane(plane);
1435 ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); 1450 CameraConstraintActive = false;
1436 CameraConstraintActive = false;
1437 }
1438 }
1439 }
1440 } 1451 }
1441 } 1452 }
1442 1453
@@ -1511,12 +1522,6 @@ namespace OpenSim.Region.Framework.Scenes
1511 // DrawDistance = agentData.Far; 1522 // DrawDistance = agentData.Far;
1512 DrawDistance = Scene.DefaultDrawDistance; 1523 DrawDistance = Scene.DefaultDrawDistance;
1513 1524
1514 // Check if Client has camera in 'follow cam' or 'build' mode.
1515 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
1516
1517 m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f)
1518 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
1519
1520 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; 1525 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
1521 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; 1526 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
1522 1527
@@ -1536,24 +1541,38 @@ namespace OpenSim.Region.Framework.Scenes
1536 StandUp(); 1541 StandUp();
1537 } 1542 }
1538 1543
1539 //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto);
1540 // Raycast from the avatar's head to the camera to see if there's anything blocking the view 1544 // Raycast from the avatar's head to the camera to see if there's anything blocking the view
1541 if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) 1545 // this exclude checks may not be complete
1546
1547 if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast())
1542 { 1548 {
1543 if (m_followCamAuto) 1549 if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0)
1544 { 1550 {
1545 // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; 1551 Vector3 posAdjusted = AbsolutePosition;
1546 // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); 1552// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f;
1547 1553 posAdjusted.Z += 1.0f; // viewer current camera focus point
1548 Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; 1554 Vector3 tocam = CameraPosition - posAdjusted;
1549 Vector3 distTocam = CameraPosition - posAdjusted; 1555 tocam.X = (float)Math.Round(tocam.X, 1);
1550 float distTocamlen = distTocam.Length(); 1556 tocam.Y = (float)Math.Round(tocam.Y, 1);
1551 if (distTocamlen > 0) 1557 tocam.Z = (float)Math.Round(tocam.Z, 1);
1558
1559 float distTocamlen = tocam.Length();
1560 if (distTocamlen > 0.3f)
1552 { 1561 {
1553 distTocam *= 1.0f / distTocamlen; 1562 tocam *= (1.0f / distTocamlen);
1554 m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); 1563 posAdjusted.X = (float)Math.Round(posAdjusted.X, 1);
1564 posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1);
1565 posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1);
1566
1567 m_doingCamRayCast = true;
1568 m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback);
1555 } 1569 }
1556 1570 }
1571 else if (CameraConstraintActive && (m_mouseLook || ParentID != 0))
1572 {
1573 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right...
1574 UpdateCameraCollisionPlane(plane);
1575 CameraConstraintActive = false;
1557 } 1576 }
1558 } 1577 }
1559 1578
@@ -2525,13 +2544,10 @@ namespace OpenSim.Region.Framework.Scenes
2525 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to 2544 // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to
2526 // grab the latest PhysicsActor velocity, whereas m_velocity is often 2545 // grab the latest PhysicsActor velocity, whereas m_velocity is often
2527 // storing a requested force instead of an actual traveling velocity 2546 // storing a requested force instead of an actual traveling velocity
2528 if (Appearance.AvatarSize != m_lastSize) 2547 if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn)
2529 {
2530 m_lastSize = Appearance.AvatarSize;
2531 SendAvatarDataToAllAgents(); 2548 SendAvatarDataToAllAgents();
2532 }
2533 2549
2534 else if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || 2550 if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
2535 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || 2551 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
2536 !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) 2552 !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))
2537 { 2553 {
@@ -2722,6 +2738,8 @@ namespace OpenSim.Region.Framework.Scenes
2722 return; 2738 return;
2723 } 2739 }
2724 2740
2741 m_lastSize = Appearance.AvatarSize;
2742
2725 int count = 0; 2743 int count = 0;
2726 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2744 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2727 { 2745 {