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, 144 insertions, 75 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index c8b39a4..428fe1c 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;
@@ -210,8 +220,7 @@ namespace OpenSim.Region.Framework.Scenes
210 220
211 public Vector3 RotationAxis = Vector3.One; 221 public Vector3 RotationAxis = Vector3.One;
212 222
213 public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this 223 public bool VolumeDetectActive;
214 // Certainly this must be a persistant setting finally
215 224
216 public bool IsWaitingForFirstSpinUpdatePacket; 225 public bool IsWaitingForFirstSpinUpdatePacket;
217 226
@@ -252,6 +261,7 @@ namespace OpenSim.Region.Framework.Scenes
252 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 261 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
253 private Vector3 m_sitTargetPosition; 262 private Vector3 m_sitTargetPosition;
254 private string m_sitAnimation = "SIT"; 263 private string m_sitAnimation = "SIT";
264 private bool m_occupied; // KF if any av is sitting on this prim
255 private string m_text = String.Empty; 265 private string m_text = String.Empty;
256 private string m_touchName = String.Empty; 266 private string m_touchName = String.Empty;
257 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); 267 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5);
@@ -286,6 +296,7 @@ namespace OpenSim.Region.Framework.Scenes
286 protected Vector3 m_lastAcceleration; 296 protected Vector3 m_lastAcceleration;
287 protected Vector3 m_lastAngularVelocity; 297 protected Vector3 m_lastAngularVelocity;
288 protected int m_lastTerseSent; 298 protected int m_lastTerseSent;
299 protected float m_buoyancy = 0.0f;
289 300
290 /// <summary> 301 /// <summary>
291 /// Stores media texture data 302 /// Stores media texture data
@@ -341,7 +352,7 @@ namespace OpenSim.Region.Framework.Scenes
341 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 352 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
342 Quaternion rotationOffset, Vector3 offsetPosition) : this() 353 Quaternion rotationOffset, Vector3 offsetPosition) : this()
343 { 354 {
344 m_name = "Primitive"; 355 m_name = "Object";
345 356
346 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 357 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
347 LastOwnerID = CreatorID = OwnerID = ownerID; 358 LastOwnerID = CreatorID = OwnerID = ownerID;
@@ -381,7 +392,7 @@ namespace OpenSim.Region.Framework.Scenes
381 private uint _ownerMask = (uint)PermissionMask.All; 392 private uint _ownerMask = (uint)PermissionMask.All;
382 private uint _groupMask = (uint)PermissionMask.None; 393 private uint _groupMask = (uint)PermissionMask.None;
383 private uint _everyoneMask = (uint)PermissionMask.None; 394 private uint _everyoneMask = (uint)PermissionMask.None;
384 private uint _nextOwnerMask = (uint)PermissionMask.All; 395 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
385 private PrimFlags _flags = PrimFlags.None; 396 private PrimFlags _flags = PrimFlags.None;
386 private DateTime m_expires; 397 private DateTime m_expires;
387 private DateTime m_rezzed; 398 private DateTime m_rezzed;
@@ -475,12 +486,16 @@ namespace OpenSim.Region.Framework.Scenes
475 } 486 }
476 487
477 /// <value> 488 /// <value>
478 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 489 /// Get the inventory list
479 /// </value> 490 /// </value>
480 public TaskInventoryDictionary TaskInventory 491 public TaskInventoryDictionary TaskInventory
481 { 492 {
482 get { return m_inventory.Items; } 493 get {
483 set { m_inventory.Items = value; } 494 return m_inventory.Items;
495 }
496 set {
497 m_inventory.Items = value;
498 }
484 } 499 }
485 500
486 /// <summary> 501 /// <summary>
@@ -625,14 +640,12 @@ namespace OpenSim.Region.Framework.Scenes
625 set { m_LoopSoundSlavePrims = value; } 640 set { m_LoopSoundSlavePrims = value; }
626 } 641 }
627 642
628
629 public Byte[] TextureAnimation 643 public Byte[] TextureAnimation
630 { 644 {
631 get { return m_TextureAnimation; } 645 get { return m_TextureAnimation; }
632 set { m_TextureAnimation = value; } 646 set { m_TextureAnimation = value; }
633 } 647 }
634 648
635
636 public Byte[] ParticleSystem 649 public Byte[] ParticleSystem
637 { 650 {
638 get { return m_particleSystem; } 651 get { return m_particleSystem; }
@@ -669,9 +682,11 @@ namespace OpenSim.Region.Framework.Scenes
669 { 682 {
670 // If this is a linkset, we don't want the physics engine mucking up our group position here. 683 // If this is a linkset, we don't want the physics engine mucking up our group position here.
671 PhysicsActor actor = PhysActor; 684 PhysicsActor actor = PhysActor;
672 if (actor != null && ParentID == 0) 685 if (ParentID == 0)
673 { 686 {
674 m_groupPosition = actor.Position; 687 if (actor != null)
688 m_groupPosition = actor.Position;
689 return m_groupPosition;
675 } 690 }
676 691
677 if (ParentGroup.IsAttachment) 692 if (ParentGroup.IsAttachment)
@@ -681,12 +696,14 @@ namespace OpenSim.Region.Framework.Scenes
681 return sp.AbsolutePosition; 696 return sp.AbsolutePosition;
682 } 697 }
683 698
699 // use root prim's group position. Physics may have updated it
700 if (ParentGroup.RootPart != this)
701 m_groupPosition = ParentGroup.RootPart.GroupPosition;
684 return m_groupPosition; 702 return m_groupPosition;
685 } 703 }
686 set 704 set
687 { 705 {
688 m_groupPosition = value; 706 m_groupPosition = value;
689
690 PhysicsActor actor = PhysActor; 707 PhysicsActor actor = PhysActor;
691 if (actor != null) 708 if (actor != null)
692 { 709 {
@@ -712,16 +729,6 @@ namespace OpenSim.Region.Framework.Scenes
712 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 729 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
713 } 730 }
714 } 731 }
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 } 732 }
726 } 733 }
727 734
@@ -730,7 +737,7 @@ namespace OpenSim.Region.Framework.Scenes
730 get { return m_offsetPosition; } 737 get { return m_offsetPosition; }
731 set 738 set
732 { 739 {
733// StoreUndoState(); 740 Vector3 oldpos = m_offsetPosition;
734 m_offsetPosition = value; 741 m_offsetPosition = value;
735 742
736 if (ParentGroup != null && !ParentGroup.IsDeleted) 743 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -745,7 +752,22 @@ namespace OpenSim.Region.Framework.Scenes
745 if (ParentGroup.Scene != null) 752 if (ParentGroup.Scene != null)
746 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 753 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
747 } 754 }
755
756 if (!m_parentGroup.m_dupeInProgress)
757 {
758 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
759 foreach (ScenePresence av in avs)
760 {
761 if (av.ParentID == m_localId)
762 {
763 Vector3 offset = (m_offsetPosition - oldpos);
764 av.AbsolutePosition += offset;
765 av.SendAvatarDataToAllAgents();
766 }
767 }
768 }
748 } 769 }
770 TriggerScriptChangedEvent(Changed.POSITION);
749 } 771 }
750 } 772 }
751 773
@@ -894,7 +916,16 @@ namespace OpenSim.Region.Framework.Scenes
894 /// <summary></summary> 916 /// <summary></summary>
895 public Vector3 Acceleration 917 public Vector3 Acceleration
896 { 918 {
897 get { return m_acceleration; } 919 get
920 {
921 PhysicsActor actor = PhysActor;
922 if (actor != null)
923 {
924 m_acceleration = actor.Acceleration;
925 }
926 return m_acceleration;
927 }
928
898 set { m_acceleration = value; } 929 set { m_acceleration = value; }
899 } 930 }
900 931
@@ -1049,10 +1080,7 @@ namespace OpenSim.Region.Framework.Scenes
1049 { 1080 {
1050 get 1081 get
1051 { 1082 {
1052 if (ParentGroup.IsAttachment) 1083 return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset);
1053 return GroupPosition;
1054
1055 return m_offsetPosition + m_groupPosition;
1056 } 1084 }
1057 } 1085 }
1058 1086
@@ -1222,6 +1250,13 @@ namespace OpenSim.Region.Framework.Scenes
1222 _flags = value; 1250 _flags = value;
1223 } 1251 }
1224 } 1252 }
1253
1254 [XmlIgnore]
1255 public bool IsOccupied // KF If an av is sittingon this prim
1256 {
1257 get { return m_occupied; }
1258 set { m_occupied = value; }
1259 }
1225 1260
1226 /// <summary> 1261 /// <summary>
1227 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1262 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1281,6 +1316,19 @@ namespace OpenSim.Region.Framework.Scenes
1281 set { m_collisionSoundVolume = value; } 1316 set { m_collisionSoundVolume = value; }
1282 } 1317 }
1283 1318
1319 public float Buoyancy
1320 {
1321 get { return m_buoyancy; }
1322 set
1323 {
1324 m_buoyancy = value;
1325 if (PhysActor != null)
1326 {
1327 PhysActor.Buoyancy = value;
1328 }
1329 }
1330 }
1331
1284 #endregion Public Properties with only Get 1332 #endregion Public Properties with only Get
1285 1333
1286 private uint ApplyMask(uint val, bool set, uint mask) 1334 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1602,6 +1650,9 @@ namespace OpenSim.Region.Framework.Scenes
1602 1650
1603 // Move afterwards ResetIDs as it clears the localID 1651 // Move afterwards ResetIDs as it clears the localID
1604 dupe.LocalId = localID; 1652 dupe.LocalId = localID;
1653 if(dupe.PhysActor != null)
1654 dupe.PhysActor.LocalID = localID;
1655
1605 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1656 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1606 dupe.LastOwnerID = OwnerID; 1657 dupe.LastOwnerID = OwnerID;
1607 1658
@@ -1963,19 +2014,17 @@ namespace OpenSim.Region.Framework.Scenes
1963 public Vector3 GetWorldPosition() 2014 public Vector3 GetWorldPosition()
1964 { 2015 {
1965 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2016 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
1966
1967 Vector3 axPos = OffsetPosition; 2017 Vector3 axPos = OffsetPosition;
1968
1969 axPos *= parentRot; 2018 axPos *= parentRot;
1970 Vector3 translationOffsetPosition = axPos; 2019 Vector3 translationOffsetPosition = axPos;
1971 2020 if(_parentID == 0)
1972// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2021 {
1973 2022 return GroupPosition;
1974 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2023 }
1975 2024 else
1976// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2025 {
1977 2026 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
1978 return worldPos; 2027 }
1979 } 2028 }
1980 2029
1981 /// <summary> 2030 /// <summary>
@@ -2613,17 +2662,18 @@ namespace OpenSim.Region.Framework.Scenes
2613 //Trys to fetch sound id from prim's inventory. 2662 //Trys to fetch sound id from prim's inventory.
2614 //Prim's inventory doesn't support non script items yet 2663 //Prim's inventory doesn't support non script items yet
2615 2664
2616 lock (TaskInventory) 2665 TaskInventory.LockItemsForRead(true);
2666
2667 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2617 { 2668 {
2618 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2669 if (item.Value.Name == sound)
2619 { 2670 {
2620 if (item.Value.Name == sound) 2671 soundID = item.Value.ItemID;
2621 { 2672 break;
2622 soundID = item.Value.ItemID;
2623 break;
2624 }
2625 } 2673 }
2626 } 2674 }
2675
2676 TaskInventory.LockItemsForRead(false);
2627 } 2677 }
2628 2678
2629 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2679 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2706,7 +2756,7 @@ namespace OpenSim.Region.Framework.Scenes
2706 2756
2707 public void RotLookAt(Quaternion target, float strength, float damping) 2757 public void RotLookAt(Quaternion target, float strength, float damping)
2708 { 2758 {
2709 rotLookAt(target, strength, damping); 2759 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2710 } 2760 }
2711 2761
2712 public void rotLookAt(Quaternion target, float strength, float damping) 2762 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -2942,8 +2992,8 @@ namespace OpenSim.Region.Framework.Scenes
2942 { 2992 {
2943 const float ROTATION_TOLERANCE = 0.01f; 2993 const float ROTATION_TOLERANCE = 0.01f;
2944 const float VELOCITY_TOLERANCE = 0.001f; 2994 const float VELOCITY_TOLERANCE = 0.001f;
2945 const float POSITION_TOLERANCE = 0.05f; 2995 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2946 const int TIME_MS_TOLERANCE = 3000; 2996 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2947 2997
2948 switch (UpdateFlag) 2998 switch (UpdateFlag)
2949 { 2999 {
@@ -3007,17 +3057,16 @@ namespace OpenSim.Region.Framework.Scenes
3007 if (!UUID.TryParse(sound, out soundID)) 3057 if (!UUID.TryParse(sound, out soundID))
3008 { 3058 {
3009 // search sound file from inventory 3059 // search sound file from inventory
3010 lock (TaskInventory) 3060 TaskInventory.LockItemsForRead(true);
3061 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3011 { 3062 {
3012 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3063 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3013 { 3064 {
3014 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3065 soundID = item.Value.ItemID;
3015 { 3066 break;
3016 soundID = item.Value.ItemID;
3017 break;
3018 }
3019 } 3067 }
3020 } 3068 }
3069 TaskInventory.LockItemsForRead(false);
3021 } 3070 }
3022 3071
3023 if (soundID == UUID.Zero) 3072 if (soundID == UUID.Zero)
@@ -3486,10 +3535,10 @@ namespace OpenSim.Region.Framework.Scenes
3486 // TODO: May need to fix for group comparison 3535 // TODO: May need to fix for group comparison
3487 if (last.Compare(this)) 3536 if (last.Compare(this))
3488 { 3537 {
3489 // m_log.DebugFormat( 3538 // 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}", 3539 // "[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); 3540 // Name, LocalId, m_undo.Count);
3492 3541
3493 return; 3542 return;
3494 } 3543 }
3495 } 3544 }
@@ -3502,29 +3551,29 @@ namespace OpenSim.Region.Framework.Scenes
3502 if (ParentGroup.GetSceneMaxUndo() > 0) 3551 if (ParentGroup.GetSceneMaxUndo() > 0)
3503 { 3552 {
3504 UndoState nUndo = new UndoState(this, forGroup); 3553 UndoState nUndo = new UndoState(this, forGroup);
3505 3554
3506 m_undo.Push(nUndo); 3555 m_undo.Push(nUndo);
3507 3556
3508 if (m_redo.Count > 0) 3557 if (m_redo.Count > 0)
3509 m_redo.Clear(); 3558 m_redo.Clear();
3510 3559
3511 // m_log.DebugFormat( 3560 // m_log.DebugFormat(
3512 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3561 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3513 // Name, LocalId, forGroup, m_undo.Count); 3562 // Name, LocalId, forGroup, m_undo.Count);
3514 } 3563 }
3515 } 3564 }
3516 } 3565 }
3517 } 3566 }
3518// else 3567 // else
3519// { 3568 // {
3520// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3569 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3521// } 3570 // }
3522 } 3571 }
3523// else 3572 // else
3524// { 3573 // {
3525// m_log.DebugFormat( 3574 // m_log.DebugFormat(
3526// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3575 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3527// } 3576 // }
3528 } 3577 }
3529 3578
3530 /// <summary> 3579 /// <summary>
@@ -4255,6 +4304,9 @@ namespace OpenSim.Region.Framework.Scenes
4255 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4304 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4256 bool wasVD = VolumeDetectActive; 4305 bool wasVD = VolumeDetectActive;
4257 4306
4307// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4308// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4309
4258 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4310 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4259 return; 4311 return;
4260 4312
@@ -4284,6 +4336,11 @@ namespace OpenSim.Region.Framework.Scenes
4284 SetPhantom = false; 4336 SetPhantom = false;
4285 } 4337 }
4286 } 4338 }
4339 else if (wasVD)
4340 {
4341 // Correspondingly, if VD is turned off, also turn off phantom
4342 SetPhantom = false;
4343 }
4287 4344
4288 if (UsePhysics && IsJoint()) 4345 if (UsePhysics && IsJoint())
4289 { 4346 {
@@ -4778,5 +4835,17 @@ namespace OpenSim.Region.Framework.Scenes
4778 Color color = Color; 4835 Color color = Color;
4779 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4836 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4780 } 4837 }
4838
4839 public void ResetOwnerChangeFlag()
4840 {
4841 List<UUID> inv = Inventory.GetInventoryList();
4842
4843 foreach (UUID itemID in inv)
4844 {
4845 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4846 item.OwnerChanged = false;
4847 Inventory.UpdateInventoryItem(item, false, false);
4848 }
4849 }
4781 } 4850 }
4782} 4851}