aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorDan Lake2011-12-12 02:43:38 -0800
committerDan Lake2011-12-12 02:43:38 -0800
commitc34ab0ee669f674b29d863267e64104b1a3437ef (patch)
tree3ec315180616a056578f735f61d6311414603aeb /OpenSim/Region/Framework/Scenes/ScenePresence.cs
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC-c34ab0ee669f674b29d863267e64104b1a3437ef.zip
opensim-SC-c34ab0ee669f674b29d863267e64104b1a3437ef.tar.gz
opensim-SC-c34ab0ee669f674b29d863267e64104b1a3437ef.tar.bz2
opensim-SC-c34ab0ee669f674b29d863267e64104b1a3437ef.tar.xz
Cleaned up ScenePresence parameters for Flying, WasFlying, FlyingOld and IsColliding
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs89
1 files changed, 49 insertions, 40 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index fa731a7..beff239 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -142,12 +142,27 @@ namespace OpenSim.Region.Framework.Scenes
142 { 142 {
143 get { return m_userFlags; } 143 get { return m_userFlags; }
144 } 144 }
145 private bool m_flyingOld; // add for fly velocity control 145
146 // Flying
147 public bool Flying
148 {
149 get { return PhysicsActor != null && PhysicsActor.Flying; }
150 set { PhysicsActor.Flying = value; }
151 }
152
153 // add for fly velocity control
154 private bool FlyingOld {get; set;}
146 public bool WasFlying 155 public bool WasFlying
147 { 156 {
148 get { return m_wasFlying; } 157 get; private set;
158 }
159
160 public bool IsColliding
161 {
162 get { return PhysicsActor != null && PhysicsActor.IsColliding; }
163 // We would expect setting IsColliding to be private but it's used by a hack in Scene
164 set { PhysicsActor.IsColliding = value; }
149 } 165 }
150 private bool m_wasFlying; // add for fly velocity control
151 166
152// private int m_lastColCount = -1; //KF: Look for Collision chnages 167// private int m_lastColCount = -1; //KF: Look for Collision chnages
153// private int m_updateCount = 0; //KF: Update Anims for a while 168// private int m_updateCount = 0; //KF: Update Anims for a while
@@ -682,9 +697,9 @@ namespace OpenSim.Region.Framework.Scenes
682 set { 697 set {
683 if(value) 698 if(value)
684 { 699 {
685 if ((PhysicsActor != null) && PhysicsActor.Flying) 700 if (Flying)
686 m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; 701 m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY;
687 else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) 702 else
688 m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; 703 m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY;
689 } 704 }
690 m_inTransit = value; 705 m_inTransit = value;
@@ -908,11 +923,11 @@ namespace OpenSim.Region.Framework.Scenes
908 923
909 if (ForceFly) 924 if (ForceFly)
910 { 925 {
911 PhysicsActor.Flying = true; 926 Flying = true;
912 } 927 }
913 else if (FlyDisabled) 928 else if (FlyDisabled)
914 { 929 {
915 PhysicsActor.Flying = false; 930 Flying = false;
916 } 931 }
917 932
918 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 933 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
@@ -1037,10 +1052,7 @@ namespace OpenSim.Region.Framework.Scenes
1037 /// <param name="pos"></param> 1052 /// <param name="pos"></param>
1038 public void Teleport(Vector3 pos) 1053 public void Teleport(Vector3 pos)
1039 { 1054 {
1040 bool isFlying = false; 1055 bool isFlying = Flying;
1041 if (PhysicsActor != null)
1042 isFlying = PhysicsActor.Flying;
1043
1044 RemoveFromPhysicalScene(); 1056 RemoveFromPhysicalScene();
1045 Velocity = Vector3.Zero; 1057 Velocity = Vector3.Zero;
1046 AbsolutePosition = pos; 1058 AbsolutePosition = pos;
@@ -1051,10 +1063,7 @@ namespace OpenSim.Region.Framework.Scenes
1051 1063
1052 public void TeleportWithMomentum(Vector3 pos) 1064 public void TeleportWithMomentum(Vector3 pos)
1053 { 1065 {
1054 bool isFlying = false; 1066 bool isFlying = Flying;
1055 if (PhysicsActor != null)
1056 isFlying = PhysicsActor.Flying;
1057
1058 RemoveFromPhysicalScene(); 1067 RemoveFromPhysicalScene();
1059 AbsolutePosition = pos; 1068 AbsolutePosition = pos;
1060 AddToPhysicalScene(isFlying); 1069 AddToPhysicalScene(isFlying);
@@ -1188,8 +1197,8 @@ namespace OpenSim.Region.Framework.Scenes
1188 AbsolutePosition = pos; 1197 AbsolutePosition = pos;
1189 } 1198 }
1190 1199
1191 bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1200 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1192 MakeRootAgent(AbsolutePosition, m_flying); 1201 MakeRootAgent(AbsolutePosition, flying);
1193 1202
1194 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1203 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1195 { 1204 {
@@ -1414,7 +1423,7 @@ namespace OpenSim.Region.Framework.Scenes
1414 bool DCFlagKeyPressed = false; 1423 bool DCFlagKeyPressed = false;
1415 Vector3 agent_control_v3 = Vector3.Zero; 1424 Vector3 agent_control_v3 = Vector3.Zero;
1416 1425
1417 bool oldflying = PhysicsActor.Flying; 1426 bool oldflying = Flying;
1418 1427
1419 if (ForceFly) 1428 if (ForceFly)
1420 actor.Flying = true; 1429 actor.Flying = true;
@@ -1434,7 +1443,7 @@ namespace OpenSim.Region.Framework.Scenes
1434 1443
1435 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying 1444 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
1436 // this prevents 'jumping' in inappropriate situations. 1445 // this prevents 'jumping' in inappropriate situations.
1437 if ((m_mouseLook && !PhysicsActor.Flying) || (m_leftButtonDown && !PhysicsActor.Flying)) 1446 if (!Flying && (m_mouseLook || m_leftButtonDown))
1438 dirVectors = GetWalkDirectionVectors(); 1447 dirVectors = GetWalkDirectionVectors();
1439 else 1448 else
1440 dirVectors = Dir_Vectors; 1449 dirVectors = Dir_Vectors;
@@ -1521,7 +1530,7 @@ namespace OpenSim.Region.Framework.Scenes
1521 // with something with the down arrow pressed. 1530 // with something with the down arrow pressed.
1522 1531
1523 // Only do this if we're flying 1532 // Only do this if we're flying
1524 if (PhysicsActor != null && PhysicsActor.Flying && !ForceFly) 1533 if (Flying && !ForceFly)
1525 { 1534 {
1526 // Landing detection code 1535 // Landing detection code
1527 1536
@@ -1529,7 +1538,7 @@ namespace OpenSim.Region.Framework.Scenes
1529 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1538 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1530 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1539 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1531 1540
1532 if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland) 1541 if (Flying && IsColliding && controlland)
1533 { 1542 {
1534 // nesting this check because LengthSquared() is expensive and we don't 1543 // nesting this check because LengthSquared() is expensive and we don't
1535 // want to do it every step when flying. 1544 // want to do it every step when flying.
@@ -1742,9 +1751,9 @@ namespace OpenSim.Region.Framework.Scenes
1742 Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); 1751 Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
1743 1752
1744 if (noFly) 1753 if (noFly)
1745 PhysicsActor.Flying = false; 1754 Flying = false;
1746 else if (pos.Z > terrainHeight) 1755 else if (pos.Z > terrainHeight)
1747 PhysicsActor.Flying = true; 1756 Flying = true;
1748 1757
1749 LandAtTarget = landAtTarget; 1758 LandAtTarget = landAtTarget;
1750 MovingToTarget = true; 1759 MovingToTarget = true;
@@ -2307,42 +2316,42 @@ namespace OpenSim.Region.Framework.Scenes
2307 Vector3 direc = vec * Rotation; 2316 Vector3 direc = vec * Rotation;
2308 direc.Normalize(); 2317 direc.Normalize();
2309 2318
2310 if (PhysicsActor.Flying != m_flyingOld) // add for fly velocity control 2319 if (Flying != FlyingOld) // add for fly velocity control
2311 { 2320 {
2312 m_flyingOld = PhysicsActor.Flying; // add for fly velocity control 2321 FlyingOld = Flying; // add for fly velocity control
2313 if (!PhysicsActor.Flying) 2322 if (!Flying)
2314 m_wasFlying = true; // add for fly velocity control 2323 WasFlying = true; // add for fly velocity control
2315 } 2324 }
2316 2325
2317 if (PhysicsActor.IsColliding == true) 2326 if (IsColliding)
2318 m_wasFlying = false; // add for fly velocity control 2327 WasFlying = false; // add for fly velocity control
2319 2328
2320 if ((vec.Z == 0f) && !PhysicsActor.Flying) 2329 if ((vec.Z == 0f) && !Flying)
2321 direc.Z = 0f; // Prevent camera WASD up. 2330 direc.Z = 0f; // Prevent camera WASD up.
2322 2331
2323 direc *= 0.03f * 128f * SpeedModifier; 2332 direc *= 0.03f * 128f * SpeedModifier;
2324 2333
2325 if (PhysicsActor != null) 2334 if (PhysicsActor != null)
2326 { 2335 {
2327 if (PhysicsActor.Flying) 2336 if (Flying)
2328 { 2337 {
2329 direc *= 4.0f; 2338 direc *= 4.0f;
2330 //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 2339 //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
2331 //if (controlland) 2340 //if (controlland)
2332 // m_log.Info("[AGENT]: landCommand"); 2341 // m_log.Info("[AGENT]: landCommand");
2333 //if (PhysicsActor.IsColliding) 2342 //if (IsColliding)
2334 // m_log.Info("[AGENT]: colliding"); 2343 // m_log.Info("[AGENT]: colliding");
2335 //if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland) 2344 //if (Flying && IsColliding && controlland)
2336 //{ 2345 //{
2337 // StopFlying(); 2346 // StopFlying();
2338 // m_log.Info("[AGENT]: Stop Flying"); 2347 // m_log.Info("[AGENT]: Stop Flying");
2339 //} 2348 //}
2340 } 2349 }
2341 if (Animator.Falling && m_wasFlying) // if falling from flying, disable motion add 2350 if (Animator.Falling && WasFlying) // if falling from flying, disable motion add
2342 { 2351 {
2343 direc *= 0.0f; 2352 direc *= 0.0f;
2344 } 2353 }
2345 else if (!PhysicsActor.Flying && PhysicsActor.IsColliding) 2354 else if (!Flying && IsColliding)
2346 { 2355 {
2347 if (direc.Z > 2.0f) 2356 if (direc.Z > 2.0f)
2348 { 2357 {
@@ -2809,7 +2818,7 @@ namespace OpenSim.Region.Framework.Scenes
2809 { 2818 {
2810 if (m_requestedSitTargetUUID == UUID.Zero) 2819 if (m_requestedSitTargetUUID == UUID.Zero)
2811 { 2820 {
2812 bool isFlying = PhysicsActor.Flying; 2821 bool isFlying = Flying;
2813 RemoveFromPhysicalScene(); 2822 RemoveFromPhysicalScene();
2814 2823
2815 Vector3 pos = AbsolutePosition; 2824 Vector3 pos = AbsolutePosition;
@@ -2836,7 +2845,7 @@ namespace OpenSim.Region.Framework.Scenes
2836 { 2845 {
2837 if (m_requestedSitTargetUUID == UUID.Zero) 2846 if (m_requestedSitTargetUUID == UUID.Zero)
2838 { 2847 {
2839 bool isFlying = PhysicsActor.Flying; 2848 bool isFlying = Flying;
2840 RemoveFromPhysicalScene(); 2849 RemoveFromPhysicalScene();
2841 2850
2842 Vector3 pos = AbsolutePosition; 2851 Vector3 pos = AbsolutePosition;
@@ -2886,7 +2895,7 @@ namespace OpenSim.Region.Framework.Scenes
2886 { 2895 {
2887 try 2896 try
2888 { 2897 {
2889 return m_scene.CrossAgentToNewRegion(this, PhysicsActor.Flying); 2898 return m_scene.CrossAgentToNewRegion(this, Flying);
2890 } 2899 }
2891 catch 2900 catch
2892 { 2901 {
@@ -3162,7 +3171,7 @@ namespace OpenSim.Region.Framework.Scenes
3162 Appearance = new AvatarAppearance(cAgent.Appearance); 3171 Appearance = new AvatarAppearance(cAgent.Appearance);
3163 if (PhysicsActor != null) 3172 if (PhysicsActor != null)
3164 { 3173 {
3165 bool isFlying = PhysicsActor.Flying; 3174 bool isFlying = Flying;
3166 RemoveFromPhysicalScene(); 3175 RemoveFromPhysicalScene();
3167 AddToPhysicalScene(isFlying); 3176 AddToPhysicalScene(isFlying);
3168 } 3177 }
@@ -3265,7 +3274,7 @@ namespace OpenSim.Region.Framework.Scenes
3265 3274
3266 private void OutOfBoundsCall(Vector3 pos) 3275 private void OutOfBoundsCall(Vector3 pos)
3267 { 3276 {
3268 //bool flying = PhysicsActor.Flying; 3277 //bool flying = Flying;
3269 //RemoveFromPhysicalScene(); 3278 //RemoveFromPhysicalScene();
3270 3279
3271 //AddToPhysicalScene(flying); 3280 //AddToPhysicalScene(flying);