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 f693b36..45ca0b7 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)
@@ -1619,6 +1671,9 @@ namespace OpenSim.Region.Framework.Scenes
1619 1671
1620 // Move afterwards ResetIDs as it clears the localID 1672 // Move afterwards ResetIDs as it clears the localID
1621 dupe.LocalId = localID; 1673 dupe.LocalId = localID;
1674 if(dupe.PhysActor != null)
1675 dupe.PhysActor.LocalID = localID;
1676
1622 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1677 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1623 dupe.LastOwnerID = OwnerID; 1678 dupe.LastOwnerID = OwnerID;
1624 1679
@@ -1980,19 +2035,17 @@ namespace OpenSim.Region.Framework.Scenes
1980 public Vector3 GetWorldPosition() 2035 public Vector3 GetWorldPosition()
1981 { 2036 {
1982 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2037 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
1983
1984 Vector3 axPos = OffsetPosition; 2038 Vector3 axPos = OffsetPosition;
1985
1986 axPos *= parentRot; 2039 axPos *= parentRot;
1987 Vector3 translationOffsetPosition = axPos; 2040 Vector3 translationOffsetPosition = axPos;
1988 2041 if(_parentID == 0)
1989// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2042 {
1990 2043 return GroupPosition;
1991 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2044 }
1992 2045 else
1993// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2046 {
1994 2047 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
1995 return worldPos; 2048 }
1996 } 2049 }
1997 2050
1998 /// <summary> 2051 /// <summary>
@@ -2630,17 +2683,18 @@ namespace OpenSim.Region.Framework.Scenes
2630 //Trys to fetch sound id from prim's inventory. 2683 //Trys to fetch sound id from prim's inventory.
2631 //Prim's inventory doesn't support non script items yet 2684 //Prim's inventory doesn't support non script items yet
2632 2685
2633 lock (TaskInventory) 2686 TaskInventory.LockItemsForRead(true);
2687
2688 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2634 { 2689 {
2635 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2690 if (item.Value.Name == sound)
2636 { 2691 {
2637 if (item.Value.Name == sound) 2692 soundID = item.Value.ItemID;
2638 { 2693 break;
2639 soundID = item.Value.ItemID;
2640 break;
2641 }
2642 } 2694 }
2643 } 2695 }
2696
2697 TaskInventory.LockItemsForRead(false);
2644 } 2698 }
2645 2699
2646 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2700 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2723,7 +2777,7 @@ namespace OpenSim.Region.Framework.Scenes
2723 2777
2724 public void RotLookAt(Quaternion target, float strength, float damping) 2778 public void RotLookAt(Quaternion target, float strength, float damping)
2725 { 2779 {
2726 rotLookAt(target, strength, damping); 2780 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2727 } 2781 }
2728 2782
2729 public void rotLookAt(Quaternion target, float strength, float damping) 2783 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -2959,8 +3013,8 @@ namespace OpenSim.Region.Framework.Scenes
2959 { 3013 {
2960 const float ROTATION_TOLERANCE = 0.01f; 3014 const float ROTATION_TOLERANCE = 0.01f;
2961 const float VELOCITY_TOLERANCE = 0.001f; 3015 const float VELOCITY_TOLERANCE = 0.001f;
2962 const float POSITION_TOLERANCE = 0.05f; 3016 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2963 const int TIME_MS_TOLERANCE = 3000; 3017 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2964 3018
2965 switch (UpdateFlag) 3019 switch (UpdateFlag)
2966 { 3020 {
@@ -3024,17 +3078,16 @@ namespace OpenSim.Region.Framework.Scenes
3024 if (!UUID.TryParse(sound, out soundID)) 3078 if (!UUID.TryParse(sound, out soundID))
3025 { 3079 {
3026 // search sound file from inventory 3080 // search sound file from inventory
3027 lock (TaskInventory) 3081 TaskInventory.LockItemsForRead(true);
3082 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3028 { 3083 {
3029 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3084 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3030 { 3085 {
3031 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3086 soundID = item.Value.ItemID;
3032 { 3087 break;
3033 soundID = item.Value.ItemID;
3034 break;
3035 }
3036 } 3088 }
3037 } 3089 }
3090 TaskInventory.LockItemsForRead(false);
3038 } 3091 }
3039 3092
3040 if (soundID == UUID.Zero) 3093 if (soundID == UUID.Zero)
@@ -3496,10 +3549,10 @@ namespace OpenSim.Region.Framework.Scenes
3496 // TODO: May need to fix for group comparison 3549 // TODO: May need to fix for group comparison
3497 if (last.Compare(this)) 3550 if (last.Compare(this))
3498 { 3551 {
3499 // m_log.DebugFormat( 3552 // m_log.DebugFormat(
3500 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3553 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3501 // Name, LocalId, m_undo.Count); 3554 // Name, LocalId, m_undo.Count);
3502 3555
3503 return; 3556 return;
3504 } 3557 }
3505 } 3558 }
@@ -3512,29 +3565,29 @@ namespace OpenSim.Region.Framework.Scenes
3512 if (ParentGroup.GetSceneMaxUndo() > 0) 3565 if (ParentGroup.GetSceneMaxUndo() > 0)
3513 { 3566 {
3514 UndoState nUndo = new UndoState(this, forGroup); 3567 UndoState nUndo = new UndoState(this, forGroup);
3515 3568
3516 m_undo.Push(nUndo); 3569 m_undo.Push(nUndo);
3517 3570
3518 if (m_redo.Count > 0) 3571 if (m_redo.Count > 0)
3519 m_redo.Clear(); 3572 m_redo.Clear();
3520 3573
3521 // m_log.DebugFormat( 3574 // m_log.DebugFormat(
3522 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3575 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3523 // Name, LocalId, forGroup, m_undo.Count); 3576 // Name, LocalId, forGroup, m_undo.Count);
3524 } 3577 }
3525 } 3578 }
3526 } 3579 }
3527 } 3580 }
3528// else 3581 // else
3529// { 3582 // {
3530// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3583 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3531// } 3584 // }
3532 } 3585 }
3533// else 3586 // else
3534// { 3587 // {
3535// m_log.DebugFormat( 3588 // m_log.DebugFormat(
3536// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3589 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3537// } 3590 // }
3538 } 3591 }
3539 3592
3540 /// <summary> 3593 /// <summary>
@@ -4589,8 +4642,9 @@ namespace OpenSim.Region.Framework.Scenes
4589 { 4642 {
4590 m_shape.TextureEntry = textureEntry; 4643 m_shape.TextureEntry = textureEntry;
4591 TriggerScriptChangedEvent(Changed.TEXTURE); 4644 TriggerScriptChangedEvent(Changed.TEXTURE);
4592 4645 UpdateFlag = UpdateRequired.FULL;
4593 ParentGroup.HasGroupChanged = true; 4646 ParentGroup.HasGroupChanged = true;
4647
4594 //This is madness.. 4648 //This is madness..
4595 //ParentGroup.ScheduleGroupForFullUpdate(); 4649 //ParentGroup.ScheduleGroupForFullUpdate();
4596 //This is sparta 4650 //This is sparta
@@ -4787,5 +4841,17 @@ namespace OpenSim.Region.Framework.Scenes
4787 Color color = Color; 4841 Color color = Color;
4788 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4842 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4789 } 4843 }
4844
4845 public void ResetOwnerChangeFlag()
4846 {
4847 List<UUID> inv = Inventory.GetInventoryList();
4848
4849 foreach (UUID itemID in inv)
4850 {
4851 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4852 item.OwnerChanged = false;
4853 Inventory.UpdateInventoryItem(item, false, false);
4854 }
4855 }
4790 } 4856 }
4791} 4857}