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.cs204
1 files changed, 135 insertions, 69 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4e79311..e214f57 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;
@@ -253,6 +263,7 @@ namespace OpenSim.Region.Framework.Scenes
253 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 263 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
254 private Vector3 m_sitTargetPosition; 264 private Vector3 m_sitTargetPosition;
255 private string m_sitAnimation = "SIT"; 265 private string m_sitAnimation = "SIT";
266 private bool m_occupied; // KF if any av is sitting on this prim
256 private string m_text = String.Empty; 267 private string m_text = String.Empty;
257 private string m_touchName = String.Empty; 268 private string m_touchName = String.Empty;
258 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); 269 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5);
@@ -287,6 +298,7 @@ namespace OpenSim.Region.Framework.Scenes
287 protected Vector3 m_lastAcceleration; 298 protected Vector3 m_lastAcceleration;
288 protected Vector3 m_lastAngularVelocity; 299 protected Vector3 m_lastAngularVelocity;
289 protected int m_lastTerseSent; 300 protected int m_lastTerseSent;
301 protected float m_buoyancy = 0.0f;
290 302
291 /// <summary> 303 /// <summary>
292 /// Stores media texture data 304 /// Stores media texture data
@@ -339,7 +351,7 @@ namespace OpenSim.Region.Framework.Scenes
339 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 351 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
340 Quaternion rotationOffset, Vector3 offsetPosition) 352 Quaternion rotationOffset, Vector3 offsetPosition)
341 { 353 {
342 m_name = "Primitive"; 354 m_name = "Object";
343 355
344 Rezzed = DateTime.UtcNow; 356 Rezzed = DateTime.UtcNow;
345 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 357 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
@@ -389,7 +401,7 @@ namespace OpenSim.Region.Framework.Scenes
389 private uint _ownerMask = (uint)PermissionMask.All; 401 private uint _ownerMask = (uint)PermissionMask.All;
390 private uint _groupMask = (uint)PermissionMask.None; 402 private uint _groupMask = (uint)PermissionMask.None;
391 private uint _everyoneMask = (uint)PermissionMask.None; 403 private uint _everyoneMask = (uint)PermissionMask.None;
392 private uint _nextOwnerMask = (uint)PermissionMask.All; 404 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
393 private PrimFlags _flags = PrimFlags.None; 405 private PrimFlags _flags = PrimFlags.None;
394 private DateTime m_expires; 406 private DateTime m_expires;
395 private DateTime m_rezzed; 407 private DateTime m_rezzed;
@@ -483,12 +495,16 @@ namespace OpenSim.Region.Framework.Scenes
483 } 495 }
484 496
485 /// <value> 497 /// <value>
486 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 498 /// Get the inventory list
487 /// </value> 499 /// </value>
488 public TaskInventoryDictionary TaskInventory 500 public TaskInventoryDictionary TaskInventory
489 { 501 {
490 get { return m_inventory.Items; } 502 get {
491 set { m_inventory.Items = value; } 503 return m_inventory.Items;
504 }
505 set {
506 m_inventory.Items = value;
507 }
492 } 508 }
493 509
494 /// <summary> 510 /// <summary>
@@ -633,14 +649,12 @@ namespace OpenSim.Region.Framework.Scenes
633 set { m_LoopSoundSlavePrims = value; } 649 set { m_LoopSoundSlavePrims = value; }
634 } 650 }
635 651
636
637 public Byte[] TextureAnimation 652 public Byte[] TextureAnimation
638 { 653 {
639 get { return m_TextureAnimation; } 654 get { return m_TextureAnimation; }
640 set { m_TextureAnimation = value; } 655 set { m_TextureAnimation = value; }
641 } 656 }
642 657
643
644 public Byte[] ParticleSystem 658 public Byte[] ParticleSystem
645 { 659 {
646 get { return m_particleSystem; } 660 get { return m_particleSystem; }
@@ -679,7 +693,9 @@ namespace OpenSim.Region.Framework.Scenes
679 PhysicsActor actor = PhysActor; 693 PhysicsActor actor = PhysActor;
680 if (actor != null && ParentID == 0) 694 if (actor != null && ParentID == 0)
681 { 695 {
682 m_groupPosition = actor.Position; 696 if (actor != null)
697 m_groupPosition = actor.Position;
698 return m_groupPosition;
683 } 699 }
684 700
685 if (ParentGroup.IsAttachment) 701 if (ParentGroup.IsAttachment)
@@ -689,12 +705,14 @@ namespace OpenSim.Region.Framework.Scenes
689 return sp.AbsolutePosition; 705 return sp.AbsolutePosition;
690 } 706 }
691 707
708 // use root prim's group position. Physics may have updated it
709 if (ParentGroup.RootPart != this)
710 m_groupPosition = ParentGroup.RootPart.GroupPosition;
692 return m_groupPosition; 711 return m_groupPosition;
693 } 712 }
694 set 713 set
695 { 714 {
696 m_groupPosition = value; 715 m_groupPosition = value;
697
698 PhysicsActor actor = PhysActor; 716 PhysicsActor actor = PhysActor;
699 if (actor != null) 717 if (actor != null)
700 { 718 {
@@ -720,16 +738,6 @@ namespace OpenSim.Region.Framework.Scenes
720 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 738 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
721 } 739 }
722 } 740 }
723
724 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
725 if (SitTargetAvatar != UUID.Zero)
726 {
727 ScenePresence avatar;
728 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
729 {
730 avatar.ParentPosition = GetWorldPosition();
731 }
732 }
733 } 741 }
734 } 742 }
735 743
@@ -738,7 +746,7 @@ namespace OpenSim.Region.Framework.Scenes
738 get { return m_offsetPosition; } 746 get { return m_offsetPosition; }
739 set 747 set
740 { 748 {
741// StoreUndoState(); 749 Vector3 oldpos = m_offsetPosition;
742 m_offsetPosition = value; 750 m_offsetPosition = value;
743 751
744 if (ParentGroup != null && !ParentGroup.IsDeleted) 752 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -753,7 +761,22 @@ namespace OpenSim.Region.Framework.Scenes
753 if (ParentGroup.Scene != null) 761 if (ParentGroup.Scene != null)
754 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 762 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
755 } 763 }
764
765 if (!m_parentGroup.m_dupeInProgress)
766 {
767 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
768 foreach (ScenePresence av in avs)
769 {
770 if (av.ParentID == m_localId)
771 {
772 Vector3 offset = (m_offsetPosition - oldpos);
773 av.AbsolutePosition += offset;
774 av.SendAvatarDataToAllAgents();
775 }
776 }
777 }
756 } 778 }
779 TriggerScriptChangedEvent(Changed.POSITION);
757 } 780 }
758 } 781 }
759 782
@@ -902,7 +925,16 @@ namespace OpenSim.Region.Framework.Scenes
902 /// <summary></summary> 925 /// <summary></summary>
903 public Vector3 Acceleration 926 public Vector3 Acceleration
904 { 927 {
905 get { return m_acceleration; } 928 get
929 {
930 PhysicsActor actor = PhysActor;
931 if (actor != null)
932 {
933 m_acceleration = actor.Acceleration;
934 }
935 return m_acceleration;
936 }
937
906 set { m_acceleration = value; } 938 set { m_acceleration = value; }
907 } 939 }
908 940
@@ -1242,6 +1274,13 @@ namespace OpenSim.Region.Framework.Scenes
1242 _flags = value; 1274 _flags = value;
1243 } 1275 }
1244 } 1276 }
1277
1278 [XmlIgnore]
1279 public bool IsOccupied // KF If an av is sittingon this prim
1280 {
1281 get { return m_occupied; }
1282 set { m_occupied = value; }
1283 }
1245 1284
1246 /// <summary> 1285 /// <summary>
1247 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1286 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1301,6 +1340,19 @@ namespace OpenSim.Region.Framework.Scenes
1301 set { m_collisionSoundVolume = value; } 1340 set { m_collisionSoundVolume = value; }
1302 } 1341 }
1303 1342
1343 public float Buoyancy
1344 {
1345 get { return m_buoyancy; }
1346 set
1347 {
1348 m_buoyancy = value;
1349 if (PhysActor != null)
1350 {
1351 PhysActor.Buoyancy = value;
1352 }
1353 }
1354 }
1355
1304 #endregion Public Properties with only Get 1356 #endregion Public Properties with only Get
1305 1357
1306 private uint ApplyMask(uint val, bool set, uint mask) 1358 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1623,6 +1675,9 @@ namespace OpenSim.Region.Framework.Scenes
1623 1675
1624 // Move afterwards ResetIDs as it clears the localID 1676 // Move afterwards ResetIDs as it clears the localID
1625 dupe.LocalId = localID; 1677 dupe.LocalId = localID;
1678 if(dupe.PhysActor != null)
1679 dupe.PhysActor.LocalID = localID;
1680
1626 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1681 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1627 dupe.LastOwnerID = OwnerID; 1682 dupe.LastOwnerID = OwnerID;
1628 1683
@@ -1984,19 +2039,17 @@ namespace OpenSim.Region.Framework.Scenes
1984 public Vector3 GetWorldPosition() 2039 public Vector3 GetWorldPosition()
1985 { 2040 {
1986 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2041 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
1987
1988 Vector3 axPos = OffsetPosition; 2042 Vector3 axPos = OffsetPosition;
1989
1990 axPos *= parentRot; 2043 axPos *= parentRot;
1991 Vector3 translationOffsetPosition = axPos; 2044 Vector3 translationOffsetPosition = axPos;
1992 2045 if(_parentID == 0)
1993// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2046 {
1994 2047 return GroupPosition;
1995 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2048 }
1996 2049 else
1997// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2050 {
1998 2051 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
1999 return worldPos; 2052 }
2000 } 2053 }
2001 2054
2002 /// <summary> 2055 /// <summary>
@@ -2634,17 +2687,18 @@ namespace OpenSim.Region.Framework.Scenes
2634 //Trys to fetch sound id from prim's inventory. 2687 //Trys to fetch sound id from prim's inventory.
2635 //Prim's inventory doesn't support non script items yet 2688 //Prim's inventory doesn't support non script items yet
2636 2689
2637 lock (TaskInventory) 2690 TaskInventory.LockItemsForRead(true);
2691
2692 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2638 { 2693 {
2639 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2694 if (item.Value.Name == sound)
2640 { 2695 {
2641 if (item.Value.Name == sound) 2696 soundID = item.Value.ItemID;
2642 { 2697 break;
2643 soundID = item.Value.ItemID;
2644 break;
2645 }
2646 } 2698 }
2647 } 2699 }
2700
2701 TaskInventory.LockItemsForRead(false);
2648 } 2702 }
2649 2703
2650 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2704 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2727,7 +2781,7 @@ namespace OpenSim.Region.Framework.Scenes
2727 2781
2728 public void RotLookAt(Quaternion target, float strength, float damping) 2782 public void RotLookAt(Quaternion target, float strength, float damping)
2729 { 2783 {
2730 rotLookAt(target, strength, damping); 2784 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2731 } 2785 }
2732 2786
2733 public void rotLookAt(Quaternion target, float strength, float damping) 2787 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -2963,8 +3017,8 @@ namespace OpenSim.Region.Framework.Scenes
2963 { 3017 {
2964 const float ROTATION_TOLERANCE = 0.01f; 3018 const float ROTATION_TOLERANCE = 0.01f;
2965 const float VELOCITY_TOLERANCE = 0.001f; 3019 const float VELOCITY_TOLERANCE = 0.001f;
2966 const float POSITION_TOLERANCE = 0.05f; 3020 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2967 const int TIME_MS_TOLERANCE = 3000; 3021 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2968 3022
2969 switch (UpdateFlag) 3023 switch (UpdateFlag)
2970 { 3024 {
@@ -3028,17 +3082,16 @@ namespace OpenSim.Region.Framework.Scenes
3028 if (!UUID.TryParse(sound, out soundID)) 3082 if (!UUID.TryParse(sound, out soundID))
3029 { 3083 {
3030 // search sound file from inventory 3084 // search sound file from inventory
3031 lock (TaskInventory) 3085 TaskInventory.LockItemsForRead(true);
3086 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3032 { 3087 {
3033 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3088 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3034 { 3089 {
3035 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3090 soundID = item.Value.ItemID;
3036 { 3091 break;
3037 soundID = item.Value.ItemID;
3038 break;
3039 }
3040 } 3092 }
3041 } 3093 }
3094 TaskInventory.LockItemsForRead(false);
3042 } 3095 }
3043 3096
3044 if (soundID == UUID.Zero) 3097 if (soundID == UUID.Zero)
@@ -3500,10 +3553,10 @@ namespace OpenSim.Region.Framework.Scenes
3500 // TODO: May need to fix for group comparison 3553 // TODO: May need to fix for group comparison
3501 if (last.Compare(this)) 3554 if (last.Compare(this))
3502 { 3555 {
3503 // m_log.DebugFormat( 3556 // m_log.DebugFormat(
3504 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3557 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3505 // Name, LocalId, m_undo.Count); 3558 // Name, LocalId, m_undo.Count);
3506 3559
3507 return; 3560 return;
3508 } 3561 }
3509 } 3562 }
@@ -3516,29 +3569,29 @@ namespace OpenSim.Region.Framework.Scenes
3516 if (ParentGroup.GetSceneMaxUndo() > 0) 3569 if (ParentGroup.GetSceneMaxUndo() > 0)
3517 { 3570 {
3518 UndoState nUndo = new UndoState(this, forGroup); 3571 UndoState nUndo = new UndoState(this, forGroup);
3519 3572
3520 m_undo.Push(nUndo); 3573 m_undo.Push(nUndo);
3521 3574
3522 if (m_redo.Count > 0) 3575 if (m_redo.Count > 0)
3523 m_redo.Clear(); 3576 m_redo.Clear();
3524 3577
3525 // m_log.DebugFormat( 3578 // m_log.DebugFormat(
3526 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3579 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3527 // Name, LocalId, forGroup, m_undo.Count); 3580 // Name, LocalId, forGroup, m_undo.Count);
3528 } 3581 }
3529 } 3582 }
3530 } 3583 }
3531 } 3584 }
3532// else 3585 // else
3533// { 3586 // {
3534// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3587 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3535// } 3588 // }
3536 } 3589 }
3537// else 3590 // else
3538// { 3591 // {
3539// m_log.DebugFormat( 3592 // m_log.DebugFormat(
3540// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3593 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3541// } 3594 // }
3542 } 3595 }
3543 3596
3544 /// <summary> 3597 /// <summary>
@@ -4593,8 +4646,9 @@ namespace OpenSim.Region.Framework.Scenes
4593 { 4646 {
4594 m_shape.TextureEntry = textureEntry; 4647 m_shape.TextureEntry = textureEntry;
4595 TriggerScriptChangedEvent(Changed.TEXTURE); 4648 TriggerScriptChangedEvent(Changed.TEXTURE);
4596 4649 UpdateFlag = UpdateRequired.FULL;
4597 ParentGroup.HasGroupChanged = true; 4650 ParentGroup.HasGroupChanged = true;
4651
4598 //This is madness.. 4652 //This is madness..
4599 //ParentGroup.ScheduleGroupForFullUpdate(); 4653 //ParentGroup.ScheduleGroupForFullUpdate();
4600 //This is sparta 4654 //This is sparta
@@ -4791,5 +4845,17 @@ namespace OpenSim.Region.Framework.Scenes
4791 Color color = Color; 4845 Color color = Color;
4792 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4846 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4793 } 4847 }
4848
4849 public void ResetOwnerChangeFlag()
4850 {
4851 List<UUID> inv = Inventory.GetInventoryList();
4852
4853 foreach (UUID itemID in inv)
4854 {
4855 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4856 item.OwnerChanged = false;
4857 Inventory.UpdateInventoryItem(item, false, false);
4858 }
4859 }
4794 } 4860 }
4795} 4861}