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 b77f1b6..c8f28c7 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
@@ -1240,6 +1273,13 @@ namespace OpenSim.Region.Framework.Scenes
1240 _flags = value; 1273 _flags = value;
1241 } 1274 }
1242 } 1275 }
1276
1277 [XmlIgnore]
1278 public bool IsOccupied // KF If an av is sittingon this prim
1279 {
1280 get { return m_occupied; }
1281 set { m_occupied = value; }
1282 }
1243 1283
1244 /// <summary> 1284 /// <summary>
1245 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1285 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1299,6 +1339,19 @@ namespace OpenSim.Region.Framework.Scenes
1299 set { m_collisionSoundVolume = value; } 1339 set { m_collisionSoundVolume = value; }
1300 } 1340 }
1301 1341
1342 public float Buoyancy
1343 {
1344 get { return m_buoyancy; }
1345 set
1346 {
1347 m_buoyancy = value;
1348 if (PhysActor != null)
1349 {
1350 PhysActor.Buoyancy = value;
1351 }
1352 }
1353 }
1354
1302 #endregion Public Properties with only Get 1355 #endregion Public Properties with only Get
1303 1356
1304 private uint ApplyMask(uint val, bool set, uint mask) 1357 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1670,6 +1723,9 @@ namespace OpenSim.Region.Framework.Scenes
1670 1723
1671 // Move afterwards ResetIDs as it clears the localID 1724 // Move afterwards ResetIDs as it clears the localID
1672 dupe.LocalId = localID; 1725 dupe.LocalId = localID;
1726 if(dupe.PhysActor != null)
1727 dupe.PhysActor.LocalID = localID;
1728
1673 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1729 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1674 dupe._lastOwnerID = OwnerID; 1730 dupe._lastOwnerID = OwnerID;
1675 1731
@@ -2031,19 +2087,17 @@ namespace OpenSim.Region.Framework.Scenes
2031 public Vector3 GetWorldPosition() 2087 public Vector3 GetWorldPosition()
2032 { 2088 {
2033 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2089 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
2034
2035 Vector3 axPos = OffsetPosition; 2090 Vector3 axPos = OffsetPosition;
2036
2037 axPos *= parentRot; 2091 axPos *= parentRot;
2038 Vector3 translationOffsetPosition = axPos; 2092 Vector3 translationOffsetPosition = axPos;
2039 2093 if(_parentID == 0)
2040// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2094 {
2041 2095 return GroupPosition;
2042 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2096 }
2043 2097 else
2044// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2098 {
2045 2099 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
2046 return worldPos; 2100 }
2047 } 2101 }
2048 2102
2049 /// <summary> 2103 /// <summary>
@@ -2683,17 +2737,18 @@ namespace OpenSim.Region.Framework.Scenes
2683 //Trys to fetch sound id from prim's inventory. 2737 //Trys to fetch sound id from prim's inventory.
2684 //Prim's inventory doesn't support non script items yet 2738 //Prim's inventory doesn't support non script items yet
2685 2739
2686 lock (TaskInventory) 2740 TaskInventory.LockItemsForRead(true);
2741
2742 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2687 { 2743 {
2688 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2744 if (item.Value.Name == sound)
2689 { 2745 {
2690 if (item.Value.Name == sound) 2746 soundID = item.Value.ItemID;
2691 { 2747 break;
2692 soundID = item.Value.ItemID;
2693 break;
2694 }
2695 } 2748 }
2696 } 2749 }
2750
2751 TaskInventory.LockItemsForRead(false);
2697 } 2752 }
2698 2753
2699 m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2754 m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2776,7 +2831,7 @@ namespace OpenSim.Region.Framework.Scenes
2776 2831
2777 public void RotLookAt(Quaternion target, float strength, float damping) 2832 public void RotLookAt(Quaternion target, float strength, float damping)
2778 { 2833 {
2779 rotLookAt(target, strength, damping); 2834 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2780 } 2835 }
2781 2836
2782 public void rotLookAt(Quaternion target, float strength, float damping) 2837 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -3022,8 +3077,8 @@ namespace OpenSim.Region.Framework.Scenes
3022 { 3077 {
3023 const float ROTATION_TOLERANCE = 0.01f; 3078 const float ROTATION_TOLERANCE = 0.01f;
3024 const float VELOCITY_TOLERANCE = 0.001f; 3079 const float VELOCITY_TOLERANCE = 0.001f;
3025 const float POSITION_TOLERANCE = 0.05f; 3080 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
3026 const int TIME_MS_TOLERANCE = 3000; 3081 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
3027 3082
3028 switch (UpdateFlag) 3083 switch (UpdateFlag)
3029 { 3084 {
@@ -3086,17 +3141,16 @@ namespace OpenSim.Region.Framework.Scenes
3086 if (!UUID.TryParse(sound, out soundID)) 3141 if (!UUID.TryParse(sound, out soundID))
3087 { 3142 {
3088 // search sound file from inventory 3143 // search sound file from inventory
3089 lock (TaskInventory) 3144 TaskInventory.LockItemsForRead(true);
3145 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3090 { 3146 {
3091 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3147 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3092 { 3148 {
3093 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3149 soundID = item.Value.ItemID;
3094 { 3150 break;
3095 soundID = item.Value.ItemID;
3096 break;
3097 }
3098 } 3151 }
3099 } 3152 }
3153 TaskInventory.LockItemsForRead(false);
3100 } 3154 }
3101 3155
3102 if (soundID == UUID.Zero) 3156 if (soundID == UUID.Zero)
@@ -3507,7 +3561,7 @@ namespace OpenSim.Region.Framework.Scenes
3507 3561
3508 public void StopLookAt() 3562 public void StopLookAt()
3509 { 3563 {
3510 m_parentGroup.stopLookAt(); 3564 m_parentGroup.stopLookAt(); // This calls method in SceneObjectGroup.
3511 3565
3512 m_parentGroup.ScheduleGroupForTerseUpdate(); 3566 m_parentGroup.ScheduleGroupForTerseUpdate();
3513 } 3567 }
@@ -3558,45 +3612,45 @@ namespace OpenSim.Region.Framework.Scenes
3558 // TODO: May need to fix for group comparison 3612 // TODO: May need to fix for group comparison
3559 if (last.Compare(this)) 3613 if (last.Compare(this))
3560 { 3614 {
3561 // m_log.DebugFormat( 3615 // m_log.DebugFormat(
3562 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3616 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3563 // Name, LocalId, m_undo.Count); 3617 // Name, LocalId, m_undo.Count);
3564 3618
3565 return; 3619 return;
3566 } 3620 }
3567 } 3621 }
3568 } 3622 }
3569 3623
3570 // m_log.DebugFormat( 3624 // m_log.DebugFormat(
3571 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", 3625 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3572 // Name, LocalId, forGroup, m_undo.Count); 3626 // Name, LocalId, forGroup, m_undo.Count);
3573 3627
3574 if (m_parentGroup.GetSceneMaxUndo() > 0) 3628 if (m_parentGroup.GetSceneMaxUndo() > 0)
3575 { 3629 {
3576 UndoState nUndo = new UndoState(this, forGroup); 3630 UndoState nUndo = new UndoState(this, forGroup);
3577 3631
3578 m_undo.Push(nUndo); 3632 m_undo.Push(nUndo);
3579 3633
3580 if (m_redo.Count > 0) 3634 if (m_redo.Count > 0)
3581 m_redo.Clear(); 3635 m_redo.Clear();
3582 3636
3583 // m_log.DebugFormat( 3637 // m_log.DebugFormat(
3584 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3638 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3585 // Name, LocalId, forGroup, m_undo.Count); 3639 // Name, LocalId, forGroup, m_undo.Count);
3586 } 3640 }
3587 } 3641 }
3588 } 3642 }
3589 } 3643 }
3590// else 3644 // else
3591// { 3645 // {
3592// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3646 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3593// } 3647 // }
3594 } 3648 }
3595// else 3649 // else
3596// { 3650 // {
3597// m_log.DebugFormat( 3651 // m_log.DebugFormat(
3598// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3652 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3599// } 3653 // }
3600 } 3654 }
3601 3655
3602 /// <summary> 3656 /// <summary>
@@ -4644,8 +4698,9 @@ namespace OpenSim.Region.Framework.Scenes
4644 { 4698 {
4645 m_shape.TextureEntry = textureEntry; 4699 m_shape.TextureEntry = textureEntry;
4646 TriggerScriptChangedEvent(Changed.TEXTURE); 4700 TriggerScriptChangedEvent(Changed.TEXTURE);
4647 4701 UpdateFlag = UpdateRequired.FULL;
4648 ParentGroup.HasGroupChanged = true; 4702 ParentGroup.HasGroupChanged = true;
4703
4649 //This is madness.. 4704 //This is madness..
4650 //ParentGroup.ScheduleGroupForFullUpdate(); 4705 //ParentGroup.ScheduleGroupForFullUpdate();
4651 //This is sparta 4706 //This is sparta
@@ -4842,5 +4897,17 @@ namespace OpenSim.Region.Framework.Scenes
4842 Color color = Color; 4897 Color color = Color;
4843 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4898 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4844 } 4899 }
4900
4901 public void ResetOwnerChangeFlag()
4902 {
4903 List<UUID> inv = Inventory.GetInventoryList();
4904
4905 foreach (UUID itemID in inv)
4906 {
4907 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4908 item.OwnerChanged = false;
4909 Inventory.UpdateInventoryItem(item, false, false);
4910 }
4911 }
4845 } 4912 }
4846} 4913}