diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1632 |
1 files changed, 1138 insertions, 494 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f6e8c7f..1cfa8ed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -64,7 +64,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
64 | TELEPORT = 512, | 64 | TELEPORT = 512, |
65 | REGION_RESTART = 1024, | 65 | REGION_RESTART = 1024, |
66 | MEDIA = 2048, | 66 | MEDIA = 2048, |
67 | ANIMATION = 16384 | 67 | ANIMATION = 16384, |
68 | POSITION = 32768 | ||
68 | } | 69 | } |
69 | 70 | ||
70 | // I don't really know where to put this except here. | 71 | // I don't really know where to put this except here. |
@@ -123,7 +124,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
123 | /// Denote all sides of the prim | 124 | /// Denote all sides of the prim |
124 | /// </value> | 125 | /// </value> |
125 | public const int ALL_SIDES = -1; | 126 | public const int ALL_SIDES = -1; |
126 | 127 | ||
128 | private const scriptEvents PhysicsNeededSubsEvents = ( | ||
129 | scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | | ||
130 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
131 | ); | ||
132 | private const scriptEvents PhyscicsPhantonSubsEvents = ( | ||
133 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
134 | ); | ||
135 | private const scriptEvents PhyscicsVolumeDtcSubsEvents = ( | ||
136 | scriptEvents.collision_start | scriptEvents.collision_end | ||
137 | ); | ||
138 | |||
127 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 139 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
128 | 140 | ||
129 | /// <summary> | 141 | /// <summary> |
@@ -160,7 +172,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | /// </remarks> | 172 | /// </remarks> |
161 | public bool IsRoot | 173 | public bool IsRoot |
162 | { | 174 | { |
163 | get { return ParentGroup.RootPart == this; } | 175 | get { return Object.ReferenceEquals(ParentGroup.RootPart, this); } |
164 | } | 176 | } |
165 | 177 | ||
166 | /// <summary> | 178 | /// <summary> |
@@ -233,6 +245,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
233 | 245 | ||
234 | public uint TimeStampTerse; | 246 | public uint TimeStampTerse; |
235 | 247 | ||
248 | // The following two are to hold the attachment data | ||
249 | // while an object is inworld | ||
250 | [XmlIgnore] | ||
251 | public byte AttachPoint = 0; | ||
252 | |||
253 | [XmlIgnore] | ||
254 | public Quaternion AttachRotation = Quaternion.Identity; | ||
255 | |||
256 | [XmlIgnore] | ||
236 | public int STATUS_ROTATE_X; | 257 | public int STATUS_ROTATE_X; |
237 | 258 | ||
238 | public int STATUS_ROTATE_Y; | 259 | public int STATUS_ROTATE_Y; |
@@ -259,8 +280,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
259 | 280 | ||
260 | public Vector3 RotationAxis = Vector3.One; | 281 | public Vector3 RotationAxis = Vector3.One; |
261 | 282 | ||
262 | public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this | 283 | public bool VolumeDetectActive; |
263 | // Certainly this must be a persistant setting finally | ||
264 | 284 | ||
265 | public bool IsWaitingForFirstSpinUpdatePacket; | 285 | public bool IsWaitingForFirstSpinUpdatePacket; |
266 | 286 | ||
@@ -300,10 +320,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
300 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 320 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
301 | private Vector3 m_sitTargetPosition; | 321 | private Vector3 m_sitTargetPosition; |
302 | private string m_sitAnimation = "SIT"; | 322 | private string m_sitAnimation = "SIT"; |
323 | private bool m_occupied; // KF if any av is sitting on this prim | ||
303 | private string m_text = String.Empty; | 324 | private string m_text = String.Empty; |
304 | private string m_touchName = String.Empty; | 325 | private string m_touchName = String.Empty; |
305 | private readonly List<UndoState> m_undo = new List<UndoState>(5); | 326 | private UndoRedoState m_UndoRedo = null; |
306 | private readonly List<UndoState> m_redo = new List<UndoState>(5); | ||
307 | 327 | ||
308 | private bool m_passTouches = false; | 328 | private bool m_passTouches = false; |
309 | private bool m_passCollisions = false; | 329 | private bool m_passCollisions = false; |
@@ -331,14 +351,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
331 | protected Vector3 m_lastVelocity; | 351 | protected Vector3 m_lastVelocity; |
332 | protected Vector3 m_lastAcceleration; | 352 | protected Vector3 m_lastAcceleration; |
333 | protected Vector3 m_lastAngularVelocity; | 353 | protected Vector3 m_lastAngularVelocity; |
334 | protected int m_lastTerseSent; | 354 | protected int m_lastUpdateSentTime; |
355 | protected float m_buoyancy = 0.0f; | ||
356 | protected Vector3 m_force; | ||
357 | protected Vector3 m_torque; | ||
335 | 358 | ||
336 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; | 359 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; |
337 | protected float m_density = 1000.0f; // in kg/m^3 | 360 | protected float m_density = 1000.0f; // in kg/m^3 |
338 | protected float m_gravitymod = 1.0f; | 361 | protected float m_gravitymod = 1.0f; |
339 | protected float m_friction = 0.6f; // wood | 362 | protected float m_friction = 0.6f; // wood |
340 | protected float m_bounce = 0.5f; // wood | 363 | protected float m_bounce = 0.5f; // wood |
341 | 364 | ||
365 | |||
366 | protected bool m_isSelected = false; | ||
367 | |||
342 | /// <summary> | 368 | /// <summary> |
343 | /// Stores media texture data | 369 | /// Stores media texture data |
344 | /// </summary> | 370 | /// </summary> |
@@ -350,15 +376,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | private Vector3 m_cameraAtOffset; | 376 | private Vector3 m_cameraAtOffset; |
351 | private bool m_forceMouselook; | 377 | private bool m_forceMouselook; |
352 | 378 | ||
353 | // TODO: Collision sound should have default. | 379 | |
380 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
381 | private sbyte m_collisionSoundType; | ||
354 | private UUID m_collisionSound; | 382 | private UUID m_collisionSound; |
355 | private float m_collisionSoundVolume; | 383 | private float m_collisionSoundVolume; |
356 | 384 | ||
385 | private int LastColSoundSentTime; | ||
386 | |||
387 | |||
388 | private SOPVehicle m_vehicleParams = null; | ||
389 | |||
357 | public KeyframeMotion KeyframeMotion | 390 | public KeyframeMotion KeyframeMotion |
358 | { | 391 | { |
359 | get; set; | 392 | get; set; |
360 | } | 393 | } |
361 | 394 | ||
395 | |||
362 | #endregion Fields | 396 | #endregion Fields |
363 | 397 | ||
364 | // ~SceneObjectPart() | 398 | // ~SceneObjectPart() |
@@ -388,6 +422,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
388 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 422 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
389 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 423 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
390 | m_inventory = new SceneObjectPartInventory(this); | 424 | m_inventory = new SceneObjectPartInventory(this); |
425 | LastColSoundSentTime = Util.EnvironmentTickCount(); | ||
391 | } | 426 | } |
392 | 427 | ||
393 | /// <summary> | 428 | /// <summary> |
@@ -402,7 +437,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
402 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 437 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
403 | Quaternion rotationOffset, Vector3 offsetPosition) : this() | 438 | Quaternion rotationOffset, Vector3 offsetPosition) : this() |
404 | { | 439 | { |
405 | m_name = "Primitive"; | 440 | m_name = "Object"; |
406 | 441 | ||
407 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 442 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
408 | LastOwnerID = CreatorID = OwnerID = ownerID; | 443 | LastOwnerID = CreatorID = OwnerID = ownerID; |
@@ -441,7 +476,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
441 | private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export); | 476 | private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export); |
442 | private uint _groupMask = (uint)PermissionMask.None; | 477 | private uint _groupMask = (uint)PermissionMask.None; |
443 | private uint _everyoneMask = (uint)PermissionMask.None; | 478 | private uint _everyoneMask = (uint)PermissionMask.None; |
444 | private uint _nextOwnerMask = (uint)PermissionMask.All; | 479 | private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); |
445 | private PrimFlags _flags = PrimFlags.None; | 480 | private PrimFlags _flags = PrimFlags.None; |
446 | private DateTime m_expires; | 481 | private DateTime m_expires; |
447 | private DateTime m_rezzed; | 482 | private DateTime m_rezzed; |
@@ -539,12 +574,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
539 | } | 574 | } |
540 | 575 | ||
541 | /// <value> | 576 | /// <value> |
542 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 577 | /// Get the inventory list |
543 | /// </value> | 578 | /// </value> |
544 | public TaskInventoryDictionary TaskInventory | 579 | public TaskInventoryDictionary TaskInventory |
545 | { | 580 | { |
546 | get { return m_inventory.Items; } | 581 | get { |
547 | set { m_inventory.Items = value; } | 582 | return m_inventory.Items; |
583 | } | ||
584 | set { | ||
585 | m_inventory.Items = value; | ||
586 | } | ||
548 | } | 587 | } |
549 | 588 | ||
550 | /// <summary> | 589 | /// <summary> |
@@ -594,20 +633,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
594 | } | 633 | } |
595 | } | 634 | } |
596 | 635 | ||
597 | public byte Material | ||
598 | { | ||
599 | get { return (byte) m_material; } | ||
600 | set | ||
601 | { | ||
602 | m_material = (Material)value; | ||
603 | |||
604 | PhysicsActor pa = PhysActor; | ||
605 | |||
606 | if (pa != null) | ||
607 | pa.SetMaterial((int)value); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | [XmlIgnore] | 636 | [XmlIgnore] |
612 | public bool PassTouches | 637 | public bool PassTouches |
613 | { | 638 | { |
@@ -633,6 +658,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
633 | } | 658 | } |
634 | } | 659 | } |
635 | 660 | ||
661 | public bool IsSelected | ||
662 | { | ||
663 | get { return m_isSelected; } | ||
664 | set | ||
665 | { | ||
666 | m_isSelected = value; | ||
667 | if (ParentGroup != null) | ||
668 | ParentGroup.PartSelectChanged(value); | ||
669 | |||
670 | } | ||
671 | } | ||
672 | |||
673 | |||
636 | public Dictionary<int, string> CollisionFilter | 674 | public Dictionary<int, string> CollisionFilter |
637 | { | 675 | { |
638 | get { return m_CollisionFilter; } | 676 | get { return m_CollisionFilter; } |
@@ -707,14 +745,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
707 | set { m_LoopSoundSlavePrims = value; } | 745 | set { m_LoopSoundSlavePrims = value; } |
708 | } | 746 | } |
709 | 747 | ||
710 | |||
711 | public Byte[] TextureAnimation | 748 | public Byte[] TextureAnimation |
712 | { | 749 | { |
713 | get { return m_TextureAnimation; } | 750 | get { return m_TextureAnimation; } |
714 | set { m_TextureAnimation = value; } | 751 | set { m_TextureAnimation = value; } |
715 | } | 752 | } |
716 | 753 | ||
717 | |||
718 | public Byte[] ParticleSystem | 754 | public Byte[] ParticleSystem |
719 | { | 755 | { |
720 | get { return m_particleSystem; } | 756 | get { return m_particleSystem; } |
@@ -742,18 +778,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
742 | set { m_damage = value; } | 778 | set { m_damage = value; } |
743 | } | 779 | } |
744 | 780 | ||
781 | |||
782 | |||
783 | |||
784 | public void setGroupPosition(Vector3 pos) | ||
785 | { | ||
786 | m_groupPosition = pos; | ||
787 | } | ||
788 | |||
745 | /// <summary> | 789 | /// <summary> |
746 | /// The position of the entire group that this prim belongs to. | 790 | /// The position of the entire group that this prim belongs to. |
747 | /// </summary> | 791 | /// </summary> |
792 | /// | ||
793 | |||
794 | |||
748 | public Vector3 GroupPosition | 795 | public Vector3 GroupPosition |
749 | { | 796 | { |
750 | get | 797 | get |
751 | { | 798 | { |
752 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 799 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
753 | PhysicsActor actor = PhysActor; | 800 | PhysicsActor actor = PhysActor; |
754 | // If physical and the root prim of a linkset, the position of the group is what physics thinks. | 801 | if (ParentID == 0) |
755 | if (actor != null && ParentID == 0) | 802 | { |
756 | m_groupPosition = actor.Position; | 803 | if (actor != null) |
804 | m_groupPosition = actor.Position; | ||
805 | return m_groupPosition; | ||
806 | } | ||
757 | 807 | ||
758 | // If I'm an attachment, my position is reported as the position of who I'm attached to | 808 | // If I'm an attachment, my position is reported as the position of who I'm attached to |
759 | if (ParentGroup.IsAttachment) | 809 | if (ParentGroup.IsAttachment) |
@@ -763,21 +813,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
763 | return sp.AbsolutePosition; | 813 | return sp.AbsolutePosition; |
764 | } | 814 | } |
765 | 815 | ||
816 | // use root prim's group position. Physics may have updated it | ||
817 | if (ParentGroup.RootPart != this) | ||
818 | m_groupPosition = ParentGroup.RootPart.GroupPosition; | ||
766 | return m_groupPosition; | 819 | return m_groupPosition; |
767 | } | 820 | } |
768 | set | 821 | set |
769 | { | 822 | { |
770 | m_groupPosition = value; | 823 | m_groupPosition = value; |
771 | |||
772 | PhysicsActor actor = PhysActor; | 824 | PhysicsActor actor = PhysActor; |
773 | if (actor != null) | 825 | if (actor != null && ParentGroup.Scene.PhysicsScene != null) |
774 | { | 826 | { |
775 | try | 827 | try |
776 | { | 828 | { |
777 | // Root prim actually goes at Position | 829 | // Root prim actually goes at Position |
778 | if (ParentID == 0) | 830 | if (ParentID == 0) |
779 | { | 831 | { |
780 | actor.Position = value; | 832 | actor.Position = value; |
781 | } | 833 | } |
782 | else | 834 | else |
783 | { | 835 | { |
@@ -798,12 +850,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
798 | } | 850 | } |
799 | } | 851 | } |
800 | 852 | ||
853 | public void setOffsetPosition(Vector3 pos) | ||
854 | { | ||
855 | m_offsetPosition = pos; | ||
856 | } | ||
857 | |||
801 | public Vector3 OffsetPosition | 858 | public Vector3 OffsetPosition |
802 | { | 859 | { |
803 | get { return m_offsetPosition; } | 860 | get { return m_offsetPosition; } |
804 | set | 861 | set |
805 | { | 862 | { |
806 | // StoreUndoState(); | 863 | Vector3 oldpos = m_offsetPosition; |
807 | m_offsetPosition = value; | 864 | m_offsetPosition = value; |
808 | 865 | ||
809 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 866 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -815,10 +872,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
815 | actor.Orientation = GetWorldRotation(); | 872 | actor.Orientation = GetWorldRotation(); |
816 | 873 | ||
817 | // Tell the physics engines that this prim changed. | 874 | // Tell the physics engines that this prim changed. |
818 | if (ParentGroup.Scene != null) | 875 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) |
819 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 876 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
820 | } | 877 | } |
878 | |||
879 | if (!m_parentGroup.m_dupeInProgress) | ||
880 | { | ||
881 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
882 | foreach (ScenePresence av in avs) | ||
883 | { | ||
884 | if (av.ParentID == m_localId) | ||
885 | { | ||
886 | Vector3 offset = (m_offsetPosition - oldpos); | ||
887 | av.AbsolutePosition += offset; | ||
888 | // av.SendAvatarDataToAllAgents(); | ||
889 | av.SendTerseUpdateToAllClients(); | ||
890 | } | ||
891 | } | ||
892 | } | ||
821 | } | 893 | } |
894 | TriggerScriptChangedEvent(Changed.POSITION); | ||
822 | } | 895 | } |
823 | } | 896 | } |
824 | 897 | ||
@@ -840,6 +913,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
840 | } | 913 | } |
841 | } | 914 | } |
842 | 915 | ||
916 | public void setRotationOffset(Quaternion q) | ||
917 | { | ||
918 | m_rotationOffset = q; | ||
919 | } | ||
920 | |||
843 | public Quaternion RotationOffset | 921 | public Quaternion RotationOffset |
844 | { | 922 | { |
845 | get | 923 | get |
@@ -869,7 +947,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
869 | 947 | ||
870 | set | 948 | set |
871 | { | 949 | { |
872 | StoreUndoState(); | 950 | // StoreUndoState(); |
873 | m_rotationOffset = value; | 951 | m_rotationOffset = value; |
874 | 952 | ||
875 | PhysicsActor actor = PhysActor; | 953 | PhysicsActor actor = PhysActor; |
@@ -960,7 +1038,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
960 | get | 1038 | get |
961 | { | 1039 | { |
962 | PhysicsActor actor = PhysActor; | 1040 | PhysicsActor actor = PhysActor; |
963 | if ((actor != null) && actor.IsPhysical) | 1041 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this) |
964 | { | 1042 | { |
965 | m_angularVelocity = actor.RotationalVelocity; | 1043 | m_angularVelocity = actor.RotationalVelocity; |
966 | } | 1044 | } |
@@ -968,6 +1046,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
968 | } | 1046 | } |
969 | set | 1047 | set |
970 | { | 1048 | { |
1049 | <<<<<<< HEAD | ||
971 | if (Util.IsNanOrInfinity(value)) | 1050 | if (Util.IsNanOrInfinity(value)) |
972 | m_angularVelocity = Vector3.Zero; | 1051 | m_angularVelocity = Vector3.Zero; |
973 | else | 1052 | else |
@@ -976,12 +1055,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
976 | PhysicsActor actor = PhysActor; | 1055 | PhysicsActor actor = PhysActor; |
977 | if ((actor != null) && actor.IsPhysical) | 1056 | if ((actor != null) && actor.IsPhysical) |
978 | actor.RotationalVelocity = m_angularVelocity; | 1057 | actor.RotationalVelocity = m_angularVelocity; |
1058 | ======= | ||
1059 | m_angularVelocity = value; | ||
1060 | PhysicsActor actor = PhysActor; | ||
1061 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE) | ||
1062 | { | ||
1063 | actor.RotationalVelocity = m_angularVelocity; | ||
1064 | } | ||
1065 | >>>>>>> avn/ubitvar | ||
979 | } | 1066 | } |
980 | } | 1067 | } |
981 | 1068 | ||
982 | /// <summary></summary> | 1069 | /// <summary></summary> |
983 | public Vector3 Acceleration | 1070 | public Vector3 Acceleration |
984 | { | 1071 | { |
1072 | <<<<<<< HEAD | ||
985 | get { return m_acceleration; } | 1073 | get { return m_acceleration; } |
986 | set | 1074 | set |
987 | { | 1075 | { |
@@ -990,6 +1078,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
990 | else | 1078 | else |
991 | m_acceleration = value; | 1079 | m_acceleration = value; |
992 | } | 1080 | } |
1081 | ======= | ||
1082 | get | ||
1083 | { | ||
1084 | PhysicsActor actor = PhysActor; | ||
1085 | if (actor != null) | ||
1086 | { | ||
1087 | m_acceleration = actor.Acceleration; | ||
1088 | } | ||
1089 | return m_acceleration; | ||
1090 | } | ||
1091 | |||
1092 | set { m_acceleration = value; } | ||
1093 | >>>>>>> avn/ubitvar | ||
993 | } | 1094 | } |
994 | 1095 | ||
995 | public string Description { get; set; } | 1096 | public string Description { get; set; } |
@@ -1056,7 +1157,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1056 | public PrimitiveBaseShape Shape | 1157 | public PrimitiveBaseShape Shape |
1057 | { | 1158 | { |
1058 | get { return m_shape; } | 1159 | get { return m_shape; } |
1059 | set { m_shape = value;} | 1160 | set |
1161 | { | ||
1162 | m_shape = value; | ||
1163 | } | ||
1060 | } | 1164 | } |
1061 | 1165 | ||
1062 | /// <summary> | 1166 | /// <summary> |
@@ -1069,7 +1173,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1069 | { | 1173 | { |
1070 | if (m_shape != null) | 1174 | if (m_shape != null) |
1071 | { | 1175 | { |
1072 | StoreUndoState(); | ||
1073 | 1176 | ||
1074 | m_shape.Scale = value; | 1177 | m_shape.Scale = value; |
1075 | 1178 | ||
@@ -1137,10 +1240,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1137 | { | 1240 | { |
1138 | get | 1241 | get |
1139 | { | 1242 | { |
1140 | if (ParentGroup.IsAttachment) | 1243 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); |
1141 | return GroupPosition; | ||
1142 | |||
1143 | return m_offsetPosition + m_groupPosition; | ||
1144 | } | 1244 | } |
1145 | } | 1245 | } |
1146 | 1246 | ||
@@ -1309,6 +1409,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1309 | _flags = value; | 1409 | _flags = value; |
1310 | } | 1410 | } |
1311 | } | 1411 | } |
1412 | |||
1413 | [XmlIgnore] | ||
1414 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1415 | { | ||
1416 | get { return m_occupied; } | ||
1417 | set { m_occupied = value; } | ||
1418 | } | ||
1312 | 1419 | ||
1313 | /// <summary> | 1420 | /// <summary> |
1314 | /// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero | 1421 | /// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero |
@@ -1359,12 +1466,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1359 | set { m_sitAnimation = value; } | 1466 | set { m_sitAnimation = value; } |
1360 | } | 1467 | } |
1361 | 1468 | ||
1469 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | ||
1470 | |||
1471 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
1472 | // runtime thing.. do not persist | ||
1473 | [XmlIgnore] | ||
1474 | public sbyte CollisionSoundType | ||
1475 | { | ||
1476 | get | ||
1477 | { | ||
1478 | return m_collisionSoundType; | ||
1479 | } | ||
1480 | set | ||
1481 | { | ||
1482 | m_collisionSoundType = value; | ||
1483 | if (value == -1) | ||
1484 | m_collisionSound = invalidCollisionSoundUUID; | ||
1485 | else if (value == 0) | ||
1486 | m_collisionSound = UUID.Zero; | ||
1487 | } | ||
1488 | } | ||
1489 | |||
1362 | public UUID CollisionSound | 1490 | public UUID CollisionSound |
1363 | { | 1491 | { |
1364 | get { return m_collisionSound; } | 1492 | get { return m_collisionSound; } |
1365 | set | 1493 | set |
1366 | { | 1494 | { |
1367 | m_collisionSound = value; | 1495 | m_collisionSound = value; |
1496 | |||
1497 | if (value == invalidCollisionSoundUUID) | ||
1498 | m_collisionSoundType = -1; | ||
1499 | else if (value == UUID.Zero) | ||
1500 | m_collisionSoundType = 0; | ||
1501 | else | ||
1502 | m_collisionSoundType = 1; | ||
1503 | |||
1368 | aggregateScriptEvents(); | 1504 | aggregateScriptEvents(); |
1369 | } | 1505 | } |
1370 | } | 1506 | } |
@@ -1375,6 +1511,125 @@ namespace OpenSim.Region.Framework.Scenes | |||
1375 | set { m_collisionSoundVolume = value; } | 1511 | set { m_collisionSoundVolume = value; } |
1376 | } | 1512 | } |
1377 | 1513 | ||
1514 | public float Buoyancy | ||
1515 | { | ||
1516 | get | ||
1517 | { | ||
1518 | if (ParentGroup.RootPart == this) | ||
1519 | return m_buoyancy; | ||
1520 | |||
1521 | return ParentGroup.RootPart.Buoyancy; | ||
1522 | } | ||
1523 | set | ||
1524 | { | ||
1525 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1526 | { | ||
1527 | ParentGroup.RootPart.Buoyancy = value; | ||
1528 | return; | ||
1529 | } | ||
1530 | m_buoyancy = value; | ||
1531 | if (PhysActor != null) | ||
1532 | PhysActor.Buoyancy = value; | ||
1533 | } | ||
1534 | } | ||
1535 | |||
1536 | public Vector3 Force | ||
1537 | { | ||
1538 | get | ||
1539 | { | ||
1540 | if (ParentGroup.RootPart == this) | ||
1541 | return m_force; | ||
1542 | |||
1543 | return ParentGroup.RootPart.Force; | ||
1544 | } | ||
1545 | |||
1546 | set | ||
1547 | { | ||
1548 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1549 | { | ||
1550 | ParentGroup.RootPart.Force = value; | ||
1551 | return; | ||
1552 | } | ||
1553 | m_force = value; | ||
1554 | if (PhysActor != null) | ||
1555 | PhysActor.Force = value; | ||
1556 | } | ||
1557 | } | ||
1558 | |||
1559 | public Vector3 Torque | ||
1560 | { | ||
1561 | get | ||
1562 | { | ||
1563 | if (ParentGroup.RootPart == this) | ||
1564 | return m_torque; | ||
1565 | |||
1566 | return ParentGroup.RootPart.Torque; | ||
1567 | } | ||
1568 | |||
1569 | set | ||
1570 | { | ||
1571 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1572 | { | ||
1573 | ParentGroup.RootPart.Torque = value; | ||
1574 | return; | ||
1575 | } | ||
1576 | m_torque = value; | ||
1577 | if (PhysActor != null) | ||
1578 | PhysActor.Torque = value; | ||
1579 | } | ||
1580 | } | ||
1581 | |||
1582 | public byte Material | ||
1583 | { | ||
1584 | get { return (byte)m_material; } | ||
1585 | set | ||
1586 | { | ||
1587 | if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) | ||
1588 | { | ||
1589 | bool update = false; | ||
1590 | |||
1591 | if (m_material != (Material)value) | ||
1592 | { | ||
1593 | update = true; | ||
1594 | m_material = (Material)value; | ||
1595 | } | ||
1596 | |||
1597 | if (m_friction != SOPMaterialData.friction(m_material)) | ||
1598 | { | ||
1599 | update = true; | ||
1600 | m_friction = SOPMaterialData.friction(m_material); | ||
1601 | } | ||
1602 | |||
1603 | if (m_bounce != SOPMaterialData.bounce(m_material)) | ||
1604 | { | ||
1605 | update = true; | ||
1606 | m_bounce = SOPMaterialData.bounce(m_material); | ||
1607 | } | ||
1608 | |||
1609 | if (update) | ||
1610 | { | ||
1611 | if (PhysActor != null) | ||
1612 | { | ||
1613 | PhysActor.SetMaterial((int)value); | ||
1614 | } | ||
1615 | if(ParentGroup != null) | ||
1616 | ParentGroup.HasGroupChanged = true; | ||
1617 | ScheduleFullUpdateIfNone(); | ||
1618 | UpdatePhysRequired = true; | ||
1619 | } | ||
1620 | } | ||
1621 | } | ||
1622 | } | ||
1623 | |||
1624 | // not a propriety to move to methods place later | ||
1625 | private bool HasMesh() | ||
1626 | { | ||
1627 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1628 | return true; | ||
1629 | return false; | ||
1630 | } | ||
1631 | |||
1632 | // not a propriety to move to methods place later | ||
1378 | public byte DefaultPhysicsShapeType() | 1633 | public byte DefaultPhysicsShapeType() |
1379 | { | 1634 | { |
1380 | byte type; | 1635 | byte type; |
@@ -1387,6 +1642,65 @@ namespace OpenSim.Region.Framework.Scenes | |||
1387 | return type; | 1642 | return type; |
1388 | } | 1643 | } |
1389 | 1644 | ||
1645 | [XmlIgnore] | ||
1646 | public bool UsesComplexCost | ||
1647 | { | ||
1648 | get | ||
1649 | { | ||
1650 | byte pst = PhysicsShapeType; | ||
1651 | if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh()) | ||
1652 | return true; | ||
1653 | return false; | ||
1654 | } | ||
1655 | } | ||
1656 | |||
1657 | [XmlIgnore] | ||
1658 | public float PhysicsCost | ||
1659 | { | ||
1660 | get | ||
1661 | { | ||
1662 | if(PhysicsShapeType == (byte)PhysShapeType.none) | ||
1663 | return 0; | ||
1664 | |||
1665 | float cost = 0.1f; | ||
1666 | if (PhysActor != null) | ||
1667 | cost = PhysActor.PhysicsCost; | ||
1668 | else | ||
1669 | cost = 0.1f; | ||
1670 | |||
1671 | if ((Flags & PrimFlags.Physics) != 0) | ||
1672 | cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 | ||
1673 | return cost; | ||
1674 | } | ||
1675 | } | ||
1676 | |||
1677 | [XmlIgnore] | ||
1678 | public float StreamingCost | ||
1679 | { | ||
1680 | get | ||
1681 | { | ||
1682 | float cost; | ||
1683 | if (PhysActor != null) | ||
1684 | cost = PhysActor.StreamCost; | ||
1685 | else | ||
1686 | cost = 1.0f; | ||
1687 | return 1.0f; | ||
1688 | } | ||
1689 | } | ||
1690 | |||
1691 | [XmlIgnore] | ||
1692 | public float SimulationCost | ||
1693 | { | ||
1694 | get | ||
1695 | { | ||
1696 | // ignoring scripts. Don't like considering them for this | ||
1697 | if((Flags & PrimFlags.Physics) != 0) | ||
1698 | return 1.0f; | ||
1699 | |||
1700 | return 0.5f; | ||
1701 | } | ||
1702 | } | ||
1703 | |||
1390 | public byte PhysicsShapeType | 1704 | public byte PhysicsShapeType |
1391 | { | 1705 | { |
1392 | get { return m_physicsShapeType; } | 1706 | get { return m_physicsShapeType; } |
@@ -1420,11 +1734,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1420 | } | 1734 | } |
1421 | else if (PhysActor == null) | 1735 | else if (PhysActor == null) |
1422 | { | 1736 | { |
1423 | ApplyPhysics((uint)Flags, VolumeDetectActive); | 1737 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); |
1738 | UpdatePhysicsSubscribedEvents(); | ||
1424 | } | 1739 | } |
1425 | else | 1740 | else |
1426 | { | 1741 | { |
1427 | PhysActor.PhysicsShapeType = m_physicsShapeType; | 1742 | PhysActor.PhysicsShapeType = m_physicsShapeType; |
1743 | // if (Shape.SculptEntry) | ||
1744 | // CheckSculptAndLoad(); | ||
1428 | } | 1745 | } |
1429 | 1746 | ||
1430 | if (ParentGroup != null) | 1747 | if (ParentGroup != null) |
@@ -1526,6 +1843,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1526 | } | 1843 | } |
1527 | } | 1844 | } |
1528 | 1845 | ||
1846 | |||
1529 | #endregion Public Properties with only Get | 1847 | #endregion Public Properties with only Get |
1530 | 1848 | ||
1531 | private uint ApplyMask(uint val, bool set, uint mask) | 1849 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1614,6 +1932,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1614 | 1932 | ||
1615 | public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim) | 1933 | public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim) |
1616 | { | 1934 | { |
1935 | <<<<<<< HEAD | ||
1617 | byte[] data; | 1936 | byte[] data; |
1618 | 1937 | ||
1619 | if (pTexAnim.Flags == Primitive.TextureAnimMode.ANIM_OFF) | 1938 | if (pTexAnim.Flags == Primitive.TextureAnimMode.ANIM_OFF) |
@@ -1625,6 +1944,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1625 | data = new byte[16]; | 1944 | data = new byte[16]; |
1626 | int pos = 0; | 1945 | int pos = 0; |
1627 | 1946 | ||
1947 | ======= | ||
1948 | if (((int)pTexAnim.Flags & 1) != 0) // ANIM_ON | ||
1949 | { | ||
1950 | byte[] data = new byte[16]; | ||
1951 | int pos = 0; | ||
1952 | |||
1953 | >>>>>>> avn/ubitvar | ||
1628 | // The flags don't like conversion from uint to byte, so we have to do | 1954 | // The flags don't like conversion from uint to byte, so we have to do |
1629 | // it the crappy way. See the above function :( | 1955 | // it the crappy way. See the above function :( |
1630 | 1956 | ||
@@ -1636,9 +1962,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1636 | Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); | 1962 | Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); |
1637 | Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4); | 1963 | Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4); |
1638 | Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); | 1964 | Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); |
1965 | <<<<<<< HEAD | ||
1639 | } | 1966 | } |
1967 | ======= | ||
1968 | >>>>>>> avn/ubitvar | ||
1640 | 1969 | ||
1641 | m_TextureAnimation = data; | 1970 | m_TextureAnimation = data; |
1971 | } | ||
1972 | else | ||
1973 | { | ||
1974 | m_TextureAnimation = Utils.EmptyBytes; | ||
1975 | } | ||
1642 | } | 1976 | } |
1643 | 1977 | ||
1644 | public void AdjustSoundGain(double volume) | 1978 | public void AdjustSoundGain(double volume) |
@@ -1680,6 +2014,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1680 | } | 2014 | } |
1681 | } | 2015 | } |
1682 | 2016 | ||
2017 | // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future | ||
2018 | public void SetVelocity(Vector3 pVel, bool localGlobalTF) | ||
2019 | { | ||
2020 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
2021 | return; | ||
2022 | |||
2023 | if (ParentGroup.IsAttachment) | ||
2024 | return; // don't work on attachments (for now ??) | ||
2025 | |||
2026 | SceneObjectPart root = ParentGroup.RootPart; | ||
2027 | |||
2028 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
2029 | return; | ||
2030 | |||
2031 | PhysicsActor pa = root.PhysActor; | ||
2032 | |||
2033 | if (pa == null || !pa.IsPhysical) | ||
2034 | return; | ||
2035 | |||
2036 | if (localGlobalTF) | ||
2037 | { | ||
2038 | pVel = pVel * GetWorldRotation(); | ||
2039 | } | ||
2040 | |||
2041 | ParentGroup.Velocity = pVel; | ||
2042 | } | ||
2043 | |||
2044 | // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future | ||
2045 | public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF) | ||
2046 | { | ||
2047 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
2048 | return; | ||
2049 | |||
2050 | if (ParentGroup.IsAttachment) | ||
2051 | return; // don't work on attachments (for now ??) | ||
2052 | |||
2053 | SceneObjectPart root = ParentGroup.RootPart; | ||
2054 | |||
2055 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
2056 | return; | ||
2057 | |||
2058 | PhysicsActor pa = root.PhysActor; | ||
2059 | |||
2060 | if (pa == null || !pa.IsPhysical) | ||
2061 | return; | ||
2062 | |||
2063 | if (localGlobalTF) | ||
2064 | { | ||
2065 | pAngVel = pAngVel * GetWorldRotation(); | ||
2066 | } | ||
2067 | |||
2068 | root.AngularVelocity = pAngVel; | ||
2069 | } | ||
2070 | |||
2071 | |||
1683 | /// <summary> | 2072 | /// <summary> |
1684 | /// hook to the physics scene to apply angular impulse | 2073 | /// hook to the physics scene to apply angular impulse |
1685 | /// This is sent up to the group, which then finds the root prim | 2074 | /// This is sent up to the group, which then finds the root prim |
@@ -1700,7 +2089,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1700 | impulse = newimpulse; | 2089 | impulse = newimpulse; |
1701 | } | 2090 | } |
1702 | 2091 | ||
1703 | ParentGroup.applyAngularImpulse(impulse); | 2092 | ParentGroup.ApplyAngularImpulse(impulse); |
1704 | } | 2093 | } |
1705 | 2094 | ||
1706 | /// <summary> | 2095 | /// <summary> |
@@ -1710,20 +2099,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1710 | /// </summary> | 2099 | /// </summary> |
1711 | /// <param name="impulsei">Vector force</param> | 2100 | /// <param name="impulsei">Vector force</param> |
1712 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 2101 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1713 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 2102 | |
2103 | // this is actualy Set Torque.. keeping naming so not to edit lslapi also | ||
2104 | public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF) | ||
1714 | { | 2105 | { |
1715 | Vector3 impulse = impulsei; | 2106 | Vector3 torque = torquei; |
1716 | 2107 | ||
1717 | if (localGlobalTF) | 2108 | if (localGlobalTF) |
1718 | { | 2109 | { |
2110 | /* | ||
1719 | Quaternion grot = GetWorldRotation(); | 2111 | Quaternion grot = GetWorldRotation(); |
1720 | Quaternion AXgrot = grot; | 2112 | Quaternion AXgrot = grot; |
1721 | Vector3 AXimpulsei = impulsei; | 2113 | Vector3 AXimpulsei = impulsei; |
1722 | Vector3 newimpulse = AXimpulsei * AXgrot; | 2114 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1723 | impulse = newimpulse; | 2115 | */ |
2116 | torque *= GetWorldRotation(); | ||
1724 | } | 2117 | } |
1725 | 2118 | ||
1726 | ParentGroup.setAngularImpulse(impulse); | 2119 | Torque = torque; |
1727 | } | 2120 | } |
1728 | 2121 | ||
1729 | /// <summary> | 2122 | /// <summary> |
@@ -1731,7 +2124,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1731 | /// </summary> | 2124 | /// </summary> |
1732 | /// <param name="rootObjectFlags"></param> | 2125 | /// <param name="rootObjectFlags"></param> |
1733 | /// <param name="VolumeDetectActive"></param> | 2126 | /// <param name="VolumeDetectActive"></param> |
1734 | public void ApplyPhysics(uint rootObjectFlags, bool _VolumeDetectActive) | 2127 | /// <param name="building"></param> |
2128 | |||
2129 | public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) | ||
1735 | { | 2130 | { |
1736 | VolumeDetectActive = _VolumeDetectActive; | 2131 | VolumeDetectActive = _VolumeDetectActive; |
1737 | 2132 | ||
@@ -1741,8 +2136,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1741 | if (PhysicsShapeType == (byte)PhysShapeType.none) | 2136 | if (PhysicsShapeType == (byte)PhysShapeType.none) |
1742 | return; | 2137 | return; |
1743 | 2138 | ||
1744 | bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; | 2139 | bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; |
1745 | bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; | 2140 | bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0; |
1746 | 2141 | ||
1747 | if (_VolumeDetectActive) | 2142 | if (_VolumeDetectActive) |
1748 | isPhantom = true; | 2143 | isPhantom = true; |
@@ -1756,7 +2151,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1756 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment | 2151 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment |
1757 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | 2152 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1758 | { | 2153 | { |
1759 | AddToPhysics(isPhysical, isPhantom, isPhysical); | 2154 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
2155 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here | ||
1760 | } | 2156 | } |
1761 | else | 2157 | else |
1762 | PhysActor = null; // just to be sure | 2158 | PhysActor = null; // just to be sure |
@@ -1785,7 +2181,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1785 | /// <param name="linkNum"></param> | 2181 | /// <param name="linkNum"></param> |
1786 | /// <param name="userExposed">True if the duplicate will immediately be in the scene, false otherwise</param> | 2182 | /// <param name="userExposed">True if the duplicate will immediately be in the scene, false otherwise</param> |
1787 | /// <returns></returns> | 2183 | /// <returns></returns> |
1788 | public SceneObjectPart Copy(uint localID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed) | 2184 | public SceneObjectPart Copy(uint plocalID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed) |
1789 | { | 2185 | { |
1790 | // FIXME: This is dangerous since it's easy to forget to reset some references when necessary and end up | 2186 | // FIXME: This is dangerous since it's easy to forget to reset some references when necessary and end up |
1791 | // with bugs that only occur in some circumstances (e.g. crossing between regions on the same simulator | 2187 | // with bugs that only occur in some circumstances (e.g. crossing between regions on the same simulator |
@@ -1815,6 +2211,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1815 | dupe.Category = Category; | 2211 | dupe.Category = Category; |
1816 | dupe.m_rezzed = m_rezzed; | 2212 | dupe.m_rezzed = m_rezzed; |
1817 | 2213 | ||
2214 | dupe.m_UndoRedo = null; | ||
2215 | dupe.m_isSelected = false; | ||
2216 | |||
2217 | dupe.IgnoreUndoUpdate = false; | ||
2218 | dupe.Undoing = false; | ||
2219 | |||
1818 | dupe.m_inventory = new SceneObjectPartInventory(dupe); | 2220 | dupe.m_inventory = new SceneObjectPartInventory(dupe); |
1819 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); | 2221 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); |
1820 | 2222 | ||
@@ -1829,7 +2231,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1829 | } | 2231 | } |
1830 | 2232 | ||
1831 | // Move afterwards ResetIDs as it clears the localID | 2233 | // Move afterwards ResetIDs as it clears the localID |
1832 | dupe.LocalId = localID; | 2234 | dupe.LocalId = plocalID; |
2235 | |||
1833 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. | 2236 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. |
1834 | dupe.LastOwnerID = OwnerID; | 2237 | dupe.LastOwnerID = OwnerID; |
1835 | 2238 | ||
@@ -1856,8 +2259,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1856 | */ | 2259 | */ |
1857 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); | 2260 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); |
1858 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); | 2261 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); |
2262 | // dupe.UpdatePhysicsSubscribedEvents(); // not sure... | ||
1859 | } | 2263 | } |
1860 | 2264 | ||
2265 | if (dupe.PhysActor != null) | ||
2266 | dupe.PhysActor.LocalID = plocalID; | ||
2267 | |||
1861 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); | 2268 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); |
1862 | 2269 | ||
1863 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); | 2270 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); |
@@ -1876,10 +2283,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1876 | { | 2283 | { |
1877 | if (asset != null) | 2284 | if (asset != null) |
1878 | SculptTextureCallback(asset); | 2285 | SculptTextureCallback(asset); |
1879 | else | 2286 | // else |
1880 | m_log.WarnFormat( | 2287 | // m_log.WarnFormat( |
1881 | "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", | 2288 | // "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", |
1882 | Name, UUID, id); | 2289 | // Name, UUID, id); |
1883 | } | 2290 | } |
1884 | */ | 2291 | */ |
1885 | /// <summary> | 2292 | /// <summary> |
@@ -1978,6 +2385,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1978 | 2385 | ||
1979 | /// <summary> | 2386 | /// <summary> |
1980 | /// Do a physics propery update for this part. | 2387 | /// Do a physics propery update for this part. |
2388 | /// now also updates phantom and volume detector | ||
1981 | /// </summary> | 2389 | /// </summary> |
1982 | /// <param name="UsePhysics"></param> | 2390 | /// <param name="UsePhysics"></param> |
1983 | /// <param name="isNew"></param> | 2391 | /// <param name="isNew"></param> |
@@ -2003,64 +2411,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
2003 | { | 2411 | { |
2004 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 2412 | if (pa.IsPhysical) // implies UsePhysics==false for this block |
2005 | { | 2413 | { |
2006 | if (!isNew) | 2414 | if (!isNew) // implies UsePhysics==false for this block |
2415 | { | ||
2007 | ParentGroup.Scene.RemovePhysicalPrim(1); | 2416 | ParentGroup.Scene.RemovePhysicalPrim(1); |
2008 | 2417 | ||
2009 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 2418 | Velocity = new Vector3(0, 0, 0); |
2010 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 2419 | Acceleration = new Vector3(0, 0, 0); |
2011 | pa.delink(); | 2420 | if (ParentGroup.RootPart == this) |
2421 | AngularVelocity = new Vector3(0, 0, 0); | ||
2012 | 2422 | ||
2013 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 2423 | if (pa.Phantom && !VolumeDetectActive) |
2014 | { | 2424 | { |
2015 | // destroy all joints connected to this now deactivated body | 2425 | RemoveFromPhysics(); |
2016 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 2426 | return; |
2017 | } | 2427 | } |
2018 | 2428 | ||
2019 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 2429 | pa.IsPhysical = UsePhysics; |
2020 | // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, | 2430 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
2021 | // which stops client-side interpolation of deactivated joint proxy objects. | 2431 | pa.OnOutOfBounds -= PhysicsOutOfBounds; |
2432 | pa.delink(); | ||
2433 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | ||
2434 | { | ||
2435 | // destroy all joints connected to this now deactivated body | ||
2436 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | ||
2437 | } | ||
2438 | } | ||
2022 | } | 2439 | } |
2023 | 2440 | ||
2024 | if (!UsePhysics && !isNew) | 2441 | if (pa.IsPhysical != UsePhysics) |
2025 | { | 2442 | pa.IsPhysical = UsePhysics; |
2026 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the | ||
2027 | // prim still has velocity and continues to interpolate its position along the old | ||
2028 | // velocity-vector. | ||
2029 | Velocity = new Vector3(0, 0, 0); | ||
2030 | Acceleration = new Vector3(0, 0, 0); | ||
2031 | AngularVelocity = new Vector3(0, 0, 0); | ||
2032 | //RotationalVelocity = new Vector3(0, 0, 0); | ||
2033 | } | ||
2034 | 2443 | ||
2035 | pa.IsPhysical = UsePhysics; | 2444 | if (UsePhysics) |
2445 | { | ||
2446 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
2447 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2448 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2449 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
2036 | 2450 | ||
2037 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 2451 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
2038 | //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 2452 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
2039 | /// that's not wholesome. Had to make Scene public | ||
2040 | //PhysActor = null; | ||
2041 | 2453 | ||
2042 | if ((Flags & PrimFlags.Phantom) == 0) | 2454 | if (ParentID != 0 && ParentID != LocalId) |
2043 | { | ||
2044 | if (UsePhysics) | ||
2045 | { | 2455 | { |
2046 | if (ParentGroup.RootPart.KeyframeMotion != null) | 2456 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
2047 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2048 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2049 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
2050 | |||
2051 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
2052 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
2053 | if (ParentID != 0 && ParentID != LocalId) | ||
2054 | { | ||
2055 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
2056 | 2457 | ||
2057 | if (parentPa != null) | 2458 | if (parentPa != null) |
2058 | { | 2459 | { |
2059 | pa.link(parentPa); | 2460 | pa.link(parentPa); |
2060 | } | ||
2061 | } | 2461 | } |
2062 | } | 2462 | } |
2063 | } | 2463 | } |
2464 | } | ||
2465 | |||
2466 | bool phan = ((Flags & PrimFlags.Phantom) != 0); | ||
2467 | if (pa.Phantom != phan) | ||
2468 | pa.Phantom = phan; | ||
2469 | |||
2470 | // some engines dont' have this check still | ||
2471 | // if (VolumeDetectActive != pa.IsVolumeDtc) | ||
2472 | { | ||
2473 | if (VolumeDetectActive) | ||
2474 | pa.SetVolumeDetect(1); | ||
2475 | else | ||
2476 | pa.SetVolumeDetect(0); | ||
2064 | } | 2477 | } |
2065 | 2478 | ||
2066 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the | 2479 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the |
@@ -2163,42 +2576,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
2163 | 2576 | ||
2164 | public Vector3 GetGeometricCenter() | 2577 | public Vector3 GetGeometricCenter() |
2165 | { | 2578 | { |
2579 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
2580 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
2581 | // ignoring tortured prims details since sl also seems to ignore | ||
2582 | // so no real use in doing it on physics | ||
2583 | if (ParentGroup.IsDeleted) | ||
2584 | return new Vector3(0, 0, 0); | ||
2585 | |||
2586 | return ParentGroup.GetGeometricCenter(); | ||
2587 | } | ||
2588 | |||
2589 | public float GetMass() | ||
2590 | { | ||
2166 | PhysicsActor pa = PhysActor; | 2591 | PhysicsActor pa = PhysActor; |
2167 | 2592 | ||
2168 | if (pa != null) | 2593 | if (pa != null) |
2169 | return pa.GeometricCenter; | 2594 | return pa.Mass; |
2170 | else | 2595 | else |
2171 | return Vector3.Zero; | 2596 | return 0; |
2172 | } | 2597 | } |
2173 | 2598 | ||
2174 | public Vector3 GetCenterOfMass() | 2599 | public Vector3 GetCenterOfMass() |
2175 | { | 2600 | { |
2601 | if (ParentGroup.RootPart == this) | ||
2602 | { | ||
2603 | if (ParentGroup.IsDeleted) | ||
2604 | return AbsolutePosition; | ||
2605 | return ParentGroup.GetCenterOfMass(); | ||
2606 | } | ||
2607 | |||
2176 | PhysicsActor pa = PhysActor; | 2608 | PhysicsActor pa = PhysActor; |
2177 | 2609 | ||
2178 | if (pa != null) | 2610 | if (pa != null) |
2179 | return pa.CenterOfMass; | 2611 | { |
2612 | Vector3 tmp = pa.CenterOfMass; | ||
2613 | return tmp; | ||
2614 | } | ||
2180 | else | 2615 | else |
2181 | return Vector3.Zero; | 2616 | return AbsolutePosition; |
2182 | } | 2617 | } |
2183 | 2618 | ||
2184 | public float GetMass() | 2619 | public Vector3 GetPartCenterOfMass() |
2185 | { | 2620 | { |
2186 | PhysicsActor pa = PhysActor; | 2621 | PhysicsActor pa = PhysActor; |
2187 | 2622 | ||
2188 | if (pa != null) | 2623 | if (pa != null) |
2189 | return pa.Mass; | 2624 | { |
2625 | Vector3 tmp = pa.CenterOfMass; | ||
2626 | return tmp; | ||
2627 | } | ||
2190 | else | 2628 | else |
2191 | return 0; | 2629 | return AbsolutePosition; |
2192 | } | 2630 | } |
2193 | 2631 | ||
2632 | |||
2194 | public Vector3 GetForce() | 2633 | public Vector3 GetForce() |
2195 | { | 2634 | { |
2196 | PhysicsActor pa = PhysActor; | 2635 | return Force; |
2197 | |||
2198 | if (pa != null) | ||
2199 | return pa.Force; | ||
2200 | else | ||
2201 | return Vector3.Zero; | ||
2202 | } | 2636 | } |
2203 | 2637 | ||
2204 | /// <summary> | 2638 | /// <summary> |
@@ -2313,6 +2747,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2313 | detobj.velVector = obj.Velocity; | 2747 | detobj.velVector = obj.Velocity; |
2314 | detobj.colliderType = 0; | 2748 | detobj.colliderType = 0; |
2315 | detobj.groupUUID = obj.GroupID; | 2749 | detobj.groupUUID = obj.GroupID; |
2750 | detobj.linkNumber = LinkNum; // pass my link number | ||
2316 | 2751 | ||
2317 | return detobj; | 2752 | return detobj; |
2318 | } | 2753 | } |
@@ -2328,6 +2763,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2328 | detobj.velVector = av.Velocity; | 2763 | detobj.velVector = av.Velocity; |
2329 | detobj.colliderType = 0; | 2764 | detobj.colliderType = 0; |
2330 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | 2765 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; |
2766 | detobj.linkNumber = LinkNum; // pass my link number | ||
2331 | 2767 | ||
2332 | return detobj; | 2768 | return detobj; |
2333 | } | 2769 | } |
@@ -2343,6 +2779,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2343 | detobj.velVector = Vector3.Zero; | 2779 | detobj.velVector = Vector3.Zero; |
2344 | detobj.colliderType = 0; | 2780 | detobj.colliderType = 0; |
2345 | detobj.groupUUID = UUID.Zero; | 2781 | detobj.groupUUID = UUID.Zero; |
2782 | detobj.linkNumber = LinkNum; // pass my link number not sure needed.. but no harm | ||
2346 | 2783 | ||
2347 | return detobj; | 2784 | return detobj; |
2348 | } | 2785 | } |
@@ -2413,14 +2850,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2413 | 2850 | ||
2414 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) | 2851 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) |
2415 | { | 2852 | { |
2416 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) | 2853 | bool sendToRoot = true; |
2417 | { | ||
2418 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2419 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2420 | |||
2421 | colliding.Add(CreateDetObjectForGround()); | ||
2422 | LandCollidingMessage.Colliders = colliding; | ||
2423 | 2854 | ||
2855 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2856 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2857 | |||
2858 | colliding.Add(CreateDetObjectForGround()); | ||
2859 | LandCollidingMessage.Colliders = colliding; | ||
2860 | |||
2861 | <<<<<<< HEAD | ||
2424 | DoNotify(notify, LocalId, LandCollidingMessage); | 2862 | DoNotify(notify, LocalId, LandCollidingMessage); |
2425 | } | 2863 | } |
2426 | } | 2864 | } |
@@ -2448,6 +2886,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2448 | else | 2886 | else |
2449 | { | 2887 | { |
2450 | notify(id, collargs); | 2888 | notify(id, collargs); |
2889 | ======= | ||
2890 | if (Inventory.ContainsScripts()) | ||
2891 | { | ||
2892 | if (!PassCollisions) | ||
2893 | sendToRoot = false; | ||
2894 | } | ||
2895 | if ((ScriptEvents & ev) != 0) | ||
2896 | notify(LocalId, LandCollidingMessage); | ||
2897 | |||
2898 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) | ||
2899 | { | ||
2900 | notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); | ||
2901 | >>>>>>> avn/ubitvar | ||
2451 | } | 2902 | } |
2452 | } | 2903 | } |
2453 | 2904 | ||
@@ -2463,44 +2914,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
2463 | List<uint> endedColliders = new List<uint>(); | 2914 | List<uint> endedColliders = new List<uint>(); |
2464 | List<uint> startedColliders = new List<uint>(); | 2915 | List<uint> startedColliders = new List<uint>(); |
2465 | 2916 | ||
2466 | // calculate things that started colliding this time | 2917 | if (collissionswith.Count == 0) |
2467 | // and build up list of colliders this time | ||
2468 | foreach (uint localid in collissionswith.Keys) | ||
2469 | { | 2918 | { |
2470 | thisHitColliders.Add(localid); | 2919 | if (m_lastColliders.Count == 0) |
2471 | if (!m_lastColliders.Contains(localid)) | 2920 | return; // nothing to do |
2472 | startedColliders.Add(localid); | ||
2473 | } | ||
2474 | 2921 | ||
2475 | // calculate things that ended colliding | 2922 | foreach (uint localID in m_lastColliders) |
2476 | foreach (uint localID in m_lastColliders) | 2923 | { |
2477 | { | ||
2478 | if (!thisHitColliders.Contains(localID)) | ||
2479 | endedColliders.Add(localID); | 2924 | endedColliders.Add(localID); |
2925 | } | ||
2926 | m_lastColliders.Clear(); | ||
2480 | } | 2927 | } |
2481 | 2928 | ||
2482 | //add the items that started colliding this time to the last colliders list. | 2929 | else |
2483 | foreach (uint localID in startedColliders) | 2930 | { |
2484 | m_lastColliders.Add(localID); | 2931 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); |
2485 | 2932 | ||
2486 | // remove things that ended colliding from the last colliders list | 2933 | // calculate things that started colliding this time |
2487 | foreach (uint localID in endedColliders) | 2934 | // and build up list of colliders this time |
2488 | m_lastColliders.Remove(localID); | 2935 | if (!VolumeDetectActive && CollisionSoundType >= 0) |
2936 | { | ||
2937 | CollisionForSoundInfo soundinfo; | ||
2938 | ContactPoint curcontact; | ||
2489 | 2939 | ||
2490 | // play the sound. | 2940 | foreach (uint id in collissionswith.Keys) |
2491 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2941 | { |
2492 | { | 2942 | thisHitColliders.Add(id); |
2493 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | 2943 | if (!m_lastColliders.Contains(id)) |
2494 | if (soundModule != null) | 2944 | { |
2945 | startedColliders.Add(id); | ||
2946 | |||
2947 | curcontact = collissionswith[id]; | ||
2948 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2949 | { | ||
2950 | soundinfo = new CollisionForSoundInfo(); | ||
2951 | soundinfo.colliderID = id; | ||
2952 | soundinfo.position = curcontact.Position; | ||
2953 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2954 | soundinfolist.Add(soundinfo); | ||
2955 | } | ||
2956 | } | ||
2957 | } | ||
2958 | } | ||
2959 | else | ||
2960 | { | ||
2961 | foreach (uint id in collissionswith.Keys) | ||
2962 | { | ||
2963 | thisHitColliders.Add(id); | ||
2964 | if (!m_lastColliders.Contains(id)) | ||
2965 | startedColliders.Add(id); | ||
2966 | } | ||
2967 | } | ||
2968 | |||
2969 | // calculate things that ended colliding | ||
2970 | foreach (uint localID in m_lastColliders) | ||
2495 | { | 2971 | { |
2496 | soundModule.SendSound(UUID, CollisionSound, | 2972 | if (!thisHitColliders.Contains(localID)) |
2497 | CollisionSoundVolume, true, 0, 0, false, | 2973 | endedColliders.Add(localID); |
2498 | false); | ||
2499 | } | 2974 | } |
2975 | |||
2976 | //add the items that started colliding this time to the last colliders list. | ||
2977 | foreach (uint localID in startedColliders) | ||
2978 | m_lastColliders.Add(localID); | ||
2979 | |||
2980 | // remove things that ended colliding from the last colliders list | ||
2981 | foreach (uint localID in endedColliders) | ||
2982 | m_lastColliders.Remove(localID); | ||
2983 | |||
2984 | // play sounds. | ||
2985 | if (soundinfolist.Count > 0) | ||
2986 | CollisionSounds.PartCollisionSound(this, soundinfolist); | ||
2500 | } | 2987 | } |
2501 | 2988 | ||
2502 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2989 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2503 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2990 | if (!VolumeDetectActive) |
2991 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2504 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2992 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2505 | 2993 | ||
2506 | if (startedColliders.Contains(0)) | 2994 | if (startedColliders.Contains(0)) |
@@ -2511,6 +2999,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
2511 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2999 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2512 | } | 3000 | } |
2513 | 3001 | ||
3002 | // The Collision sounds code calls this | ||
3003 | public void SendCollisionSound(UUID soundID, double volume, Vector3 position) | ||
3004 | { | ||
3005 | if (soundID == UUID.Zero) | ||
3006 | return; | ||
3007 | |||
3008 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
3009 | if (soundModule == null) | ||
3010 | return; | ||
3011 | |||
3012 | if (volume > 1) | ||
3013 | volume = 1; | ||
3014 | if (volume < 0) | ||
3015 | volume = 0; | ||
3016 | |||
3017 | int now = Util.EnvironmentTickCount(); | ||
3018 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) | ||
3019 | return; | ||
3020 | |||
3021 | LastColSoundSentTime = now; | ||
3022 | |||
3023 | UUID ownerID = OwnerID; | ||
3024 | UUID objectID = ParentGroup.RootPart.UUID; | ||
3025 | UUID parentID = ParentGroup.UUID; | ||
3026 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
3027 | |||
3028 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); | ||
3029 | } | ||
3030 | |||
2514 | public void PhysicsOutOfBounds(Vector3 pos) | 3031 | public void PhysicsOutOfBounds(Vector3 pos) |
2515 | { | 3032 | { |
2516 | // Note: This is only being called on the root prim at this time. | 3033 | // Note: This is only being called on the root prim at this time. |
@@ -2529,7 +3046,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2529 | 3046 | ||
2530 | if (pa != null) | 3047 | if (pa != null) |
2531 | { | 3048 | { |
3049 | <<<<<<< HEAD | ||
2532 | Vector3 newpos = pa.Position; | 3050 | Vector3 newpos = pa.Position; |
3051 | ======= | ||
3052 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | ||
3053 | |||
3054 | >>>>>>> avn/ubitvar | ||
2533 | if (!ParentGroup.Scene.PositionIsInCurrentRegion(newpos)) | 3055 | if (!ParentGroup.Scene.PositionIsInCurrentRegion(newpos)) |
2534 | { | 3056 | { |
2535 | // Setting position outside current region will start region crossing | 3057 | // Setting position outside current region will start region crossing |
@@ -2538,7 +3060,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2538 | } | 3060 | } |
2539 | //ParentGroup.RootPart.m_groupPosition = newpos; | 3061 | //ParentGroup.RootPart.m_groupPosition = newpos; |
2540 | } | 3062 | } |
2541 | 3063 | /* ubit: there are no flexible links | |
2542 | if (pa != null && ParentID != 0 && ParentGroup != null) | 3064 | if (pa != null && ParentID != 0 && ParentGroup != null) |
2543 | { | 3065 | { |
2544 | // Special case where a child object is requesting property updates. | 3066 | // Special case where a child object is requesting property updates. |
@@ -2558,7 +3080,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2558 | // m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}", | 3080 | // m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}", |
2559 | // "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset); | 3081 | // "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset); |
2560 | } | 3082 | } |
2561 | 3083 | */ | |
2562 | ScheduleTerseUpdate(); | 3084 | ScheduleTerseUpdate(); |
2563 | } | 3085 | } |
2564 | 3086 | ||
@@ -2811,7 +3333,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2811 | 3333 | ||
2812 | // m_log.DebugFormat( | 3334 | // m_log.DebugFormat( |
2813 | // "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); | 3335 | // "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); |
2814 | 3336 | ||
3337 | |||
3338 | if (ParentGroup.IsAttachment) | ||
3339 | { | ||
3340 | ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); | ||
3341 | if (sp != null) | ||
3342 | { | ||
3343 | sp.SendAttachmentUpdate(this, UpdateRequired.FULL); | ||
3344 | } | ||
3345 | } | ||
3346 | |||
3347 | /* this does nothing | ||
3348 | SendFullUpdateToClient(remoteClient, Position) ignores position parameter | ||
2815 | if (IsRoot) | 3349 | if (IsRoot) |
2816 | { | 3350 | { |
2817 | if (ParentGroup.IsAttachment) | 3351 | if (ParentGroup.IsAttachment) |
@@ -2823,6 +3357,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2823 | SendFullUpdateToClient(remoteClient, AbsolutePosition); | 3357 | SendFullUpdateToClient(remoteClient, AbsolutePosition); |
2824 | } | 3358 | } |
2825 | } | 3359 | } |
3360 | */ | ||
2826 | else | 3361 | else |
2827 | { | 3362 | { |
2828 | SendFullUpdateToClient(remoteClient); | 3363 | SendFullUpdateToClient(remoteClient); |
@@ -2832,17 +3367,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
2832 | /// <summary> | 3367 | /// <summary> |
2833 | /// Send a full update for this part to all clients. | 3368 | /// Send a full update for this part to all clients. |
2834 | /// </summary> | 3369 | /// </summary> |
2835 | public void SendFullUpdateToAllClients() | 3370 | public void SendFullUpdateToAllClientsInternal() |
2836 | { | 3371 | { |
2837 | if (ParentGroup == null) | 3372 | if (ParentGroup == null) |
2838 | return; | 3373 | return; |
2839 | 3374 | ||
3375 | // Update the "last" values | ||
3376 | m_lastPosition = OffsetPosition; | ||
3377 | m_lastRotation = RotationOffset; | ||
3378 | m_lastVelocity = Velocity; | ||
3379 | m_lastAcceleration = Acceleration; | ||
3380 | m_lastAngularVelocity = AngularVelocity; | ||
3381 | m_lastUpdateSentTime = Environment.TickCount; | ||
3382 | |||
2840 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 3383 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2841 | { | 3384 | { |
2842 | SendFullUpdate(avatar.ControllingClient); | 3385 | SendFullUpdate(avatar.ControllingClient); |
2843 | }); | 3386 | }); |
2844 | } | 3387 | } |
2845 | 3388 | ||
3389 | public void SendFullUpdateToAllClients() | ||
3390 | { | ||
3391 | if (ParentGroup == null) | ||
3392 | return; | ||
3393 | |||
3394 | // Update the "last" values | ||
3395 | m_lastPosition = OffsetPosition; | ||
3396 | m_lastRotation = RotationOffset; | ||
3397 | m_lastVelocity = Velocity; | ||
3398 | m_lastAcceleration = Acceleration; | ||
3399 | m_lastAngularVelocity = AngularVelocity; | ||
3400 | m_lastUpdateSentTime = Environment.TickCount; | ||
3401 | |||
3402 | if (ParentGroup.IsAttachment) | ||
3403 | { | ||
3404 | ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); | ||
3405 | if (sp != null) | ||
3406 | { | ||
3407 | sp.SendAttachmentUpdate(this, UpdateRequired.FULL); | ||
3408 | } | ||
3409 | } | ||
3410 | else | ||
3411 | { | ||
3412 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | ||
3413 | { | ||
3414 | SendFullUpdate(avatar.ControllingClient); | ||
3415 | }); | ||
3416 | } | ||
3417 | } | ||
3418 | |||
2846 | /// <summary> | 3419 | /// <summary> |
2847 | /// Sends a full update to the client | 3420 | /// Sends a full update to the client |
2848 | /// </summary> | 3421 | /// </summary> |
@@ -2863,9 +3436,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2863 | return; | 3436 | return; |
2864 | 3437 | ||
2865 | // Suppress full updates during attachment editing | 3438 | // Suppress full updates during attachment editing |
2866 | // | 3439 | // sl Does send them |
2867 | if (ParentGroup.IsSelected && ParentGroup.IsAttachment) | 3440 | // if (ParentGroup.IsSelected && ParentGroup.IsAttachment) |
2868 | return; | 3441 | // return; |
2869 | 3442 | ||
2870 | if (ParentGroup.IsDeleted) | 3443 | if (ParentGroup.IsDeleted) |
2871 | return; | 3444 | return; |
@@ -2895,8 +3468,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2895 | { | 3468 | { |
2896 | const float ROTATION_TOLERANCE = 0.01f; | 3469 | const float ROTATION_TOLERANCE = 0.01f; |
2897 | const float VELOCITY_TOLERANCE = 0.001f; | 3470 | const float VELOCITY_TOLERANCE = 0.001f; |
2898 | const float POSITION_TOLERANCE = 0.05f; | 3471 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2899 | const int TIME_MS_TOLERANCE = 3000; | 3472 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2900 | 3473 | ||
2901 | switch (UpdateFlag) | 3474 | switch (UpdateFlag) |
2902 | { | 3475 | { |
@@ -2910,40 +3483,74 @@ namespace OpenSim.Region.Framework.Scenes | |||
2910 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || | 3483 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || |
2911 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || | 3484 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || |
2912 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 3485 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
2913 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 3486 | Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) |
2914 | { | 3487 | { |
2915 | SendTerseUpdateToAllClients(); | 3488 | SendTerseUpdateToAllClientsInternal(); |
2916 | |||
2917 | // Update the "last" values | ||
2918 | m_lastPosition = OffsetPosition; | ||
2919 | m_lastRotation = RotationOffset; | ||
2920 | m_lastVelocity = Velocity; | ||
2921 | m_lastAcceleration = Acceleration; | ||
2922 | m_lastAngularVelocity = AngularVelocity; | ||
2923 | m_lastTerseSent = Environment.TickCount; | ||
2924 | } | 3489 | } |
2925 | break; | 3490 | break; |
2926 | } | 3491 | } |
2927 | case UpdateRequired.FULL: | 3492 | case UpdateRequired.FULL: |
2928 | { | 3493 | { |
2929 | ClearUpdateSchedule(); | 3494 | ClearUpdateSchedule(); |
2930 | SendFullUpdateToAllClients(); | 3495 | SendFullUpdateToAllClientsInternal(); |
2931 | break; | 3496 | break; |
2932 | } | 3497 | } |
2933 | } | 3498 | } |
2934 | } | 3499 | } |
2935 | 3500 | ||
3501 | |||
2936 | /// <summary> | 3502 | /// <summary> |
2937 | /// Send a terse update to all clients | 3503 | /// Send a terse update to all clients |
2938 | /// </summary> | 3504 | /// </summary> |
2939 | public void SendTerseUpdateToAllClients() | 3505 | public void SendTerseUpdateToAllClientsInternal() |
2940 | { | 3506 | { |
3507 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3508 | return; | ||
3509 | |||
3510 | // Update the "last" values | ||
3511 | m_lastPosition = OffsetPosition; | ||
3512 | m_lastRotation = RotationOffset; | ||
3513 | m_lastVelocity = Velocity; | ||
3514 | m_lastAcceleration = Acceleration; | ||
3515 | m_lastAngularVelocity = AngularVelocity; | ||
3516 | m_lastUpdateSentTime = Environment.TickCount; | ||
3517 | |||
2941 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3518 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
2942 | { | 3519 | { |
2943 | SendTerseUpdateToClient(client); | 3520 | SendTerseUpdateToClient(client); |
2944 | }); | 3521 | }); |
2945 | } | 3522 | } |
2946 | 3523 | ||
3524 | public void SendTerseUpdateToAllClients() | ||
3525 | { | ||
3526 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3527 | return; | ||
3528 | |||
3529 | // Update the "last" values | ||
3530 | m_lastPosition = OffsetPosition; | ||
3531 | m_lastRotation = RotationOffset; | ||
3532 | m_lastVelocity = Velocity; | ||
3533 | m_lastAcceleration = Acceleration; | ||
3534 | m_lastAngularVelocity = AngularVelocity; | ||
3535 | m_lastUpdateSentTime = Environment.TickCount; | ||
3536 | |||
3537 | if (ParentGroup.IsAttachment) | ||
3538 | { | ||
3539 | ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); | ||
3540 | if (sp != null) | ||
3541 | { | ||
3542 | sp.SendAttachmentUpdate(this, UpdateRequired.TERSE); | ||
3543 | } | ||
3544 | } | ||
3545 | else | ||
3546 | { | ||
3547 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | ||
3548 | { | ||
3549 | SendTerseUpdateToClient(client); | ||
3550 | }); | ||
3551 | } | ||
3552 | } | ||
3553 | |||
2947 | public void SetAxisRotation(int axis, int rotate) | 3554 | public void SetAxisRotation(int axis, int rotate) |
2948 | { | 3555 | { |
2949 | ParentGroup.SetAxisRotation(axis, rotate); | 3556 | ParentGroup.SetAxisRotation(axis, rotate); |
@@ -2961,10 +3568,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2961 | 3568 | ||
2962 | public void SetBuoyancy(float fvalue) | 3569 | public void SetBuoyancy(float fvalue) |
2963 | { | 3570 | { |
2964 | PhysicsActor pa = PhysActor; | 3571 | Buoyancy = fvalue; |
2965 | 3572 | /* | |
2966 | if (pa != null) | 3573 | if (PhysActor != null) |
2967 | pa.Buoyancy = fvalue; | 3574 | { |
3575 | PhysActor.Buoyancy = fvalue; | ||
3576 | } | ||
3577 | */ | ||
2968 | } | 3578 | } |
2969 | 3579 | ||
2970 | public void SetDieAtEdge(bool p) | 3580 | public void SetDieAtEdge(bool p) |
@@ -2980,47 +3590,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2980 | PhysicsActor pa = PhysActor; | 3590 | PhysicsActor pa = PhysActor; |
2981 | 3591 | ||
2982 | if (pa != null) | 3592 | if (pa != null) |
2983 | pa.FloatOnWater = floatYN == 1; | 3593 | pa.FloatOnWater = (floatYN == 1); |
2984 | } | 3594 | } |
2985 | 3595 | ||
2986 | public void SetForce(Vector3 force) | 3596 | public void SetForce(Vector3 force) |
2987 | { | 3597 | { |
2988 | PhysicsActor pa = PhysActor; | 3598 | Force = force; |
3599 | } | ||
2989 | 3600 | ||
2990 | if (pa != null) | 3601 | public SOPVehicle VehicleParams |
2991 | pa.Force = force; | 3602 | { |
3603 | get | ||
3604 | { | ||
3605 | return m_vehicleParams; | ||
3606 | } | ||
3607 | set | ||
3608 | { | ||
3609 | m_vehicleParams = value; | ||
3610 | } | ||
3611 | } | ||
3612 | |||
3613 | |||
3614 | public int VehicleType | ||
3615 | { | ||
3616 | get | ||
3617 | { | ||
3618 | if (m_vehicleParams == null) | ||
3619 | return (int)Vehicle.TYPE_NONE; | ||
3620 | else | ||
3621 | return (int)m_vehicleParams.Type; | ||
3622 | } | ||
3623 | set | ||
3624 | { | ||
3625 | SetVehicleType(value); | ||
3626 | } | ||
2992 | } | 3627 | } |
2993 | 3628 | ||
2994 | public void SetVehicleType(int type) | 3629 | public void SetVehicleType(int type) |
2995 | { | 3630 | { |
2996 | PhysicsActor pa = PhysActor; | 3631 | m_vehicleParams = null; |
3632 | |||
3633 | if (type == (int)Vehicle.TYPE_NONE) | ||
3634 | { | ||
3635 | if (_parentID ==0 && PhysActor != null) | ||
3636 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | ||
3637 | return; | ||
3638 | } | ||
3639 | m_vehicleParams = new SOPVehicle(); | ||
3640 | m_vehicleParams.ProcessTypeChange((Vehicle)type); | ||
3641 | { | ||
3642 | if (_parentID ==0 && PhysActor != null) | ||
3643 | PhysActor.VehicleType = type; | ||
3644 | return; | ||
3645 | } | ||
3646 | } | ||
2997 | 3647 | ||
2998 | if (pa != null) | 3648 | public void SetVehicleFlags(int param, bool remove) |
2999 | pa.VehicleType = type; | 3649 | { |
3650 | if (m_vehicleParams == null) | ||
3651 | return; | ||
3652 | |||
3653 | m_vehicleParams.ProcessVehicleFlags(param, remove); | ||
3654 | |||
3655 | if (_parentID ==0 && PhysActor != null) | ||
3656 | { | ||
3657 | PhysActor.VehicleFlags(param, remove); | ||
3658 | } | ||
3000 | } | 3659 | } |
3001 | 3660 | ||
3002 | public void SetVehicleFloatParam(int param, float value) | 3661 | public void SetVehicleFloatParam(int param, float value) |
3003 | { | 3662 | { |
3004 | PhysicsActor pa = PhysActor; | 3663 | if (m_vehicleParams == null) |
3664 | return; | ||
3005 | 3665 | ||
3006 | if (pa != null) | 3666 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
3007 | pa.VehicleFloatParam(param, value); | 3667 | |
3668 | if (_parentID == 0 && PhysActor != null) | ||
3669 | { | ||
3670 | PhysActor.VehicleFloatParam(param, value); | ||
3671 | } | ||
3008 | } | 3672 | } |
3009 | 3673 | ||
3010 | public void SetVehicleVectorParam(int param, Vector3 value) | 3674 | public void SetVehicleVectorParam(int param, Vector3 value) |
3011 | { | 3675 | { |
3012 | PhysicsActor pa = PhysActor; | 3676 | if (m_vehicleParams == null) |
3677 | return; | ||
3013 | 3678 | ||
3014 | if (pa != null) | 3679 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
3015 | pa.VehicleVectorParam(param, value); | 3680 | |
3681 | if (_parentID == 0 && PhysActor != null) | ||
3682 | { | ||
3683 | PhysActor.VehicleVectorParam(param, value); | ||
3684 | } | ||
3016 | } | 3685 | } |
3017 | 3686 | ||
3018 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3687 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
3019 | { | 3688 | { |
3020 | PhysicsActor pa = PhysActor; | 3689 | if (m_vehicleParams == null) |
3690 | return; | ||
3021 | 3691 | ||
3022 | if (pa != null) | 3692 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
3023 | pa.VehicleRotationParam(param, rotation); | 3693 | |
3694 | if (_parentID == 0 && PhysActor != null) | ||
3695 | { | ||
3696 | PhysActor.VehicleRotationParam(param, rotation); | ||
3697 | } | ||
3024 | } | 3698 | } |
3025 | 3699 | ||
3026 | /// <summary> | 3700 | /// <summary> |
@@ -3221,14 +3895,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3221 | hasProfileCut = hasDimple; // is it the same thing? | 3895 | hasProfileCut = hasDimple; // is it the same thing? |
3222 | } | 3896 | } |
3223 | 3897 | ||
3224 | public void SetVehicleFlags(int param, bool remove) | ||
3225 | { | ||
3226 | PhysicsActor pa = PhysActor; | ||
3227 | |||
3228 | if (pa != null) | ||
3229 | pa.VehicleFlags(param, remove); | ||
3230 | } | ||
3231 | |||
3232 | public void SetGroup(UUID groupID, IClientAPI client) | 3898 | public void SetGroup(UUID groupID, IClientAPI client) |
3233 | { | 3899 | { |
3234 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3900 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3237,8 +3903,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3237 | // Name, groupID, OwnerID); | 3903 | // Name, groupID, OwnerID); |
3238 | 3904 | ||
3239 | GroupID = groupID; | 3905 | GroupID = groupID; |
3240 | if (client != null) | 3906 | // if (client != null) |
3241 | SendPropertiesToClient(client); | 3907 | // SendPropertiesToClient(client); |
3242 | UpdateFlag = UpdateRequired.FULL; | 3908 | UpdateFlag = UpdateRequired.FULL; |
3243 | } | 3909 | } |
3244 | 3910 | ||
@@ -3330,70 +3996,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3330 | 3996 | ||
3331 | public void StopMoveToTarget() | 3997 | public void StopMoveToTarget() |
3332 | { | 3998 | { |
3999 | <<<<<<< HEAD | ||
3333 | ParentGroup.StopMoveToTarget(); | 4000 | ParentGroup.StopMoveToTarget(); |
3334 | } | 4001 | ======= |
4002 | ParentGroup.stopMoveToTarget(); | ||
3335 | 4003 | ||
3336 | public void StoreUndoState() | 4004 | // ParentGroup.ScheduleGroupForTerseUpdate(); |
3337 | { | 4005 | //ParentGroup.ScheduleGroupForFullUpdate(); |
3338 | StoreUndoState(false); | 4006 | >>>>>>> avn/ubitvar |
3339 | } | 4007 | } |
3340 | 4008 | ||
3341 | public void StoreUndoState(bool forGroup) | 4009 | public void StoreUndoState(ObjectChangeType change) |
3342 | { | 4010 | { |
3343 | if (ParentGroup == null || ParentGroup.Scene == null) | 4011 | if (m_UndoRedo == null) |
3344 | return; | 4012 | m_UndoRedo = new UndoRedoState(5); |
3345 | |||
3346 | if (Undoing) | ||
3347 | { | ||
3348 | // m_log.DebugFormat( | ||
3349 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | ||
3350 | return; | ||
3351 | } | ||
3352 | 4013 | ||
3353 | if (IgnoreUndoUpdate) | 4014 | lock (m_UndoRedo) |
3354 | { | 4015 | { |
3355 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | 4016 | if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended |
3356 | return; | ||
3357 | } | ||
3358 | |||
3359 | lock (m_undo) | ||
3360 | { | ||
3361 | if (m_undo.Count > 0) | ||
3362 | { | ||
3363 | UndoState last = m_undo[m_undo.Count - 1]; | ||
3364 | if (last != null) | ||
3365 | { | ||
3366 | // TODO: May need to fix for group comparison | ||
3367 | if (last.Compare(this)) | ||
3368 | { | ||
3369 | // m_log.DebugFormat( | ||
3370 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | ||
3371 | // Name, LocalId, m_undo.Count); | ||
3372 | |||
3373 | return; | ||
3374 | } | ||
3375 | } | ||
3376 | } | ||
3377 | |||
3378 | // m_log.DebugFormat( | ||
3379 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | ||
3380 | // Name, LocalId, forGroup, m_undo.Count); | ||
3381 | |||
3382 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3383 | { | 4017 | { |
3384 | UndoState nUndo = new UndoState(this, forGroup); | 4018 | m_UndoRedo.StoreUndo(this, change); |
3385 | |||
3386 | m_undo.Add(nUndo); | ||
3387 | |||
3388 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3389 | m_undo.RemoveAt(0); | ||
3390 | |||
3391 | if (m_redo.Count > 0) | ||
3392 | m_redo.Clear(); | ||
3393 | |||
3394 | // m_log.DebugFormat( | ||
3395 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | ||
3396 | // Name, LocalId, forGroup, m_undo.Count); | ||
3397 | } | 4019 | } |
3398 | } | 4020 | } |
3399 | } | 4021 | } |
@@ -3405,88 +4027,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3405 | { | 4027 | { |
3406 | get | 4028 | get |
3407 | { | 4029 | { |
3408 | lock (m_undo) | 4030 | if (m_UndoRedo == null) |
3409 | return m_undo.Count; | 4031 | return 0; |
4032 | return m_UndoRedo.Count; | ||
3410 | } | 4033 | } |
3411 | } | 4034 | } |
3412 | 4035 | ||
3413 | public void Undo() | 4036 | public void Undo() |
3414 | { | 4037 | { |
3415 | lock (m_undo) | 4038 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3416 | { | 4039 | return; |
3417 | // m_log.DebugFormat( | ||
3418 | // "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", | ||
3419 | // Name, LocalId, m_undo.Count); | ||
3420 | |||
3421 | if (m_undo.Count > 0) | ||
3422 | { | ||
3423 | UndoState goback = m_undo[m_undo.Count - 1]; | ||
3424 | m_undo.RemoveAt(m_undo.Count - 1); | ||
3425 | |||
3426 | UndoState nUndo = null; | ||
3427 | |||
3428 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3429 | { | ||
3430 | nUndo = new UndoState(this, goback.ForGroup); | ||
3431 | } | ||
3432 | |||
3433 | goback.PlaybackState(this); | ||
3434 | |||
3435 | if (nUndo != null) | ||
3436 | { | ||
3437 | m_redo.Add(nUndo); | ||
3438 | |||
3439 | if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3440 | m_redo.RemoveAt(0); | ||
3441 | } | ||
3442 | } | ||
3443 | 4040 | ||
3444 | // m_log.DebugFormat( | 4041 | lock (m_UndoRedo) |
3445 | // "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", | 4042 | { |
3446 | // Name, LocalId, m_undo.Count); | 4043 | Undoing = true; |
4044 | m_UndoRedo.Undo(this); | ||
4045 | Undoing = false; | ||
3447 | } | 4046 | } |
3448 | } | 4047 | } |
3449 | 4048 | ||
3450 | public void Redo() | 4049 | public void Redo() |
3451 | { | 4050 | { |
3452 | lock (m_undo) | 4051 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3453 | { | 4052 | return; |
3454 | // m_log.DebugFormat( | ||
3455 | // "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", | ||
3456 | // Name, LocalId, m_redo.Count); | ||
3457 | |||
3458 | if (m_redo.Count > 0) | ||
3459 | { | ||
3460 | UndoState gofwd = m_redo[m_redo.Count - 1]; | ||
3461 | m_redo.RemoveAt(m_redo.Count - 1); | ||
3462 | |||
3463 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3464 | { | ||
3465 | UndoState nUndo = new UndoState(this, gofwd.ForGroup); | ||
3466 | |||
3467 | m_undo.Add(nUndo); | ||
3468 | |||
3469 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3470 | m_undo.RemoveAt(0); | ||
3471 | } | ||
3472 | |||
3473 | gofwd.PlayfwdState(this); | ||
3474 | 4053 | ||
3475 | // m_log.DebugFormat( | 4054 | lock (m_UndoRedo) |
3476 | // "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", | 4055 | { |
3477 | // Name, LocalId, m_redo.Count); | 4056 | Undoing = true; |
3478 | } | 4057 | m_UndoRedo.Redo(this); |
4058 | Undoing = false; | ||
3479 | } | 4059 | } |
3480 | } | 4060 | } |
3481 | 4061 | ||
3482 | public void ClearUndoState() | 4062 | public void ClearUndoState() |
3483 | { | 4063 | { |
3484 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); | 4064 | if (m_UndoRedo == null || Undoing) |
4065 | return; | ||
3485 | 4066 | ||
3486 | lock (m_undo) | 4067 | lock (m_UndoRedo) |
3487 | { | 4068 | { |
3488 | m_undo.Clear(); | 4069 | m_UndoRedo.Clear(); |
3489 | m_redo.Clear(); | ||
3490 | } | 4070 | } |
3491 | } | 4071 | } |
3492 | 4072 | ||
@@ -4038,7 +4618,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4038 | if (god) | 4618 | if (god) |
4039 | { | 4619 | { |
4040 | BaseMask = ApplyMask(BaseMask, set, mask); | 4620 | BaseMask = ApplyMask(BaseMask, set, mask); |
4041 | Inventory.ApplyGodPermissions(_baseMask); | 4621 | Inventory.ApplyGodPermissions(BaseMask); |
4042 | } | 4622 | } |
4043 | 4623 | ||
4044 | break; | 4624 | break; |
@@ -4069,7 +4649,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4069 | } | 4649 | } |
4070 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & | 4650 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & |
4071 | baseMask; | 4651 | baseMask; |
4072 | // Prevent the client from creating no mod, no copy | 4652 | // Prevent the client from creating no copy, no transfer |
4073 | // objects | 4653 | // objects |
4074 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) | 4654 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) |
4075 | NextOwnerMask |= (uint)PermissionMask.Transfer; | 4655 | NextOwnerMask |= (uint)PermissionMask.Transfer; |
@@ -4087,20 +4667,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4087 | { | 4667 | { |
4088 | bool update = false; | 4668 | bool update = false; |
4089 | 4669 | ||
4090 | if (BaseMask != source.BaseMask || | 4670 | uint prevOwnerMask = OwnerMask; |
4091 | OwnerMask != source.OwnerMask || | 4671 | uint prevGroupMask = GroupMask; |
4092 | GroupMask != source.GroupMask || | 4672 | uint prevEveryoneMask = EveryoneMask; |
4093 | EveryoneMask != source.EveryoneMask || | 4673 | uint prevNextOwnerMask = NextOwnerMask; |
4094 | NextOwnerMask != source.NextOwnerMask) | ||
4095 | update = true; | ||
4096 | 4674 | ||
4097 | BaseMask = source.BaseMask; | 4675 | OwnerMask = source.OwnerMask & BaseMask; |
4098 | OwnerMask = source.OwnerMask; | 4676 | GroupMask = source.GroupMask & BaseMask; |
4099 | GroupMask = source.GroupMask; | 4677 | EveryoneMask = source.EveryoneMask & BaseMask; |
4100 | EveryoneMask = source.EveryoneMask; | 4678 | NextOwnerMask = source.NextOwnerMask & BaseMask; |
4101 | NextOwnerMask = source.NextOwnerMask; | ||
4102 | 4679 | ||
4103 | if (update) | 4680 | if (OwnerMask != prevOwnerMask || |
4681 | GroupMask != prevGroupMask || | ||
4682 | EveryoneMask != prevEveryoneMask || | ||
4683 | NextOwnerMask != prevNextOwnerMask) | ||
4104 | SendFullUpdateToAllClients(); | 4684 | SendFullUpdateToAllClients(); |
4105 | } | 4685 | } |
4106 | 4686 | ||
@@ -4151,6 +4731,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4151 | } | 4731 | } |
4152 | } | 4732 | } |
4153 | 4733 | ||
4734 | |||
4154 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) | 4735 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) |
4155 | { | 4736 | { |
4156 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) | 4737 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) |
@@ -4178,7 +4759,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4178 | /// <param name="SetTemporary"></param> | 4759 | /// <param name="SetTemporary"></param> |
4179 | /// <param name="SetPhantom"></param> | 4760 | /// <param name="SetPhantom"></param> |
4180 | /// <param name="SetVD"></param> | 4761 | /// <param name="SetVD"></param> |
4181 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4762 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
4182 | { | 4763 | { |
4183 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4764 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
4184 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4765 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -4188,99 +4769,110 @@ namespace OpenSim.Region.Framework.Scenes | |||
4188 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4769 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
4189 | return; | 4770 | return; |
4190 | 4771 | ||
4191 | PhysicsActor pa = PhysActor; | 4772 | VolumeDetectActive = SetVD; |
4192 | |||
4193 | // Special cases for VD. VD can only be called from a script | ||
4194 | // and can't be combined with changes to other states. So we can rely | ||
4195 | // that... | ||
4196 | // ... if VD is changed, all others are not. | ||
4197 | // ... if one of the others is changed, VD is not. | ||
4198 | if (SetVD) // VD is active, special logic applies | ||
4199 | { | ||
4200 | // State machine logic for VolumeDetect | ||
4201 | // More logic below | ||
4202 | bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; | ||
4203 | |||
4204 | if (phanReset) // Phantom changes from on to off switch VD off too | ||
4205 | { | ||
4206 | SetVD = false; // Switch it of for the course of this routine | ||
4207 | VolumeDetectActive = false; // and also permanently | ||
4208 | 4773 | ||
4209 | if (pa != null) | 4774 | // volume detector implies phantom |
4210 | pa.SetVolumeDetect(0); // Let physics know about it too | 4775 | if (VolumeDetectActive) |
4211 | } | ||
4212 | else | ||
4213 | { | ||
4214 | // If volumedetect is active we don't want phantom to be applied. | ||
4215 | // If this is a new call to VD out of the state "phantom" | ||
4216 | // this will also cause the prim to be visible to physics | ||
4217 | SetPhantom = false; | ||
4218 | } | ||
4219 | } | ||
4220 | |||
4221 | if (UsePhysics && IsJoint()) | ||
4222 | { | ||
4223 | SetPhantom = true; | 4776 | SetPhantom = true; |
4224 | } | ||
4225 | 4777 | ||
4226 | if (UsePhysics) | 4778 | if (UsePhysics) |
4227 | { | ||
4228 | AddFlag(PrimFlags.Physics); | 4779 | AddFlag(PrimFlags.Physics); |
4229 | if (!wasUsingPhysics) | ||
4230 | { | ||
4231 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4232 | } | ||
4233 | } | ||
4234 | else | 4780 | else |
4235 | { | ||
4236 | RemFlag(PrimFlags.Physics); | 4781 | RemFlag(PrimFlags.Physics); |
4237 | if (wasUsingPhysics) | ||
4238 | { | ||
4239 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4240 | } | ||
4241 | } | ||
4242 | 4782 | ||
4243 | if (SetPhantom | 4783 | if (SetPhantom) |
4244 | || ParentGroup.IsAttachment | ||
4245 | || PhysicsShapeType == (byte)PhysShapeType.none | ||
4246 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | ||
4247 | { | ||
4248 | AddFlag(PrimFlags.Phantom); | 4784 | AddFlag(PrimFlags.Phantom); |
4785 | else | ||
4786 | RemFlag(PrimFlags.Phantom); | ||
4249 | 4787 | ||
4250 | if (PhysActor != null) | 4788 | if (SetTemporary) |
4789 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4790 | else | ||
4791 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4792 | |||
4793 | |||
4794 | if (ParentGroup.Scene == null) | ||
4795 | return; | ||
4796 | |||
4797 | PhysicsActor pa = PhysActor; | ||
4798 | |||
4799 | if (pa != null && building && pa.Building != building) | ||
4800 | pa.Building = building; | ||
4801 | |||
4802 | if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | ||
4803 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
4804 | { | ||
4805 | if (pa != null) | ||
4251 | { | 4806 | { |
4807 | if(wasUsingPhysics) | ||
4808 | ParentGroup.Scene.RemovePhysicalPrim(1); | ||
4252 | RemoveFromPhysics(); | 4809 | RemoveFromPhysics(); |
4253 | pa = null; | ||
4254 | } | 4810 | } |
4811 | |||
4812 | Velocity = new Vector3(0, 0, 0); | ||
4813 | Acceleration = new Vector3(0, 0, 0); | ||
4814 | if (ParentGroup.RootPart == this) | ||
4815 | AngularVelocity = new Vector3(0, 0, 0); | ||
4255 | } | 4816 | } |
4256 | else // Not phantom | 4817 | |
4818 | else | ||
4257 | { | 4819 | { |
4258 | RemFlag(PrimFlags.Phantom); | 4820 | if (ParentGroup.Scene.CollidablePrims) |
4259 | |||
4260 | if (ParentGroup.Scene == null) | ||
4261 | return; | ||
4262 | |||
4263 | if (ParentGroup.Scene.CollidablePrims && pa == null) | ||
4264 | { | 4821 | { |
4265 | AddToPhysics(UsePhysics, SetPhantom, false); | 4822 | if (pa == null) |
4266 | pa = PhysActor; | 4823 | { |
4267 | 4824 | AddToPhysics(UsePhysics, SetPhantom, building, false); | |
4268 | if (pa != null) | 4825 | pa = PhysActor; |
4826 | /* | ||
4827 | if (pa != null) | ||
4828 | { | ||
4829 | if ( | ||
4830 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4831 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4832 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4833 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4834 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4835 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4836 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4837 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4838 | (CollisionSound != UUID.Zero) | ||
4839 | ) | ||
4840 | { | ||
4841 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4842 | pa.SubscribeEvents(1000); | ||
4843 | } | ||
4844 | } | ||
4845 | */ | ||
4846 | if (pa != null) | ||
4847 | { | ||
4848 | pa.SetMaterial(Material); | ||
4849 | DoPhysicsPropertyUpdate(UsePhysics, true); | ||
4850 | } | ||
4851 | } | ||
4852 | else // it already has a physical representation | ||
4269 | { | 4853 | { |
4854 | <<<<<<< HEAD | ||
4270 | pa.SetMaterial(Material); | 4855 | pa.SetMaterial(Material); |
4271 | pa.Position = GetWorldPosition(); | 4856 | pa.Position = GetWorldPosition(); |
4272 | pa.Orientation = GetWorldRotation(); | 4857 | pa.Orientation = GetWorldRotation(); |
4273 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4858 | DoPhysicsPropertyUpdate(UsePhysics, true); |
4859 | ======= | ||
4860 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | ||
4861 | /* moved into DoPhysicsPropertyUpdate | ||
4862 | if(VolumeDetectActive) | ||
4863 | pa.SetVolumeDetect(1); | ||
4864 | else | ||
4865 | pa.SetVolumeDetect(0); | ||
4866 | */ | ||
4867 | >>>>>>> avn/ubitvar | ||
4274 | 4868 | ||
4275 | SubscribeForCollisionEvents(); | 4869 | if (pa.Building != building) |
4870 | pa.Building = building; | ||
4276 | } | 4871 | } |
4277 | } | ||
4278 | else // it already has a physical representation | ||
4279 | { | ||
4280 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim | ||
4281 | } | ||
4282 | } | ||
4283 | 4872 | ||
4873 | UpdatePhysicsSubscribedEvents(); | ||
4874 | } | ||
4875 | } | ||
4284 | if (SetVD) | 4876 | if (SetVD) |
4285 | { | 4877 | { |
4286 | // If the above logic worked (this is urgent candidate to unit tests!) | 4878 | // If the above logic worked (this is urgent candidate to unit tests!) |
@@ -4294,6 +4886,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4294 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4886 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active |
4295 | VolumeDetectActive = true; | 4887 | VolumeDetectActive = true; |
4296 | } | 4888 | } |
4889 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4297 | } | 4890 | } |
4298 | else if (SetVD != wasVD) | 4891 | else if (SetVD != wasVD) |
4299 | { | 4892 | { |
@@ -4305,105 +4898,51 @@ namespace OpenSim.Region.Framework.Scenes | |||
4305 | RemFlag(PrimFlags.Phantom); | 4898 | RemFlag(PrimFlags.Phantom); |
4306 | VolumeDetectActive = false; | 4899 | VolumeDetectActive = false; |
4307 | } | 4900 | } |
4308 | 4901 | // and last in case we have a new actor and not building | |
4309 | if (SetTemporary) | ||
4310 | { | ||
4311 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4312 | } | ||
4313 | else | ||
4314 | { | ||
4315 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4316 | } | ||
4317 | |||
4318 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4319 | 4902 | ||
4320 | if (ParentGroup != null) | 4903 | if (ParentGroup != null) |
4321 | { | 4904 | { |
4322 | ParentGroup.HasGroupChanged = true; | 4905 | ParentGroup.HasGroupChanged = true; |
4323 | ScheduleFullUpdate(); | 4906 | ScheduleFullUpdate(); |
4324 | } | 4907 | } |
4325 | 4908 | ||
4326 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4909 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4327 | } | 4910 | } |
4328 | 4911 | ||
4329 | /// <summary> | 4912 | /// <summary> |
4330 | /// Subscribe for physics collision events if needed for scripts and sounds | ||
4331 | /// </summary> | ||
4332 | public void SubscribeForCollisionEvents() | ||
4333 | { | ||
4334 | PhysicsActor pa = PhysActor; | ||
4335 | |||
4336 | if (pa != null) | ||
4337 | { | ||
4338 | if ( | ||
4339 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4340 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4341 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4342 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4343 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4344 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4345 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4346 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4347 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4348 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4349 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4350 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4351 | (CollisionSound != UUID.Zero) | ||
4352 | ) | ||
4353 | { | ||
4354 | if (!pa.SubscribedEvents()) | ||
4355 | { | ||
4356 | // If not already subscribed for event, set up for a collision event. | ||
4357 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4358 | pa.SubscribeEvents(1000); | ||
4359 | } | ||
4360 | } | ||
4361 | else | ||
4362 | { | ||
4363 | // There is no need to be subscribed to collisions so, if subscribed, remove subscription | ||
4364 | if (pa.SubscribedEvents()) | ||
4365 | { | ||
4366 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4367 | pa.UnSubscribeEvents(); | ||
4368 | } | ||
4369 | } | ||
4370 | } | ||
4371 | } | ||
4372 | |||
4373 | /// <summary> | ||
4374 | /// Adds this part to the physics scene. | 4913 | /// Adds this part to the physics scene. |
4914 | /// and sets the PhysActor property | ||
4375 | /// </summary> | 4915 | /// </summary> |
4376 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4916 | /// <param name="isPhysical">Add this prim as physical.</param> |
4377 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4917 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4378 | /// <returns> | 4918 | /// <param name="building">tells physics to delay full construction of object</param> |
4379 | /// The physics actor. null if there was a failure. | 4919 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4380 | /// </returns> | 4920 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4381 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool applyDynamics) | 4921 | { |
4382 | { | ||
4383 | PhysicsActor pa; | 4922 | PhysicsActor pa; |
4384 | 4923 | ||
4385 | Vector3 velocity = Velocity; | 4924 | Vector3 velocity = Velocity; |
4386 | Vector3 rotationalVelocity = AngularVelocity;; | 4925 | Vector3 rotationalVelocity = AngularVelocity;; |
4387 | 4926 | ||
4388 | try | 4927 | try |
4389 | { | 4928 | { |
4390 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4929 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4391 | string.Format("{0}/{1}", Name, UUID), | 4930 | string.Format("{0}/{1}", Name, UUID), |
4392 | Shape, | 4931 | Shape, |
4393 | AbsolutePosition, | 4932 | AbsolutePosition, |
4394 | Scale, | 4933 | Scale, |
4395 | GetWorldRotation(), | 4934 | GetWorldRotation(), |
4396 | isPhysical, | 4935 | isPhysical, |
4397 | isPhantom, | 4936 | isPhantom, |
4398 | PhysicsShapeType, | 4937 | PhysicsShapeType, |
4399 | m_localId); | 4938 | m_localId); |
4400 | } | 4939 | } |
4401 | catch (Exception e) | 4940 | catch (Exception e) |
4402 | { | 4941 | { |
4403 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); | 4942 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); |
4404 | pa = null; | 4943 | pa = null; |
4405 | } | 4944 | } |
4406 | 4945 | ||
4407 | if (pa != null) | 4946 | if (pa != null) |
4408 | { | 4947 | { |
4409 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4948 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
@@ -4416,9 +4955,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4416 | 4955 | ||
4417 | if (VolumeDetectActive) // change if not the default only | 4956 | if (VolumeDetectActive) // change if not the default only |
4418 | pa.SetVolumeDetect(1); | 4957 | pa.SetVolumeDetect(1); |
4958 | |||
4959 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4960 | m_vehicleParams.SetVehicle(pa); | ||
4961 | |||
4419 | // we are going to tell rest of code about physics so better have this here | 4962 | // we are going to tell rest of code about physics so better have this here |
4420 | PhysActor = pa; | 4963 | PhysActor = pa; |
4421 | 4964 | ||
4965 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4966 | // lets expand it here just with what it really needs to do | ||
4967 | |||
4422 | if (isPhysical) | 4968 | if (isPhysical) |
4423 | { | 4969 | { |
4424 | if (ParentGroup.RootPart.KeyframeMotion != null) | 4970 | if (ParentGroup.RootPart.KeyframeMotion != null) |
@@ -4440,19 +4986,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
4440 | } | 4986 | } |
4441 | } | 4987 | } |
4442 | 4988 | ||
4443 | if (applyDynamics) | 4989 | if (applyDynamics) |
4444 | // do independent of isphysical so parameters get setted (at least some) | 4990 | // do independent of isphysical so parameters get setted (at least some) |
4445 | { | 4991 | { |
4446 | Velocity = velocity; | 4992 | Velocity = velocity; |
4447 | AngularVelocity = rotationalVelocity; | 4993 | AngularVelocity = rotationalVelocity; |
4448 | // pa.Velocity = velocity; | 4994 | // pa.Velocity = velocity; |
4449 | pa.RotationalVelocity = rotationalVelocity; | 4995 | pa.RotationalVelocity = rotationalVelocity; |
4996 | |||
4997 | // if not vehicle and root part apply force and torque | ||
4998 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) | ||
4999 | && LocalId == ParentGroup.RootPart.LocalId) | ||
5000 | { | ||
5001 | pa.Force = Force; | ||
5002 | pa.Torque = Torque; | ||
5003 | } | ||
4450 | } | 5004 | } |
4451 | 5005 | ||
4452 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 5006 | // if (Shape.SculptEntry) |
5007 | // CheckSculptAndLoad(); | ||
5008 | // else | ||
5009 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
5010 | |||
5011 | if (!building) | ||
5012 | pa.Building = false; | ||
4453 | } | 5013 | } |
4454 | 5014 | ||
4455 | PhysActor = pa; | 5015 | PhysActor = pa; |
5016 | |||
4456 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); | 5017 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); |
4457 | } | 5018 | } |
4458 | 5019 | ||
@@ -4461,14 +5022,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4461 | /// </summary> | 5022 | /// </summary> |
4462 | /// <remarks> | 5023 | /// <remarks> |
4463 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 5024 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4464 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 5025 | /// representation for collision detection. |
4465 | /// phantom. | ||
4466 | /// </remarks> | 5026 | /// </remarks> |
4467 | public void RemoveFromPhysics() | 5027 | public void RemoveFromPhysics() |
4468 | { | 5028 | { |
4469 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | 5029 | PhysicsActor pa = PhysActor; |
4470 | if (ParentGroup.Scene.PhysicsScene != null) | 5030 | if (pa != null) |
4471 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 5031 | { |
5032 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5033 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
5034 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
5035 | |||
5036 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
5037 | |||
5038 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | ||
5039 | } | ||
4472 | PhysActor = null; | 5040 | PhysActor = null; |
4473 | } | 5041 | } |
4474 | 5042 | ||
@@ -4600,6 +5168,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4600 | { | 5168 | { |
4601 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); | 5169 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); |
4602 | 5170 | ||
5171 | return; | ||
5172 | |||
4603 | if (ParentGroup.IsDeleted) | 5173 | if (ParentGroup.IsDeleted) |
4604 | return; | 5174 | return; |
4605 | 5175 | ||
@@ -4723,6 +5293,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
4723 | } | 5293 | } |
4724 | } | 5294 | } |
4725 | 5295 | ||
5296 | |||
5297 | private void UpdatePhysicsSubscribedEvents() | ||
5298 | { | ||
5299 | PhysicsActor pa = PhysActor; | ||
5300 | if (pa == null) | ||
5301 | return; | ||
5302 | |||
5303 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5304 | |||
5305 | bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); | ||
5306 | |||
5307 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
5308 | |||
5309 | // merge with root part | ||
5310 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
5311 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
5312 | |||
5313 | // submit to this part case | ||
5314 | if (VolumeDetectActive) | ||
5315 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
5316 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
5317 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
5318 | else | ||
5319 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
5320 | |||
5321 | if (hassound || CombinedEvents != 0) | ||
5322 | { | ||
5323 | // subscribe to physics updates. | ||
5324 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5325 | pa.SubscribeEvents(50); // 20 reports per second | ||
5326 | } | ||
5327 | else | ||
5328 | { | ||
5329 | pa.UnSubscribeEvents(); | ||
5330 | } | ||
5331 | } | ||
5332 | |||
5333 | |||
4726 | public void aggregateScriptEvents() | 5334 | public void aggregateScriptEvents() |
4727 | { | 5335 | { |
4728 | if (ParentGroup == null || ParentGroup.RootPart == null) | 5336 | if (ParentGroup == null || ParentGroup.RootPart == null) |
@@ -4759,8 +5367,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4759 | { | 5367 | { |
4760 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5368 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4761 | } | 5369 | } |
4762 | 5370 | /* | |
4763 | SubscribeForCollisionEvents(); | 5371 | PhysicsActor pa = PhysActor; |
5372 | if (pa != null) | ||
5373 | { | ||
5374 | if ( | ||
5375 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
5376 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
5377 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
5378 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
5379 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
5380 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
5381 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
5382 | ) | ||
5383 | { | ||
5384 | // subscribe to physics updates. | ||
5385 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5386 | pa.SubscribeEvents(1000); | ||
5387 | } | ||
5388 | else | ||
5389 | { | ||
5390 | pa.UnSubscribeEvents(); | ||
5391 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5392 | } | ||
5393 | } | ||
5394 | */ | ||
5395 | UpdatePhysicsSubscribedEvents(); | ||
4764 | 5396 | ||
4765 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 5397 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4766 | //{ | 5398 | //{ |
@@ -4969,6 +5601,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4969 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 5601 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4970 | } | 5602 | } |
4971 | 5603 | ||
5604 | public void ResetOwnerChangeFlag() | ||
5605 | { | ||
5606 | List<UUID> inv = Inventory.GetInventoryList(); | ||
5607 | |||
5608 | foreach (UUID itemID in inv) | ||
5609 | { | ||
5610 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
5611 | item.OwnerChanged = false; | ||
5612 | Inventory.UpdateInventoryItem(item, false, false); | ||
5613 | } | ||
5614 | } | ||
5615 | |||
4972 | /// <summary> | 5616 | /// <summary> |
4973 | /// Record an avatar sitting on this part. | 5617 | /// Record an avatar sitting on this part. |
4974 | /// </summary> | 5618 | /// </summary> |
@@ -5062,4 +5706,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
5062 | } | 5706 | } |
5063 | } | 5707 | } |
5064 | } | 5708 | } |
5065 | } \ No newline at end of file | 5709 | } |