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 b29ecc6..fd70bfd 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)
@@ -1596,6 +1644,9 @@ namespace OpenSim.Region.Framework.Scenes
1596 1644
1597 // Move afterwards ResetIDs as it clears the localID 1645 // Move afterwards ResetIDs as it clears the localID
1598 dupe.LocalId = localID; 1646 dupe.LocalId = localID;
1647 if(dupe.PhysActor != null)
1648 dupe.PhysActor.LocalID = localID;
1649
1599 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1650 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1600 dupe.LastOwnerID = OwnerID; 1651 dupe.LastOwnerID = OwnerID;
1601 1652
@@ -1957,19 +2008,17 @@ namespace OpenSim.Region.Framework.Scenes
1957 public Vector3 GetWorldPosition() 2008 public Vector3 GetWorldPosition()
1958 { 2009 {
1959 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2010 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
1960
1961 Vector3 axPos = OffsetPosition; 2011 Vector3 axPos = OffsetPosition;
1962
1963 axPos *= parentRot; 2012 axPos *= parentRot;
1964 Vector3 translationOffsetPosition = axPos; 2013 Vector3 translationOffsetPosition = axPos;
1965 2014 if(_parentID == 0)
1966// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2015 {
1967 2016 return GroupPosition;
1968 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2017 }
1969 2018 else
1970// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2019 {
1971 2020 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
1972 return worldPos; 2021 }
1973 } 2022 }
1974 2023
1975 /// <summary> 2024 /// <summary>
@@ -2607,17 +2656,18 @@ namespace OpenSim.Region.Framework.Scenes
2607 //Trys to fetch sound id from prim's inventory. 2656 //Trys to fetch sound id from prim's inventory.
2608 //Prim's inventory doesn't support non script items yet 2657 //Prim's inventory doesn't support non script items yet
2609 2658
2610 lock (TaskInventory) 2659 TaskInventory.LockItemsForRead(true);
2660
2661 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2611 { 2662 {
2612 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2663 if (item.Value.Name == sound)
2613 { 2664 {
2614 if (item.Value.Name == sound) 2665 soundID = item.Value.ItemID;
2615 { 2666 break;
2616 soundID = item.Value.ItemID;
2617 break;
2618 }
2619 } 2667 }
2620 } 2668 }
2669
2670 TaskInventory.LockItemsForRead(false);
2621 } 2671 }
2622 2672
2623 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2673 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2700,7 +2750,7 @@ namespace OpenSim.Region.Framework.Scenes
2700 2750
2701 public void RotLookAt(Quaternion target, float strength, float damping) 2751 public void RotLookAt(Quaternion target, float strength, float damping)
2702 { 2752 {
2703 rotLookAt(target, strength, damping); 2753 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2704 } 2754 }
2705 2755
2706 public void rotLookAt(Quaternion target, float strength, float damping) 2756 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -2926,8 +2976,8 @@ namespace OpenSim.Region.Framework.Scenes
2926 { 2976 {
2927 const float ROTATION_TOLERANCE = 0.01f; 2977 const float ROTATION_TOLERANCE = 0.01f;
2928 const float VELOCITY_TOLERANCE = 0.001f; 2978 const float VELOCITY_TOLERANCE = 0.001f;
2929 const float POSITION_TOLERANCE = 0.05f; 2979 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2930 const int TIME_MS_TOLERANCE = 3000; 2980 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2931 2981
2932 switch (UpdateFlag) 2982 switch (UpdateFlag)
2933 { 2983 {
@@ -2989,17 +3039,16 @@ namespace OpenSim.Region.Framework.Scenes
2989 if (!UUID.TryParse(sound, out soundID)) 3039 if (!UUID.TryParse(sound, out soundID))
2990 { 3040 {
2991 // search sound file from inventory 3041 // search sound file from inventory
2992 lock (TaskInventory) 3042 TaskInventory.LockItemsForRead(true);
3043 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2993 { 3044 {
2994 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3045 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2995 { 3046 {
2996 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3047 soundID = item.Value.ItemID;
2997 { 3048 break;
2998 soundID = item.Value.ItemID;
2999 break;
3000 }
3001 } 3049 }
3002 } 3050 }
3051 TaskInventory.LockItemsForRead(false);
3003 } 3052 }
3004 3053
3005 if (soundID == UUID.Zero) 3054 if (soundID == UUID.Zero)
@@ -3473,10 +3522,10 @@ namespace OpenSim.Region.Framework.Scenes
3473 // TODO: May need to fix for group comparison 3522 // TODO: May need to fix for group comparison
3474 if (last.Compare(this)) 3523 if (last.Compare(this))
3475 { 3524 {
3476 // m_log.DebugFormat( 3525 // m_log.DebugFormat(
3477 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3526 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3478 // Name, LocalId, m_undo.Count); 3527 // Name, LocalId, m_undo.Count);
3479 3528
3480 return; 3529 return;
3481 } 3530 }
3482 } 3531 }
@@ -3489,29 +3538,29 @@ namespace OpenSim.Region.Framework.Scenes
3489 if (ParentGroup.GetSceneMaxUndo() > 0) 3538 if (ParentGroup.GetSceneMaxUndo() > 0)
3490 { 3539 {
3491 UndoState nUndo = new UndoState(this, forGroup); 3540 UndoState nUndo = new UndoState(this, forGroup);
3492 3541
3493 m_undo.Push(nUndo); 3542 m_undo.Push(nUndo);
3494 3543
3495 if (m_redo.Count > 0) 3544 if (m_redo.Count > 0)
3496 m_redo.Clear(); 3545 m_redo.Clear();
3497 3546
3498 // m_log.DebugFormat( 3547 // m_log.DebugFormat(
3499 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3548 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3500 // Name, LocalId, forGroup, m_undo.Count); 3549 // Name, LocalId, forGroup, m_undo.Count);
3501 } 3550 }
3502 } 3551 }
3503 } 3552 }
3504 } 3553 }
3505// else 3554 // else
3506// { 3555 // {
3507// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3556 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3508// } 3557 // }
3509 } 3558 }
3510// else 3559 // else
3511// { 3560 // {
3512// m_log.DebugFormat( 3561 // m_log.DebugFormat(
3513// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3562 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3514// } 3563 // }
3515 } 3564 }
3516 3565
3517 /// <summary> 3566 /// <summary>
@@ -4242,6 +4291,9 @@ namespace OpenSim.Region.Framework.Scenes
4242 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4291 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4243 bool wasVD = VolumeDetectActive; 4292 bool wasVD = VolumeDetectActive;
4244 4293
4294// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4295// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4296
4245 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4297 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4246 return; 4298 return;
4247 4299
@@ -4271,6 +4323,11 @@ namespace OpenSim.Region.Framework.Scenes
4271 SetPhantom = false; 4323 SetPhantom = false;
4272 } 4324 }
4273 } 4325 }
4326 else if (wasVD)
4327 {
4328 // Correspondingly, if VD is turned off, also turn off phantom
4329 SetPhantom = false;
4330 }
4274 4331
4275 if (UsePhysics && IsJoint()) 4332 if (UsePhysics && IsJoint())
4276 { 4333 {
@@ -4765,5 +4822,17 @@ namespace OpenSim.Region.Framework.Scenes
4765 Color color = Color; 4822 Color color = Color;
4766 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4823 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4767 } 4824 }
4825
4826 public void ResetOwnerChangeFlag()
4827 {
4828 List<UUID> inv = Inventory.GetInventoryList();
4829
4830 foreach (UUID itemID in inv)
4831 {
4832 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4833 item.OwnerChanged = false;
4834 Inventory.UpdateInventoryItem(item, false, false);
4835 }
4836 }
4768 } 4837 }
4769} 4838}