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 ad3bcd5..b232855 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
@@ -1041,10 +1072,7 @@ namespace OpenSim.Region.Framework.Scenes
1041 { 1072 {
1042 get 1073 get
1043 { 1074 {
1044 if (ParentGroup.IsAttachment) 1075 return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset);
1045 return GroupPosition;
1046
1047 return m_offsetPosition + m_groupPosition;
1048 } 1076 }
1049 } 1077 }
1050 1078
@@ -1214,6 +1242,13 @@ namespace OpenSim.Region.Framework.Scenes
1214 _flags = value; 1242 _flags = value;
1215 } 1243 }
1216 } 1244 }
1245
1246 [XmlIgnore]
1247 public bool IsOccupied // KF If an av is sittingon this prim
1248 {
1249 get { return m_occupied; }
1250 set { m_occupied = value; }
1251 }
1217 1252
1218 /// <summary> 1253 /// <summary>
1219 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1254 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1273,6 +1308,19 @@ namespace OpenSim.Region.Framework.Scenes
1273 set { m_collisionSoundVolume = value; } 1308 set { m_collisionSoundVolume = value; }
1274 } 1309 }
1275 1310
1311 public float Buoyancy
1312 {
1313 get { return m_buoyancy; }
1314 set
1315 {
1316 m_buoyancy = value;
1317 if (PhysActor != null)
1318 {
1319 PhysActor.Buoyancy = value;
1320 }
1321 }
1322 }
1323
1276 #endregion Public Properties with only Get 1324 #endregion Public Properties with only Get
1277 1325
1278 private uint ApplyMask(uint val, bool set, uint mask) 1326 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1597,6 +1645,9 @@ namespace OpenSim.Region.Framework.Scenes
1597 1645
1598 // Move afterwards ResetIDs as it clears the localID 1646 // Move afterwards ResetIDs as it clears the localID
1599 dupe.LocalId = localID; 1647 dupe.LocalId = localID;
1648 if(dupe.PhysActor != null)
1649 dupe.PhysActor.LocalID = localID;
1650
1600 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1651 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1601 dupe.LastOwnerID = OwnerID; 1652 dupe.LastOwnerID = OwnerID;
1602 1653
@@ -2602,17 +2653,18 @@ namespace OpenSim.Region.Framework.Scenes
2602 //Trys to fetch sound id from prim's inventory. 2653 //Trys to fetch sound id from prim's inventory.
2603 //Prim's inventory doesn't support non script items yet 2654 //Prim's inventory doesn't support non script items yet
2604 2655
2605 lock (TaskInventory) 2656 TaskInventory.LockItemsForRead(true);
2657
2658 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2606 { 2659 {
2607 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2660 if (item.Value.Name == sound)
2608 { 2661 {
2609 if (item.Value.Name == sound) 2662 soundID = item.Value.ItemID;
2610 { 2663 break;
2611 soundID = item.Value.ItemID;
2612 break;
2613 }
2614 } 2664 }
2615 } 2665 }
2666
2667 TaskInventory.LockItemsForRead(false);
2616 } 2668 }
2617 2669
2618 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2670 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2925,8 +2977,8 @@ namespace OpenSim.Region.Framework.Scenes
2925 { 2977 {
2926 const float ROTATION_TOLERANCE = 0.01f; 2978 const float ROTATION_TOLERANCE = 0.01f;
2927 const float VELOCITY_TOLERANCE = 0.001f; 2979 const float VELOCITY_TOLERANCE = 0.001f;
2928 const float POSITION_TOLERANCE = 0.05f; 2980 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2929 const int TIME_MS_TOLERANCE = 3000; 2981 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2930 2982
2931 switch (UpdateFlag) 2983 switch (UpdateFlag)
2932 { 2984 {
@@ -2988,17 +3040,16 @@ namespace OpenSim.Region.Framework.Scenes
2988 if (!UUID.TryParse(sound, out soundID)) 3040 if (!UUID.TryParse(sound, out soundID))
2989 { 3041 {
2990 // search sound file from inventory 3042 // search sound file from inventory
2991 lock (TaskInventory) 3043 TaskInventory.LockItemsForRead(true);
3044 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2992 { 3045 {
2993 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3046 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2994 { 3047 {
2995 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3048 soundID = item.Value.ItemID;
2996 { 3049 break;
2997 soundID = item.Value.ItemID;
2998 break;
2999 }
3000 } 3050 }
3001 } 3051 }
3052 TaskInventory.LockItemsForRead(false);
3002 } 3053 }
3003 3054
3004 if (soundID == UUID.Zero) 3055 if (soundID == UUID.Zero)
@@ -3465,10 +3516,10 @@ namespace OpenSim.Region.Framework.Scenes
3465 // TODO: May need to fix for group comparison 3516 // TODO: May need to fix for group comparison
3466 if (last.Compare(this)) 3517 if (last.Compare(this))
3467 { 3518 {
3468 // m_log.DebugFormat( 3519 // m_log.DebugFormat(
3469 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3520 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3470 // Name, LocalId, m_undo.Count); 3521 // Name, LocalId, m_undo.Count);
3471 3522
3472 return; 3523 return;
3473 } 3524 }
3474 } 3525 }
@@ -3481,29 +3532,29 @@ namespace OpenSim.Region.Framework.Scenes
3481 if (ParentGroup.GetSceneMaxUndo() > 0) 3532 if (ParentGroup.GetSceneMaxUndo() > 0)
3482 { 3533 {
3483 UndoState nUndo = new UndoState(this, forGroup); 3534 UndoState nUndo = new UndoState(this, forGroup);
3484 3535
3485 m_undo.Push(nUndo); 3536 m_undo.Push(nUndo);
3486 3537
3487 if (m_redo.Count > 0) 3538 if (m_redo.Count > 0)
3488 m_redo.Clear(); 3539 m_redo.Clear();
3489 3540
3490 // m_log.DebugFormat( 3541 // m_log.DebugFormat(
3491 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3542 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3492 // Name, LocalId, forGroup, m_undo.Count); 3543 // Name, LocalId, forGroup, m_undo.Count);
3493 } 3544 }
3494 } 3545 }
3495 } 3546 }
3496 } 3547 }
3497// else 3548 // else
3498// { 3549 // {
3499// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3550 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3500// } 3551 // }
3501 } 3552 }
3502// else 3553 // else
3503// { 3554 // {
3504// m_log.DebugFormat( 3555 // m_log.DebugFormat(
3505// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3556 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3506// } 3557 // }
3507 } 3558 }
3508 3559
3509 /// <summary> 3560 /// <summary>
@@ -4234,6 +4285,9 @@ namespace OpenSim.Region.Framework.Scenes
4234 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4285 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4235 bool wasVD = VolumeDetectActive; 4286 bool wasVD = VolumeDetectActive;
4236 4287
4288// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4289// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4290
4237 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4291 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4238 return; 4292 return;
4239 4293
@@ -4263,6 +4317,11 @@ namespace OpenSim.Region.Framework.Scenes
4263 SetPhantom = false; 4317 SetPhantom = false;
4264 } 4318 }
4265 } 4319 }
4320 else if (wasVD)
4321 {
4322 // Correspondingly, if VD is turned off, also turn off phantom
4323 SetPhantom = false;
4324 }
4266 4325
4267 if (UsePhysics && IsJoint()) 4326 if (UsePhysics && IsJoint())
4268 { 4327 {
@@ -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}