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 aea47e6..fa8b1c0 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)
@@ -1599,6 +1647,9 @@ namespace OpenSim.Region.Framework.Scenes
1599 1647
1600 // Move afterwards ResetIDs as it clears the localID 1648 // Move afterwards ResetIDs as it clears the localID
1601 dupe.LocalId = localID; 1649 dupe.LocalId = localID;
1650 if(dupe.PhysActor != null)
1651 dupe.PhysActor.LocalID = localID;
1652
1602 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1653 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1603 dupe.LastOwnerID = OwnerID; 1654 dupe.LastOwnerID = OwnerID;
1604 1655
@@ -1960,19 +2011,17 @@ namespace OpenSim.Region.Framework.Scenes
1960 public Vector3 GetWorldPosition() 2011 public Vector3 GetWorldPosition()
1961 { 2012 {
1962 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2013 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
1963
1964 Vector3 axPos = OffsetPosition; 2014 Vector3 axPos = OffsetPosition;
1965
1966 axPos *= parentRot; 2015 axPos *= parentRot;
1967 Vector3 translationOffsetPosition = axPos; 2016 Vector3 translationOffsetPosition = axPos;
1968 2017 if(_parentID == 0)
1969// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2018 {
1970 2019 return GroupPosition;
1971 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2020 }
1972 2021 else
1973// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2022 {
1974 2023 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
1975 return worldPos; 2024 }
1976 } 2025 }
1977 2026
1978 /// <summary> 2027 /// <summary>
@@ -2610,17 +2659,18 @@ namespace OpenSim.Region.Framework.Scenes
2610 //Trys to fetch sound id from prim's inventory. 2659 //Trys to fetch sound id from prim's inventory.
2611 //Prim's inventory doesn't support non script items yet 2660 //Prim's inventory doesn't support non script items yet
2612 2661
2613 lock (TaskInventory) 2662 TaskInventory.LockItemsForRead(true);
2663
2664 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2614 { 2665 {
2615 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2666 if (item.Value.Name == sound)
2616 { 2667 {
2617 if (item.Value.Name == sound) 2668 soundID = item.Value.ItemID;
2618 { 2669 break;
2619 soundID = item.Value.ItemID;
2620 break;
2621 }
2622 } 2670 }
2623 } 2671 }
2672
2673 TaskInventory.LockItemsForRead(false);
2624 } 2674 }
2625 2675
2626 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2676 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2703,7 +2753,7 @@ namespace OpenSim.Region.Framework.Scenes
2703 2753
2704 public void RotLookAt(Quaternion target, float strength, float damping) 2754 public void RotLookAt(Quaternion target, float strength, float damping)
2705 { 2755 {
2706 rotLookAt(target, strength, damping); 2756 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2707 } 2757 }
2708 2758
2709 public void rotLookAt(Quaternion target, float strength, float damping) 2759 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -2929,8 +2979,8 @@ namespace OpenSim.Region.Framework.Scenes
2929 { 2979 {
2930 const float ROTATION_TOLERANCE = 0.01f; 2980 const float ROTATION_TOLERANCE = 0.01f;
2931 const float VELOCITY_TOLERANCE = 0.001f; 2981 const float VELOCITY_TOLERANCE = 0.001f;
2932 const float POSITION_TOLERANCE = 0.05f; 2982 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2933 const int TIME_MS_TOLERANCE = 3000; 2983 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2934 2984
2935 switch (UpdateFlag) 2985 switch (UpdateFlag)
2936 { 2986 {
@@ -2992,17 +3042,16 @@ namespace OpenSim.Region.Framework.Scenes
2992 if (!UUID.TryParse(sound, out soundID)) 3042 if (!UUID.TryParse(sound, out soundID))
2993 { 3043 {
2994 // search sound file from inventory 3044 // search sound file from inventory
2995 lock (TaskInventory) 3045 TaskInventory.LockItemsForRead(true);
3046 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2996 { 3047 {
2997 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3048 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2998 { 3049 {
2999 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3050 soundID = item.Value.ItemID;
3000 { 3051 break;
3001 soundID = item.Value.ItemID;
3002 break;
3003 }
3004 } 3052 }
3005 } 3053 }
3054 TaskInventory.LockItemsForRead(false);
3006 } 3055 }
3007 3056
3008 if (soundID == UUID.Zero) 3057 if (soundID == UUID.Zero)
@@ -3476,10 +3525,10 @@ namespace OpenSim.Region.Framework.Scenes
3476 // TODO: May need to fix for group comparison 3525 // TODO: May need to fix for group comparison
3477 if (last.Compare(this)) 3526 if (last.Compare(this))
3478 { 3527 {
3479 // m_log.DebugFormat( 3528 // m_log.DebugFormat(
3480 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3529 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3481 // Name, LocalId, m_undo.Count); 3530 // Name, LocalId, m_undo.Count);
3482 3531
3483 return; 3532 return;
3484 } 3533 }
3485 } 3534 }
@@ -3492,29 +3541,29 @@ namespace OpenSim.Region.Framework.Scenes
3492 if (ParentGroup.GetSceneMaxUndo() > 0) 3541 if (ParentGroup.GetSceneMaxUndo() > 0)
3493 { 3542 {
3494 UndoState nUndo = new UndoState(this, forGroup); 3543 UndoState nUndo = new UndoState(this, forGroup);
3495 3544
3496 m_undo.Push(nUndo); 3545 m_undo.Push(nUndo);
3497 3546
3498 if (m_redo.Count > 0) 3547 if (m_redo.Count > 0)
3499 m_redo.Clear(); 3548 m_redo.Clear();
3500 3549
3501 // m_log.DebugFormat( 3550 // m_log.DebugFormat(
3502 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3551 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3503 // Name, LocalId, forGroup, m_undo.Count); 3552 // Name, LocalId, forGroup, m_undo.Count);
3504 } 3553 }
3505 } 3554 }
3506 } 3555 }
3507 } 3556 }
3508// else 3557 // else
3509// { 3558 // {
3510// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3559 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3511// } 3560 // }
3512 } 3561 }
3513// else 3562 // else
3514// { 3563 // {
3515// m_log.DebugFormat( 3564 // m_log.DebugFormat(
3516// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3565 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3517// } 3566 // }
3518 } 3567 }
3519 3568
3520 /// <summary> 3569 /// <summary>
@@ -4245,6 +4294,9 @@ namespace OpenSim.Region.Framework.Scenes
4245 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4294 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4246 bool wasVD = VolumeDetectActive; 4295 bool wasVD = VolumeDetectActive;
4247 4296
4297// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4298// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4299
4248 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4300 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4249 return; 4301 return;
4250 4302
@@ -4274,6 +4326,11 @@ namespace OpenSim.Region.Framework.Scenes
4274 SetPhantom = false; 4326 SetPhantom = false;
4275 } 4327 }
4276 } 4328 }
4329 else if (wasVD)
4330 {
4331 // Correspondingly, if VD is turned off, also turn off phantom
4332 SetPhantom = false;
4333 }
4277 4334
4278 if (UsePhysics && IsJoint()) 4335 if (UsePhysics && IsJoint())
4279 { 4336 {
@@ -4768,5 +4825,17 @@ namespace OpenSim.Region.Framework.Scenes
4768 Color color = Color; 4825 Color color = Color;
4769 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4826 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4770 } 4827 }
4828
4829 public void ResetOwnerChangeFlag()
4830 {
4831 List<UUID> inv = Inventory.GetInventoryList();
4832
4833 foreach (UUID itemID in inv)
4834 {
4835 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4836 item.OwnerChanged = false;
4837 Inventory.UpdateInventoryItem(item, false, false);
4838 }
4839 }
4771 } 4840 }
4772} 4841}