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.cs212
1 files changed, 142 insertions, 70 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index c8b39a4..0e48515 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);
@@ -286,6 +296,7 @@ namespace OpenSim.Region.Framework.Scenes
286 protected Vector3 m_lastAcceleration; 296 protected Vector3 m_lastAcceleration;
287 protected Vector3 m_lastAngularVelocity; 297 protected Vector3 m_lastAngularVelocity;
288 protected int m_lastTerseSent; 298 protected int m_lastTerseSent;
299 protected float m_buoyancy = 0.0f;
289 300
290 /// <summary> 301 /// <summary>
291 /// Stores media texture data 302 /// Stores media texture data
@@ -341,7 +352,7 @@ namespace OpenSim.Region.Framework.Scenes
341 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 352 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
342 Quaternion rotationOffset, Vector3 offsetPosition) : this() 353 Quaternion rotationOffset, Vector3 offsetPosition) : this()
343 { 354 {
344 m_name = "Primitive"; 355 m_name = "Object";
345 356
346 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 357 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
347 LastOwnerID = CreatorID = OwnerID = ownerID; 358 LastOwnerID = CreatorID = OwnerID = ownerID;
@@ -381,7 +392,7 @@ namespace OpenSim.Region.Framework.Scenes
381 private uint _ownerMask = (uint)PermissionMask.All; 392 private uint _ownerMask = (uint)PermissionMask.All;
382 private uint _groupMask = (uint)PermissionMask.None; 393 private uint _groupMask = (uint)PermissionMask.None;
383 private uint _everyoneMask = (uint)PermissionMask.None; 394 private uint _everyoneMask = (uint)PermissionMask.None;
384 private uint _nextOwnerMask = (uint)PermissionMask.All; 395 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
385 private PrimFlags _flags = PrimFlags.None; 396 private PrimFlags _flags = PrimFlags.None;
386 private DateTime m_expires; 397 private DateTime m_expires;
387 private DateTime m_rezzed; 398 private DateTime m_rezzed;
@@ -475,12 +486,16 @@ namespace OpenSim.Region.Framework.Scenes
475 } 486 }
476 487
477 /// <value> 488 /// <value>
478 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 489 /// Get the inventory list
479 /// </value> 490 /// </value>
480 public TaskInventoryDictionary TaskInventory 491 public TaskInventoryDictionary TaskInventory
481 { 492 {
482 get { return m_inventory.Items; } 493 get {
483 set { m_inventory.Items = value; } 494 return m_inventory.Items;
495 }
496 set {
497 m_inventory.Items = value;
498 }
484 } 499 }
485 500
486 /// <summary> 501 /// <summary>
@@ -625,14 +640,12 @@ namespace OpenSim.Region.Framework.Scenes
625 set { m_LoopSoundSlavePrims = value; } 640 set { m_LoopSoundSlavePrims = value; }
626 } 641 }
627 642
628
629 public Byte[] TextureAnimation 643 public Byte[] TextureAnimation
630 { 644 {
631 get { return m_TextureAnimation; } 645 get { return m_TextureAnimation; }
632 set { m_TextureAnimation = value; } 646 set { m_TextureAnimation = value; }
633 } 647 }
634 648
635
636 public Byte[] ParticleSystem 649 public Byte[] ParticleSystem
637 { 650 {
638 get { return m_particleSystem; } 651 get { return m_particleSystem; }
@@ -671,7 +684,9 @@ namespace OpenSim.Region.Framework.Scenes
671 PhysicsActor actor = PhysActor; 684 PhysicsActor actor = PhysActor;
672 if (actor != null && ParentID == 0) 685 if (actor != null && ParentID == 0)
673 { 686 {
674 m_groupPosition = actor.Position; 687 if (actor != null)
688 m_groupPosition = actor.Position;
689 return m_groupPosition;
675 } 690 }
676 691
677 if (ParentGroup.IsAttachment) 692 if (ParentGroup.IsAttachment)
@@ -681,12 +696,14 @@ namespace OpenSim.Region.Framework.Scenes
681 return sp.AbsolutePosition; 696 return sp.AbsolutePosition;
682 } 697 }
683 698
699 // use root prim's group position. Physics may have updated it
700 if (ParentGroup.RootPart != this)
701 m_groupPosition = ParentGroup.RootPart.GroupPosition;
684 return m_groupPosition; 702 return m_groupPosition;
685 } 703 }
686 set 704 set
687 { 705 {
688 m_groupPosition = value; 706 m_groupPosition = value;
689
690 PhysicsActor actor = PhysActor; 707 PhysicsActor actor = PhysActor;
691 if (actor != null) 708 if (actor != null)
692 { 709 {
@@ -712,16 +729,6 @@ namespace OpenSim.Region.Framework.Scenes
712 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 729 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
713 } 730 }
714 } 731 }
715
716 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
717 if (SitTargetAvatar != UUID.Zero)
718 {
719 ScenePresence avatar;
720 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
721 {
722 avatar.ParentPosition = GetWorldPosition();
723 }
724 }
725 } 732 }
726 } 733 }
727 734
@@ -730,7 +737,7 @@ namespace OpenSim.Region.Framework.Scenes
730 get { return m_offsetPosition; } 737 get { return m_offsetPosition; }
731 set 738 set
732 { 739 {
733// StoreUndoState(); 740 Vector3 oldpos = m_offsetPosition;
734 m_offsetPosition = value; 741 m_offsetPosition = value;
735 742
736 if (ParentGroup != null && !ParentGroup.IsDeleted) 743 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -745,7 +752,22 @@ namespace OpenSim.Region.Framework.Scenes
745 if (ParentGroup.Scene != null) 752 if (ParentGroup.Scene != null)
746 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 753 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
747 } 754 }
755
756 if (!m_parentGroup.m_dupeInProgress)
757 {
758 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
759 foreach (ScenePresence av in avs)
760 {
761 if (av.ParentID == m_localId)
762 {
763 Vector3 offset = (m_offsetPosition - oldpos);
764 av.AbsolutePosition += offset;
765 av.SendAvatarDataToAllAgents();
766 }
767 }
768 }
748 } 769 }
770 TriggerScriptChangedEvent(Changed.POSITION);
749 } 771 }
750 } 772 }
751 773
@@ -894,7 +916,16 @@ namespace OpenSim.Region.Framework.Scenes
894 /// <summary></summary> 916 /// <summary></summary>
895 public Vector3 Acceleration 917 public Vector3 Acceleration
896 { 918 {
897 get { return m_acceleration; } 919 get
920 {
921 PhysicsActor actor = PhysActor;
922 if (actor != null)
923 {
924 m_acceleration = actor.Acceleration;
925 }
926 return m_acceleration;
927 }
928
898 set { m_acceleration = value; } 929 set { m_acceleration = value; }
899 } 930 }
900 931
@@ -1222,6 +1253,13 @@ namespace OpenSim.Region.Framework.Scenes
1222 _flags = value; 1253 _flags = value;
1223 } 1254 }
1224 } 1255 }
1256
1257 [XmlIgnore]
1258 public bool IsOccupied // KF If an av is sittingon this prim
1259 {
1260 get { return m_occupied; }
1261 set { m_occupied = value; }
1262 }
1225 1263
1226 /// <summary> 1264 /// <summary>
1227 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1265 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1281,6 +1319,19 @@ namespace OpenSim.Region.Framework.Scenes
1281 set { m_collisionSoundVolume = value; } 1319 set { m_collisionSoundVolume = value; }
1282 } 1320 }
1283 1321
1322 public float Buoyancy
1323 {
1324 get { return m_buoyancy; }
1325 set
1326 {
1327 m_buoyancy = value;
1328 if (PhysActor != null)
1329 {
1330 PhysActor.Buoyancy = value;
1331 }
1332 }
1333 }
1334
1284 #endregion Public Properties with only Get 1335 #endregion Public Properties with only Get
1285 1336
1286 private uint ApplyMask(uint val, bool set, uint mask) 1337 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1602,6 +1653,9 @@ namespace OpenSim.Region.Framework.Scenes
1602 1653
1603 // Move afterwards ResetIDs as it clears the localID 1654 // Move afterwards ResetIDs as it clears the localID
1604 dupe.LocalId = localID; 1655 dupe.LocalId = localID;
1656 if(dupe.PhysActor != null)
1657 dupe.PhysActor.LocalID = localID;
1658
1605 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1659 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1606 dupe.LastOwnerID = OwnerID; 1660 dupe.LastOwnerID = OwnerID;
1607 1661
@@ -1963,19 +2017,17 @@ namespace OpenSim.Region.Framework.Scenes
1963 public Vector3 GetWorldPosition() 2017 public Vector3 GetWorldPosition()
1964 { 2018 {
1965 Quaternion parentRot = ParentGroup.RootPart.RotationOffset; 2019 Quaternion parentRot = ParentGroup.RootPart.RotationOffset;
1966
1967 Vector3 axPos = OffsetPosition; 2020 Vector3 axPos = OffsetPosition;
1968
1969 axPos *= parentRot; 2021 axPos *= parentRot;
1970 Vector3 translationOffsetPosition = axPos; 2022 Vector3 translationOffsetPosition = axPos;
1971 2023 if(_parentID == 0)
1972// m_log.DebugFormat("[SCENE OBJECT PART]: Found group pos {0} for part {1}", GroupPosition, Name); 2024 {
1973 2025 return GroupPosition;
1974 Vector3 worldPos = GroupPosition + translationOffsetPosition; 2026 }
1975 2027 else
1976// m_log.DebugFormat("[SCENE OBJECT PART]: Found world pos {0} for part {1}", worldPos, Name); 2028 {
1977 2029 return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position
1978 return worldPos; 2030 }
1979 } 2031 }
1980 2032
1981 /// <summary> 2033 /// <summary>
@@ -2613,17 +2665,18 @@ namespace OpenSim.Region.Framework.Scenes
2613 //Trys to fetch sound id from prim's inventory. 2665 //Trys to fetch sound id from prim's inventory.
2614 //Prim's inventory doesn't support non script items yet 2666 //Prim's inventory doesn't support non script items yet
2615 2667
2616 lock (TaskInventory) 2668 TaskInventory.LockItemsForRead(true);
2669
2670 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2617 { 2671 {
2618 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2672 if (item.Value.Name == sound)
2619 { 2673 {
2620 if (item.Value.Name == sound) 2674 soundID = item.Value.ItemID;
2621 { 2675 break;
2622 soundID = item.Value.ItemID;
2623 break;
2624 }
2625 } 2676 }
2626 } 2677 }
2678
2679 TaskInventory.LockItemsForRead(false);
2627 } 2680 }
2628 2681
2629 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2682 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2706,7 +2759,7 @@ namespace OpenSim.Region.Framework.Scenes
2706 2759
2707 public void RotLookAt(Quaternion target, float strength, float damping) 2760 public void RotLookAt(Quaternion target, float strength, float damping)
2708 { 2761 {
2709 rotLookAt(target, strength, damping); 2762 m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup.
2710 } 2763 }
2711 2764
2712 public void rotLookAt(Quaternion target, float strength, float damping) 2765 public void rotLookAt(Quaternion target, float strength, float damping)
@@ -2942,8 +2995,8 @@ namespace OpenSim.Region.Framework.Scenes
2942 { 2995 {
2943 const float ROTATION_TOLERANCE = 0.01f; 2996 const float ROTATION_TOLERANCE = 0.01f;
2944 const float VELOCITY_TOLERANCE = 0.001f; 2997 const float VELOCITY_TOLERANCE = 0.001f;
2945 const float POSITION_TOLERANCE = 0.05f; 2998 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2946 const int TIME_MS_TOLERANCE = 3000; 2999 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2947 3000
2948 switch (UpdateFlag) 3001 switch (UpdateFlag)
2949 { 3002 {
@@ -3007,17 +3060,16 @@ namespace OpenSim.Region.Framework.Scenes
3007 if (!UUID.TryParse(sound, out soundID)) 3060 if (!UUID.TryParse(sound, out soundID))
3008 { 3061 {
3009 // search sound file from inventory 3062 // search sound file from inventory
3010 lock (TaskInventory) 3063 TaskInventory.LockItemsForRead(true);
3064 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
3011 { 3065 {
3012 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3066 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
3013 { 3067 {
3014 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3068 soundID = item.Value.ItemID;
3015 { 3069 break;
3016 soundID = item.Value.ItemID;
3017 break;
3018 }
3019 } 3070 }
3020 } 3071 }
3072 TaskInventory.LockItemsForRead(false);
3021 } 3073 }
3022 3074
3023 if (soundID == UUID.Zero) 3075 if (soundID == UUID.Zero)
@@ -3486,10 +3538,10 @@ namespace OpenSim.Region.Framework.Scenes
3486 // TODO: May need to fix for group comparison 3538 // TODO: May need to fix for group comparison
3487 if (last.Compare(this)) 3539 if (last.Compare(this))
3488 { 3540 {
3489 // m_log.DebugFormat( 3541 // m_log.DebugFormat(
3490 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3542 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3491 // Name, LocalId, m_undo.Count); 3543 // Name, LocalId, m_undo.Count);
3492 3544
3493 return; 3545 return;
3494 } 3546 }
3495 } 3547 }
@@ -3502,29 +3554,29 @@ namespace OpenSim.Region.Framework.Scenes
3502 if (ParentGroup.GetSceneMaxUndo() > 0) 3554 if (ParentGroup.GetSceneMaxUndo() > 0)
3503 { 3555 {
3504 UndoState nUndo = new UndoState(this, forGroup); 3556 UndoState nUndo = new UndoState(this, forGroup);
3505 3557
3506 m_undo.Push(nUndo); 3558 m_undo.Push(nUndo);
3507 3559
3508 if (m_redo.Count > 0) 3560 if (m_redo.Count > 0)
3509 m_redo.Clear(); 3561 m_redo.Clear();
3510 3562
3511 // m_log.DebugFormat( 3563 // m_log.DebugFormat(
3512 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3564 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3513 // Name, LocalId, forGroup, m_undo.Count); 3565 // Name, LocalId, forGroup, m_undo.Count);
3514 } 3566 }
3515 } 3567 }
3516 } 3568 }
3517 } 3569 }
3518// else 3570 // else
3519// { 3571 // {
3520// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3572 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3521// } 3573 // }
3522 } 3574 }
3523// else 3575 // else
3524// { 3576 // {
3525// m_log.DebugFormat( 3577 // m_log.DebugFormat(
3526// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3578 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3527// } 3579 // }
3528 } 3580 }
3529 3581
3530 /// <summary> 3582 /// <summary>
@@ -4255,6 +4307,9 @@ namespace OpenSim.Region.Framework.Scenes
4255 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4307 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4256 bool wasVD = VolumeDetectActive; 4308 bool wasVD = VolumeDetectActive;
4257 4309
4310// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4311// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4312
4258 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4313 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4259 return; 4314 return;
4260 4315
@@ -4284,6 +4339,11 @@ namespace OpenSim.Region.Framework.Scenes
4284 SetPhantom = false; 4339 SetPhantom = false;
4285 } 4340 }
4286 } 4341 }
4342 else if (wasVD)
4343 {
4344 // Correspondingly, if VD is turned off, also turn off phantom
4345 SetPhantom = false;
4346 }
4287 4347
4288 if (UsePhysics && IsJoint()) 4348 if (UsePhysics && IsJoint())
4289 { 4349 {
@@ -4778,5 +4838,17 @@ namespace OpenSim.Region.Framework.Scenes
4778 Color color = Color; 4838 Color color = Color;
4779 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4839 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4780 } 4840 }
4841
4842 public void ResetOwnerChangeFlag()
4843 {
4844 List<UUID> inv = Inventory.GetInventoryList();
4845
4846 foreach (UUID itemID in inv)
4847 {
4848 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
4849 item.OwnerChanged = false;
4850 Inventory.UpdateInventoryItem(item, false, false);
4851 }
4852 }
4781 } 4853 }
4782} 4854}