aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/world/Avatar.cs15
-rw-r--r--src/world/PhysicsEngine.cs11
-rw-r--r--src/world/World.cs25
3 files changed, 30 insertions, 21 deletions
diff --git a/src/world/Avatar.cs b/src/world/Avatar.cs
index 68606c4..fbd78b7 100644
--- a/src/world/Avatar.cs
+++ b/src/world/Avatar.cs
@@ -13,7 +13,10 @@ namespace OpenSim.world
13 public string firstname; 13 public string firstname;
14 public string lastname; 14 public string lastname;
15 public OpenSimClient ControllingClient; 15 public OpenSimClient ControllingClient;
16 public LLVector3 oldvel;
17 public LLVector3 oldpos;
16 public uint CurrentKeyMask; 18 public uint CurrentKeyMask;
19 public bool walking;
17 20
18 private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; 21 private libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
19 22
@@ -30,18 +33,22 @@ namespace OpenSim.world
30 base.update(); 33 base.update();
31 34
32 Console.WriteLine("KeyMask: " + this.CurrentKeyMask); 35 Console.WriteLine("KeyMask: " + this.CurrentKeyMask);
33 36
37 oldvel=this.velocity;
38 oldpos=this.position;
34 if((this.CurrentKeyMask & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) { 39 if((this.CurrentKeyMask & (uint)MainAvatar.AgentUpdateFlags.AGENT_CONTROL_AT_POS) != 0) {
35 Vector3 tmpVelocity = this.rotation * new Vector3(1.0f,0.0f,0.0f); 40 Vector3 tmpVelocity = this.rotation * new Vector3(1.0f,0.0f,0.0f);
36 tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.3f; 41 tmpVelocity.Normalize(); tmpVelocity = tmpVelocity * 0.5f;
37 this.velocity.X = tmpVelocity.x; 42 this.velocity.X = tmpVelocity.x;
38 this.velocity.Y = tmpVelocity.y; 43 this.velocity.Y = tmpVelocity.y;
39 this.velocity.Z = tmpVelocity.z; 44 this.velocity.Z = tmpVelocity.z;
40 Console.WriteLine("Walking at "+ this.velocity.ToString()); 45 Console.WriteLine("Walking at "+ this.velocity.ToString());
46 this.walking=true;
41 } else { 47 } else {
42 this.velocity.X=0; 48 this.velocity.X=0;
43 this.velocity.Y=0; 49 this.velocity.Y=0;
44 this.velocity.Z=0; 50 this.velocity.Z=0;
51 this.walking=false;
45 } 52 }
46 } 53 }
47 } 54 }
@@ -238,10 +245,8 @@ namespace OpenSim.world
238 245
239 public void HandleAgentUpdate(AgentUpdatePacket update) { 246 public void HandleAgentUpdate(AgentUpdatePacket update) {
240 lock(this) { 247 lock(this) {
241 // FIXME: shouldn't update these direction
242 this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z);
243
244 this.CurrentKeyMask = update.AgentData.ControlFlags; 248 this.CurrentKeyMask = update.AgentData.ControlFlags;
249 this.rotation = new Quaternion(update.AgentData.BodyRotation.W, update.AgentData.BodyRotation.X, update.AgentData.BodyRotation.Y, update.AgentData.BodyRotation.Z);
245 this.needupdate = true; 250 this.needupdate = true;
246 } 251 }
247 } 252 }
diff --git a/src/world/PhysicsEngine.cs b/src/world/PhysicsEngine.cs
index a789828..d9351af 100644
--- a/src/world/PhysicsEngine.cs
+++ b/src/world/PhysicsEngine.cs
@@ -20,11 +20,12 @@ namespace OpenSim.world
20 public void DoStuff(World simworld) { 20 public void DoStuff(World simworld) {
21 foreach (libsecondlife.LLUUID UUID in simworld.Entities.Keys) 21 foreach (libsecondlife.LLUUID UUID in simworld.Entities.Keys)
22 { 22 {
23 if( true /* simworld.Entities[UUID].needupdate */) { // FIXME! 23 if((simworld.Entities[UUID].position.X>0) & (simworld.Entities[UUID].position.X<256) & (simworld.Entities[UUID].position.Y>1) & (simworld.Entities[UUID].position.Y<256)) {
24 simworld.Entities[UUID].position += simworld.Entities[UUID].velocity; 24 simworld.Entities[UUID].position += simworld.Entities[UUID].velocity;
25 Console.WriteLine("Moving "+UUID.ToString()+ " to "+ simworld.Entities[UUID].position.ToString()); 25 simworld.Entities[UUID].position.Z = simworld.LandMap[(int)simworld.Entities[UUID].position.Y * 256 + (int)simworld.Entities[UUID].position.X]+1;
26 } 26 } else {
27 27 simworld.Entities[UUID].velocity = new LLVector3(0f,0f,0f);
28 }
28 } 29 }
29 } 30 }
30 } 31 }
diff --git a/src/world/World.cs b/src/world/World.cs
index b261884..f32f9ef 100644
--- a/src/world/World.cs
+++ b/src/world/World.cs
@@ -50,17 +50,20 @@ namespace OpenSim.world
50 { 50 {
51 if(Entities[UUID].needupdate) { 51 if(Entities[UUID].needupdate) {
52 Entities[UUID].update(); 52 Entities[UUID].update();
53 } 53
54 if(Entities[UUID] is Avatar) { // FIXME: only send updates when avatar moves. 54 if(Entities[UUID] is Avatar) {
55 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock(); 55 Avatar avatar=(Avatar)Entities[UUID];
56 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) { 56 if((avatar.oldpos!=avatar.position) || (avatar.oldvel!=avatar.velocity) || avatar.walking) {
57 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); 57 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = Entities[UUID].CreateTerseBlock();
58 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME 58 foreach(OpenSimClient client in OpenSim_Main.sim.ClientThreads.Values) {
59 terse.RegionData.TimeDilation = 0; 59 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
60 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 60 terse.RegionData.RegionHandle = OpenSim_Main.cfg.RegionHandle; // FIXME
61 terse.ObjectData[0] = terseBlock; 61 terse.RegionData.TimeDilation = 0;
62 client.OutPacket(terse); 62 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
63 } 63 terse.ObjectData[0] = terseBlock;
64 client.OutPacket(terse);
65 }
66 }}
64 } 67 }
65 } 68 }
66 } 69 }