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.cs107
1 files changed, 82 insertions, 25 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index aa538dc..4e5fee1 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes
73// { 73// {
74// m_log.Debug("[ScenePresence] Destructor called"); 74// m_log.Debug("[ScenePresence] Destructor called");
75// } 75// }
76 76
77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
78 78
79 private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; 79 private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 };
@@ -146,7 +146,6 @@ namespace OpenSim.Region.Framework.Scenes
146 private int m_perfMonMS; 146 private int m_perfMonMS;
147 147
148 private bool m_setAlwaysRun; 148 private bool m_setAlwaysRun;
149
150 private bool m_forceFly; 149 private bool m_forceFly;
151 private bool m_flyDisabled; 150 private bool m_flyDisabled;
152 151
@@ -154,6 +153,8 @@ namespace OpenSim.Region.Framework.Scenes
154 153
155 private Quaternion m_bodyRot= Quaternion.Identity; 154 private Quaternion m_bodyRot= Quaternion.Identity;
156 155
156 private const int LAND_VELOCITYMAG_MAX = 12;
157
157 public bool IsRestrictedToRegion; 158 public bool IsRestrictedToRegion;
158 159
159 public string JID = String.Empty; 160 public string JID = String.Empty;
@@ -168,7 +169,8 @@ namespace OpenSim.Region.Framework.Scenes
168 protected RegionInfo m_regionInfo; 169 protected RegionInfo m_regionInfo;
169 protected ulong crossingFromRegion; 170 protected ulong crossingFromRegion;
170 171
171 private readonly Vector3[] Dir_Vectors = new Vector3[6]; 172 private readonly Vector3[] Dir_Vectors = new Vector3[9];
173 private bool m_isNudging = false;
172 174
173 // Position of agent's camera in world (region cordinates) 175 // Position of agent's camera in world (region cordinates)
174 protected Vector3 m_CameraCenter; 176 protected Vector3 m_CameraCenter;
@@ -232,6 +234,8 @@ namespace OpenSim.Region.Framework.Scenes
232 DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, 234 DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG,
233 DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, 235 DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS,
234 DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, 236 DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
237 DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS,
238 DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
235 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG 239 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
236 } 240 }
237 241
@@ -247,7 +251,7 @@ namespace OpenSim.Region.Framework.Scenes
247 /// <value> 251 /// <value>
248 /// Script engines present in the scene 252 /// Script engines present in the scene
249 /// </value> 253 /// </value>
250 private IScriptModule[] m_scriptEngines; 254 private IScriptModule[] m_scriptEngines;
251 255
252 #region Properties 256 #region Properties
253 257
@@ -674,7 +678,7 @@ namespace OpenSim.Region.Framework.Scenes
674 AvatarWearable[] wearables) 678 AvatarWearable[] wearables)
675 : this(client, world, reginfo) 679 : this(client, world, reginfo)
676 { 680 {
677 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams); 681 m_appearance = new AvatarAppearance(m_uuid, wearables, visualParams);
678 } 682 }
679 683
680 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance) 684 public ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo, AvatarAppearance appearance)
@@ -716,21 +720,41 @@ namespace OpenSim.Region.Framework.Scenes
716 Dir_Vectors[3] = -Vector3.UnitY; //RIGHT 720 Dir_Vectors[3] = -Vector3.UnitY; //RIGHT
717 Dir_Vectors[4] = Vector3.UnitZ; //UP 721 Dir_Vectors[4] = Vector3.UnitZ; //UP
718 Dir_Vectors[5] = -Vector3.UnitZ; //DOWN 722 Dir_Vectors[5] = -Vector3.UnitZ; //DOWN
719 Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge 723 Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE
724 Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE
725 Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
720 } 726 }
721 727
722 private Vector3[] GetWalkDirectionVectors() 728 private Vector3[] GetWalkDirectionVectors()
723 { 729 {
724 Vector3[] vector = new Vector3[6]; 730 Vector3[] vector = new Vector3[9];
725 vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD 731 vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD
726 vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK 732 vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK
727 vector[2] = Vector3.UnitY; //LEFT 733 vector[2] = Vector3.UnitY; //LEFT
728 vector[3] = -Vector3.UnitY; //RIGHT 734 vector[3] = -Vector3.UnitY; //RIGHT
729 vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP 735 vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP
730 vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN 736 vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN
731 vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge 737 vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE
738 vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE
739 vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
732 return vector; 740 return vector;
733 } 741 }
742
743 private bool[] GetDirectionIsNudge()
744 {
745 bool[] isNudge = new bool[9];
746 isNudge[0] = false; //FORWARD
747 isNudge[1] = false; //BACK
748 isNudge[2] = false; //LEFT
749 isNudge[3] = false; //RIGHT
750 isNudge[4] = false; //UP
751 isNudge[5] = false; //DOWN
752 isNudge[6] = true; //FORWARD_NUDGE
753 isNudge[7] = true; //BACK_NUDGE
754 isNudge[8] = true; //DOWN_Nudge
755 return isNudge;
756 }
757
734 758
735 #endregion 759 #endregion
736 760
@@ -980,8 +1004,8 @@ namespace OpenSim.Region.Framework.Scenes
980 public void StopFlying() 1004 public void StopFlying()
981 { 1005 {
982 // It turns out to get the agent to stop flying, you have to feed it stop flying velocities 1006 // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
983 // and send a full object update. 1007 // There's no explicit message to send the client to tell it to stop flying.. it relies on the
984 // There's no message to send the client to tell it to stop flying 1008 // velocity, collision plane and avatar height
985 1009
986 // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air 1010 // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
987 // when the avatar stands up 1011 // when the avatar stands up
@@ -995,8 +1019,8 @@ namespace OpenSim.Region.Framework.Scenes
995 AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); 1019 AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f));
996 } 1020 }
997 1021
998 Animator.TrySetMovementAnimation("LAND"); 1022 ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
999 SendFullUpdateToAllClients(); 1023 AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
1000 } 1024 }
1001 1025
1002 public void AddNeighbourRegion(ulong regionHandle, string cap) 1026 public void AddNeighbourRegion(ulong regionHandle, string cap)
@@ -1147,7 +1171,6 @@ namespace OpenSim.Region.Framework.Scenes
1147 // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); 1171 // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent");
1148 // return; 1172 // return;
1149 //} 1173 //}
1150
1151 m_perfMonMS = Environment.TickCount; 1174 m_perfMonMS = Environment.TickCount;
1152 1175
1153 ++m_movementUpdateCount; 1176 ++m_movementUpdateCount;
@@ -1229,7 +1252,6 @@ namespace OpenSim.Region.Framework.Scenes
1229 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); 1252 m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback);
1230 } 1253 }
1231 } 1254 }
1232
1233 lock (scriptedcontrols) 1255 lock (scriptedcontrols)
1234 { 1256 {
1235 if (scriptedcontrols.Count > 0) 1257 if (scriptedcontrols.Count > 0)
@@ -1261,7 +1283,6 @@ namespace OpenSim.Region.Framework.Scenes
1261 { 1283 {
1262 return; 1284 return;
1263 } 1285 }
1264
1265 if (m_allowMovement) 1286 if (m_allowMovement)
1266 { 1287 {
1267 int i = 0; 1288 int i = 0;
@@ -1289,6 +1310,11 @@ namespace OpenSim.Region.Framework.Scenes
1289 update_rotation = true; 1310 update_rotation = true;
1290 } 1311 }
1291 1312
1313 //guilty until proven innocent..
1314 bool Nudging = true;
1315 //Basically, if there is at least one non-nudge control then we don't need
1316 //to worry about stopping the avatar
1317
1292 if (m_parentID == 0) 1318 if (m_parentID == 0)
1293 { 1319 {
1294 bool bAllowUpdateMoveToPosition = false; 1320 bool bAllowUpdateMoveToPosition = false;
@@ -1303,6 +1329,12 @@ namespace OpenSim.Region.Framework.Scenes
1303 else 1329 else
1304 dirVectors = Dir_Vectors; 1330 dirVectors = Dir_Vectors;
1305 1331
1332 bool[] isNudge = GetDirectionIsNudge();
1333
1334
1335
1336
1337
1306 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) 1338 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
1307 { 1339 {
1308 if (((uint)flags & (uint)DCF) != 0) 1340 if (((uint)flags & (uint)DCF) != 0)
@@ -1312,6 +1344,10 @@ namespace OpenSim.Region.Framework.Scenes
1312 try 1344 try
1313 { 1345 {
1314 agent_control_v3 += dirVectors[i]; 1346 agent_control_v3 += dirVectors[i];
1347 if (isNudge[i] == false)
1348 {
1349 Nudging = false;
1350 }
1315 } 1351 }
1316 catch (IndexOutOfRangeException) 1352 catch (IndexOutOfRangeException)
1317 { 1353 {
@@ -1373,6 +1409,9 @@ namespace OpenSim.Region.Framework.Scenes
1373 // Ignore z component of vector 1409 // Ignore z component of vector
1374 Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); 1410 Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f);
1375 LocalVectorToTarget2D.Normalize(); 1411 LocalVectorToTarget2D.Normalize();
1412
1413 //We're not nudging
1414 Nudging = false;
1376 agent_control_v3 += LocalVectorToTarget2D; 1415 agent_control_v3 += LocalVectorToTarget2D;
1377 1416
1378 // update avatar movement flags. the avatar coordinate system is as follows: 1417 // update avatar movement flags. the avatar coordinate system is as follows:
@@ -1431,6 +1470,8 @@ namespace OpenSim.Region.Framework.Scenes
1431 // Only do this if we're flying 1470 // Only do this if we're flying
1432 if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) 1471 if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly)
1433 { 1472 {
1473 // Landing detection code
1474
1434 // Are the landing controls requirements filled? 1475 // Are the landing controls requirements filled?
1435 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1476 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1436 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1477 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
@@ -1440,7 +1481,10 @@ namespace OpenSim.Region.Framework.Scenes
1440 1481
1441 if (m_physicsActor.Flying && colliding && controlland) 1482 if (m_physicsActor.Flying && colliding && controlland)
1442 { 1483 {
1443 StopFlying(); 1484 // nesting this check because LengthSquared() is expensive and we don't
1485 // want to do it every step when flying.
1486 if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX))
1487 StopFlying();
1444 } 1488 }
1445 } 1489 }
1446 1490
@@ -1450,7 +1494,7 @@ namespace OpenSim.Region.Framework.Scenes
1450 // m_log.DebugFormat( 1494 // m_log.DebugFormat(
1451 // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); 1495 // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3);
1452 1496
1453 AddNewMovement(agent_control_v3, q); 1497 AddNewMovement(agent_control_v3, q, Nudging);
1454 1498
1455 if (update_movementflag) 1499 if (update_movementflag)
1456 Animator.UpdateMovementAnimations(); 1500 Animator.UpdateMovementAnimations();
@@ -1923,7 +1967,7 @@ namespace OpenSim.Region.Framework.Scenes
1923 /// </summary> 1967 /// </summary>
1924 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> 1968 /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
1925 /// <param name="rotation">The direction in which this avatar should now face. 1969 /// <param name="rotation">The direction in which this avatar should now face.
1926 public void AddNewMovement(Vector3 vec, Quaternion rotation) 1970 public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging)
1927 { 1971 {
1928 if (m_isChildAgent) 1972 if (m_isChildAgent)
1929 { 1973 {
@@ -1997,7 +2041,7 @@ namespace OpenSim.Region.Framework.Scenes
1997 2041
1998 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2042 // TODO: Add the force instead of only setting it to support multiple forces per frame?
1999 m_forceToApply = direc; 2043 m_forceToApply = direc;
2000 2044 m_isNudging = Nudging;
2001 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); 2045 m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS);
2002 } 2046 }
2003 2047
@@ -2012,7 +2056,7 @@ namespace OpenSim.Region.Framework.Scenes
2012 const float POSITION_TOLERANCE = 0.05f; 2056 const float POSITION_TOLERANCE = 0.05f;
2013 //const int TIME_MS_TOLERANCE = 3000; 2057 //const int TIME_MS_TOLERANCE = 3000;
2014 2058
2015 SendPrimUpdates(); 2059
2016 2060
2017 if (m_newCoarseLocations) 2061 if (m_newCoarseLocations)
2018 { 2062 {
@@ -2048,6 +2092,9 @@ namespace OpenSim.Region.Framework.Scenes
2048 CheckForBorderCrossing(); 2092 CheckForBorderCrossing();
2049 CheckForSignificantMovement(); // sends update to the modules. 2093 CheckForSignificantMovement(); // sends update to the modules.
2050 } 2094 }
2095
2096 //Sending prim updates AFTER the avatar terse updates are sent
2097 SendPrimUpdates();
2051 } 2098 }
2052 2099
2053 #endregion 2100 #endregion
@@ -2901,14 +2948,24 @@ namespace OpenSim.Region.Framework.Scenes
2901 { 2948 {
2902 if (m_forceToApply.HasValue) 2949 if (m_forceToApply.HasValue)
2903 { 2950 {
2904 Vector3 force = m_forceToApply.Value;
2905 2951
2952 Vector3 force = m_forceToApply.Value;
2906 m_updateflag = true; 2953 m_updateflag = true;
2907// movementvector = force;
2908 Velocity = force; 2954 Velocity = force;
2909 2955
2910 m_forceToApply = null; 2956 m_forceToApply = null;
2911 } 2957 }
2958 else
2959 {
2960 if (m_isNudging)
2961 {
2962 Vector3 force = Vector3.Zero;
2963
2964 m_updateflag = true;
2965 Velocity = force;
2966 m_isNudging = false;
2967 }
2968 }
2912 } 2969 }
2913 2970
2914 public override void SetText(string text, Vector3 color, double alpha) 2971 public override void SetText(string text, Vector3 color, double alpha)
@@ -3084,7 +3141,7 @@ namespace OpenSim.Region.Framework.Scenes
3084 3141
3085 public ScenePresence() 3142 public ScenePresence()
3086 { 3143 {
3087 m_sendCourseLocationsMethod = SendCoarseLocationsDefault; 3144 m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
3088 CreateSceneViewer(); 3145 CreateSceneViewer();
3089 m_animator = new ScenePresenceAnimator(this); 3146 m_animator = new ScenePresenceAnimator(this);
3090 } 3147 }
@@ -3172,8 +3229,8 @@ namespace OpenSim.Region.Framework.Scenes
3172 } 3229 }
3173 } 3230 }
3174 } 3231 }
3175 } 3232 }
3176 } 3233 }
3177 3234
3178 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent) 3235 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3179 { 3236 {