aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
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
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-c34ab0ee669f674b29d863267e64104b1a3437ef.zip
opensim-SC_OLD-c34ab0ee669f674b29d863267e64104b1a3437ef.tar.gz
opensim-SC_OLD-c34ab0ee669f674b29d863267e64104b1a3437ef.tar.bz2
opensim-SC_OLD-c34ab0ee669f674b29d863267e64104b1a3437ef.tar.xz
Cleaned up ScenePresence parameters for Flying, WasFlying, FlyingOld and IsColliding
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs89
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs4
6 files changed, 57 insertions, 50 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 85debc4..4ab6fe4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -5083,7 +5083,7 @@ namespace OpenSim.Region.Framework.Scenes
5083 presence.AbsolutePosition = presence.MoveToPositionTarget; 5083 presence.AbsolutePosition = presence.MoveToPositionTarget;
5084 presence.ResetMoveToTarget(); 5084 presence.ResetMoveToTarget();
5085 5085
5086 if (presence.PhysicsActor.Flying) 5086 if (presence.Flying)
5087 { 5087 {
5088 // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot 5088 // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot
5089 // the target if flying. 5089 // the target if flying.
@@ -5091,16 +5091,16 @@ namespace OpenSim.Region.Framework.Scenes
5091 // least be able to set collision status once, rather than 5 times to give it enough 5091 // least be able to set collision status once, rather than 5 times to give it enough
5092 // weighting so that that PhysicsActor thinks it really is colliding. 5092 // weighting so that that PhysicsActor thinks it really is colliding.
5093 for (int i = 0; i < 5; i++) 5093 for (int i = 0; i < 5; i++)
5094 presence.PhysicsActor.IsColliding = true; 5094 presence.IsColliding = true;
5095 5095
5096 if (presence.LandAtTarget) 5096 if (presence.LandAtTarget)
5097 presence.PhysicsActor.Flying = false; 5097 presence.Flying = false;
5098 5098
5099// Vector3 targetPos = presence.MoveToPositionTarget; 5099// Vector3 targetPos = presence.MoveToPositionTarget;
5100// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; 5100// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
5101// if (targetPos.Z - terrainHeight < 0.2) 5101// if (targetPos.Z - terrainHeight < 0.2)
5102// { 5102// {
5103// presence.PhysicsActor.Flying = false; 5103// presence.Flying = false;
5104// } 5104// }
5105 } 5105 }
5106 5106
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);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
index 4a0533c..89f8007 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
61 61
62 TestScene scene = SceneHelpers.SetupScene(); 62 TestScene scene = SceneHelpers.SetupScene();
63 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 63 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
64 sp.PhysicsActor.Flying = true; 64 sp.Flying = true;
65 sp.PhysicsCollisionUpdate(new CollisionEventUpdate()); 65 sp.PhysicsCollisionUpdate(new CollisionEventUpdate());
66 66
67 Assert.That(sp.Animator.CurrentMovementAnimation, Is.EqualTo("HOVER")); 67 Assert.That(sp.Animator.CurrentMovementAnimation, Is.EqualTo("HOVER"));
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
index 64c36ff..442cb8b 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
79// Vector3 startPos = new Vector3(128, 128, 30); 79// Vector3 startPos = new Vector3(128, 128, 30);
80 80
81 // For now, we'll make the scene presence fly to simplify this test, but this needs to change. 81 // For now, we'll make the scene presence fly to simplify this test, but this needs to change.
82 sp.PhysicsActor.Flying = true; 82 sp.Flying = true;
83 83
84 m_scene.Update(); 84 m_scene.Update();
85 Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos)); 85 Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index dce0ec8..9c66b25 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -175,7 +175,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
175 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 175 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
176 176
177 // For now, we'll make the scene presence fly to simplify this test, but this needs to change. 177 // For now, we'll make the scene presence fly to simplify this test, but this needs to change.
178 npc.PhysicsActor.Flying = true; 178 npc.Flying = true;
179 179
180 scene.Update(); 180 scene.Update();
181 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 181 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6d067b0..443e7a5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5573,9 +5573,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5573 // note: this may need some tweaking when walking downhill. you "fall down" for a brief instant 5573 // note: this may need some tweaking when walking downhill. you "fall down" for a brief instant
5574 // and don't collide when walking downhill, which instantly registers as in-air, briefly. should 5574 // and don't collide when walking downhill, which instantly registers as in-air, briefly. should
5575 // there be some minimum non-collision threshold time before claiming the avatar is in-air? 5575 // there be some minimum non-collision threshold time before claiming the avatar is in-air?
5576 if ((flags & ScriptBaseClass.AGENT_WALKING) == 0 && 5576 if ((flags & ScriptBaseClass.AGENT_WALKING) == 0 && !agent.IsColliding )
5577 agent.PhysicsActor != null &&
5578 !agent.PhysicsActor.IsColliding)
5579 { 5577 {
5580 flags |= ScriptBaseClass.AGENT_IN_AIR; 5578 flags |= ScriptBaseClass.AGENT_IN_AIR;
5581 } 5579 }