aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2013-01-08 12:14:01 +0100
committerMelanie2013-01-08 12:14:01 +0100
commit4cd1fd74855c61cee0d175b159c4cb9b4144d14c (patch)
tree3656f49a2c4f9327f9c6440c15f0dd2966d6486c
parentRemove sending AvatarData because this also happens on login, where it chokes (diff)
parent put back position and rot change check before sending releasing plane constrain (diff)
downloadopensim-SC_OLD-4cd1fd74855c61cee0d175b159c4cb9b4144d14c.zip
opensim-SC_OLD-4cd1fd74855c61cee0d175b159c4cb9b4144d14c.tar.gz
opensim-SC_OLD-4cd1fd74855c61cee0d175b159c4cb9b4144d14c.tar.bz2
opensim-SC_OLD-4cd1fd74855c61cee0d175b159c4cb9b4144d14c.tar.xz
Merge branch 'ubitwork' into avination
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs106
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs41
2 files changed, 90 insertions, 57 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index b6407d2..be3a39a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -225,8 +225,6 @@ namespace OpenSim.Region.Framework.Scenes
225 /// </summary> 225 /// </summary>
226 public bool LandAtTarget { get; private set; } 226 public bool LandAtTarget { get; private set; }
227 227
228 private bool m_followCamAuto;
229
230 private int m_movementUpdateCount; 228 private int m_movementUpdateCount;
231 private const int NumMovementsBetweenRayCast = 5; 229 private const int NumMovementsBetweenRayCast = 5;
232 230
@@ -355,6 +353,9 @@ namespace OpenSim.Region.Framework.Scenes
355 /// </summary> 353 /// </summary>
356 protected Vector3 m_lastCameraPosition; 354 protected Vector3 m_lastCameraPosition;
357 355
356 private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1);
357 private bool m_doingCamRayCast = false;
358
358 public Vector3 CameraPosition { get; set; } 359 public Vector3 CameraPosition { get; set; }
359 360
360 public Quaternion CameraRotation 361 public Quaternion CameraRotation
@@ -1405,36 +1406,43 @@ namespace OpenSim.Region.Framework.Scenes
1405 /// <param name="collisionPoint"></param> 1406 /// <param name="collisionPoint"></param>
1406 /// <param name="localid"></param> 1407 /// <param name="localid"></param>
1407 /// <param name="distance"></param> 1408 /// <param name="distance"></param>
1409 ///
1410
1411 private void UpdateCameraCollisionPlane(Vector4 plane)
1412 {
1413 if (m_lastCameraCollisionPlane != plane)
1414 {
1415 m_lastCameraCollisionPlane = plane;
1416 ControllingClient.SendCameraConstraint(plane);
1417 }
1418 }
1419
1408 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) 1420 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal)
1409 { 1421 {
1410 const float POSITION_TOLERANCE = 0.02f; 1422 const float POSITION_TOLERANCE = 0.02f;
1411 const float VELOCITY_TOLERANCE = 0.02f;
1412 const float ROTATION_TOLERANCE = 0.02f; 1423 const float ROTATION_TOLERANCE = 0.02f;
1413 1424
1414 if (m_followCamAuto) 1425 m_doingCamRayCast = false;
1426 if (hitYN && localid != LocalId)
1415 { 1427 {
1416 if (hitYN && localid != LocalId) 1428 CameraConstraintActive = true;
1417 { 1429 pNormal.X = (float)Math.Round(pNormal.X, 2);
1418 1430 pNormal.Y = (float)Math.Round(pNormal.Y, 2);
1419 CameraConstraintActive = true; 1431 pNormal.Z = (float)Math.Round(pNormal.Z, 2);
1420 //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); 1432 pNormal.Normalize();
1421 1433 collisionPoint.X = (float)Math.Round(collisionPoint.X, 1);
1422 Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); 1434 collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1);
1423 ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); 1435 collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1);
1424 } 1436
1425 else 1437 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal));
1426 { 1438 UpdateCameraCollisionPlane(plane);
1427 if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 1439 }
1428 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || 1440 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
1429 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) 1441 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
1430 { 1442 {
1431 if (CameraConstraintActive) 1443 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right...
1432 { 1444 UpdateCameraCollisionPlane(plane);
1433 ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); 1445 CameraConstraintActive = false;
1434 CameraConstraintActive = false;
1435 }
1436 }
1437 }
1438 } 1446 }
1439 } 1447 }
1440 1448
@@ -1509,12 +1517,6 @@ namespace OpenSim.Region.Framework.Scenes
1509 // DrawDistance = agentData.Far; 1517 // DrawDistance = agentData.Far;
1510 DrawDistance = Scene.DefaultDrawDistance; 1518 DrawDistance = Scene.DefaultDrawDistance;
1511 1519
1512 // Check if Client has camera in 'follow cam' or 'build' mode.
1513 Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation);
1514
1515 m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f)
1516 && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false;
1517
1518 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; 1520 m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0;
1519 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; 1521 m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0;
1520 1522
@@ -1534,24 +1536,38 @@ namespace OpenSim.Region.Framework.Scenes
1534 StandUp(); 1536 StandUp();
1535 } 1537 }
1536 1538
1537 //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto);
1538 // Raycast from the avatar's head to the camera to see if there's anything blocking the view 1539 // Raycast from the avatar's head to the camera to see if there's anything blocking the view
1539 if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) 1540 // this exclude checks may not be complete
1541
1542 if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast())
1540 { 1543 {
1541 if (m_followCamAuto) 1544 if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0)
1542 { 1545 {
1543 // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; 1546 Vector3 posAdjusted = AbsolutePosition;
1544 // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); 1547// posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f;
1545 1548 posAdjusted.Z += 1.0f; // viewer current camera focus point
1546 Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; 1549 Vector3 tocam = CameraPosition - posAdjusted;
1547 Vector3 distTocam = CameraPosition - posAdjusted; 1550 tocam.X = (float)Math.Round(tocam.X, 1);
1548 float distTocamlen = distTocam.Length(); 1551 tocam.Y = (float)Math.Round(tocam.Y, 1);
1549 if (distTocamlen > 0) 1552 tocam.Z = (float)Math.Round(tocam.Z, 1);
1553
1554 float distTocamlen = tocam.Length();
1555 if (distTocamlen > 0.3f)
1550 { 1556 {
1551 distTocam *= 1.0f / distTocamlen; 1557 tocam *= (1.0f / distTocamlen);
1552 m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); 1558 posAdjusted.X = (float)Math.Round(posAdjusted.X, 1);
1559 posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1);
1560 posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1);
1561
1562 m_doingCamRayCast = true;
1563 m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback);
1553 } 1564 }
1554 1565 }
1566 else if (CameraConstraintActive && (m_mouseLook || ParentID != 0))
1567 {
1568 Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right...
1569 UpdateCameraCollisionPlane(plane);
1570 CameraConstraintActive = false;
1555 } 1571 }
1556 } 1572 }
1557 1573
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
index 6e9281b..7fe3109 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs
@@ -173,8 +173,13 @@ namespace OpenSim.Region.Physics.OdePlugin
173 d.GeomRaySetClosestHit(ray, closestHit); 173 d.GeomRaySetClosestHit(ray, closestHit);
174 174
175 if (req.callbackMethod is RaycastCallback) 175 if (req.callbackMethod is RaycastCallback)
176 {
176 // if we only want one get only one per Collision pair saving memory 177 // if we only want one get only one per Collision pair saving memory
177 CurrentRayFilter |= RayFilterFlags.ClosestHit; 178 CurrentRayFilter |= RayFilterFlags.ClosestHit;
179 d.GeomRaySetClosestHit(ray, 1);
180 }
181 else
182 d.GeomRaySetClosestHit(ray, closestHit);
178 } 183 }
179 184
180 if ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0) 185 if ((CurrentRayFilter & RayFilterFlags.ContactsUnImportant) != 0)
@@ -555,10 +560,13 @@ namespace OpenSim.Region.Physics.OdePlugin
555 560
556 ContactResult collisionresult = new ContactResult(); 561 ContactResult collisionresult = new ContactResult();
557 collisionresult.ConsumerID = ID; 562 collisionresult.ConsumerID = ID;
558 collisionresult.Pos = new Vector3(curcontact.pos.X, curcontact.pos.Y, curcontact.pos.Z); 563 collisionresult.Pos.X = curcontact.pos.X;
564 collisionresult.Pos.Y = curcontact.pos.Y;
565 collisionresult.Pos.Z = curcontact.pos.Z;
559 collisionresult.Depth = curcontact.depth; 566 collisionresult.Depth = curcontact.depth;
560 collisionresult.Normal = new Vector3(curcontact.normal.X, curcontact.normal.Y, 567 collisionresult.Normal.X = curcontact.normal.X;
561 curcontact.normal.Z); 568 collisionresult.Normal.Y = curcontact.normal.Y;
569 collisionresult.Normal.Z = curcontact.normal.Z;
562 lock (m_contactResults) 570 lock (m_contactResults)
563 { 571 {
564 m_contactResults.Add(collisionresult); 572 m_contactResults.Add(collisionresult);
@@ -581,10 +589,13 @@ namespace OpenSim.Region.Physics.OdePlugin
581 589
582 if (curcontact.depth < collisionresult.Depth) 590 if (curcontact.depth < collisionresult.Depth)
583 { 591 {
584 collisionresult.Pos = new Vector3(curcontact.pos.X, curcontact.pos.Y, curcontact.pos.Z); 592 collisionresult.Pos.X = curcontact.pos.X;
593 collisionresult.Pos.Y = curcontact.pos.Y;
594 collisionresult.Pos.Z = curcontact.pos.Z;
585 collisionresult.Depth = curcontact.depth; 595 collisionresult.Depth = curcontact.depth;
586 collisionresult.Normal = new Vector3(curcontact.normal.X, curcontact.normal.Y, 596 collisionresult.Normal.X = curcontact.normal.X;
587 curcontact.normal.Z); 597 collisionresult.Normal.Y = curcontact.normal.Y;
598 collisionresult.Normal.Z = curcontact.normal.Z;
588 } 599 }
589 } 600 }
590 601
@@ -699,10 +710,13 @@ namespace OpenSim.Region.Physics.OdePlugin
699 710
700 ContactResult collisionresult = new ContactResult(); 711 ContactResult collisionresult = new ContactResult();
701 collisionresult.ConsumerID = ID; 712 collisionresult.ConsumerID = ID;
702 collisionresult.Pos = new Vector3(curcontact.pos.X, curcontact.pos.Y, curcontact.pos.Z); 713 collisionresult.Pos.X = curcontact.pos.X;
714 collisionresult.Pos.Y = curcontact.pos.Y;
715 collisionresult.Pos.Z = curcontact.pos.Z;
703 collisionresult.Depth = curcontact.depth; 716 collisionresult.Depth = curcontact.depth;
704 collisionresult.Normal = new Vector3(curcontact.normal.X, curcontact.normal.Y, 717 collisionresult.Normal.X = curcontact.normal.X;
705 curcontact.normal.Z); 718 collisionresult.Normal.Y = curcontact.normal.Y;
719 collisionresult.Normal.Z = curcontact.normal.Z;
706 lock (m_contactResults) 720 lock (m_contactResults)
707 { 721 {
708 m_contactResults.Add(collisionresult); 722 m_contactResults.Add(collisionresult);
@@ -725,10 +739,13 @@ namespace OpenSim.Region.Physics.OdePlugin
725 739
726 if (curcontact.depth < collisionresult.Depth) 740 if (curcontact.depth < collisionresult.Depth)
727 { 741 {
728 collisionresult.Pos = new Vector3(curcontact.pos.X, curcontact.pos.Y, curcontact.pos.Z); 742 collisionresult.Pos.X = curcontact.pos.X;
743 collisionresult.Pos.Y = curcontact.pos.Y;
744 collisionresult.Pos.Z = curcontact.pos.Z;
729 collisionresult.Depth = curcontact.depth; 745 collisionresult.Depth = curcontact.depth;
730 collisionresult.Normal = new Vector3(curcontact.normal.X, curcontact.normal.Y, 746 collisionresult.Normal.X = curcontact.normal.X;
731 curcontact.normal.Z); 747 collisionresult.Normal.Y = curcontact.normal.Y;
748 collisionresult.Normal.Z = curcontact.normal.Z;
732 } 749 }
733 } 750 }
734 751