diff options
Switched in NameSpaceChanges
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs (renamed from OpenSim/OpenSim.Region/Scenes/ScenePresence.cs) | 82 |
1 files changed, 53 insertions, 29 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 45d3fed..b90004e 100644 --- a/OpenSim/OpenSim.Region/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -37,7 +37,7 @@ using OpenSim.Framework.Interfaces; | |||
37 | using OpenSim.Framework.Types; | 37 | using OpenSim.Framework.Types; |
38 | using Axiom.MathLib; | 38 | using Axiom.MathLib; |
39 | 39 | ||
40 | namespace OpenSim.Region.Scenes | 40 | namespace OpenSim.Region.Environment.Scenes |
41 | { | 41 | { |
42 | public partial class ScenePresence : Entity | 42 | public partial class ScenePresence : Entity |
43 | { | 43 | { |
@@ -66,6 +66,17 @@ namespace OpenSim.Region.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.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,46 @@ namespace OpenSim.Region.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 | this.PhysActor.Flying = ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_FLY) != 0); | ||
246 | |||
247 | if (q != this.bodyRot) | ||
221 | { | 248 | { |
222 | Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); | 249 | this.bodyRot = q; |
223 | if (((movementflag & 1) == 0) || (q != this.bodyRot)) | 250 | 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 | } | 251 | } |
231 | else if ((flags & (uint)MainAvatar.ControlFlags.AGENT_CONTROL_AT_NEG) != 0) | 252 | foreach (Dir_ControlFlags DCF in Enum.GetValues(typeof(Dir_ControlFlags))) |
232 | { | 253 | { |
233 | Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(bodyRotation.W, bodyRotation.X, bodyRotation.Y, bodyRotation.Z); | 254 | if ((flags & (uint)DCF) != 0) |
234 | if (((movementflag & 2) == 0) || (q != this.bodyRot)) | 255 | { |
235 | { | 256 | DCFlagKeyPressed = true; |
236 | Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0); | 257 | agent_control_v3 += Dir_Vectors[i]; |
237 | this.AddNewMovement(v3, q); | 258 | if ((movementflag & (uint)DCF) == 0) |
238 | movementflag = 2; | 259 | { |
239 | this.bodyRot = q; | 260 | movementflag += (byte)(uint)DCF; |
261 | update_movementflag = true; | ||
262 | } | ||
240 | } | 263 | } |
241 | } | 264 | else |
242 | else | ||
243 | { | ||
244 | if ((movementflag) != 0) | ||
245 | { | 265 | { |
246 | NewForce newVelocity = new NewForce(); | 266 | if ((movementflag & (uint)DCF) != 0) |
247 | newVelocity.X = 0; | 267 | { |
248 | newVelocity.Y = 0; | 268 | movementflag -= (byte)(uint)DCF; |
249 | newVelocity.Z = 0; | 269 | update_movementflag = true; |
250 | this.forcesList.Add(newVelocity); | 270 | } |
251 | movementflag = 0; | ||
252 | } | 271 | } |
272 | i++; | ||
273 | } | ||
274 | if ((update_movementflag) || (update_rotation && DCFlagKeyPressed)) | ||
275 | { | ||
276 | this.AddNewMovement(agent_control_v3, q); | ||
253 | } | 277 | } |
254 | 278 | ||
255 | } | 279 | } |