aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/ScenePresence.cs81
1 files changed, 53 insertions, 28 deletions
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 96e5c94..23434a0 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -66,6 +66,17 @@ namespace OpenSim.Region.Environment.Scenes
66 66
67 protected RegionInfo m_regionInfo; 67 protected RegionInfo m_regionInfo;
68 68
69 private Vector3[] Dir_Vectors = new Vector3[6];
70 private enum Dir_ControlFlags
71 {
72 DIR_CONTROL_FLAG_FOWARD = MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS,
73 DIR_CONTROL_FLAG_BACK = MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG,
74 DIR_CONTROL_FLAG_LEFT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_POS,
75 DIR_CONTROL_FLAG_RIGHT = MainAvatar.ControlFlags.AGENT_CONTROL_LEFT_NEG,
76 DIR_CONTROL_FLAG_UP = MainAvatar.ControlFlags.AGENT_CONTROL_UP_POS,
77 DIR_CONTROL_FLAG_DOWN = MainAvatar.ControlFlags.AGENT_CONTROL_UP_NEG
78 }
79
69 #region Properties 80 #region Properties
70 /// <summary> 81 /// <summary>
71 /// 82 ///
@@ -125,6 +136,13 @@ namespace OpenSim.Region.Environment.Scenes
125 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); 136 // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange);
126 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); 137 //ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement);
127 138
139 Dir_Vectors[0] = new Vector3(1, 0, 0); //FOWARD
140 Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK
141 Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT
142 Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT
143 Dir_Vectors[4] = new Vector3(0, 0, 1); //UP
144 Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN
145
128 } 146 }
129 #endregion 147 #endregion
130 148
@@ -216,40 +234,47 @@ namespace OpenSim.Region.Environment.Scenes
216 /// </summary> 234 /// </summary>
217 /// <param name="pack"></param> 235 /// <param name="pack"></param>
218 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation) 236 public void HandleAgentUpdate(IClientAPI remoteClient, uint flags, LLQuaternion bodyRotation)
219 { 237 {
220 if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_POS) != 0) 238 int i = 0;
239 bool update_movementflag = false;
240 bool update_rotation = false;
241 bool DCFlagKeyPressed = false;
242 Vector3 agent_control_v3 = new Vector3(0, 0, 0);
243 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z);
244
245
246 // this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0);
247
248 if (q != this.bodyRot)
221 { 249 {
222 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); 250 this.bodyRot = q;
223 if (((movementflag & 1) == 0) || (q != this.bodyRot)) 251 update_rotation = true;
224 {
225 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
226 this.AddNewMovement(v3, q);
227 movementflag = 1;
228 this.bodyRot = q;
229 }
230 } 252 }
231 else if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG) != 0) 253 foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags)))
232 { 254 {
233 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); 255 if ((flags & (uint)DCF) != 0)
234 if (((movementflag & 2) == 0) || (q != this.bodyRot)) 256 {
235 { 257 DCFlagKeyPressed = true;
236 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0); 258 agent_control_v3 += Dir_Vectors[i];
237 this.AddNewMovement(v3, q); 259 if ((movementflag & (uint)DCF) == 0)
238 movementflag = 2; 260 {
239 this.bodyRot = q; 261 movementflag += (byte)(uint)DCF;
262 update_movementflag = true;
263 }
240 } 264 }
241 } 265 else
242 else
243 {
244 if ((movementflag) != 0)
245 { 266 {
246 NewForce newVelocity = new NewForce(); 267 if ((movementflag & (uint)DCF) != 0)
247 newVelocity.X = 0; 268 {
248 newVelocity.Y = 0; 269 movementflag -= (byte)(uint)DCF;
249 newVelocity.Z = 0; 270 update_movementflag = true;
250 this.forcesList.Add(newVelocity); 271 }
251 movementflag = 0;
252 } 272 }
273 i++;
274 }
275 if ((update_movementflag) || (update_rotation && DCFlagKeyPressed))
276 {
277 this.AddNewMovement(agent_control_v3, q);
253 } 278 }
254 279
255 } 280 }