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 0e899ca..a6c234e 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
@@ -338,7 +349,7 @@ namespace OpenSim.Region.Framework.Scenes
338 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 349 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
339 Quaternion rotationOffset, Vector3 offsetPosition) : this() 350 Quaternion rotationOffset, Vector3 offsetPosition) : this()
340 { 351 {
341 m_name = "Primitive"; 352 m_name = "Object";
342 353
343 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 354 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
344 LastOwnerID = CreatorID = OwnerID = ownerID; 355 LastOwnerID = CreatorID = OwnerID = ownerID;
@@ -378,7 +389,7 @@ namespace OpenSim.Region.Framework.Scenes
378 private uint _ownerMask = (uint)PermissionMask.All; 389 private uint _ownerMask = (uint)PermissionMask.All;
379 private uint _groupMask = (uint)PermissionMask.None; 390 private uint _groupMask = (uint)PermissionMask.None;
380 private uint _everyoneMask = (uint)PermissionMask.None; 391 private uint _everyoneMask = (uint)PermissionMask.None;
381 private uint _nextOwnerMask = (uint)PermissionMask.All; 392 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
382 private PrimFlags _flags = PrimFlags.None; 393 private PrimFlags _flags = PrimFlags.None;
383 private DateTime m_expires; 394 private DateTime m_expires;
384 private DateTime m_rezzed; 395 private DateTime m_rezzed;
@@ -472,12 +483,16 @@ namespace OpenSim.Region.Framework.Scenes
472 } 483 }
473 484
474 /// <value> 485 /// <value>
475 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 486 /// Get the inventory list
476 /// </value> 487 /// </value>
477 public TaskInventoryDictionary TaskInventory 488 public TaskInventoryDictionary TaskInventory
478 { 489 {
479 get { return m_inventory.Items; } 490 get {
480 set { m_inventory.Items = value; } 491 return m_inventory.Items;
492 }
493 set {
494 m_inventory.Items = value;
495 }
481 } 496 }
482 497
483 /// <summary> 498 /// <summary>
@@ -621,14 +636,12 @@ namespace OpenSim.Region.Framework.Scenes
621 set { m_LoopSoundSlavePrims = value; } 636 set { m_LoopSoundSlavePrims = value; }
622 } 637 }
623 638
624
625 public Byte[] TextureAnimation 639 public Byte[] TextureAnimation
626 { 640 {
627 get { return m_TextureAnimation; } 641 get { return m_TextureAnimation; }
628 set { m_TextureAnimation = value; } 642 set { m_TextureAnimation = value; }
629 } 643 }
630 644
631
632 public Byte[] ParticleSystem 645 public Byte[] ParticleSystem
633 { 646 {
634 get { return m_particleSystem; } 647 get { return m_particleSystem; }
@@ -665,9 +678,11 @@ namespace OpenSim.Region.Framework.Scenes
665 { 678 {
666 // If this is a linkset, we don't want the physics engine mucking up our group position here. 679 // If this is a linkset, we don't want the physics engine mucking up our group position here.
667 PhysicsActor actor = PhysActor; 680 PhysicsActor actor = PhysActor;
668 if (actor != null && ParentID == 0) 681 if (ParentID == 0)
669 { 682 {
670 m_groupPosition = actor.Position; 683 if (actor != null)
684 m_groupPosition = actor.Position;
685 return m_groupPosition;
671 } 686 }
672 687
673 if (ParentGroup.IsAttachment) 688 if (ParentGroup.IsAttachment)
@@ -677,12 +692,14 @@ namespace OpenSim.Region.Framework.Scenes
677 return sp.AbsolutePosition; 692 return sp.AbsolutePosition;
678 } 693 }
679 694
695 // use root prim's group position. Physics may have updated it
696 if (ParentGroup.RootPart != this)
697 m_groupPosition = ParentGroup.RootPart.GroupPosition;
680 return m_groupPosition; 698 return m_groupPosition;
681 } 699 }
682 set 700 set
683 { 701 {
684 m_groupPosition = value; 702 m_groupPosition = value;
685
686 PhysicsActor actor = PhysActor; 703 PhysicsActor actor = PhysActor;
687 if (actor != null) 704 if (actor != null)
688 { 705 {
@@ -708,16 +725,6 @@ namespace OpenSim.Region.Framework.Scenes
708 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 725 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
709 } 726 }
710 } 727 }
711
712 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
713 if (SitTargetAvatar != UUID.Zero)
714 {
715 ScenePresence avatar;
716 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
717 {
718 avatar.ParentPosition = GetWorldPosition();
719 }
720 }
721 } 728 }
722 } 729 }
723 730
@@ -726,7 +733,7 @@ namespace OpenSim.Region.Framework.Scenes
726 get { return m_offsetPosition; } 733 get { return m_offsetPosition; }
727 set 734 set
728 { 735 {
729// StoreUndoState(); 736 Vector3 oldpos = m_offsetPosition;
730 m_offsetPosition = value; 737 m_offsetPosition = value;
731 738
732 if (ParentGroup != null && !ParentGroup.IsDeleted) 739 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -741,7 +748,22 @@ namespace OpenSim.Region.Framework.Scenes
741 if (ParentGroup.Scene != null) 748 if (ParentGroup.Scene != null)
742 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 749 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
743 } 750 }
751
752 if (!m_parentGroup.m_dupeInProgress)
753 {
754 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
755 foreach (ScenePresence av in avs)
756 {
757 if (av.ParentID == m_localId)
758 {
759 Vector3 offset = (m_offsetPosition - oldpos);
760 av.AbsolutePosition += offset;
761 av.SendAvatarDataToAllAgents();
762 }
763 }
764 }
744 } 765 }
766 TriggerScriptChangedEvent(Changed.POSITION);
745 } 767 }
746 } 768 }
747 769
@@ -890,7 +912,16 @@ namespace OpenSim.Region.Framework.Scenes
890 /// <summary></summary> 912 /// <summary></summary>
891 public Vector3 Acceleration 913 public Vector3 Acceleration
892 { 914 {
893 get { return m_acceleration; } 915 get
916 {
917 PhysicsActor actor = PhysActor;
918 if (actor != null)
919 {
920 m_acceleration = actor.Acceleration;
921 }
922 return m_acceleration;
923 }
924
894 set { m_acceleration = value; } 925 set { m_acceleration = value; }
895 } 926 }
896 927
@@ -1027,10 +1058,7 @@ namespace OpenSim.Region.Framework.Scenes
1027 { 1058 {
1028 get 1059 get
1029 { 1060 {
1030 if (ParentGroup.IsAttachment) 1061 return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset);
1031 return GroupPosition;
1032
1033 return m_offsetPosition + m_groupPosition;
1034 } 1062 }
1035 } 1063 }
1036 1064
@@ -1200,6 +1228,13 @@ namespace OpenSim.Region.Framework.Scenes
1200 _flags = value; 1228 _flags = value;
1201 } 1229 }
1202 } 1230 }
1231
1232 [XmlIgnore]
1233 public bool IsOccupied // KF If an av is sittingon this prim
1234 {
1235 get { return m_occupied; }
1236 set { m_occupied = value; }
1237 }
1203 1238
1204 /// <summary> 1239 /// <summary>
1205 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1240 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1259,6 +1294,19 @@ namespace OpenSim.Region.Framework.Scenes
1259 set { m_collisionSoundVolume = value; } 1294 set { m_collisionSoundVolume = value; }
1260 } 1295 }
1261 1296
1297 public float Buoyancy
1298 {
1299 get { return m_buoyancy; }
1300 set
1301 {
1302 m_buoyancy = value;
1303 if (PhysActor != null)
1304 {
1305 PhysActor.Buoyancy = value;
1306 }
1307 }
1308 }
1309
1262 #endregion Public Properties with only Get 1310 #endregion Public Properties with only Get
1263 1311
1264 private uint ApplyMask(uint val, bool set, uint mask) 1312 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1583,6 +1631,9 @@ namespace OpenSim.Region.Framework.Scenes
1583 1631
1584 // Move afterwards ResetIDs as it clears the localID 1632 // Move afterwards ResetIDs as it clears the localID
1585 dupe.LocalId = localID; 1633 dupe.LocalId = localID;
1634 if(dupe.PhysActor != null)
1635 dupe.PhysActor.LocalID = localID;
1636
1586 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1637 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1587 dupe.LastOwnerID = OwnerID; 1638 dupe.LastOwnerID = OwnerID;
1588 1639
@@ -2588,17 +2639,18 @@ namespace OpenSim.Region.Framework.Scenes
2588 //Trys to fetch sound id from prim's inventory. 2639 //Trys to fetch sound id from prim's inventory.
2589 //Prim's inventory doesn't support non script items yet 2640 //Prim's inventory doesn't support non script items yet
2590 2641
2591 lock (TaskInventory) 2642 TaskInventory.LockItemsForRead(true);
2643
2644 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2592 { 2645 {
2593 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2646 if (item.Value.Name == sound)
2594 { 2647 {
2595 if (item.Value.Name == sound) 2648 soundID = item.Value.ItemID;
2596 { 2649 break;
2597 soundID = item.Value.ItemID;
2598 break;
2599 }
2600 } 2650 }
2601 } 2651 }
2652
2653 TaskInventory.LockItemsForRead(false);
2602 } 2654 }
2603 2655
2604 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2656 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2918,8 +2970,8 @@ namespace OpenSim.Region.Framework.Scenes
2918 { 2970 {
2919 const float ROTATION_TOLERANCE = 0.01f; 2971 const float ROTATION_TOLERANCE = 0.01f;
2920 const float VELOCITY_TOLERANCE = 0.001f; 2972 const float VELOCITY_TOLERANCE = 0.001f;
2921 const float POSITION_TOLERANCE = 0.05f; 2973 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2922 const int TIME_MS_TOLERANCE = 3000; 2974 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2923 2975
2924 switch (UpdateFlag) 2976 switch (UpdateFlag)
2925 { 2977 {
@@ -2981,17 +3033,16 @@ namespace OpenSim.Region.Framework.Scenes
2981 if (!UUID.TryParse(sound, out soundID)) 3033 if (!UUID.TryParse(sound, out soundID))
2982 { 3034 {
2983 // search sound file from inventory 3035 // search sound file from inventory
2984 lock (TaskInventory) 3036 TaskInventory.LockItemsForRead(true);
3037 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2985 { 3038 {
2986 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3039 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2987 { 3040 {
2988 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3041 soundID = item.Value.ItemID;
2989 { 3042 break;
2990 soundID = item.Value.ItemID;
2991 break;
2992 }
2993 } 3043 }
2994 } 3044 }
3045 TaskInventory.LockItemsForRead(false);
2995 } 3046 }
2996 3047
2997 if (soundID == UUID.Zero) 3048 if (soundID == UUID.Zero)
@@ -3458,10 +3509,10 @@ namespace OpenSim.Region.Framework.Scenes
3458 // TODO: May need to fix for group comparison 3509 // TODO: May need to fix for group comparison
3459 if (last.Compare(this)) 3510 if (last.Compare(this))
3460 { 3511 {
3461 // m_log.DebugFormat( 3512 // m_log.DebugFormat(
3462 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3513 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3463 // Name, LocalId, m_undo.Count); 3514 // Name, LocalId, m_undo.Count);
3464 3515
3465 return; 3516 return;
3466 } 3517 }
3467 } 3518 }
@@ -3474,29 +3525,29 @@ namespace OpenSim.Region.Framework.Scenes
3474 if (ParentGroup.GetSceneMaxUndo() > 0) 3525 if (ParentGroup.GetSceneMaxUndo() > 0)
3475 { 3526 {
3476 UndoState nUndo = new UndoState(this, forGroup); 3527 UndoState nUndo = new UndoState(this, forGroup);
3477 3528
3478 m_undo.Push(nUndo); 3529 m_undo.Push(nUndo);
3479 3530
3480 if (m_redo.Count > 0) 3531 if (m_redo.Count > 0)
3481 m_redo.Clear(); 3532 m_redo.Clear();
3482 3533
3483 // m_log.DebugFormat( 3534 // m_log.DebugFormat(
3484 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3535 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3485 // Name, LocalId, forGroup, m_undo.Count); 3536 // Name, LocalId, forGroup, m_undo.Count);
3486 } 3537 }
3487 } 3538 }
3488 } 3539 }
3489 } 3540 }
3490// else 3541 // else
3491// { 3542 // {
3492// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3543 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3493// } 3544 // }
3494 } 3545 }
3495// else 3546 // else
3496// { 3547 // {
3497// m_log.DebugFormat( 3548 // m_log.DebugFormat(
3498// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3549 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3499// } 3550 // }
3500 } 3551 }
3501 3552
3502 /// <summary> 3553 /// <summary>
@@ -4227,6 +4278,9 @@ namespace OpenSim.Region.Framework.Scenes
4227 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4278 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4228 bool wasVD = VolumeDetectActive; 4279 bool wasVD = VolumeDetectActive;
4229 4280
4281// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4282// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4283
4230 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4284 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4231 return; 4285 return;
4232 4286
@@ -4256,6 +4310,11 @@ namespace OpenSim.Region.Framework.Scenes
4256 SetPhantom = false; 4310 SetPhantom = false;
4257 } 4311 }
4258 } 4312 }
4313 else if (wasVD)
4314 {
4315 // Correspondingly, if VD is turned off, also turn off phantom
4316 SetPhantom = false;
4317 }
4259 4318
4260 if (UsePhysics && IsJoint()) 4319 if (UsePhysics && IsJoint())
4261 { 4320 {
@@ -4754,5 +4813,17 @@ namespace OpenSim.Region.Framework.Scenes
4754 Color color = Color; 4813 Color color = Color;
4755 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4814 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4756 } 4815 }
4816
4817 public void ResetOwnerChangeFlag()
4818 {
4819 List<UUID> inv = Inventory.GetInventoryList();
4820
4821 foreach (UUID itemID in inv)
4822 {
4823 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4824 item.OwnerChanged = false;
4825 Inventory.UpdateInventoryItem(item, false, false);
4826 }
4827 }
4757 } 4828 }
4758} 4829}