aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorUbitUmarov2014-10-03 18:32:52 +0100
committerUbitUmarov2014-10-03 18:32:52 +0100
commit94f42cef90a8d5732f4bf9e033ae5e9f5508ae7e (patch)
tree4f3bd08eb810d6d31221c953469f16821f2d4f40 /OpenSim/Region/Framework/Scenes
parentclean up coments, use a even faster XY move request detection (diff)
downloadopensim-SC_OLD-94f42cef90a8d5732f4bf9e033ae5e9f5508ae7e.zip
opensim-SC_OLD-94f42cef90a8d5732f4bf9e033ae5e9f5508ae7e.tar.gz
opensim-SC_OLD-94f42cef90a8d5732f4bf9e033ae5e9f5508ae7e.tar.bz2
opensim-SC_OLD-94f42cef90a8d5732f4bf9e033ae5e9f5508ae7e.tar.xz
added a missing angularVelocity.Zero on sitting, removed odd camera based
movement vectors, plus little other things
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs129
1 files changed, 68 insertions, 61 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 42d3684..dbeba9a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -336,7 +336,7 @@ namespace OpenSim.Region.Framework.Scenes
336 336
337 protected ulong crossingFromRegion; 337 protected ulong crossingFromRegion;
338 338
339 private readonly Vector3[] Dir_Vectors = new Vector3[11]; 339 private readonly Vector3[] Dir_Vectors = new Vector3[12];
340 340
341 protected Timer m_reprioritization_timer; 341 protected Timer m_reprioritization_timer;
342 protected bool m_reprioritizing; 342 protected bool m_reprioritizing;
@@ -393,7 +393,7 @@ namespace OpenSim.Region.Framework.Scenes
393 /// <summary> 393 /// <summary>
394 /// Implemented Control Flags 394 /// Implemented Control Flags
395 /// </summary> 395 /// </summary>
396 private enum Dir_ControlFlags 396 private enum Dir_ControlFlags:uint
397 { 397 {
398 DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, 398 DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS,
399 DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, 399 DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG,
@@ -405,6 +405,7 @@ namespace OpenSim.Region.Framework.Scenes
405 DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, 405 DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
406 DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, 406 DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS,
407 DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, 407 DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG,
408 DIR_CONTROL_FLAG_UP_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS,
408 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG 409 DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
409 } 410 }
410 411
@@ -728,24 +729,7 @@ namespace OpenSim.Region.Framework.Scenes
728// Scene.RegionInfo.RegionName, Name, m_velocity); 729// Scene.RegionInfo.RegionName, Name, m_velocity);
729 } 730 }
730 } 731 }
731/*
732 public override Vector3 AngularVelocity
733 {
734 get
735 {
736 if (PhysicsActor != null)
737 {
738 m_rotationalvelocity = PhysicsActor.RotationalVelocity;
739 732
740 // m_log.DebugFormat(
741 // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!",
742 // m_velocity, Name, Scene.RegionInfo.RegionName);
743 }
744
745 return m_rotationalvelocity;
746 }
747 }
748*/
749 private Quaternion m_bodyRot = Quaternion.Identity; 733 private Quaternion m_bodyRot = Quaternion.Identity;
750 734
751 /// <summary> 735 /// <summary>
@@ -915,13 +899,6 @@ namespace OpenSim.Region.Framework.Scenes
915 } 899 }
916 } 900 }
917 901
918 private float m_speedModifier = 1.0f;
919
920 public float SpeedModifier
921 {
922 get { return m_speedModifier; }
923 set { m_speedModifier = value; }
924 }
925 902
926 /// <summary> 903 /// <summary>
927 /// Modifier for agent movement if we get an AGENT_CONTROL_STOP whilst walking or running 904 /// Modifier for agent movement if we get an AGENT_CONTROL_STOP whilst walking or running
@@ -929,7 +906,20 @@ namespace OpenSim.Region.Framework.Scenes
929 /// <remarks> 906 /// <remarks>
930 /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. 907 /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers.
931 /// </remarks> 908 /// </remarks>
932 private float AgentControlStopSlowWhilstMoving = 0.2f; 909 private const float AgentControlStopSlowVel = 0.2f;
910 // velocities
911 public const float AgentControlNudgeVel = 1.0f; // setting this diferent from normal as no effect currently
912 public const float AgentControlNormalVel = 1.0f;
913
914 // old normal speed was tuned to match sl normal plus Fast modifiers
915 // so we need to rescale it
916 private float m_speedModifier = 1.0f;
917
918 public float SpeedModifier
919 {
920 get { return m_speedModifier; }
921 set { m_speedModifier = value; }
922 }
933 923
934 private bool m_forceFly; 924 private bool m_forceFly;
935 925
@@ -1057,22 +1047,24 @@ namespace OpenSim.Region.Framework.Scenes
1057 1047
1058 private void SetDirectionVectors() 1048 private void SetDirectionVectors()
1059 { 1049 {
1060 Dir_Vectors[0] = Vector3.UnitX; //FORWARD 1050 Dir_Vectors[0] = new Vector3(AgentControlNormalVel,0,0); //FORWARD
1061 Dir_Vectors[1] = -Vector3.UnitX; //BACK 1051 Dir_Vectors[1] = new Vector3(-AgentControlNormalVel,0,0);; //BACK
1062 Dir_Vectors[2] = Vector3.UnitY; //LEFT 1052 Dir_Vectors[2] = new Vector3(0,AgentControlNormalVel,0); //LEFT
1063 Dir_Vectors[3] = -Vector3.UnitY; //RIGHT 1053 Dir_Vectors[3] = new Vector3(0,-AgentControlNormalVel,0); //RIGHT
1064 Dir_Vectors[4] = Vector3.UnitZ; //UP 1054 Dir_Vectors[4] = new Vector3(0,0,AgentControlNormalVel); //UP
1065 Dir_Vectors[5] = -Vector3.UnitZ; //DOWN 1055 Dir_Vectors[5] = new Vector3(0,0,-AgentControlNormalVel); //DOWN
1066 Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE 1056 Dir_Vectors[6] = new Vector3(AgentControlNudgeVel, 0f, 0f); //FORWARD_NUDGE
1067 Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE 1057 Dir_Vectors[7] = new Vector3(-AgentControlNudgeVel, 0f, 0f); //BACK_NUDGE
1068 Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE 1058 Dir_Vectors[8] = new Vector3(0f, AgentControlNudgeVel, 0f); //LEFT_NUDGE
1069 Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE 1059 Dir_Vectors[9] = new Vector3(0f, -AgentControlNudgeVel, 0f); //RIGHT_NUDGE
1070 Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge 1060 Dir_Vectors[10] = new Vector3(0f, 0f, AgentControlNudgeVel); //UP_Nudge
1071 } 1061 Dir_Vectors[11] = new Vector3(0f, 0f, -AgentControlNudgeVel); //DOWN_Nudge
1072 1062 }
1063
1064/* dont see any use for this
1073 private Vector3[] GetWalkDirectionVectors() 1065 private Vector3[] GetWalkDirectionVectors()
1074 { 1066 {
1075 Vector3[] vector = new Vector3[11]; 1067 Vector3[] vector = new Vector3[12];
1076 vector[0] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD 1068 vector[0] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD
1077 vector[1] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK 1069 vector[1] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK
1078 vector[2] = Vector3.UnitY; //LEFT 1070 vector[2] = Vector3.UnitY; //LEFT
@@ -1083,10 +1075,11 @@ namespace OpenSim.Region.Framework.Scenes
1083 vector[7] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK_NUDGE 1075 vector[7] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK_NUDGE
1084 vector[8] = Vector3.UnitY; //LEFT_NUDGE 1076 vector[8] = Vector3.UnitY; //LEFT_NUDGE
1085 vector[9] = -Vector3.UnitY; //RIGHT_NUDGE 1077 vector[9] = -Vector3.UnitY; //RIGHT_NUDGE
1086 vector[10] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN_NUDGE 1078 vector[10] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP_NUDGE
1079 vector[11] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN_NUDGE
1087 return vector; 1080 return vector;
1088 } 1081 }
1089 1082*/
1090 #endregion 1083 #endregion
1091 1084
1092 #region Status Methods 1085 #region Status Methods
@@ -2192,11 +2185,12 @@ namespace OpenSim.Region.Framework.Scenes
2192 2185
2193 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying 2186 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
2194 // this prevents 'jumping' in inappropriate situations. 2187 // this prevents 'jumping' in inappropriate situations.
2195 if (!Flying && (m_mouseLook || m_leftButtonDown)) 2188// if (!Flying && (m_mouseLook || m_leftButtonDown))
2196 dirVectors = GetWalkDirectionVectors(); 2189// dirVectors = GetWalkDirectionVectors();
2197 else 2190// else
2198 dirVectors = Dir_Vectors; 2191 dirVectors = Dir_Vectors;
2199 2192
2193
2200 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. 2194 // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction.
2201 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) 2195 foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
2202 { 2196 {
@@ -2214,10 +2208,10 @@ namespace OpenSim.Region.Framework.Scenes
2214 // Why did I get this? 2208 // Why did I get this?
2215 } 2209 }
2216 2210
2217 if (((MovementFlag & (uint)DCF) == 0) & !AgentControlStopActive) 2211 if (((MovementFlag & (uint)DCF) == 0))
2218 { 2212 {
2219 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); 2213 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
2220 MovementFlag += (uint)DCF; 2214 MovementFlag |= (uint)DCF;
2221 update_movementflag = true; 2215 update_movementflag = true;
2222 } 2216 }
2223 } 2217 }
@@ -2226,7 +2220,7 @@ namespace OpenSim.Region.Framework.Scenes
2226 if ((MovementFlag & (uint)DCF) != 0) 2220 if ((MovementFlag & (uint)DCF) != 0)
2227 { 2221 {
2228 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); 2222 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF);
2229 MovementFlag -= (uint)DCF; 2223 MovementFlag &= (uint)~DCF;
2230 update_movementflag = true; 2224 update_movementflag = true;
2231 2225
2232 /* 2226 /*
@@ -2344,17 +2338,18 @@ namespace OpenSim.Region.Framework.Scenes
2344 2338
2345 if (AgentControlStopActive) 2339 if (AgentControlStopActive)
2346 { 2340 {
2347// if (MovementFlag == 0 && Animator.Falling) 2341 // if (MovementFlag == 0 && Animator.Falling)
2348 if (MovementFlag == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) 2342 if (MovementFlag == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling)
2349 { 2343 {
2350 AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving, true); 2344 AddNewMovement(agent_control_v3, AgentControlStopSlowVel, true);
2351 } 2345 }
2352 else 2346 else
2353 AddNewMovement(agent_control_v3, AgentControlStopSlowWhilstMoving); 2347 AddNewMovement(agent_control_v3, AgentControlStopSlowVel);
2354 } 2348 }
2355
2356 else 2349 else
2350 {
2357 AddNewMovement(agent_control_v3); 2351 AddNewMovement(agent_control_v3);
2352 }
2358 2353
2359 } 2354 }
2360 2355
@@ -2453,11 +2448,13 @@ namespace OpenSim.Region.Framework.Scenes
2453 2448
2454 bool updated = false; 2449 bool updated = false;
2455 2450
2451 Vector3 LocalVectorToTarget3D = MoveToPositionTarget - AbsolutePosition;
2452
2456// m_log.DebugFormat( 2453// m_log.DebugFormat(
2457// "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", 2454// "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}",
2458// allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); 2455// allowUpdate, m_moveToPositionInProgress, m_autopilotMoving);
2459 2456
2460 double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); 2457 double distanceToTarget = LocalVectorToTarget3D.Length();
2461 2458
2462// m_log.DebugFormat( 2459// m_log.DebugFormat(
2463// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", 2460// "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}",
@@ -2480,11 +2477,11 @@ namespace OpenSim.Region.Framework.Scenes
2480 // Theoretically we might need a more complex PID approach here if other 2477 // Theoretically we might need a more complex PID approach here if other
2481 // unknown forces are acting on the avatar and we need to adaptively respond 2478 // unknown forces are acting on the avatar and we need to adaptively respond
2482 // to such forces, but the following simple approach seems to works fine. 2479 // to such forces, but the following simple approach seems to works fine.
2483 Vector3 LocalVectorToTarget3D = 2480
2484 (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords 2481 LocalVectorToTarget3D = LocalVectorToTarget3D * Quaternion.Inverse(Rotation); // change to avatar coords
2485 * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords
2486 // Ignore z component of vector 2482 // Ignore z component of vector
2487// Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); 2483// Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f);
2484
2488 LocalVectorToTarget3D.Normalize(); 2485 LocalVectorToTarget3D.Normalize();
2489 2486
2490 // update avatar movement flags. the avatar coordinate system is as follows: 2487 // update avatar movement flags. the avatar coordinate system is as follows:
@@ -2508,28 +2505,37 @@ namespace OpenSim.Region.Framework.Scenes
2508 2505
2509 // based on the above avatar coordinate system, classify the movement into 2506 // based on the above avatar coordinate system, classify the movement into
2510 // one of left/right/back/forward. 2507 // one of left/right/back/forward.
2508
2509 const uint noMovFlagsMask = (uint)(~(Dir_ControlFlags.DIR_CONTROL_FLAG_BACK |
2510 Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD | Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT |
2511 Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT | Dir_ControlFlags.DIR_CONTROL_FLAG_UP |
2512 Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN));
2513
2514 MovementFlag &= noMovFlagsMask;
2515 AgentControlFlags &= noMovFlagsMask;
2516
2511 if (LocalVectorToTarget3D.X < 0) //MoveBack 2517 if (LocalVectorToTarget3D.X < 0) //MoveBack
2512 { 2518 {
2513 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; 2519 MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
2514 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; 2520 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK;
2515 updated = true; 2521 updated = true;
2516 } 2522 }
2517 else if (LocalVectorToTarget3D.X > 0) //Move Forward 2523 else if (LocalVectorToTarget3D.X > 0) //Move Forward
2518 { 2524 {
2519 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; 2525 MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
2520 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; 2526 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD;
2521 updated = true; 2527 updated = true;
2522 } 2528 }
2523 2529
2524 if (LocalVectorToTarget3D.Y > 0) //MoveLeft 2530 if (LocalVectorToTarget3D.Y > 0) //MoveLeft
2525 { 2531 {
2526 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; 2532 MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
2527 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; 2533 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT;
2528 updated = true; 2534 updated = true;
2529 } 2535 }
2530 else if (LocalVectorToTarget3D.Y < 0) //MoveRight 2536 else if (LocalVectorToTarget3D.Y < 0) //MoveRight
2531 { 2537 {
2532 MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; 2538 MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
2533 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; 2539 AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT;
2534 updated = true; 2540 updated = true;
2535 } 2541 }
@@ -3016,6 +3022,7 @@ namespace OpenSim.Region.Framework.Scenes
3016 ResetMoveToTarget(); 3022 ResetMoveToTarget();
3017 3023
3018 Velocity = Vector3.Zero; 3024 Velocity = Vector3.Zero;
3025 m_AngularVelocity = Vector3.Zero;
3019 3026
3020 part.AddSittingAvatar(UUID); 3027 part.AddSittingAvatar(UUID);
3021 3028