aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs170
1 files changed, 159 insertions, 11 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index a9195f7..230cb23 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -204,6 +204,11 @@ namespace OpenSim.Region.Framework.Scenes
204 204
205 private const int LAND_VELOCITYMAG_MAX = 12; 205 private const int LAND_VELOCITYMAG_MAX = 12;
206 206
207 private const float FLY_ROLL_MAX_RADIANS = 1.1f;
208
209 private const float FLY_ROLL_RADIANS_PER_UPDATE = 0.06f;
210 private const float FLY_ROLL_RESET_RADIANS_PER_UPDATE = 0.02f;
211
207 private float m_health = 100f; 212 private float m_health = 100f;
208 213
209 protected ulong crossingFromRegion; 214 protected ulong crossingFromRegion;
@@ -438,6 +443,8 @@ namespace OpenSim.Region.Framework.Scenes
438 get { return (IClientCore)ControllingClient; } 443 get { return (IClientCore)ControllingClient; }
439 } 444 }
440 445
446 public UUID COF { get; set; }
447
441// public Vector3 ParentPosition { get; set; } 448// public Vector3 ParentPosition { get; set; }
442 449
443 /// <summary> 450 /// <summary>
@@ -606,6 +613,14 @@ namespace OpenSim.Region.Framework.Scenes
606 } 613 }
607 } 614 }
608 615
616 // Used for limited viewer 'fake' user rotations.
617 private Vector3 m_AngularVelocity = Vector3.Zero;
618
619 public Vector3 AngularVelocity
620 {
621 get { return m_AngularVelocity; }
622 }
623
609 public bool IsChildAgent { get; set; } 624 public bool IsChildAgent { get; set; }
610 public bool IsLoggingIn { get; set; } 625 public bool IsLoggingIn { get; set; }
611 626
@@ -736,6 +751,8 @@ namespace OpenSim.Region.Framework.Scenes
736 751
737 #endregion 752 #endregion
738 753
754
755
739 #region Constructor(s) 756 #region Constructor(s)
740 757
741 public ScenePresence( 758 public ScenePresence(
@@ -1225,6 +1242,85 @@ namespace OpenSim.Region.Framework.Scenes
1225 ControllingClient.StopFlying(this); 1242 ControllingClient.StopFlying(this);
1226 } 1243 }
1227 1244
1245 /// <summary>
1246 /// Applies a roll accumulator to the avatar's angular velocity for the avatar fly roll effect.
1247 /// </summary>
1248 /// <param name="amount">Postive or negative roll amount in radians</param>
1249 private void ApplyFlyingRoll(float amount, bool PressingUp, bool PressingDown)
1250 {
1251
1252 float rollAmount = Util.Clamp(m_AngularVelocity.Z + amount, -FLY_ROLL_MAX_RADIANS, FLY_ROLL_MAX_RADIANS);
1253 m_AngularVelocity.Z = rollAmount;
1254
1255 // APPLY EXTRA consideration for flying up and flying down during this time.
1256 // if we're turning left
1257 if (amount > 0)
1258 {
1259
1260 // If we're at the max roll and pressing up, we want to swing BACK a bit
1261 // Automatically adds noise
1262 if (PressingUp)
1263 {
1264 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS - 0.04f)
1265 m_AngularVelocity.Z -= 0.9f;
1266 }
1267 // If we're at the max roll and pressing down, we want to swing MORE a bit
1268 if (PressingDown)
1269 {
1270 if (m_AngularVelocity.Z >= FLY_ROLL_MAX_RADIANS && m_AngularVelocity.Z < FLY_ROLL_MAX_RADIANS + 0.6f)
1271 m_AngularVelocity.Z += 0.6f;
1272 }
1273 }
1274 else // we're turning right.
1275 {
1276 // If we're at the max roll and pressing up, we want to swing BACK a bit
1277 // Automatically adds noise
1278 if (PressingUp)
1279 {
1280 if (m_AngularVelocity.Z <= (-FLY_ROLL_MAX_RADIANS))
1281 m_AngularVelocity.Z += 0.6f;
1282 }
1283 // If we're at the max roll and pressing down, we want to swing MORE a bit
1284 if (PressingDown)
1285 {
1286 if (m_AngularVelocity.Z >= -FLY_ROLL_MAX_RADIANS - 0.6f)
1287 m_AngularVelocity.Z -= 0.6f;
1288 }
1289 }
1290 }
1291
1292 /// <summary>
1293 /// incrementally sets roll amount to zero
1294 /// </summary>
1295 /// <param name="amount">Positive roll amount in radians</param>
1296 /// <returns></returns>
1297 private float CalculateFlyingRollResetToZero(float amount)
1298 {
1299 const float rollMinRadians = 0f;
1300
1301 if (m_AngularVelocity.Z > 0)
1302 {
1303
1304 float leftOverToMin = m_AngularVelocity.Z - rollMinRadians;
1305 if (amount > leftOverToMin)
1306 return -leftOverToMin;
1307 else
1308 return -amount;
1309
1310 }
1311 else
1312 {
1313
1314 float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians;
1315 if (amount > leftOverToMin)
1316 return leftOverToMin;
1317 else
1318 return amount;
1319 }
1320 }
1321
1322
1323
1228 // neighbouring regions we have enabled a child agent in 1324 // neighbouring regions we have enabled a child agent in
1229 // holds the seed cap for the child agent in that region 1325 // holds the seed cap for the child agent in that region
1230 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); 1326 private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>();
@@ -1430,17 +1526,42 @@ namespace OpenSim.Region.Framework.Scenes
1430 m_doingCamRayCast = false; 1526 m_doingCamRayCast = false;
1431 if (hitYN && localid != LocalId) 1527 if (hitYN && localid != LocalId)
1432 { 1528 {
1433 CameraConstraintActive = true; 1529 SceneObjectGroup group = m_scene.GetGroupByPrim(localid);
1434 pNormal.X = (float)Math.Round(pNormal.X, 2); 1530 bool IsPrim = group != null;
1435 pNormal.Y = (float)Math.Round(pNormal.Y, 2); 1531 if (IsPrim)
1436 pNormal.Z = (float)Math.Round(pNormal.Z, 2); 1532 {
1437 pNormal.Normalize(); 1533 SceneObjectPart part = group.GetPart(localid);
1438 collisionPoint.X = (float)Math.Round(collisionPoint.X, 1); 1534 if (part != null && !part.VolumeDetectActive)
1439 collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1); 1535 {
1440 collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1); 1536 CameraConstraintActive = true;
1441 1537 pNormal.X = (float) Math.Round(pNormal.X, 2);
1442 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal)); 1538 pNormal.Y = (float) Math.Round(pNormal.Y, 2);
1443 UpdateCameraCollisionPlane(plane); 1539 pNormal.Z = (float) Math.Round(pNormal.Z, 2);
1540 pNormal.Normalize();
1541 collisionPoint.X = (float) Math.Round(collisionPoint.X, 1);
1542 collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1);
1543 collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1);
1544
1545 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z,
1546 Vector3.Dot(collisionPoint, pNormal));
1547 UpdateCameraCollisionPlane(plane);
1548 }
1549 }
1550 else
1551 {
1552 CameraConstraintActive = true;
1553 pNormal.X = (float) Math.Round(pNormal.X, 2);
1554 pNormal.Y = (float) Math.Round(pNormal.Y, 2);
1555 pNormal.Z = (float) Math.Round(pNormal.Z, 2);
1556 pNormal.Normalize();
1557 collisionPoint.X = (float) Math.Round(collisionPoint.X, 1);
1558 collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1);
1559 collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1);
1560
1561 Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z,
1562 Vector3.Dot(collisionPoint, pNormal));
1563 UpdateCameraCollisionPlane(plane);
1564 }
1444 } 1565 }
1445 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || 1566 else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
1446 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) 1567 !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE))
@@ -1741,6 +1862,33 @@ namespace OpenSim.Region.Framework.Scenes
1741 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1862 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1742 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1863 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1743 1864
1865
1866 //m_log.Debug("[CONTROL]: " +flags);
1867 // Applies a satisfying roll effect to the avatar when flying.
1868 if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0))
1869 {
1870
1871 ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0));
1872
1873
1874 }
1875 else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) &&
1876 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0))
1877 {
1878 ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0));
1879
1880
1881 }
1882 else
1883 {
1884 if (m_AngularVelocity.Z != 0)
1885 m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
1886
1887 }
1888
1889
1890
1891
1744 if (Flying && IsColliding && controlland) 1892 if (Flying && IsColliding && controlland)
1745 { 1893 {
1746 // nesting this check because LengthSquared() is expensive and we don't 1894 // nesting this check because LengthSquared() is expensive and we don't