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.cs219
1 files changed, 143 insertions, 76 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4071159..e4bee0c 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);
@@ -288,6 +299,7 @@ namespace OpenSim.Region.Framework.Scenes
288 protected Vector3 m_lastAcceleration; 299 protected Vector3 m_lastAcceleration;
289 protected Vector3 m_lastAngularVelocity; 300 protected Vector3 m_lastAngularVelocity;
290 protected int m_lastTerseSent; 301 protected int m_lastTerseSent;
302 protected float m_buoyancy = 0.0f;
291 303
292 /// <summary> 304 /// <summary>
293 /// Stores media texture data 305 /// Stores media texture data
@@ -340,7 +352,7 @@ namespace OpenSim.Region.Framework.Scenes
340 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 352 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
341 Quaternion rotationOffset, Vector3 offsetPosition) 353 Quaternion rotationOffset, Vector3 offsetPosition)
342 { 354 {
343 m_name = "Primitive"; 355 m_name = "Object";
344 356
345 Rezzed = DateTime.UtcNow; 357 Rezzed = DateTime.UtcNow;
346 _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 358 _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
@@ -395,7 +407,7 @@ namespace OpenSim.Region.Framework.Scenes
395 private uint _ownerMask = (uint)PermissionMask.All; 407 private uint _ownerMask = (uint)PermissionMask.All;
396 private uint _groupMask = (uint)PermissionMask.None; 408 private uint _groupMask = (uint)PermissionMask.None;
397 private uint _everyoneMask = (uint)PermissionMask.None; 409 private uint _everyoneMask = (uint)PermissionMask.None;
398 private uint _nextOwnerMask = (uint)PermissionMask.All; 410 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
399 private PrimFlags _flags = PrimFlags.None; 411 private PrimFlags _flags = PrimFlags.None;
400 private DateTime m_expires; 412 private DateTime m_expires;
401 private DateTime m_rezzed; 413 private DateTime m_rezzed;
@@ -494,12 +506,16 @@ namespace OpenSim.Region.Framework.Scenes
494 } 506 }
495 507
496 /// <value> 508 /// <value>
497 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 509 /// Get the inventory list
498 /// </value> 510 /// </value>
499 public TaskInventoryDictionary TaskInventory 511 public TaskInventoryDictionary TaskInventory
500 { 512 {
501 get { return m_inventory.Items; } 513 get {
502 set { m_inventory.Items = value; } 514 return m_inventory.Items;
515 }
516 set {
517 m_inventory.Items = value;
518 }
503 } 519 }
504 520
505 /// <summary> 521 /// <summary>
@@ -640,14 +656,12 @@ namespace OpenSim.Region.Framework.Scenes
640 set { m_LoopSoundSlavePrims = value; } 656 set { m_LoopSoundSlavePrims = value; }
641 } 657 }
642 658
643
644 public Byte[] TextureAnimation 659 public Byte[] TextureAnimation
645 { 660 {
646 get { return m_TextureAnimation; } 661 get { return m_TextureAnimation; }
647 set { m_TextureAnimation = value; } 662 set { m_TextureAnimation = value; }
648 } 663 }
649 664
650
651 public Byte[] ParticleSystem 665 public Byte[] ParticleSystem
652 { 666 {
653 get { return m_particleSystem; } 667 get { return m_particleSystem; }
@@ -684,9 +698,11 @@ namespace OpenSim.Region.Framework.Scenes
684 { 698 {
685 // If this is a linkset, we don't want the physics engine mucking up our group position here. 699 // If this is a linkset, we don't want the physics engine mucking up our group position here.
686 PhysicsActor actor = PhysActor; 700 PhysicsActor actor = PhysActor;
687 if (actor != null && _parentID == 0) 701 if (_parentID == 0)
688 { 702 {
689 m_groupPosition = actor.Position; 703 if (actor != null)
704 m_groupPosition = actor.Position;
705 return m_groupPosition;
690 } 706 }
691 707
692 if (m_parentGroup.IsAttachment) 708 if (m_parentGroup.IsAttachment)
@@ -696,12 +712,14 @@ namespace OpenSim.Region.Framework.Scenes
696 return sp.AbsolutePosition; 712 return sp.AbsolutePosition;
697 } 713 }
698 714
715 // use root prim's group position. Physics may have updated it
716 if (ParentGroup.RootPart != this)
717 m_groupPosition = ParentGroup.RootPart.GroupPosition;
699 return m_groupPosition; 718 return m_groupPosition;
700 } 719 }
701 set 720 set
702 { 721 {
703 m_groupPosition = value; 722 m_groupPosition = value;
704
705 PhysicsActor actor = PhysActor; 723 PhysicsActor actor = PhysActor;
706 if (actor != null) 724 if (actor != null)
707 { 725 {
@@ -721,22 +739,13 @@ namespace OpenSim.Region.Framework.Scenes
721 739
722 // Tell the physics engines that this prim changed. 740 // Tell the physics engines that this prim changed.
723 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 741 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
742
724 } 743 }
725 catch (Exception e) 744 catch (Exception e)
726 { 745 {
727 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 746 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
728 } 747 }
729 } 748 }
730
731 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
732 if (m_sitTargetAvatar != UUID.Zero)
733 {
734 ScenePresence avatar;
735 if (m_parentGroup.Scene.TryGetScenePresence(m_sitTargetAvatar, out avatar))
736 {
737 avatar.ParentPosition = GetWorldPosition();
738 }
739 }
740 } 749 }
741 } 750 }
742 751
@@ -745,7 +754,7 @@ namespace OpenSim.Region.Framework.Scenes
745 get { return m_offsetPosition; } 754 get { return m_offsetPosition; }
746 set 755 set
747 { 756 {
748// StoreUndoState(); 757 Vector3 oldpos = m_offsetPosition;
749 m_offsetPosition = value; 758 m_offsetPosition = value;
750 759
751 if (ParentGroup != null && !ParentGroup.IsDeleted) 760 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -760,7 +769,22 @@ namespace OpenSim.Region.Framework.Scenes
760 if (m_parentGroup.Scene != null) 769 if (m_parentGroup.Scene != null)
761 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 770 m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
762 } 771 }
772
773 if (!m_parentGroup.m_dupeInProgress)
774 {
775 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
776 foreach (ScenePresence av in avs)
777 {
778 if (av.ParentID == m_localId)
779 {
780 Vector3 offset = (m_offsetPosition - oldpos);
781 av.AbsolutePosition += offset;
782 av.SendAvatarDataToAllAgents();
783 }
784 }
785 }
763 } 786 }
787 TriggerScriptChangedEvent(Changed.POSITION);
764 } 788 }
765 } 789 }
766 790
@@ -909,7 +933,16 @@ namespace OpenSim.Region.Framework.Scenes
909 /// <summary></summary> 933 /// <summary></summary>
910 public Vector3 Acceleration 934 public Vector3 Acceleration
911 { 935 {
912 get { return m_acceleration; } 936 get
937 {
938 PhysicsActor actor = PhysActor;
939 if (actor != null)
940 {
941 m_acceleration = actor.Acceleration;
942 }
943 return m_acceleration;
944 }
945
913 set { m_acceleration = value; } 946 set { m_acceleration = value; }
914 } 947 }
915 948
@@ -1248,6 +1281,13 @@ namespace OpenSim.Region.Framework.Scenes
1248 _flags = value; 1281 _flags = value;
1249 } 1282 }
1250 } 1283 }
1284
1285 [XmlIgnore]
1286 public bool IsOccupied // KF If an av is sittingon this prim
1287 {
1288 get { return m_occupied; }
1289 set { m_occupied = value; }
1290 }
1251 1291
1252 /// <summary> 1292 /// <summary>
1253 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1293 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1307,6 +1347,19 @@ namespace OpenSim.Region.Framework.Scenes
1307 set { m_collisionSoundVolume = value; } 1347 set { m_collisionSoundVolume = value; }
1308 } 1348 }
1309 1349
1350 public float Buoyancy
1351 {
1352 get { return m_buoyancy; }
1353 set
1354 {
1355 m_buoyancy = value;
1356 if (PhysActor != null)
1357 {
1358 PhysActor.Buoyancy = value;
1359 }
1360 }
1361 }
1362
1310 #endregion Public Properties with only Get 1363 #endregion Public Properties with only Get
1311 1364
1312 private uint ApplyMask(uint val, bool set, uint mask) 1365 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1678,6 +1731,9 @@ namespace OpenSim.Region.Framework.Scenes
1678 1731
1679 // Move afterwards ResetIDs as it clears the localID 1732 // Move afterwards ResetIDs as it clears the localID
1680 dupe.LocalId = localID; 1733 dupe.LocalId = localID;
1734 if(dupe.PhysActor != null)
1735 dupe.PhysActor.LocalID = localID;
1736
1681 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1737 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1682 dupe._lastOwnerID = OwnerID; 1738 dupe._lastOwnerID = OwnerID;
1683 1739
@@ -2039,19 +2095,17 @@ namespace OpenSim.Region.Framework.Scenes
2039 public Vector3 GetWorldPosition() 2095 public Vector3 GetWorldPosition()
2040 { 2096 {
2041 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2097 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
2042
2043 Vector3 axPos = OffsetPosition; 2098 Vector3 axPos = OffsetPosition;
2044
2045 axPos *= parentRot; 2099 axPos *= parentRot;
2046 Vector3 translationOffsetPosition = axPos; 2100 Vector3 translationOffsetPosition = axPos;
2047 2101 if(_parentID == 0)
2048// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2102 {
2049 2103 return GroupPosition;
2050 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2104 }
2051 2105 else
2052// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2106 {
2053 2107 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
2054 return worldPos; 2108 }
2055 } 2109 }
2056 2110
2057 /// <summary> 2111 /// <summary>
@@ -2691,17 +2745,18 @@ namespace OpenSim.Region.Framework.Scenes
2691 //Trys to fetch sound id from prim's inventory. 2745 //Trys to fetch sound id from prim's inventory.
2692 //Prim's inventory doesn't support non script items yet 2746 //Prim's inventory doesn't support non script items yet
2693 2747
2694 lock (TaskInventory) 2748 TaskInventory.LockItemsForRead(true);
2749
2750 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2695 { 2751 {
2696 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2752 if (item.Value.Name == sound)
2697 { 2753 {
2698 if (item.Value.Name == sound) 2754 soundID = item.Value.ItemID;
2699 { 2755 break;
2700 soundID = item.Value.ItemID;
2701 break;
2702 }
2703 } 2756 }
2704 } 2757 }
2758
2759 TaskInventory.LockItemsForRead(false);
2705 } 2760 }
2706 2761
2707 m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2762 m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2784,7 +2839,7 @@ namespace OpenSim.Region.Framework.Scenes
2784 2839
2785 public void RotLookAt(Quaternion target, float strength, float damping) 2840 public void RotLookAt(Quaternion target, float strength, float damping)
2786 { 2841 {
2787 rotLookAt(target, strength, damping); 2842 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2788 } 2843 }
2789 2844
2790 public void rotLookAt(Quaternion target, float strength, float damping) 2845 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -3030,8 +3085,8 @@ namespace OpenSim.Region.Framework.Scenes
3030 { 3085 {
3031 const float ROTATION_TOLERANCE = 0.01f; 3086 const float ROTATION_TOLERANCE = 0.01f;
3032 const float VELOCITY_TOLERANCE = 0.001f; 3087 const float VELOCITY_TOLERANCE = 0.001f;
3033 const float POSITION_TOLERANCE = 0.05f; 3088 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
3034 const int TIME_MS_TOLERANCE = 3000; 3089 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
3035 3090
3036 switch (UpdateFlag) 3091 switch (UpdateFlag)
3037 { 3092 {
@@ -3094,17 +3149,16 @@ namespace OpenSim.Region.Framework.Scenes
3094 if (!UUID.TryParse(sound, out soundID)) 3149 if (!UUID.TryParse(sound, out soundID))
3095 { 3150 {
3096 // search sound file from inventory 3151 // search sound file from inventory
3097 lock (TaskInventory) 3152 TaskInventory.LockItemsForRead(true);
3153 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3098 { 3154 {
3099 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3155 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3100 { 3156 {
3101 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3157 soundID = item.Value.ItemID;
3102 { 3158 break;
3103 soundID = item.Value.ItemID;
3104 break;
3105 }
3106 } 3159 }
3107 } 3160 }
3161 TaskInventory.LockItemsForRead(false);
3108 } 3162 }
3109 3163
3110 if (soundID == UUID.Zero) 3164 if (soundID == UUID.Zero)
@@ -3515,7 +3569,7 @@ namespace OpenSim.Region.Framework.Scenes
3515 3569
3516 public void StopLookAt() 3570 public void StopLookAt()
3517 { 3571 {
3518 m_parentGroup.stopLookAt(); 3572 m_parentGroup.stopLookAt(); // This calls method in SceneObjectGroup.
3519 3573
3520 m_parentGroup.ScheduleGroupForTerseUpdate(); 3574 m_parentGroup.ScheduleGroupForTerseUpdate();
3521 } 3575 }
@@ -3566,45 +3620,45 @@ namespace OpenSim.Region.Framework.Scenes
3566 // TODO: May need to fix for group comparison 3620 // TODO: May need to fix for group comparison
3567 if (last.Compare(this)) 3621 if (last.Compare(this))
3568 { 3622 {
3569 // m_log.DebugFormat( 3623 // m_log.DebugFormat(
3570 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3624 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3571 // Name, LocalId, m_undo.Count); 3625 // Name, LocalId, m_undo.Count);
3572 3626
3573 return; 3627 return;
3574 } 3628 }
3575 } 3629 }
3576 } 3630 }
3577 3631
3578 // m_log.DebugFormat( 3632 // m_log.DebugFormat(
3579 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", 3633 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3580 // Name, LocalId, forGroup, m_undo.Count); 3634 // Name, LocalId, forGroup, m_undo.Count);
3581 3635
3582 if (m_parentGroup.GetSceneMaxUndo() > 0) 3636 if (m_parentGroup.GetSceneMaxUndo() > 0)
3583 { 3637 {
3584 UndoState nUndo = new UndoState(this, forGroup); 3638 UndoState nUndo = new UndoState(this, forGroup);
3585 3639
3586 m_undo.Push(nUndo); 3640 m_undo.Push(nUndo);
3587 3641
3588 if (m_redo.Count > 0) 3642 if (m_redo.Count > 0)
3589 m_redo.Clear(); 3643 m_redo.Clear();
3590 3644
3591 // m_log.DebugFormat( 3645 // m_log.DebugFormat(
3592 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3646 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3593 // Name, LocalId, forGroup, m_undo.Count); 3647 // Name, LocalId, forGroup, m_undo.Count);
3594 } 3648 }
3595 } 3649 }
3596 } 3650 }
3597 } 3651 }
3598// else 3652 // else
3599// { 3653 // {
3600// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3654 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3601// } 3655 // }
3602 } 3656 }
3603// else 3657 // else
3604// { 3658 // {
3605// m_log.DebugFormat( 3659 // m_log.DebugFormat(
3606// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3660 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3607// } 3661 // }
3608 } 3662 }
3609 3663
3610 /// <summary> 3664 /// <summary>
@@ -4652,8 +4706,9 @@ namespace OpenSim.Region.Framework.Scenes
4652 { 4706 {
4653 m_shape.TextureEntry = textureEntry; 4707 m_shape.TextureEntry = textureEntry;
4654 TriggerScriptChangedEvent(Changed.TEXTURE); 4708 TriggerScriptChangedEvent(Changed.TEXTURE);
4655 4709 UpdateFlag = UpdateRequired.FULL;
4656 ParentGroup.HasGroupChanged = true; 4710 ParentGroup.HasGroupChanged = true;
4711
4657 //This is madness.. 4712 //This is madness..
4658 //ParentGroup.ScheduleGroupForFullUpdate(); 4713 //ParentGroup.ScheduleGroupForFullUpdate();
4659 //This is sparta 4714 //This is sparta
@@ -4850,5 +4905,17 @@ namespace OpenSim.Region.Framework.Scenes
4850 Color color = Color; 4905 Color color = Color;
4851 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4906 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4852 } 4907 }
4908
4909 public void ResetOwnerChangeFlag()
4910 {
4911 List<UUID> inv = Inventory.GetInventoryList();
4912
4913 foreach (UUID itemID in inv)
4914 {
4915 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4916 item.OwnerChanged = false;
4917 Inventory.UpdateInventoryItem(item, false, false);
4918 }
4919 }
4853 } 4920 }
4854} 4921}