aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs199
1 files changed, 135 insertions, 64 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4c339d9..ac39b6b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -62,7 +62,8 @@ namespace OpenSim.Region.Framework.Scenes
62 TELEPORT = 512, 62 TELEPORT = 512,
63 REGION_RESTART = 1024, 63 REGION_RESTART = 1024,
64 MEDIA = 2048, 64 MEDIA = 2048,
65 ANIMATION = 16384 65 ANIMATION = 16384,
66 POSITION = 32768
66 } 67 }
67 68
68 // I don't really know where to put this except here. 69 // I don't really know where to put this except here.
@@ -184,6 +185,15 @@ namespace OpenSim.Region.Framework.Scenes
184 185
185 public UUID FromFolderID; 186 public UUID FromFolderID;
186 187
188 // The following two are to hold the attachment data
189 // while an object is inworld
190 [XmlIgnore]
191 public byte AttachPoint = 0;
192
193 [XmlIgnore]
194 public Vector3 AttachOffset = Vector3.Zero;
195
196 [XmlIgnore]
187 public int STATUS_ROTATE_X; 197 public int STATUS_ROTATE_X;
188 198
189 public int STATUS_ROTATE_Y; 199 public int STATUS_ROTATE_Y;
@@ -210,8 +220,7 @@ namespace OpenSim.Region.Framework.Scenes
210 220
211 public Vector3 RotationAxis = Vector3.One; 221 public Vector3 RotationAxis = Vector3.One;
212 222
213 public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this 223 public bool VolumeDetectActive;
214 // Certainly this must be a persistant setting finally
215 224
216 public bool IsWaitingForFirstSpinUpdatePacket; 225 public bool IsWaitingForFirstSpinUpdatePacket;
217 226
@@ -251,6 +260,7 @@ namespace OpenSim.Region.Framework.Scenes
251 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 260 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
252 private Vector3 m_sitTargetPosition; 261 private Vector3 m_sitTargetPosition;
253 private string m_sitAnimation = "SIT"; 262 private string m_sitAnimation = "SIT";
263 private bool m_occupied; // KF if any av is sitting on this prim
254 private string m_text = String.Empty; 264 private string m_text = String.Empty;
255 private string m_touchName = String.Empty; 265 private string m_touchName = String.Empty;
256 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); 266 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5);
@@ -283,6 +293,7 @@ namespace OpenSim.Region.Framework.Scenes
283 protected Vector3 m_lastAcceleration; 293 protected Vector3 m_lastAcceleration;
284 protected Vector3 m_lastAngularVelocity; 294 protected Vector3 m_lastAngularVelocity;
285 protected int m_lastTerseSent; 295 protected int m_lastTerseSent;
296 protected float m_buoyancy = 0.0f;
286 297
287 /// <summary> 298 /// <summary>
288 /// Stores media texture data 299 /// Stores media texture data
@@ -338,7 +349,7 @@ namespace OpenSim.Region.Framework.Scenes
338 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 349 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
339 Quaternion rotationOffset, Vector3 offsetPosition) : this() 350 Quaternion rotationOffset, Vector3 offsetPosition) : this()
340 { 351 {
341 m_name = "Primitive"; 352 m_name = "Object";
342 353
343 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 354 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
344 LastOwnerID = CreatorID = OwnerID = ownerID; 355 LastOwnerID = CreatorID = OwnerID = ownerID;
@@ -378,7 +389,7 @@ namespace OpenSim.Region.Framework.Scenes
378 private uint _ownerMask = (uint)PermissionMask.All; 389 private uint _ownerMask = (uint)PermissionMask.All;
379 private uint _groupMask = (uint)PermissionMask.None; 390 private uint _groupMask = (uint)PermissionMask.None;
380 private uint _everyoneMask = (uint)PermissionMask.None; 391 private uint _everyoneMask = (uint)PermissionMask.None;
381 private uint _nextOwnerMask = (uint)PermissionMask.All; 392 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
382 private PrimFlags _flags = PrimFlags.None; 393 private PrimFlags _flags = PrimFlags.None;
383 private DateTime m_expires; 394 private DateTime m_expires;
384 private DateTime m_rezzed; 395 private DateTime m_rezzed;
@@ -472,12 +483,16 @@ namespace OpenSim.Region.Framework.Scenes
472 } 483 }
473 484
474 /// <value> 485 /// <value>
475 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 486 /// Get the inventory list
476 /// </value> 487 /// </value>
477 public TaskInventoryDictionary TaskInventory 488 public TaskInventoryDictionary TaskInventory
478 { 489 {
479 get { return m_inventory.Items; } 490 get {
480 set { m_inventory.Items = value; } 491 return m_inventory.Items;
492 }
493 set {
494 m_inventory.Items = value;
495 }
481 } 496 }
482 497
483 /// <summary> 498 /// <summary>
@@ -621,14 +636,12 @@ namespace OpenSim.Region.Framework.Scenes
621 set { m_LoopSoundSlavePrims = value; } 636 set { m_LoopSoundSlavePrims = value; }
622 } 637 }
623 638
624
625 public Byte[] TextureAnimation 639 public Byte[] TextureAnimation
626 { 640 {
627 get { return m_TextureAnimation; } 641 get { return m_TextureAnimation; }
628 set { m_TextureAnimation = value; } 642 set { m_TextureAnimation = value; }
629 } 643 }
630 644
631
632 public Byte[] ParticleSystem 645 public Byte[] ParticleSystem
633 { 646 {
634 get { return m_particleSystem; } 647 get { return m_particleSystem; }
@@ -665,9 +678,11 @@ namespace OpenSim.Region.Framework.Scenes
665 { 678 {
666 // If this is a linkset, we don't want the physics engine mucking up our group position here. 679 // If this is a linkset, we don't want the physics engine mucking up our group position here.
667 PhysicsActor actor = PhysActor; 680 PhysicsActor actor = PhysActor;
668 if (actor != null && ParentID == 0) 681 if (ParentID == 0)
669 { 682 {
670 m_groupPosition = actor.Position; 683 if (actor != null)
684 m_groupPosition = actor.Position;
685 return m_groupPosition;
671 } 686 }
672 687
673 if (ParentGroup.IsAttachment) 688 if (ParentGroup.IsAttachment)
@@ -677,12 +692,14 @@ namespace OpenSim.Region.Framework.Scenes
677 return sp.AbsolutePosition; 692 return sp.AbsolutePosition;
678 } 693 }
679 694
695 // use root prim's group position. Physics may have updated it
696 if (ParentGroup.RootPart != this)
697 m_groupPosition = ParentGroup.RootPart.GroupPosition;
680 return m_groupPosition; 698 return m_groupPosition;
681 } 699 }
682 set 700 set
683 { 701 {
684 m_groupPosition = value; 702 m_groupPosition = value;
685
686 PhysicsActor actor = PhysActor; 703 PhysicsActor actor = PhysActor;
687 if (actor != null) 704 if (actor != null)
688 { 705 {
@@ -708,16 +725,6 @@ namespace OpenSim.Region.Framework.Scenes
708 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 725 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
709 } 726 }
710 } 727 }
711
712 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
713 if (SitTargetAvatar != UUID.Zero)
714 {
715 ScenePresence avatar;
716 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
717 {
718 avatar.ParentPosition = GetWorldPosition();
719 }
720 }
721 } 728 }
722 } 729 }
723 730
@@ -726,7 +733,7 @@ namespace OpenSim.Region.Framework.Scenes
726 get { return m_offsetPosition; } 733 get { return m_offsetPosition; }
727 set 734 set
728 { 735 {
729// StoreUndoState(); 736 Vector3 oldpos = m_offsetPosition;
730 m_offsetPosition = value; 737 m_offsetPosition = value;
731 738
732 if (ParentGroup != null && !ParentGroup.IsDeleted) 739 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -741,7 +748,22 @@ namespace OpenSim.Region.Framework.Scenes
741 if (ParentGroup.Scene != null) 748 if (ParentGroup.Scene != null)
742 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 749 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
743 } 750 }
751
752 if (!m_parentGroup.m_dupeInProgress)
753 {
754 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
755 foreach (ScenePresence av in avs)
756 {
757 if (av.ParentID == m_localId)
758 {
759 Vector3 offset = (m_offsetPosition - oldpos);
760 av.AbsolutePosition += offset;
761 av.SendAvatarDataToAllAgents();
762 }
763 }
764 }
744 } 765 }
766 TriggerScriptChangedEvent(Changed.POSITION);
745 } 767 }
746 } 768 }
747 769
@@ -890,7 +912,16 @@ namespace OpenSim.Region.Framework.Scenes
890 /// <summary></summary> 912 /// <summary></summary>
891 public Vector3 Acceleration 913 public Vector3 Acceleration
892 { 914 {
893 get { return m_acceleration; } 915 get
916 {
917 PhysicsActor actor = PhysActor;
918 if (actor != null)
919 {
920 m_acceleration = actor.Acceleration;
921 }
922 return m_acceleration;
923 }
924
894 set { m_acceleration = value; } 925 set { m_acceleration = value; }
895 } 926 }
896 927
@@ -1027,10 +1058,7 @@ namespace OpenSim.Region.Framework.Scenes
1027 { 1058 {
1028 get 1059 get
1029 { 1060 {
1030 if (ParentGroup.IsAttachment) 1061 return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset);
1031 return GroupPosition;
1032
1033 return m_offsetPosition + m_groupPosition;
1034 } 1062 }
1035 } 1063 }
1036 1064
@@ -1200,6 +1228,13 @@ namespace OpenSim.Region.Framework.Scenes
1200 _flags = value; 1228 _flags = value;
1201 } 1229 }
1202 } 1230 }
1231
1232 [XmlIgnore]
1233 public bool IsOccupied // KF If an av is sittingon this prim
1234 {
1235 get { return m_occupied; }
1236 set { m_occupied = value; }
1237 }
1203 1238
1204 /// <summary> 1239 /// <summary>
1205 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1240 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1259,6 +1294,19 @@ namespace OpenSim.Region.Framework.Scenes
1259 set { m_collisionSoundVolume = value; } 1294 set { m_collisionSoundVolume = value; }
1260 } 1295 }
1261 1296
1297 public float Buoyancy
1298 {
1299 get { return m_buoyancy; }
1300 set
1301 {
1302 m_buoyancy = value;
1303 if (PhysActor != null)
1304 {
1305 PhysActor.Buoyancy = value;
1306 }
1307 }
1308 }
1309
1262 #endregion Public Properties with only Get 1310 #endregion Public Properties with only Get
1263 1311
1264 private uint ApplyMask(uint val, bool set, uint mask) 1312 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1579,6 +1627,9 @@ namespace OpenSim.Region.Framework.Scenes
1579 1627
1580 // Move afterwards ResetIDs as it clears the localID 1628 // Move afterwards ResetIDs as it clears the localID
1581 dupe.LocalId = localID; 1629 dupe.LocalId = localID;
1630 if(dupe.PhysActor != null)
1631 dupe.PhysActor.LocalID = localID;
1632
1582 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1633 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1583 dupe.LastOwnerID = OwnerID; 1634 dupe.LastOwnerID = OwnerID;
1584 1635
@@ -2584,17 +2635,18 @@ namespace OpenSim.Region.Framework.Scenes
2584 //Trys to fetch sound id from prim's inventory. 2635 //Trys to fetch sound id from prim's inventory.
2585 //Prim's inventory doesn't support non script items yet 2636 //Prim's inventory doesn't support non script items yet
2586 2637
2587 lock (TaskInventory) 2638 TaskInventory.LockItemsForRead(true);
2639
2640 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2588 { 2641 {
2589 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2642 if (item.Value.Name == sound)
2590 { 2643 {
2591 if (item.Value.Name == sound) 2644 soundID = item.Value.ItemID;
2592 { 2645 break;
2593 soundID = item.Value.ItemID;
2594 break;
2595 }
2596 } 2646 }
2597 } 2647 }
2648
2649 TaskInventory.LockItemsForRead(false);
2598 } 2650 }
2599 2651
2600 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2652 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2914,8 +2966,8 @@ namespace OpenSim.Region.Framework.Scenes
2914 { 2966 {
2915 const float ROTATION_TOLERANCE = 0.01f; 2967 const float ROTATION_TOLERANCE = 0.01f;
2916 const float VELOCITY_TOLERANCE = 0.001f; 2968 const float VELOCITY_TOLERANCE = 0.001f;
2917 const float POSITION_TOLERANCE = 0.05f; 2969 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2918 const int TIME_MS_TOLERANCE = 3000; 2970 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2919 2971
2920 switch (UpdateFlag) 2972 switch (UpdateFlag)
2921 { 2973 {
@@ -2977,17 +3029,16 @@ namespace OpenSim.Region.Framework.Scenes
2977 if (!UUID.TryParse(sound, out soundID)) 3029 if (!UUID.TryParse(sound, out soundID))
2978 { 3030 {
2979 // search sound file from inventory 3031 // search sound file from inventory
2980 lock (TaskInventory) 3032 TaskInventory.LockItemsForRead(true);
3033 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2981 { 3034 {
2982 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3035 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2983 { 3036 {
2984 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3037 soundID = item.Value.ItemID;
2985 { 3038 break;
2986 soundID = item.Value.ItemID;
2987 break;
2988 }
2989 } 3039 }
2990 } 3040 }
3041 TaskInventory.LockItemsForRead(false);
2991 } 3042 }
2992 3043
2993 if (soundID == UUID.Zero) 3044 if (soundID == UUID.Zero)
@@ -3454,10 +3505,10 @@ namespace OpenSim.Region.Framework.Scenes
3454 // TODO: May need to fix for group comparison 3505 // TODO: May need to fix for group comparison
3455 if (last.Compare(this)) 3506 if (last.Compare(this))
3456 { 3507 {
3457 // m_log.DebugFormat( 3508 // m_log.DebugFormat(
3458 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3509 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3459 // Name, LocalId, m_undo.Count); 3510 // Name, LocalId, m_undo.Count);
3460 3511
3461 return; 3512 return;
3462 } 3513 }
3463 } 3514 }
@@ -3470,29 +3521,29 @@ namespace OpenSim.Region.Framework.Scenes
3470 if (ParentGroup.GetSceneMaxUndo() > 0) 3521 if (ParentGroup.GetSceneMaxUndo() > 0)
3471 { 3522 {
3472 UndoState nUndo = new UndoState(this, forGroup); 3523 UndoState nUndo = new UndoState(this, forGroup);
3473 3524
3474 m_undo.Push(nUndo); 3525 m_undo.Push(nUndo);
3475 3526
3476 if (m_redo.Count > 0) 3527 if (m_redo.Count > 0)
3477 m_redo.Clear(); 3528 m_redo.Clear();
3478 3529
3479 // m_log.DebugFormat( 3530 // m_log.DebugFormat(
3480 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3531 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3481 // Name, LocalId, forGroup, m_undo.Count); 3532 // Name, LocalId, forGroup, m_undo.Count);
3482 } 3533 }
3483 } 3534 }
3484 } 3535 }
3485 } 3536 }
3486// else 3537 // else
3487// { 3538 // {
3488// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3539 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3489// } 3540 // }
3490 } 3541 }
3491// else 3542 // else
3492// { 3543 // {
3493// m_log.DebugFormat( 3544 // m_log.DebugFormat(
3494// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3545 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3495// } 3546 // }
3496 } 3547 }
3497 3548
3498 /// <summary> 3549 /// <summary>
@@ -4223,6 +4274,9 @@ namespace OpenSim.Region.Framework.Scenes
4223 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4274 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4224 bool wasVD = VolumeDetectActive; 4275 bool wasVD = VolumeDetectActive;
4225 4276
4277// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4278// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4279
4226 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4280 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4227 return; 4281 return;
4228 4282
@@ -4252,6 +4306,11 @@ namespace OpenSim.Region.Framework.Scenes
4252 SetPhantom = false; 4306 SetPhantom = false;
4253 } 4307 }
4254 } 4308 }
4309 else if (wasVD)
4310 {
4311 // Correspondingly, if VD is turned off, also turn off phantom
4312 SetPhantom = false;
4313 }
4255 4314
4256 if (UsePhysics && IsJoint()) 4315 if (UsePhysics && IsJoint())
4257 { 4316 {
@@ -4750,5 +4809,17 @@ namespace OpenSim.Region.Framework.Scenes
4750 Color color = Color; 4809 Color color = Color;
4751 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4810 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4752 } 4811 }
4812
4813 public void ResetOwnerChangeFlag()
4814 {
4815 List<UUID> inv = Inventory.GetInventoryList();
4816
4817 foreach (UUID itemID in inv)
4818 {
4819 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4820 item.OwnerChanged = false;
4821 Inventory.UpdateInventoryItem(item, false, false);
4822 }
4823 }
4753 } 4824 }
4754} 4825}