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 ad60604..0970c92 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)
@@ -1662,6 +1715,9 @@ namespace OpenSim.Region.Framework.Scenes
1662 1715
1663 // Move afterwards ResetIDs as it clears the localID 1716 // Move afterwards ResetIDs as it clears the localID
1664 dupe.LocalId = localID; 1717 dupe.LocalId = localID;
1718 if(dupe.PhysActor != null)
1719 dupe.PhysActor.LocalID = localID;
1720
1665 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1721 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1666 dupe._lastOwnerID = OwnerID; 1722 dupe._lastOwnerID = OwnerID;
1667 1723
@@ -2023,19 +2079,17 @@ namespace OpenSim.Region.Framework.Scenes
2023 public Vector3 GetWorldPosition() 2079 public Vector3 GetWorldPosition()
2024 { 2080 {
2025 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2081 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
2026
2027 Vector3 axPos = OffsetPosition; 2082 Vector3 axPos = OffsetPosition;
2028
2029 axPos *= parentRot; 2083 axPos *= parentRot;
2030 Vector3 translationOffsetPosition = axPos; 2084 Vector3 translationOffsetPosition = axPos;
2031 2085 if(_parentID == 0)
2032// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2086 {
2033 2087 return GroupPosition;
2034 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2088 }
2035 2089 else
2036// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2090 {
2037 2091 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
2038 return worldPos; 2092 }
2039 } 2093 }
2040 2094
2041 /// <summary> 2095 /// <summary>
@@ -2675,17 +2729,18 @@ namespace OpenSim.Region.Framework.Scenes
2675 //Trys to fetch sound id from prim's inventory. 2729 //Trys to fetch sound id from prim's inventory.
2676 //Prim's inventory doesn't support non script items yet 2730 //Prim's inventory doesn't support non script items yet
2677 2731
2678 lock (TaskInventory) 2732 TaskInventory.LockItemsForRead(true);
2733
2734 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2679 { 2735 {
2680 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2736 if (item.Value.Name == sound)
2681 { 2737 {
2682 if (item.Value.Name == sound) 2738 soundID = item.Value.ItemID;
2683 { 2739 break;
2684 soundID = item.Value.ItemID;
2685 break;
2686 }
2687 } 2740 }
2688 } 2741 }
2742
2743 TaskInventory.LockItemsForRead(false);
2689 } 2744 }
2690 2745
2691 m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2746 m_parentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2768,7 +2823,7 @@ namespace OpenSim.Region.Framework.Scenes
2768 2823
2769 public void RotLookAt(Quaternion target, float strength, float damping) 2824 public void RotLookAt(Quaternion target, float strength, float damping)
2770 { 2825 {
2771 rotLookAt(target, strength, damping); 2826 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2772 } 2827 }
2773 2828
2774 public void rotLookAt(Quaternion target, float strength, float damping) 2829 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -3014,8 +3069,8 @@ namespace OpenSim.Region.Framework.Scenes
3014 { 3069 {
3015 const float ROTATION_TOLERANCE = 0.01f; 3070 const float ROTATION_TOLERANCE = 0.01f;
3016 const float VELOCITY_TOLERANCE = 0.001f; 3071 const float VELOCITY_TOLERANCE = 0.001f;
3017 const float POSITION_TOLERANCE = 0.05f; 3072 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
3018 const int TIME_MS_TOLERANCE = 3000; 3073 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
3019 3074
3020 switch (UpdateFlag) 3075 switch (UpdateFlag)
3021 { 3076 {
@@ -3078,17 +3133,16 @@ namespace OpenSim.Region.Framework.Scenes
3078 if (!UUID.TryParse(sound, out soundID)) 3133 if (!UUID.TryParse(sound, out soundID))
3079 { 3134 {
3080 // search sound file from inventory 3135 // search sound file from inventory
3081 lock (TaskInventory) 3136 TaskInventory.LockItemsForRead(true);
3137 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3082 { 3138 {
3083 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3139 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3084 { 3140 {
3085 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3141 soundID = item.Value.ItemID;
3086 { 3142 break;
3087 soundID = item.Value.ItemID;
3088 break;
3089 }
3090 } 3143 }
3091 } 3144 }
3145 TaskInventory.LockItemsForRead(false);
3092 } 3146 }
3093 3147
3094 if (soundID == UUID.Zero) 3148 if (soundID == UUID.Zero)
@@ -3499,7 +3553,7 @@ namespace OpenSim.Region.Framework.Scenes
3499 3553
3500 public void StopLookAt() 3554 public void StopLookAt()
3501 { 3555 {
3502 m_parentGroup.stopLookAt(); 3556 m_parentGroup.stopLookAt(); // This calls method in SceneObjectGroup.
3503 3557
3504 m_parentGroup.ScheduleGroupForTerseUpdate(); 3558 m_parentGroup.ScheduleGroupForTerseUpdate();
3505 } 3559 }
@@ -3550,45 +3604,45 @@ namespace OpenSim.Region.Framework.Scenes
3550 // TODO: May need to fix for group comparison 3604 // TODO: May need to fix for group comparison
3551 if (last.Compare(this)) 3605 if (last.Compare(this))
3552 { 3606 {
3553 // m_log.DebugFormat( 3607 // m_log.DebugFormat(
3554 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3608 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3555 // Name, LocalId, m_undo.Count); 3609 // Name, LocalId, m_undo.Count);
3556 3610
3557 return; 3611 return;
3558 } 3612 }
3559 } 3613 }
3560 } 3614 }
3561 3615
3562 // m_log.DebugFormat( 3616 // m_log.DebugFormat(
3563 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", 3617 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3564 // Name, LocalId, forGroup, m_undo.Count); 3618 // Name, LocalId, forGroup, m_undo.Count);
3565 3619
3566 if (m_parentGroup.GetSceneMaxUndo() > 0) 3620 if (m_parentGroup.GetSceneMaxUndo() > 0)
3567 { 3621 {
3568 UndoState nUndo = new UndoState(this, forGroup); 3622 UndoState nUndo = new UndoState(this, forGroup);
3569 3623
3570 m_undo.Push(nUndo); 3624 m_undo.Push(nUndo);
3571 3625
3572 if (m_redo.Count > 0) 3626 if (m_redo.Count > 0)
3573 m_redo.Clear(); 3627 m_redo.Clear();
3574 3628
3575 // m_log.DebugFormat( 3629 // m_log.DebugFormat(
3576 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3630 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3577 // Name, LocalId, forGroup, m_undo.Count); 3631 // Name, LocalId, forGroup, m_undo.Count);
3578 } 3632 }
3579 } 3633 }
3580 } 3634 }
3581 } 3635 }
3582// else 3636 // else
3583// { 3637 // {
3584// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3638 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3585// } 3639 // }
3586 } 3640 }
3587// else 3641 // else
3588// { 3642 // {
3589// m_log.DebugFormat( 3643 // m_log.DebugFormat(
3590// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3644 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3591// } 3645 // }
3592 } 3646 }
3593 3647
3594 /// <summary> 3648 /// <summary>
@@ -4643,8 +4697,9 @@ namespace OpenSim.Region.Framework.Scenes
4643 { 4697 {
4644 m_shape.TextureEntry = textureEntry; 4698 m_shape.TextureEntry = textureEntry;
4645 TriggerScriptChangedEvent(Changed.TEXTURE); 4699 TriggerScriptChangedEvent(Changed.TEXTURE);
4646 4700 UpdateFlag = UpdateRequired.FULL;
4647 ParentGroup.HasGroupChanged = true; 4701 ParentGroup.HasGroupChanged = true;
4702
4648 //This is madness.. 4703 //This is madness..
4649 //ParentGroup.ScheduleGroupForFullUpdate(); 4704 //ParentGroup.ScheduleGroupForFullUpdate();
4650 //This is sparta 4705 //This is sparta
@@ -4841,5 +4896,17 @@ namespace OpenSim.Region.Framework.Scenes
4841 Color color = Color; 4896 Color color = Color;
4842 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4897 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4843 } 4898 }
4899
4900 public void ResetOwnerChangeFlag()
4901 {
4902 List<UUID> inv = Inventory.GetInventoryList();
4903
4904 foreach (UUID itemID in inv)
4905 {
4906 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4907 item.OwnerChanged = false;
4908 Inventory.UpdateInventoryItem(item, false, false);
4909 }
4910 }
4844 } 4911 }
4845} 4912}