aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/World/Primitive.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.Region/World/Primitive.cs')
-rw-r--r--OpenSim/OpenSim.Region/World/Primitive.cs141
1 files changed, 59 insertions, 82 deletions
diff --git a/OpenSim/OpenSim.Region/World/Primitive.cs b/OpenSim/OpenSim.Region/World/Primitive.cs
index 1f70550..d540a3b 100644
--- a/OpenSim/OpenSim.Region/World/Primitive.cs
+++ b/OpenSim/OpenSim.Region/World/Primitive.cs
@@ -14,12 +14,12 @@ namespace OpenSim.Region
14 public class Primitive : Entity 14 public class Primitive : Entity
15 { 15 {
16 protected PrimData primData; 16 protected PrimData primData;
17 //private ObjectUpdatePacket OurPacket;
18 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); 17 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
19 private Dictionary<uint, IClientAPI> m_clientThreads; 18 private Dictionary<uint, IClientAPI> m_clientThreads;
20 private ulong m_regionHandle; 19 private ulong m_regionHandle;
21 private const uint FULL_MASK_PERMISSIONS = 2147483647; 20 private const uint FULL_MASK_PERMISSIONS = 2147483647;
22 private bool physicsEnabled = false; 21 private bool physicsEnabled = false;
22 private byte updateFlag = 0;
23 23
24 private Dictionary<LLUUID, InventoryItem> inventoryItems; 24 private Dictionary<LLUUID, InventoryItem> inventoryItems;
25 25
@@ -66,7 +66,7 @@ namespace OpenSim.Region
66 inventoryItems = new Dictionary<LLUUID, InventoryItem>(); 66 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
67 } 67 }
68 68
69 public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner) 69 public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner, LLUUID fullID, uint localID)
70 { 70 {
71 m_clientThreads = clientThreads; 71 m_clientThreads = clientThreads;
72 m_regionHandle = regionHandle; 72 m_regionHandle = regionHandle;
@@ -75,8 +75,34 @@ namespace OpenSim.Region
75 this.primData = new PrimData(); 75 this.primData = new PrimData();
76 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 76 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
77 this.primData.OwnerID = owner; 77 this.primData.OwnerID = owner;
78 this.primData.FullID = this.uuid = fullID;
79 this.primData.LocalID = this.localid = localID;
78 } 80 }
79 81
82 /// <summary>
83 /// Constructor to create a default cube
84 /// </summary>
85 /// <param name="clientThreads"></param>
86 /// <param name="regionHandle"></param>
87 /// <param name="world"></param>
88 /// <param name="owner"></param>
89 /// <param name="localID"></param>
90 /// <param name="position"></param>
91 public Primitive(Dictionary<uint, IClientAPI> clientThreads, ulong regionHandle, World world, LLUUID owner, uint localID, LLVector3 position)
92 {
93 m_clientThreads = clientThreads;
94 m_regionHandle = regionHandle;
95 m_world = world;
96 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
97 this.primData = PrimData.DefaultCube();
98 this.primData.OwnerID = owner;
99 this.primData.LocalID = this.localid = localID;
100 this.Pos = this.primData.Position = position;
101
102 this.updateFlag = 1;
103 }
104
105
80 public byte[] GetByteArray() 106 public byte[] GetByteArray()
81 { 107 {
82 byte[] result = null; 108 byte[] result = null;
@@ -115,7 +141,11 @@ namespace OpenSim.Region
115 141
116 public override void update() 142 public override void update()
117 { 143 {
118 LLVector3 pos2 = new LLVector3(0, 0, 0); 144 if (this.updateFlag == 1)
145 {
146 this.SendFullUpdateToAllClients();
147 this.updateFlag = 0;
148 }
119 } 149 }
120 150
121 public override void BackUp() 151 public override void BackUp()
@@ -275,17 +305,39 @@ namespace OpenSim.Region
275 305
276 public void SendFullUpdateToAllClients() 306 public void SendFullUpdateToAllClients()
277 { 307 {
278 308 List<Avatar> avatars = this.m_world.RequestAvatarList();
309 for (int i = 0; i < avatars.Count; i++)
310 {
311 this.SendFullUpdateToClient(avatars[i].ControllingClient);
312 }
279 } 313 }
280 314
281 public void SendTerseUpdateToClient(IClientAPI RemoteClient) 315 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
282 { 316 {
317 LLVector3 lPos;
318 Axiom.MathLib.Quaternion lRot;
319 if (this._physActor != null && this.physicsEnabled)
320 {
321 PhysicsVector pPos = this._physActor.Position;
322 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
323 lRot = this._physActor.Orientation;
324 }
325 else
326 {
327 lPos = this.Pos;
328 lRot = this.rotation;
329 }
283 330
331
284 } 332 }
285 333
286 public void SendTerseUpdateToALLClients() 334 public void SendTerseUpdateToALLClients()
287 { 335 {
288 336 List<Avatar> avatars = this.m_world.RequestAvatarList();
337 for (int i = 0; i < avatars.Count; i++)
338 {
339 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
340 }
289 } 341 }
290 342
291 #endregion 343 #endregion
@@ -324,6 +376,8 @@ namespace OpenSim.Region
324 this.primData.FullID = this.uuid = LLUUID.Random(); 376 this.primData.FullID = this.uuid = LLUUID.Random();
325 this.localid = (uint)(localID); 377 this.localid = (uint)(localID);
326 this.primData.Position = this.Pos = pos1; 378 this.primData.Position = this.Pos = pos1;
379
380 this.updateFlag = 1;
327 } 381 }
328 382
329 public void CreateFromBytes(byte[] data) 383 public void CreateFromBytes(byte[] data)
@@ -343,82 +397,5 @@ namespace OpenSim.Region
343 397
344 #endregion 398 #endregion
345 399
346
347 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
348 {
349 uint ID = this.localid;
350 byte[] bytes = new byte[60];
351
352 int i = 0;
353 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
354 dat.TextureEntry = new byte[0];
355 bytes[i++] = (byte)(ID % 256);
356 bytes[i++] = (byte)((ID >> 8) % 256);
357 bytes[i++] = (byte)((ID >> 16) % 256);
358 bytes[i++] = (byte)((ID >> 24) % 256);
359 bytes[i++] = 0;
360 bytes[i++] = 0;
361
362 LLVector3 lPos;
363 Axiom.MathLib.Quaternion lRot;
364 if (this._physActor != null && this.physicsEnabled)
365 {
366 PhysicsVector pPos = this._physActor.Position;
367 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
368 lRot = this._physActor.Orientation;
369 }
370 else
371 {
372 lPos = this.Pos;
373 lRot = this.rotation;
374 }
375 byte[] pb = lPos.GetBytes();
376 Array.Copy(pb, 0, bytes, i, pb.Length);
377 i += 12;
378 ushort ac = 32767;
379
380 //vel
381 bytes[i++] = (byte)(ac % 256);
382 bytes[i++] = (byte)((ac >> 8) % 256);
383 bytes[i++] = (byte)(ac % 256);
384 bytes[i++] = (byte)((ac >> 8) % 256);
385 bytes[i++] = (byte)(ac % 256);
386 bytes[i++] = (byte)((ac >> 8) % 256);
387
388 //accel
389 bytes[i++] = (byte)(ac % 256);
390 bytes[i++] = (byte)((ac >> 8) % 256);
391 bytes[i++] = (byte)(ac % 256);
392 bytes[i++] = (byte)((ac >> 8) % 256);
393 bytes[i++] = (byte)(ac % 256);
394 bytes[i++] = (byte)((ac >> 8) % 256);
395
396 ushort rw, rx, ry, rz;
397 rw = (ushort)(32768 * (lRot.w + 1));
398 rx = (ushort)(32768 * (lRot.x + 1));
399 ry = (ushort)(32768 * (lRot.y + 1));
400 rz = (ushort)(32768 * (lRot.z + 1));
401
402 //rot
403 bytes[i++] = (byte)(rx % 256);
404 bytes[i++] = (byte)((rx >> 8) % 256);
405 bytes[i++] = (byte)(ry % 256);
406 bytes[i++] = (byte)((ry >> 8) % 256);
407 bytes[i++] = (byte)(rz % 256);
408 bytes[i++] = (byte)((rz >> 8) % 256);
409 bytes[i++] = (byte)(rw % 256);
410 bytes[i++] = (byte)((rw >> 8) % 256);
411
412 //rotation vel
413 bytes[i++] = (byte)(ac % 256);
414 bytes[i++] = (byte)((ac >> 8) % 256);
415 bytes[i++] = (byte)(ac % 256);
416 bytes[i++] = (byte)((ac >> 8) % 256);
417 bytes[i++] = (byte)(ac % 256);
418 bytes[i++] = (byte)((ac >> 8) % 256);
419
420 dat.Data = bytes;
421 return dat;
422 }
423 } 400 }
424} 401}