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, 136 insertions, 65 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 51d3586..c45cfb8 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);
@@ -284,6 +294,7 @@ namespace OpenSim.Region.Framework.Scenes
284 protected Vector3 m_lastAcceleration; 294 protected Vector3 m_lastAcceleration;
285 protected Vector3 m_lastAngularVelocity; 295 protected Vector3 m_lastAngularVelocity;
286 protected int m_lastTerseSent; 296 protected int m_lastTerseSent;
297 protected float m_buoyancy = 0.0f;
287 298
288 /// <summary> 299 /// <summary>
289 /// Stores media texture data 300 /// Stores media texture data
@@ -339,7 +350,7 @@ namespace OpenSim.Region.Framework.Scenes
339 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 350 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
340 Quaternion rotationOffset, Vector3 offsetPosition) : this() 351 Quaternion rotationOffset, Vector3 offsetPosition) : this()
341 { 352 {
342 m_name = "Primitive"; 353 m_name = "Object";
343 354
344 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 355 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
345 LastOwnerID = CreatorID = OwnerID = ownerID; 356 LastOwnerID = CreatorID = OwnerID = ownerID;
@@ -379,7 +390,7 @@ namespace OpenSim.Region.Framework.Scenes
379 private uint _ownerMask = (uint)PermissionMask.All; 390 private uint _ownerMask = (uint)PermissionMask.All;
380 private uint _groupMask = (uint)PermissionMask.None; 391 private uint _groupMask = (uint)PermissionMask.None;
381 private uint _everyoneMask = (uint)PermissionMask.None; 392 private uint _everyoneMask = (uint)PermissionMask.None;
382 private uint _nextOwnerMask = (uint)PermissionMask.All; 393 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
383 private PrimFlags _flags = PrimFlags.None; 394 private PrimFlags _flags = PrimFlags.None;
384 private DateTime m_expires; 395 private DateTime m_expires;
385 private DateTime m_rezzed; 396 private DateTime m_rezzed;
@@ -473,12 +484,16 @@ namespace OpenSim.Region.Framework.Scenes
473 } 484 }
474 485
475 /// <value> 486 /// <value>
476 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 487 /// Get the inventory list
477 /// </value> 488 /// </value>
478 public TaskInventoryDictionary TaskInventory 489 public TaskInventoryDictionary TaskInventory
479 { 490 {
480 get { return m_inventory.Items; } 491 get {
481 set { m_inventory.Items = value; } 492 return m_inventory.Items;
493 }
494 set {
495 m_inventory.Items = value;
496 }
482 } 497 }
483 498
484 /// <summary> 499 /// <summary>
@@ -623,14 +638,12 @@ namespace OpenSim.Region.Framework.Scenes
623 set { m_LoopSoundSlavePrims = value; } 638 set { m_LoopSoundSlavePrims = value; }
624 } 639 }
625 640
626
627 public Byte[] TextureAnimation 641 public Byte[] TextureAnimation
628 { 642 {
629 get { return m_TextureAnimation; } 643 get { return m_TextureAnimation; }
630 set { m_TextureAnimation = value; } 644 set { m_TextureAnimation = value; }
631 } 645 }
632 646
633
634 public Byte[] ParticleSystem 647 public Byte[] ParticleSystem
635 { 648 {
636 get { return m_particleSystem; } 649 get { return m_particleSystem; }
@@ -667,9 +680,11 @@ namespace OpenSim.Region.Framework.Scenes
667 { 680 {
668 // If this is a linkset, we don't want the physics engine mucking up our group position here. 681 // If this is a linkset, we don't want the physics engine mucking up our group position here.
669 PhysicsActor actor = PhysActor; 682 PhysicsActor actor = PhysActor;
670 if (actor != null && ParentID == 0) 683 if (ParentID == 0)
671 { 684 {
672 m_groupPosition = actor.Position; 685 if (actor != null)
686 m_groupPosition = actor.Position;
687 return m_groupPosition;
673 } 688 }
674 689
675 if (ParentGroup.IsAttachment) 690 if (ParentGroup.IsAttachment)
@@ -679,12 +694,14 @@ namespace OpenSim.Region.Framework.Scenes
679 return sp.AbsolutePosition; 694 return sp.AbsolutePosition;
680 } 695 }
681 696
697 // use root prim's group position. Physics may have updated it
698 if (ParentGroup.RootPart != this)
699 m_groupPosition = ParentGroup.RootPart.GroupPosition;
682 return m_groupPosition; 700 return m_groupPosition;
683 } 701 }
684 set 702 set
685 { 703 {
686 m_groupPosition = value; 704 m_groupPosition = value;
687
688 PhysicsActor actor = PhysActor; 705 PhysicsActor actor = PhysActor;
689 if (actor != null) 706 if (actor != null)
690 { 707 {
@@ -710,16 +727,6 @@ namespace OpenSim.Region.Framework.Scenes
710 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 727 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
711 } 728 }
712 } 729 }
713
714 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
715 if (SitTargetAvatar != UUID.Zero)
716 {
717 ScenePresence avatar;
718 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
719 {
720 avatar.ParentPosition = GetWorldPosition();
721 }
722 }
723 } 730 }
724 } 731 }
725 732
@@ -728,7 +735,7 @@ namespace OpenSim.Region.Framework.Scenes
728 get { return m_offsetPosition; } 735 get { return m_offsetPosition; }
729 set 736 set
730 { 737 {
731// StoreUndoState(); 738 Vector3 oldpos = m_offsetPosition;
732 m_offsetPosition = value; 739 m_offsetPosition = value;
733 740
734 if (ParentGroup != null && !ParentGroup.IsDeleted) 741 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -743,7 +750,22 @@ namespace OpenSim.Region.Framework.Scenes
743 if (ParentGroup.Scene != null) 750 if (ParentGroup.Scene != null)
744 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 751 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
745 } 752 }
753
754 if (!m_parentGroup.m_dupeInProgress)
755 {
756 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
757 foreach (ScenePresence av in avs)
758 {
759 if (av.ParentID == m_localId)
760 {
761 Vector3 offset = (m_offsetPosition - oldpos);
762 av.AbsolutePosition += offset;
763 av.SendAvatarDataToAllAgents();
764 }
765 }
766 }
746 } 767 }
768 TriggerScriptChangedEvent(Changed.POSITION);
747 } 769 }
748 } 770 }
749 771
@@ -892,7 +914,16 @@ namespace OpenSim.Region.Framework.Scenes
892 /// <summary></summary> 914 /// <summary></summary>
893 public Vector3 Acceleration 915 public Vector3 Acceleration
894 { 916 {
895 get { return m_acceleration; } 917 get
918 {
919 PhysicsActor actor = PhysActor;
920 if (actor != null)
921 {
922 m_acceleration = actor.Acceleration;
923 }
924 return m_acceleration;
925 }
926
896 set { m_acceleration = value; } 927 set { m_acceleration = value; }
897 } 928 }
898 929
@@ -1043,10 +1074,7 @@ namespace OpenSim.Region.Framework.Scenes
1043 { 1074 {
1044 get 1075 get
1045 { 1076 {
1046 if (ParentGroup.IsAttachment) 1077 return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset);
1047 return GroupPosition;
1048
1049 return m_offsetPosition + m_groupPosition;
1050 } 1078 }
1051 } 1079 }
1052 1080
@@ -1216,6 +1244,13 @@ namespace OpenSim.Region.Framework.Scenes
1216 _flags = value; 1244 _flags = value;
1217 } 1245 }
1218 } 1246 }
1247
1248 [XmlIgnore]
1249 public bool IsOccupied // KF If an av is sittingon this prim
1250 {
1251 get { return m_occupied; }
1252 set { m_occupied = value; }
1253 }
1219 1254
1220 /// <summary> 1255 /// <summary>
1221 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1256 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1275,6 +1310,19 @@ namespace OpenSim.Region.Framework.Scenes
1275 set { m_collisionSoundVolume = value; } 1310 set { m_collisionSoundVolume = value; }
1276 } 1311 }
1277 1312
1313 public float Buoyancy
1314 {
1315 get { return m_buoyancy; }
1316 set
1317 {
1318 m_buoyancy = value;
1319 if (PhysActor != null)
1320 {
1321 PhysActor.Buoyancy = value;
1322 }
1323 }
1324 }
1325
1278 #endregion Public Properties with only Get 1326 #endregion Public Properties with only Get
1279 1327
1280 private uint ApplyMask(uint val, bool set, uint mask) 1328 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1599,6 +1647,9 @@ namespace OpenSim.Region.Framework.Scenes
1599 1647
1600 // Move afterwards ResetIDs as it clears the localID 1648 // Move afterwards ResetIDs as it clears the localID
1601 dupe.LocalId = localID; 1649 dupe.LocalId = localID;
1650 if(dupe.PhysActor != null)
1651 dupe.PhysActor.LocalID = localID;
1652
1602 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1653 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1603 dupe.LastOwnerID = OwnerID; 1654 dupe.LastOwnerID = OwnerID;
1604 1655
@@ -2604,17 +2655,18 @@ namespace OpenSim.Region.Framework.Scenes
2604 //Trys to fetch sound id from prim's inventory. 2655 //Trys to fetch sound id from prim's inventory.
2605 //Prim's inventory doesn't support non script items yet 2656 //Prim's inventory doesn't support non script items yet
2606 2657
2607 lock (TaskInventory) 2658 TaskInventory.LockItemsForRead(true);
2659
2660 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2608 { 2661 {
2609 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2662 if (item.Value.Name == sound)
2610 { 2663 {
2611 if (item.Value.Name == sound) 2664 soundID = item.Value.ItemID;
2612 { 2665 break;
2613 soundID = item.Value.ItemID;
2614 break;
2615 }
2616 } 2666 }
2617 } 2667 }
2668
2669 TaskInventory.LockItemsForRead(false);
2618 } 2670 }
2619 2671
2620 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2672 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2697,7 +2749,7 @@ namespace OpenSim.Region.Framework.Scenes
2697 2749
2698 public void RotLookAt(Quaternion target, float strength, float damping) 2750 public void RotLookAt(Quaternion target, float strength, float damping)
2699 { 2751 {
2700 rotLookAt(target, strength, damping); 2752 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2701 } 2753 }
2702 2754
2703 public void rotLookAt(Quaternion target, float strength, float damping) 2755 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -2923,8 +2975,8 @@ namespace OpenSim.Region.Framework.Scenes
2923 { 2975 {
2924 const float ROTATION_TOLERANCE = 0.01f; 2976 const float ROTATION_TOLERANCE = 0.01f;
2925 const float VELOCITY_TOLERANCE = 0.001f; 2977 const float VELOCITY_TOLERANCE = 0.001f;
2926 const float POSITION_TOLERANCE = 0.05f; 2978 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2927 const int TIME_MS_TOLERANCE = 3000; 2979 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2928 2980
2929 switch (UpdateFlag) 2981 switch (UpdateFlag)
2930 { 2982 {
@@ -2986,17 +3038,16 @@ namespace OpenSim.Region.Framework.Scenes
2986 if (!UUID.TryParse(sound, out soundID)) 3038 if (!UUID.TryParse(sound, out soundID))
2987 { 3039 {
2988 // search sound file from inventory 3040 // search sound file from inventory
2989 lock (TaskInventory) 3041 TaskInventory.LockItemsForRead(true);
3042 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2990 { 3043 {
2991 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3044 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2992 { 3045 {
2993 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3046 soundID = item.Value.ItemID;
2994 { 3047 break;
2995 soundID = item.Value.ItemID;
2996 break;
2997 }
2998 } 3048 }
2999 } 3049 }
3050 TaskInventory.LockItemsForRead(false);
3000 } 3051 }
3001 3052
3002 if (soundID == UUID.Zero) 3053 if (soundID == UUID.Zero)
@@ -3470,10 +3521,10 @@ namespace OpenSim.Region.Framework.Scenes
3470 // TODO: May need to fix for group comparison 3521 // TODO: May need to fix for group comparison
3471 if (last.Compare(this)) 3522 if (last.Compare(this))
3472 { 3523 {
3473 // m_log.DebugFormat( 3524 // m_log.DebugFormat(
3474 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3525 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3475 // Name, LocalId, m_undo.Count); 3526 // Name, LocalId, m_undo.Count);
3476 3527
3477 return; 3528 return;
3478 } 3529 }
3479 } 3530 }
@@ -3486,29 +3537,29 @@ namespace OpenSim.Region.Framework.Scenes
3486 if (ParentGroup.GetSceneMaxUndo() > 0) 3537 if (ParentGroup.GetSceneMaxUndo() > 0)
3487 { 3538 {
3488 UndoState nUndo = new UndoState(this, forGroup); 3539 UndoState nUndo = new UndoState(this, forGroup);
3489 3540
3490 m_undo.Push(nUndo); 3541 m_undo.Push(nUndo);
3491 3542
3492 if (m_redo.Count > 0) 3543 if (m_redo.Count > 0)
3493 m_redo.Clear(); 3544 m_redo.Clear();
3494 3545
3495 // m_log.DebugFormat( 3546 // m_log.DebugFormat(
3496 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3547 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3497 // Name, LocalId, forGroup, m_undo.Count); 3548 // Name, LocalId, forGroup, m_undo.Count);
3498 } 3549 }
3499 } 3550 }
3500 } 3551 }
3501 } 3552 }
3502// else 3553 // else
3503// { 3554 // {
3504// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3555 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3505// } 3556 // }
3506 } 3557 }
3507// else 3558 // else
3508// { 3559 // {
3509// m_log.DebugFormat( 3560 // m_log.DebugFormat(
3510// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3561 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3511// } 3562 // }
3512 } 3563 }
3513 3564
3514 /// <summary> 3565 /// <summary>
@@ -4239,6 +4290,9 @@ namespace OpenSim.Region.Framework.Scenes
4239 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4290 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4240 bool wasVD = VolumeDetectActive; 4291 bool wasVD = VolumeDetectActive;
4241 4292
4293// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4294// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4295
4242 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4296 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4243 return; 4297 return;
4244 4298
@@ -4268,6 +4322,11 @@ namespace OpenSim.Region.Framework.Scenes
4268 SetPhantom = false; 4322 SetPhantom = false;
4269 } 4323 }
4270 } 4324 }
4325 else if (wasVD)
4326 {
4327 // Correspondingly, if VD is turned off, also turn off phantom
4328 SetPhantom = false;
4329 }
4271 4330
4272 if (UsePhysics && IsJoint()) 4331 if (UsePhysics && IsJoint())
4273 { 4332 {
@@ -4762,5 +4821,17 @@ namespace OpenSim.Region.Framework.Scenes
4762 Color color = Color; 4821 Color color = Color;
4763 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4822 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4764 } 4823 }
4824
4825 public void ResetOwnerChangeFlag()
4826 {
4827 List<UUID> inv = Inventory.GetInventoryList();
4828
4829 foreach (UUID itemID in inv)
4830 {
4831 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4832 item.OwnerChanged = false;
4833 Inventory.UpdateInventoryItem(item, false, false);
4834 }
4835 }
4765 } 4836 }
4766} 4837}