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 f5a00d7..666ce2a 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)
@@ -2936,8 +2986,8 @@ namespace OpenSim.Region.Framework.Scenes
2936 { 2986 {
2937 const float ROTATION_TOLERANCE = 0.01f; 2987 const float ROTATION_TOLERANCE = 0.01f;
2938 const float VELOCITY_TOLERANCE = 0.001f; 2988 const float VELOCITY_TOLERANCE = 0.001f;
2939 const float POSITION_TOLERANCE = 0.05f; 2989 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2940 const int TIME_MS_TOLERANCE = 3000; 2990 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2941 2991
2942 switch (UpdateFlag) 2992 switch (UpdateFlag)
2943 { 2993 {
@@ -2999,17 +3049,16 @@ namespace OpenSim.Region.Framework.Scenes
2999 if (!UUID.TryParse(sound, out soundID)) 3049 if (!UUID.TryParse(sound, out soundID))
3000 { 3050 {
3001 // search sound file from inventory 3051 // search sound file from inventory
3002 lock (TaskInventory) 3052 TaskInventory.LockItemsForRead(true);
3053 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3003 { 3054 {
3004 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3055 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3005 { 3056 {
3006 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3057 soundID = item.Value.ItemID;
3007 { 3058 break;
3008 soundID = item.Value.ItemID;
3009 break;
3010 }
3011 } 3059 }
3012 } 3060 }
3061 TaskInventory.LockItemsForRead(false);
3013 } 3062 }
3014 3063
3015 if (soundID == UUID.Zero) 3064 if (soundID == UUID.Zero)
@@ -3478,10 +3527,10 @@ namespace OpenSim.Region.Framework.Scenes
3478 // TODO: May need to fix for group comparison 3527 // TODO: May need to fix for group comparison
3479 if (last.Compare(this)) 3528 if (last.Compare(this))
3480 { 3529 {
3481 // m_log.DebugFormat( 3530 // m_log.DebugFormat(
3482 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3531 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3483 // Name, LocalId, m_undo.Count); 3532 // Name, LocalId, m_undo.Count);
3484 3533
3485 return; 3534 return;
3486 } 3535 }
3487 } 3536 }
@@ -3494,29 +3543,29 @@ namespace OpenSim.Region.Framework.Scenes
3494 if (ParentGroup.GetSceneMaxUndo() > 0) 3543 if (ParentGroup.GetSceneMaxUndo() > 0)
3495 { 3544 {
3496 UndoState nUndo = new UndoState(this, forGroup); 3545 UndoState nUndo = new UndoState(this, forGroup);
3497 3546
3498 m_undo.Push(nUndo); 3547 m_undo.Push(nUndo);
3499 3548
3500 if (m_redo.Count > 0) 3549 if (m_redo.Count > 0)
3501 m_redo.Clear(); 3550 m_redo.Clear();
3502 3551
3503 // m_log.DebugFormat( 3552 // m_log.DebugFormat(
3504 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3553 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3505 // Name, LocalId, forGroup, m_undo.Count); 3554 // Name, LocalId, forGroup, m_undo.Count);
3506 } 3555 }
3507 } 3556 }
3508 } 3557 }
3509 } 3558 }
3510// else 3559 // else
3511// { 3560 // {
3512// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3561 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3513// } 3562 // }
3514 } 3563 }
3515// else 3564 // else
3516// { 3565 // {
3517// m_log.DebugFormat( 3566 // m_log.DebugFormat(
3518// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3567 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3519// } 3568 // }
3520 } 3569 }
3521 3570
3522 /// <summary> 3571 /// <summary>
@@ -4247,6 +4296,9 @@ namespace OpenSim.Region.Framework.Scenes
4247 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4296 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4248 bool wasVD = VolumeDetectActive; 4297 bool wasVD = VolumeDetectActive;
4249 4298
4299// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4300// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4301
4250 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4302 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4251 return; 4303 return;
4252 4304
@@ -4276,6 +4328,11 @@ namespace OpenSim.Region.Framework.Scenes
4276 SetPhantom = false; 4328 SetPhantom = false;
4277 } 4329 }
4278 } 4330 }
4331 else if (wasVD)
4332 {
4333 // Correspondingly, if VD is turned off, also turn off phantom
4334 SetPhantom = false;
4335 }
4279 4336
4280 if (UsePhysics && IsJoint()) 4337 if (UsePhysics && IsJoint())
4281 { 4338 {
@@ -4770,5 +4827,17 @@ namespace OpenSim.Region.Framework.Scenes
4770 Color color = Color; 4827 Color color = Color;
4771 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4828 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4772 } 4829 }
4830
4831 public void ResetOwnerChangeFlag()
4832 {
4833 List<UUID> inv = Inventory.GetInventoryList();
4834
4835 foreach (UUID itemID in inv)
4836 {
4837 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4838 item.OwnerChanged = false;
4839 Inventory.UpdateInventoryItem(item, false, false);
4840 }
4841 }
4773 } 4842 }
4774} 4843}