aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/world/Avatar.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/world/Avatar.cs')
-rw-r--r--src/world/Avatar.cs103
1 files changed, 90 insertions, 13 deletions
diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs
index c09c008..facfeee 100644
--- a/src/world/Avatar.cs
+++ b/src/world/Avatar.cs
@@ -11,15 +11,17 @@ namespace OpenSim.world
11{ 11{
12 public class Avatar : Entity 12 public class Avatar : Entity
13 { 13 {
14 public static bool PhysicsEngineFlying;
14 public string firstname; 15 public string firstname;
15 public string lastname; 16 public string lastname;
16 public OpenSimClient ControllingClient; 17 public OpenSimClient ControllingClient;
17 private PhysicsActor _physActor; 18 private PhysicsActor _physActor;
18 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; 19 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
19 private bool updateflag; 20 private bool updateflag;
20 private bool walking; 21 private byte movementflag;
21 private List<NewForce> forcesList = new List<NewForce>(); 22 private List<NewForce> forcesList = new List<NewForce>();
22 private short _updateCount; 23 private short _updateCount;
24 private Axiom.MathLib.Quaternion bodyRot;
23 25
24 public Avatar(OpenSimClient TheClient) { 26 public Avatar(OpenSimClient TheClient) {
25 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); 27 ServerConsole.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
@@ -77,14 +79,14 @@ namespace OpenSim.world
77 } 79 }
78 80
79 updateflag =false; 81 updateflag =false;
80 this._updateCount = 0; 82 //this._updateCount = 0;
81 } 83 }
82 else 84 else
83 { 85 {
84 if(walking) 86 //if((movementflag & 1) !=0)
85 { 87 //{
86 _updateCount++; 88 _updateCount++;
87 if(_updateCount>3) 89 if(( (!PhysicsEngineFlying) && (_updateCount>3)) || (_updateCount>0))
88 { 90 {
89 //It has been a while since last update was sent so lets send one. 91 //It has been a while since last update was sent so lets send one.
90 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock(); 92 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = CreateTerseBlock();
@@ -98,7 +100,7 @@ namespace OpenSim.world
98 } 100 }
99 _updateCount = 0; 101 _updateCount = 0;
100 } 102 }
101 } 103 //}
102 } 104 }
103 } 105 }
104 106
@@ -249,36 +251,111 @@ namespace OpenSim.world
249 } 251 }
250 252
251 public void HandleUpdate(AgentUpdatePacket pack) { 253 public void HandleUpdate(AgentUpdatePacket pack) {
252 if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) !=0) { 254 if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_FLY) !=0)
253 if(!walking) 255 {
256 this._physActor.Flying = true;
257 }
258 else
259 {
260 this._physActor.Flying = false;
261 }
262 if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) !=0) {
263 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
264 if(((movementflag & 1) ==0) || (q!= this.bodyRot))
254 { 265 {
255 //we should add a new force to the list 266 //we should add a new force to the list
256 // but for now we will deal with velocities 267 // but for now we will deal with velocities
257 NewForce newVelocity = new NewForce(); 268 NewForce newVelocity = new NewForce();
258 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0); 269 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(1, 0, 0);
259 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
260 Axiom.MathLib.Vector3 direc = q * v3; 270 Axiom.MathLib.Vector3 direc = q * v3;
261 direc.Normalize(); 271 direc.Normalize();
262 272
263 //work out velocity for sim physics system 273 //work out velocity for sim physics system
264 direc = direc * ((0.03f) * 128f); 274 direc = direc * ((0.03f) * 128f);
275 if(this._physActor.Flying)
276 direc *=2;
277
278 newVelocity.X = direc.x;
279 newVelocity.Y = direc.y;
280 newVelocity.Z = direc.z;
281 this.forcesList.Add(newVelocity);
282 movementflag = 1;
283 this.bodyRot = q;
284 }
285 }
286 else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_POS) !=0) &&(PhysicsEngineFlying)) {
287 if(((movementflag & 2) ==0) && this._physActor.Flying)
288 {
289 //we should add a new force to the list
290 // but for now we will deal with velocities
291 NewForce newVelocity = new NewForce();
292 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, 1);
293 Axiom.MathLib.Vector3 direc = v3;
294 direc.Normalize();
295
296 //work out velocity for sim physics system
297 direc = direc * ((0.03f) * 128f *2);
298 newVelocity.X = direc.x;
299 newVelocity.Y = direc.y;
300 newVelocity.Z = direc.z;
301 this.forcesList.Add(newVelocity);
302 movementflag = 2;
303 }
304 }
305 else if((((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_UP_NEG) !=0) && (PhysicsEngineFlying)) {
306 if(((movementflag & 4) ==0) && this._physActor.Flying)
307 {
308 //we should add a new force to the list
309 // but for now we will deal with velocities
310 NewForce newVelocity = new NewForce();
311 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(0, 0, -1);
312 //Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
313 Axiom.MathLib.Vector3 direc = v3;
314 direc.Normalize();
315
316 //work out velocity for sim physics system
317 direc = direc * ((0.03f) * 128f *2);
318 newVelocity.X = direc.x;
319 newVelocity.Y = direc.y;
320 newVelocity.Z = direc.z;
321 this.forcesList.Add(newVelocity);
322 movementflag = 4;
323 }
324 }
325 else if(((uint)pack.AgentData.ControlFlags & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_NEG) !=0) {
326 Axiom.MathLib.Quaternion q = new Axiom.MathLib.Quaternion(pack.AgentData.BodyRotation.W, pack.AgentData.BodyRotation.X, pack.AgentData.BodyRotation.Y, pack.AgentData.BodyRotation.Z);
327 if(((movementflag & 8) ==0) || (q!= this.bodyRot))
328 {
329 //we should add a new force to the list
330 // but for now we will deal with velocities
331 NewForce newVelocity = new NewForce();
332 Axiom.MathLib.Vector3 v3 = new Axiom.MathLib.Vector3(-1, 0, 0);
333 Axiom.MathLib.Vector3 direc = q * v3;
334 direc.Normalize();
335
336 //work out velocity for sim physics system
337 direc = direc * ((0.03f) * 128f);
338 if(this._physActor.Flying)
339 direc *=2;
340
265 newVelocity.X = direc.x; 341 newVelocity.X = direc.x;
266 newVelocity.Y = direc.y; 342 newVelocity.Y = direc.y;
267 newVelocity.Z = direc.z; 343 newVelocity.Z = direc.z;
268 this.forcesList.Add(newVelocity); 344 this.forcesList.Add(newVelocity);
269 walking=true; 345 movementflag = 8;
346 this.bodyRot = q;
270 } 347 }
271 } 348 }
272 else 349 else
273 { 350 {
274 if(walking) 351 if((movementflag) !=0)
275 { 352 {
276 NewForce newVelocity = new NewForce(); 353 NewForce newVelocity = new NewForce();
277 newVelocity.X = 0; 354 newVelocity.X = 0;
278 newVelocity.Y = 0; 355 newVelocity.Y = 0;
279 newVelocity.Z = 0; 356 newVelocity.Z = 0;
280 this.forcesList.Add(newVelocity); 357 this.forcesList.Add(newVelocity);
281 walking = false; 358 movementflag = 0;
282 } 359 }
283 } 360 }
284 } 361 }