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.cs199
1 files changed, 135 insertions, 64 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 65905a0..4a08ce3 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
@@ -251,6 +260,7 @@ namespace OpenSim.Region.Framework.Scenes
251 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 260 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
252 private Vector3 m_sitTargetPosition; 261 private Vector3 m_sitTargetPosition;
253 private string m_sitAnimation = "SIT"; 262 private string m_sitAnimation = "SIT";
263 private bool m_occupied; // KF if any av is sitting on this prim
254 private string m_text = String.Empty; 264 private string m_text = String.Empty;
255 private string m_touchName = String.Empty; 265 private string m_touchName = String.Empty;
256 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); 266 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5);
@@ -283,6 +293,7 @@ namespace OpenSim.Region.Framework.Scenes
283 protected Vector3 m_lastAcceleration; 293 protected Vector3 m_lastAcceleration;
284 protected Vector3 m_lastAngularVelocity; 294 protected Vector3 m_lastAngularVelocity;
285 protected int m_lastTerseSent; 295 protected int m_lastTerseSent;
296 protected float m_buoyancy = 0.0f;
286 297
287 /// <summary> 298 /// <summary>
288 /// Stores media texture data 299 /// 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>
@@ -624,14 +639,12 @@ namespace OpenSim.Region.Framework.Scenes
624 set { m_LoopSoundSlavePrims = value; } 639 set { m_LoopSoundSlavePrims = value; }
625 } 640 }
626 641
627
628 public Byte[] TextureAnimation 642 public Byte[] TextureAnimation
629 { 643 {
630 get { return m_TextureAnimation; } 644 get { return m_TextureAnimation; }
631 set { m_TextureAnimation = value; } 645 set { m_TextureAnimation = value; }
632 } 646 }
633 647
634
635 public Byte[] ParticleSystem 648 public Byte[] ParticleSystem
636 { 649 {
637 get { return m_particleSystem; } 650 get { return m_particleSystem; }
@@ -668,9 +681,11 @@ namespace OpenSim.Region.Framework.Scenes
668 { 681 {
669 // If this is a linkset, we don't want the physics engine mucking up our group position here. 682 // If this is a linkset, we don't want the physics engine mucking up our group position here.
670 PhysicsActor actor = PhysActor; 683 PhysicsActor actor = PhysActor;
671 if (actor != null && ParentID == 0) 684 if (ParentID == 0)
672 { 685 {
673 m_groupPosition = actor.Position; 686 if (actor != null)
687 m_groupPosition = actor.Position;
688 return m_groupPosition;
674 } 689 }
675 690
676 if (ParentGroup.IsAttachment) 691 if (ParentGroup.IsAttachment)
@@ -680,12 +695,14 @@ namespace OpenSim.Region.Framework.Scenes
680 return sp.AbsolutePosition; 695 return sp.AbsolutePosition;
681 } 696 }
682 697
698 // use root prim's group position. Physics may have updated it
699 if (ParentGroup.RootPart != this)
700 m_groupPosition = ParentGroup.RootPart.GroupPosition;
683 return m_groupPosition; 701 return m_groupPosition;
684 } 702 }
685 set 703 set
686 { 704 {
687 m_groupPosition = value; 705 m_groupPosition = value;
688
689 PhysicsActor actor = PhysActor; 706 PhysicsActor actor = PhysActor;
690 if (actor != null) 707 if (actor != null)
691 { 708 {
@@ -711,16 +728,6 @@ namespace OpenSim.Region.Framework.Scenes
711 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 728 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
712 } 729 }
713 } 730 }
714
715 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
716 if (SitTargetAvatar != UUID.Zero)
717 {
718 ScenePresence avatar;
719 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
720 {
721 avatar.ParentPosition = GetWorldPosition();
722 }
723 }
724 } 731 }
725 } 732 }
726 733
@@ -729,7 +736,7 @@ namespace OpenSim.Region.Framework.Scenes
729 get { return m_offsetPosition; } 736 get { return m_offsetPosition; }
730 set 737 set
731 { 738 {
732// StoreUndoState(); 739 Vector3 oldpos = m_offsetPosition;
733 m_offsetPosition = value; 740 m_offsetPosition = value;
734 741
735 if (ParentGroup != null && !ParentGroup.IsDeleted) 742 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -744,7 +751,22 @@ namespace OpenSim.Region.Framework.Scenes
744 if (ParentGroup.Scene != null) 751 if (ParentGroup.Scene != null)
745 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 752 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
746 } 753 }
754
755 if (!m_parentGroup.m_dupeInProgress)
756 {
757 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
758 foreach (ScenePresence av in avs)
759 {
760 if (av.ParentID == m_localId)
761 {
762 Vector3 offset = (m_offsetPosition - oldpos);
763 av.AbsolutePosition += offset;
764 av.SendAvatarDataToAllAgents();
765 }
766 }
767 }
747 } 768 }
769 TriggerScriptChangedEvent(Changed.POSITION);
748 } 770 }
749 } 771 }
750 772
@@ -893,7 +915,16 @@ namespace OpenSim.Region.Framework.Scenes
893 /// <summary></summary> 915 /// <summary></summary>
894 public Vector3 Acceleration 916 public Vector3 Acceleration
895 { 917 {
896 get { return m_acceleration; } 918 get
919 {
920 PhysicsActor actor = PhysActor;
921 if (actor != null)
922 {
923 m_acceleration = actor.Acceleration;
924 }
925 return m_acceleration;
926 }
927
897 set { m_acceleration = value; } 928 set { m_acceleration = value; }
898 } 929 }
899 930
@@ -1030,10 +1061,7 @@ namespace OpenSim.Region.Framework.Scenes
1030 { 1061 {
1031 get 1062 get
1032 { 1063 {
1033 if (ParentGroup.IsAttachment) 1064 return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset);
1034 return GroupPosition;
1035
1036 return m_offsetPosition + m_groupPosition;
1037 } 1065 }
1038 } 1066 }
1039 1067
@@ -1203,6 +1231,13 @@ namespace OpenSim.Region.Framework.Scenes
1203 _flags = value; 1231 _flags = value;
1204 } 1232 }
1205 } 1233 }
1234
1235 [XmlIgnore]
1236 public bool IsOccupied // KF If an av is sittingon this prim
1237 {
1238 get { return m_occupied; }
1239 set { m_occupied = value; }
1240 }
1206 1241
1207 /// <summary> 1242 /// <summary>
1208 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1243 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1262,6 +1297,19 @@ namespace OpenSim.Region.Framework.Scenes
1262 set { m_collisionSoundVolume = value; } 1297 set { m_collisionSoundVolume = value; }
1263 } 1298 }
1264 1299
1300 public float Buoyancy
1301 {
1302 get { return m_buoyancy; }
1303 set
1304 {
1305 m_buoyancy = value;
1306 if (PhysActor != null)
1307 {
1308 PhysActor.Buoyancy = value;
1309 }
1310 }
1311 }
1312
1265 #endregion Public Properties with only Get 1313 #endregion Public Properties with only Get
1266 1314
1267 private uint ApplyMask(uint val, bool set, uint mask) 1315 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1582,6 +1630,9 @@ namespace OpenSim.Region.Framework.Scenes
1582 1630
1583 // Move afterwards ResetIDs as it clears the localID 1631 // Move afterwards ResetIDs as it clears the localID
1584 dupe.LocalId = localID; 1632 dupe.LocalId = localID;
1633 if(dupe.PhysActor != null)
1634 dupe.PhysActor.LocalID = localID;
1635
1585 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1636 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1586 dupe.LastOwnerID = OwnerID; 1637 dupe.LastOwnerID = OwnerID;
1587 1638
@@ -2587,17 +2638,18 @@ namespace OpenSim.Region.Framework.Scenes
2587 //Trys to fetch sound id from prim's inventory. 2638 //Trys to fetch sound id from prim's inventory.
2588 //Prim's inventory doesn't support non script items yet 2639 //Prim's inventory doesn't support non script items yet
2589 2640
2590 lock (TaskInventory) 2641 TaskInventory.LockItemsForRead(true);
2642
2643 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2591 { 2644 {
2592 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2645 if (item.Value.Name == sound)
2593 { 2646 {
2594 if (item.Value.Name == sound) 2647 soundID = item.Value.ItemID;
2595 { 2648 break;
2596 soundID = item.Value.ItemID;
2597 break;
2598 }
2599 } 2649 }
2600 } 2650 }
2651
2652 TaskInventory.LockItemsForRead(false);
2601 } 2653 }
2602 2654
2603 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2655 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2917,8 +2969,8 @@ namespace OpenSim.Region.Framework.Scenes
2917 { 2969 {
2918 const float ROTATION_TOLERANCE = 0.01f; 2970 const float ROTATION_TOLERANCE = 0.01f;
2919 const float VELOCITY_TOLERANCE = 0.001f; 2971 const float VELOCITY_TOLERANCE = 0.001f;
2920 const float POSITION_TOLERANCE = 0.05f; 2972 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2921 const int TIME_MS_TOLERANCE = 3000; 2973 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2922 2974
2923 switch (UpdateFlag) 2975 switch (UpdateFlag)
2924 { 2976 {
@@ -2980,17 +3032,16 @@ namespace OpenSim.Region.Framework.Scenes
2980 if (!UUID.TryParse(sound, out soundID)) 3032 if (!UUID.TryParse(sound, out soundID))
2981 { 3033 {
2982 // search sound file from inventory 3034 // search sound file from inventory
2983 lock (TaskInventory) 3035 TaskInventory.LockItemsForRead(true);
3036 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2984 { 3037 {
2985 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3038 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2986 { 3039 {
2987 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3040 soundID = item.Value.ItemID;
2988 { 3041 break;
2989 soundID = item.Value.ItemID;
2990 break;
2991 }
2992 } 3042 }
2993 } 3043 }
3044 TaskInventory.LockItemsForRead(false);
2994 } 3045 }
2995 3046
2996 if (soundID == UUID.Zero) 3047 if (soundID == UUID.Zero)
@@ -3457,10 +3508,10 @@ namespace OpenSim.Region.Framework.Scenes
3457 // TODO: May need to fix for group comparison 3508 // TODO: May need to fix for group comparison
3458 if (last.Compare(this)) 3509 if (last.Compare(this))
3459 { 3510 {
3460 // m_log.DebugFormat( 3511 // m_log.DebugFormat(
3461 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3512 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3462 // Name, LocalId, m_undo.Count); 3513 // Name, LocalId, m_undo.Count);
3463 3514
3464 return; 3515 return;
3465 } 3516 }
3466 } 3517 }
@@ -3473,29 +3524,29 @@ namespace OpenSim.Region.Framework.Scenes
3473 if (ParentGroup.GetSceneMaxUndo() > 0) 3524 if (ParentGroup.GetSceneMaxUndo() > 0)
3474 { 3525 {
3475 UndoState nUndo = new UndoState(this, forGroup); 3526 UndoState nUndo = new UndoState(this, forGroup);
3476 3527
3477 m_undo.Push(nUndo); 3528 m_undo.Push(nUndo);
3478 3529
3479 if (m_redo.Count > 0) 3530 if (m_redo.Count > 0)
3480 m_redo.Clear(); 3531 m_redo.Clear();
3481 3532
3482 // m_log.DebugFormat( 3533 // m_log.DebugFormat(
3483 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3534 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3484 // Name, LocalId, forGroup, m_undo.Count); 3535 // Name, LocalId, forGroup, m_undo.Count);
3485 } 3536 }
3486 } 3537 }
3487 } 3538 }
3488 } 3539 }
3489// else 3540 // else
3490// { 3541 // {
3491// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3542 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3492// } 3543 // }
3493 } 3544 }
3494// else 3545 // else
3495// { 3546 // {
3496// m_log.DebugFormat( 3547 // m_log.DebugFormat(
3497// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3548 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3498// } 3549 // }
3499 } 3550 }
3500 3551
3501 /// <summary> 3552 /// <summary>
@@ -4226,6 +4277,9 @@ namespace OpenSim.Region.Framework.Scenes
4226 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4277 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4227 bool wasVD = VolumeDetectActive; 4278 bool wasVD = VolumeDetectActive;
4228 4279
4280// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4281// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4282
4229 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4283 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4230 return; 4284 return;
4231 4285
@@ -4255,6 +4309,11 @@ namespace OpenSim.Region.Framework.Scenes
4255 SetPhantom = false; 4309 SetPhantom = false;
4256 } 4310 }
4257 } 4311 }
4312 else if (wasVD)
4313 {
4314 // Correspondingly, if VD is turned off, also turn off phantom
4315 SetPhantom = false;
4316 }
4258 4317
4259 if (UsePhysics && IsJoint()) 4318 if (UsePhysics && IsJoint())
4260 { 4319 {
@@ -4753,5 +4812,17 @@ namespace OpenSim.Region.Framework.Scenes
4753 Color color = Color; 4812 Color color = Color;
4754 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4813 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4755 } 4814 }
4815
4816 public void ResetOwnerChangeFlag()
4817 {
4818 List<UUID> inv = Inventory.GetInventoryList();
4819
4820 foreach (UUID itemID in inv)
4821 {
4822 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4823 item.OwnerChanged = false;
4824 Inventory.UpdateInventoryItem(item, false, false);
4825 }
4826 }
4756 } 4827 }
4757} 4828}