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.cs201
1 files changed, 133 insertions, 68 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index c8b39a4..dbf29d0 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;
@@ -252,6 +262,7 @@ namespace OpenSim.Region.Framework.Scenes
252 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 262 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
253 private Vector3 m_sitTargetPosition; 263 private Vector3 m_sitTargetPosition;
254 private string m_sitAnimation = "SIT"; 264 private string m_sitAnimation = "SIT";
265 private bool m_occupied; // KF if any av is sitting on this prim
255 private string m_text = String.Empty; 266 private string m_text = String.Empty;
256 private string m_touchName = String.Empty; 267 private string m_touchName = String.Empty;
257 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); 268 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5);
@@ -286,6 +297,7 @@ namespace OpenSim.Region.Framework.Scenes
286 protected Vector3 m_lastAcceleration; 297 protected Vector3 m_lastAcceleration;
287 protected Vector3 m_lastAngularVelocity; 298 protected Vector3 m_lastAngularVelocity;
288 protected int m_lastTerseSent; 299 protected int m_lastTerseSent;
300 protected float m_buoyancy = 0.0f;
289 301
290 /// <summary> 302 /// <summary>
291 /// Stores media texture data 303 /// Stores media texture data
@@ -341,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes
341 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 353 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
342 Quaternion rotationOffset, Vector3 offsetPosition) : this() 354 Quaternion rotationOffset, Vector3 offsetPosition) : this()
343 { 355 {
344 m_name = "Primitive"; 356 m_name = "Object";
345 357
346 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 358 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
347 LastOwnerID = CreatorID = OwnerID = ownerID; 359 LastOwnerID = CreatorID = OwnerID = ownerID;
@@ -381,7 +393,7 @@ namespace OpenSim.Region.Framework.Scenes
381 private uint _ownerMask = (uint)PermissionMask.All; 393 private uint _ownerMask = (uint)PermissionMask.All;
382 private uint _groupMask = (uint)PermissionMask.None; 394 private uint _groupMask = (uint)PermissionMask.None;
383 private uint _everyoneMask = (uint)PermissionMask.None; 395 private uint _everyoneMask = (uint)PermissionMask.None;
384 private uint _nextOwnerMask = (uint)PermissionMask.All; 396 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
385 private PrimFlags _flags = PrimFlags.None; 397 private PrimFlags _flags = PrimFlags.None;
386 private DateTime m_expires; 398 private DateTime m_expires;
387 private DateTime m_rezzed; 399 private DateTime m_rezzed;
@@ -475,12 +487,16 @@ namespace OpenSim.Region.Framework.Scenes
475 } 487 }
476 488
477 /// <value> 489 /// <value>
478 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 490 /// Get the inventory list
479 /// </value> 491 /// </value>
480 public TaskInventoryDictionary TaskInventory 492 public TaskInventoryDictionary TaskInventory
481 { 493 {
482 get { return m_inventory.Items; } 494 get {
483 set { m_inventory.Items = value; } 495 return m_inventory.Items;
496 }
497 set {
498 m_inventory.Items = value;
499 }
484 } 500 }
485 501
486 /// <summary> 502 /// <summary>
@@ -625,14 +641,12 @@ namespace OpenSim.Region.Framework.Scenes
625 set { m_LoopSoundSlavePrims = value; } 641 set { m_LoopSoundSlavePrims = value; }
626 } 642 }
627 643
628
629 public Byte[] TextureAnimation 644 public Byte[] TextureAnimation
630 { 645 {
631 get { return m_TextureAnimation; } 646 get { return m_TextureAnimation; }
632 set { m_TextureAnimation = value; } 647 set { m_TextureAnimation = value; }
633 } 648 }
634 649
635
636 public Byte[] ParticleSystem 650 public Byte[] ParticleSystem
637 { 651 {
638 get { return m_particleSystem; } 652 get { return m_particleSystem; }
@@ -671,7 +685,9 @@ namespace OpenSim.Region.Framework.Scenes
671 PhysicsActor actor = PhysActor; 685 PhysicsActor actor = PhysActor;
672 if (actor != null && ParentID == 0) 686 if (actor != null && ParentID == 0)
673 { 687 {
674 m_groupPosition = actor.Position; 688 if (actor != null)
689 m_groupPosition = actor.Position;
690 return m_groupPosition;
675 } 691 }
676 692
677 if (ParentGroup.IsAttachment) 693 if (ParentGroup.IsAttachment)
@@ -681,12 +697,14 @@ namespace OpenSim.Region.Framework.Scenes
681 return sp.AbsolutePosition; 697 return sp.AbsolutePosition;
682 } 698 }
683 699
700 // use root prim's group position. Physics may have updated it
701 if (ParentGroup.RootPart != this)
702 m_groupPosition = ParentGroup.RootPart.GroupPosition;
684 return m_groupPosition; 703 return m_groupPosition;
685 } 704 }
686 set 705 set
687 { 706 {
688 m_groupPosition = value; 707 m_groupPosition = value;
689
690 PhysicsActor actor = PhysActor; 708 PhysicsActor actor = PhysActor;
691 if (actor != null) 709 if (actor != null)
692 { 710 {
@@ -712,16 +730,6 @@ namespace OpenSim.Region.Framework.Scenes
712 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 730 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
713 } 731 }
714 } 732 }
715
716 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
717 if (SitTargetAvatar != UUID.Zero)
718 {
719 ScenePresence avatar;
720 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
721 {
722 avatar.ParentPosition = GetWorldPosition();
723 }
724 }
725 } 733 }
726 } 734 }
727 735
@@ -730,7 +738,7 @@ namespace OpenSim.Region.Framework.Scenes
730 get { return m_offsetPosition; } 738 get { return m_offsetPosition; }
731 set 739 set
732 { 740 {
733// StoreUndoState(); 741 Vector3 oldpos = m_offsetPosition;
734 m_offsetPosition = value; 742 m_offsetPosition = value;
735 743
736 if (ParentGroup != null && !ParentGroup.IsDeleted) 744 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -745,7 +753,22 @@ namespace OpenSim.Region.Framework.Scenes
745 if (ParentGroup.Scene != null) 753 if (ParentGroup.Scene != null)
746 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 754 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
747 } 755 }
756
757 if (!m_parentGroup.m_dupeInProgress)
758 {
759 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
760 foreach (ScenePresence av in avs)
761 {
762 if (av.ParentID == m_localId)
763 {
764 Vector3 offset = (m_offsetPosition - oldpos);
765 av.AbsolutePosition += offset;
766 av.SendAvatarDataToAllAgents();
767 }
768 }
769 }
748 } 770 }
771 TriggerScriptChangedEvent(Changed.POSITION);
749 } 772 }
750 } 773 }
751 774
@@ -894,7 +917,16 @@ namespace OpenSim.Region.Framework.Scenes
894 /// <summary></summary> 917 /// <summary></summary>
895 public Vector3 Acceleration 918 public Vector3 Acceleration
896 { 919 {
897 get { return m_acceleration; } 920 get
921 {
922 PhysicsActor actor = PhysActor;
923 if (actor != null)
924 {
925 m_acceleration = actor.Acceleration;
926 }
927 return m_acceleration;
928 }
929
898 set { m_acceleration = value; } 930 set { m_acceleration = value; }
899 } 931 }
900 932
@@ -1222,6 +1254,13 @@ namespace OpenSim.Region.Framework.Scenes
1222 _flags = value; 1254 _flags = value;
1223 } 1255 }
1224 } 1256 }
1257
1258 [XmlIgnore]
1259 public bool IsOccupied // KF If an av is sittingon this prim
1260 {
1261 get { return m_occupied; }
1262 set { m_occupied = value; }
1263 }
1225 1264
1226 /// <summary> 1265 /// <summary>
1227 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1266 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1281,6 +1320,19 @@ namespace OpenSim.Region.Framework.Scenes
1281 set { m_collisionSoundVolume = value; } 1320 set { m_collisionSoundVolume = value; }
1282 } 1321 }
1283 1322
1323 public float Buoyancy
1324 {
1325 get { return m_buoyancy; }
1326 set
1327 {
1328 m_buoyancy = value;
1329 if (PhysActor != null)
1330 {
1331 PhysActor.Buoyancy = value;
1332 }
1333 }
1334 }
1335
1284 #endregion Public Properties with only Get 1336 #endregion Public Properties with only Get
1285 1337
1286 private uint ApplyMask(uint val, bool set, uint mask) 1338 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1602,6 +1654,9 @@ namespace OpenSim.Region.Framework.Scenes
1602 1654
1603 // Move afterwards ResetIDs as it clears the localID 1655 // Move afterwards ResetIDs as it clears the localID
1604 dupe.LocalId = localID; 1656 dupe.LocalId = localID;
1657 if(dupe.PhysActor != null)
1658 dupe.PhysActor.LocalID = localID;
1659
1605 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1660 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1606 dupe.LastOwnerID = OwnerID; 1661 dupe.LastOwnerID = OwnerID;
1607 1662
@@ -1963,19 +2018,17 @@ namespace OpenSim.Region.Framework.Scenes
1963 public Vector3 GetWorldPosition() 2018 public Vector3 GetWorldPosition()
1964 { 2019 {
1965 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2020 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
1966
1967 Vector3 axPos = OffsetPosition; 2021 Vector3 axPos = OffsetPosition;
1968
1969 axPos *= parentRot; 2022 axPos *= parentRot;
1970 Vector3 translationOffsetPosition = axPos; 2023 Vector3 translationOffsetPosition = axPos;
1971 2024 if(_parentID == 0)
1972// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2025 {
1973 2026 return GroupPosition;
1974 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2027 }
1975 2028 else
1976// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2029 {
1977 2030 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
1978 return worldPos; 2031 }
1979 } 2032 }
1980 2033
1981 /// <summary> 2034 /// <summary>
@@ -2613,17 +2666,18 @@ namespace OpenSim.Region.Framework.Scenes
2613 //Trys to fetch sound id from prim's inventory. 2666 //Trys to fetch sound id from prim's inventory.
2614 //Prim's inventory doesn't support non script items yet 2667 //Prim's inventory doesn't support non script items yet
2615 2668
2616 lock (TaskInventory) 2669 TaskInventory.LockItemsForRead(true);
2670
2671 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2617 { 2672 {
2618 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2673 if (item.Value.Name == sound)
2619 { 2674 {
2620 if (item.Value.Name == sound) 2675 soundID = item.Value.ItemID;
2621 { 2676 break;
2622 soundID = item.Value.ItemID;
2623 break;
2624 }
2625 } 2677 }
2626 } 2678 }
2679
2680 TaskInventory.LockItemsForRead(false);
2627 } 2681 }
2628 2682
2629 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2683 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2706,7 +2760,7 @@ namespace OpenSim.Region.Framework.Scenes
2706 2760
2707 public void RotLookAt(Quaternion target, float strength, float damping) 2761 public void RotLookAt(Quaternion target, float strength, float damping)
2708 { 2762 {
2709 rotLookAt(target, strength, damping); 2763 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2710 } 2764 }
2711 2765
2712 public void rotLookAt(Quaternion target, float strength, float damping) 2766 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -2942,8 +2996,8 @@ namespace OpenSim.Region.Framework.Scenes
2942 { 2996 {
2943 const float ROTATION_TOLERANCE = 0.01f; 2997 const float ROTATION_TOLERANCE = 0.01f;
2944 const float VELOCITY_TOLERANCE = 0.001f; 2998 const float VELOCITY_TOLERANCE = 0.001f;
2945 const float POSITION_TOLERANCE = 0.05f; 2999 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2946 const int TIME_MS_TOLERANCE = 3000; 3000 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2947 3001
2948 switch (UpdateFlag) 3002 switch (UpdateFlag)
2949 { 3003 {
@@ -3007,17 +3061,16 @@ namespace OpenSim.Region.Framework.Scenes
3007 if (!UUID.TryParse(sound, out soundID)) 3061 if (!UUID.TryParse(sound, out soundID))
3008 { 3062 {
3009 // search sound file from inventory 3063 // search sound file from inventory
3010 lock (TaskInventory) 3064 TaskInventory.LockItemsForRead(true);
3065 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3011 { 3066 {
3012 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3067 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3013 { 3068 {
3014 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3069 soundID = item.Value.ItemID;
3015 { 3070 break;
3016 soundID = item.Value.ItemID;
3017 break;
3018 }
3019 } 3071 }
3020 } 3072 }
3073 TaskInventory.LockItemsForRead(false);
3021 } 3074 }
3022 3075
3023 if (soundID == UUID.Zero) 3076 if (soundID == UUID.Zero)
@@ -3486,10 +3539,10 @@ namespace OpenSim.Region.Framework.Scenes
3486 // TODO: May need to fix for group comparison 3539 // TODO: May need to fix for group comparison
3487 if (last.Compare(this)) 3540 if (last.Compare(this))
3488 { 3541 {
3489 // m_log.DebugFormat( 3542 // m_log.DebugFormat(
3490 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3543 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3491 // Name, LocalId, m_undo.Count); 3544 // Name, LocalId, m_undo.Count);
3492 3545
3493 return; 3546 return;
3494 } 3547 }
3495 } 3548 }
@@ -3502,29 +3555,29 @@ namespace OpenSim.Region.Framework.Scenes
3502 if (ParentGroup.GetSceneMaxUndo() > 0) 3555 if (ParentGroup.GetSceneMaxUndo() > 0)
3503 { 3556 {
3504 UndoState nUndo = new UndoState(this, forGroup); 3557 UndoState nUndo = new UndoState(this, forGroup);
3505 3558
3506 m_undo.Push(nUndo); 3559 m_undo.Push(nUndo);
3507 3560
3508 if (m_redo.Count > 0) 3561 if (m_redo.Count > 0)
3509 m_redo.Clear(); 3562 m_redo.Clear();
3510 3563
3511 // m_log.DebugFormat( 3564 // m_log.DebugFormat(
3512 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3565 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3513 // Name, LocalId, forGroup, m_undo.Count); 3566 // Name, LocalId, forGroup, m_undo.Count);
3514 } 3567 }
3515 } 3568 }
3516 } 3569 }
3517 } 3570 }
3518// else 3571 // else
3519// { 3572 // {
3520// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3573 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3521// } 3574 // }
3522 } 3575 }
3523// else 3576 // else
3524// { 3577 // {
3525// m_log.DebugFormat( 3578 // m_log.DebugFormat(
3526// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3579 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3527// } 3580 // }
3528 } 3581 }
3529 3582
3530 /// <summary> 3583 /// <summary>
@@ -4778,5 +4831,17 @@ namespace OpenSim.Region.Framework.Scenes
4778 Color color = Color; 4831 Color color = Color;
4779 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4832 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4780 } 4833 }
4834
4835 public void ResetOwnerChangeFlag()
4836 {
4837 List<UUID> inv = Inventory.GetInventoryList();
4838
4839 foreach (UUID itemID in inv)
4840 {
4841 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4842 item.OwnerChanged = false;
4843 Inventory.UpdateInventoryItem(item, false, false);
4844 }
4845 }
4781 } 4846 }
4782} 4847}