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 4e1383c..7025551 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>
@@ -629,14 +645,12 @@ namespace OpenSim.Region.Framework.Scenes
629 set { m_LoopSoundSlavePrims = value; } 645 set { m_LoopSoundSlavePrims = value; }
630 } 646 }
631 647
632
633 public Byte[] TextureAnimation 648 public Byte[] TextureAnimation
634 { 649 {
635 get { return m_TextureAnimation; } 650 get { return m_TextureAnimation; }
636 set { m_TextureAnimation = value; } 651 set { m_TextureAnimation = value; }
637 } 652 }
638 653
639
640 public Byte[] ParticleSystem 654 public Byte[] ParticleSystem
641 { 655 {
642 get { return m_particleSystem; } 656 get { return m_particleSystem; }
@@ -675,7 +689,9 @@ namespace OpenSim.Region.Framework.Scenes
675 PhysicsActor actor = PhysActor; 689 PhysicsActor actor = PhysActor;
676 if (actor != null && ParentID == 0) 690 if (actor != null && ParentID == 0)
677 { 691 {
678 m_groupPosition = actor.Position; 692 if (actor != null)
693 m_groupPosition = actor.Position;
694 return m_groupPosition;
679 } 695 }
680 696
681 if (ParentGroup.IsAttachment) 697 if (ParentGroup.IsAttachment)
@@ -685,12 +701,14 @@ namespace OpenSim.Region.Framework.Scenes
685 return sp.AbsolutePosition; 701 return sp.AbsolutePosition;
686 } 702 }
687 703
704 // use root prim's group position. Physics may have updated it
705 if (ParentGroup.RootPart != this)
706 m_groupPosition = ParentGroup.RootPart.GroupPosition;
688 return m_groupPosition; 707 return m_groupPosition;
689 } 708 }
690 set 709 set
691 { 710 {
692 m_groupPosition = value; 711 m_groupPosition = value;
693
694 PhysicsActor actor = PhysActor; 712 PhysicsActor actor = PhysActor;
695 if (actor != null) 713 if (actor != null)
696 { 714 {
@@ -716,16 +734,6 @@ namespace OpenSim.Region.Framework.Scenes
716 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 734 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
717 } 735 }
718 } 736 }
719
720 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
721 if (SitTargetAvatar != UUID.Zero)
722 {
723 ScenePresence avatar;
724 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
725 {
726 avatar.ParentPosition = GetWorldPosition();
727 }
728 }
729 } 737 }
730 } 738 }
731 739
@@ -734,7 +742,7 @@ namespace OpenSim.Region.Framework.Scenes
734 get { return m_offsetPosition; } 742 get { return m_offsetPosition; }
735 set 743 set
736 { 744 {
737// StoreUndoState(); 745 Vector3 oldpos = m_offsetPosition;
738 m_offsetPosition = value; 746 m_offsetPosition = value;
739 747
740 if (ParentGroup != null && !ParentGroup.IsDeleted) 748 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -749,7 +757,22 @@ namespace OpenSim.Region.Framework.Scenes
749 if (ParentGroup.Scene != null) 757 if (ParentGroup.Scene != null)
750 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 758 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
751 } 759 }
760
761 if (!m_parentGroup.m_dupeInProgress)
762 {
763 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
764 foreach (ScenePresence av in avs)
765 {
766 if (av.ParentID == m_localId)
767 {
768 Vector3 offset = (m_offsetPosition - oldpos);
769 av.AbsolutePosition += offset;
770 av.SendAvatarDataToAllAgents();
771 }
772 }
773 }
752 } 774 }
775 TriggerScriptChangedEvent(Changed.POSITION);
753 } 776 }
754 } 777 }
755 778
@@ -898,7 +921,16 @@ namespace OpenSim.Region.Framework.Scenes
898 /// <summary></summary> 921 /// <summary></summary>
899 public Vector3 Acceleration 922 public Vector3 Acceleration
900 { 923 {
901 get { return m_acceleration; } 924 get
925 {
926 PhysicsActor actor = PhysActor;
927 if (actor != null)
928 {
929 m_acceleration = actor.Acceleration;
930 }
931 return m_acceleration;
932 }
933
902 set { m_acceleration = value; } 934 set { m_acceleration = value; }
903 } 935 }
904 936
@@ -1238,6 +1270,13 @@ namespace OpenSim.Region.Framework.Scenes
1238 _flags = value; 1270 _flags = value;
1239 } 1271 }
1240 } 1272 }
1273
1274 [XmlIgnore]
1275 public bool IsOccupied // KF If an av is sittingon this prim
1276 {
1277 get { return m_occupied; }
1278 set { m_occupied = value; }
1279 }
1241 1280
1242 /// <summary> 1281 /// <summary>
1243 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1282 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1297,6 +1336,19 @@ namespace OpenSim.Region.Framework.Scenes
1297 set { m_collisionSoundVolume = value; } 1336 set { m_collisionSoundVolume = value; }
1298 } 1337 }
1299 1338
1339 public float Buoyancy
1340 {
1341 get { return m_buoyancy; }
1342 set
1343 {
1344 m_buoyancy = value;
1345 if (PhysActor != null)
1346 {
1347 PhysActor.Buoyancy = value;
1348 }
1349 }
1350 }
1351
1300 #endregion Public Properties with only Get 1352 #endregion Public Properties with only Get
1301 1353
1302 private uint ApplyMask(uint val, bool set, uint mask) 1354 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1652,6 +1704,9 @@ namespace OpenSim.Region.Framework.Scenes
1652 1704
1653 // Move afterwards ResetIDs as it clears the localID 1705 // Move afterwards ResetIDs as it clears the localID
1654 dupe.LocalId = localID; 1706 dupe.LocalId = localID;
1707 if(dupe.PhysActor != null)
1708 dupe.PhysActor.LocalID = localID;
1709
1655 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1710 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1656 dupe.LastOwnerID = OwnerID; 1711 dupe.LastOwnerID = OwnerID;
1657 1712
@@ -2013,19 +2068,17 @@ namespace OpenSim.Region.Framework.Scenes
2013 public Vector3 GetWorldPosition() 2068 public Vector3 GetWorldPosition()
2014 { 2069 {
2015 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2070 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
2016
2017 Vector3 axPos = OffsetPosition; 2071 Vector3 axPos = OffsetPosition;
2018
2019 axPos *= parentRot; 2072 axPos *= parentRot;
2020 Vector3 translationOffsetPosition = axPos; 2073 Vector3 translationOffsetPosition = axPos;
2021 2074 if(_parentID == 0)
2022// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2075 {
2023 2076 return GroupPosition;
2024 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2077 }
2025 2078 else
2026// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2079 {
2027 2080 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
2028 return worldPos; 2081 }
2029 } 2082 }
2030 2083
2031 /// <summary> 2084 /// <summary>
@@ -2665,17 +2718,18 @@ namespace OpenSim.Region.Framework.Scenes
2665 //Trys to fetch sound id from prim's inventory. 2718 //Trys to fetch sound id from prim's inventory.
2666 //Prim's inventory doesn't support non script items yet 2719 //Prim's inventory doesn't support non script items yet
2667 2720
2668 lock (TaskInventory) 2721 TaskInventory.LockItemsForRead(true);
2722
2723 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2669 { 2724 {
2670 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2725 if (item.Value.Name == sound)
2671 { 2726 {
2672 if (item.Value.Name == sound) 2727 soundID = item.Value.ItemID;
2673 { 2728 break;
2674 soundID = item.Value.ItemID;
2675 break;
2676 }
2677 } 2729 }
2678 } 2730 }
2731
2732 TaskInventory.LockItemsForRead(false);
2679 } 2733 }
2680 2734
2681 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2735 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2758,7 +2812,7 @@ namespace OpenSim.Region.Framework.Scenes
2758 2812
2759 public void RotLookAt(Quaternion target, float strength, float damping) 2813 public void RotLookAt(Quaternion target, float strength, float damping)
2760 { 2814 {
2761 rotLookAt(target, strength, damping); 2815 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2762 } 2816 }
2763 2817
2764 public void rotLookAt(Quaternion target, float strength, float damping) 2818 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -3004,8 +3058,8 @@ namespace OpenSim.Region.Framework.Scenes
3004 { 3058 {
3005 const float ROTATION_TOLERANCE = 0.01f; 3059 const float ROTATION_TOLERANCE = 0.01f;
3006 const float VELOCITY_TOLERANCE = 0.001f; 3060 const float VELOCITY_TOLERANCE = 0.001f;
3007 const float POSITION_TOLERANCE = 0.05f; 3061 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
3008 const int TIME_MS_TOLERANCE = 3000; 3062 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
3009 3063
3010 switch (UpdateFlag) 3064 switch (UpdateFlag)
3011 { 3065 {
@@ -3068,17 +3122,16 @@ namespace OpenSim.Region.Framework.Scenes
3068 if (!UUID.TryParse(sound, out soundID)) 3122 if (!UUID.TryParse(sound, out soundID))
3069 { 3123 {
3070 // search sound file from inventory 3124 // search sound file from inventory
3071 lock (TaskInventory) 3125 TaskInventory.LockItemsForRead(true);
3126 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3072 { 3127 {
3073 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3128 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3074 { 3129 {
3075 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3130 soundID = item.Value.ItemID;
3076 { 3131 break;
3077 soundID = item.Value.ItemID;
3078 break;
3079 }
3080 } 3132 }
3081 } 3133 }
3134 TaskInventory.LockItemsForRead(false);
3082 } 3135 }
3083 3136
3084 if (soundID == UUID.Zero) 3137 if (soundID == UUID.Zero)
@@ -3540,10 +3593,10 @@ namespace OpenSim.Region.Framework.Scenes
3540 // TODO: May need to fix for group comparison 3593 // TODO: May need to fix for group comparison
3541 if (last.Compare(this)) 3594 if (last.Compare(this))
3542 { 3595 {
3543 // m_log.DebugFormat( 3596 // m_log.DebugFormat(
3544 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3597 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3545 // Name, LocalId, m_undo.Count); 3598 // Name, LocalId, m_undo.Count);
3546 3599
3547 return; 3600 return;
3548 } 3601 }
3549 } 3602 }
@@ -3556,29 +3609,29 @@ namespace OpenSim.Region.Framework.Scenes
3556 if (ParentGroup.GetSceneMaxUndo() > 0) 3609 if (ParentGroup.GetSceneMaxUndo() > 0)
3557 { 3610 {
3558 UndoState nUndo = new UndoState(this, forGroup); 3611 UndoState nUndo = new UndoState(this, forGroup);
3559 3612
3560 m_undo.Push(nUndo); 3613 m_undo.Push(nUndo);
3561 3614
3562 if (m_redo.Count > 0) 3615 if (m_redo.Count > 0)
3563 m_redo.Clear(); 3616 m_redo.Clear();
3564 3617
3565 // m_log.DebugFormat( 3618 // m_log.DebugFormat(
3566 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3619 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3567 // Name, LocalId, forGroup, m_undo.Count); 3620 // Name, LocalId, forGroup, m_undo.Count);
3568 } 3621 }
3569 } 3622 }
3570 } 3623 }
3571 } 3624 }
3572// else 3625 // else
3573// { 3626 // {
3574// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3627 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3575// } 3628 // }
3576 } 3629 }
3577// else 3630 // else
3578// { 3631 // {
3579// m_log.DebugFormat( 3632 // m_log.DebugFormat(
3580// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3633 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3581// } 3634 // }
3582 } 3635 }
3583 3636
3584 /// <summary> 3637 /// <summary>
@@ -4633,8 +4686,9 @@ namespace OpenSim.Region.Framework.Scenes
4633 { 4686 {
4634 m_shape.TextureEntry = textureEntry; 4687 m_shape.TextureEntry = textureEntry;
4635 TriggerScriptChangedEvent(Changed.TEXTURE); 4688 TriggerScriptChangedEvent(Changed.TEXTURE);
4636 4689 UpdateFlag = UpdateRequired.FULL;
4637 ParentGroup.HasGroupChanged = true; 4690 ParentGroup.HasGroupChanged = true;
4691
4638 //This is madness.. 4692 //This is madness..
4639 //ParentGroup.ScheduleGroupForFullUpdate(); 4693 //ParentGroup.ScheduleGroupForFullUpdate();
4640 //This is sparta 4694 //This is sparta
@@ -4831,5 +4885,17 @@ namespace OpenSim.Region.Framework.Scenes
4831 Color color = Color; 4885 Color color = Color;
4832 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4886 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4833 } 4887 }
4888
4889 public void ResetOwnerChangeFlag()
4890 {
4891 List<UUID> inv = Inventory.GetInventoryList();
4892
4893 foreach (UUID itemID in inv)
4894 {
4895 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4896 item.OwnerChanged = false;
4897 Inventory.UpdateInventoryItem(item, false, false);
4898 }
4899 }
4834 } 4900 }
4835} 4901}