diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1733 |
1 files changed, 1206 insertions, 527 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6720635..f037348 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -62,7 +62,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
62 | TELEPORT = 512, | 62 | TELEPORT = 512, |
63 | REGION_RESTART = 1024, | 63 | REGION_RESTART = 1024, |
64 | MEDIA = 2048, | 64 | MEDIA = 2048, |
65 | ANIMATION = 16384 | 65 | ANIMATION = 16384, |
66 | POSITION = 32768 | ||
66 | } | 67 | } |
67 | 68 | ||
68 | // I don't really know where to put this except here. | 69 | // I don't really know where to put this except here. |
@@ -121,7 +122,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
121 | /// Denote all sides of the prim | 122 | /// Denote all sides of the prim |
122 | /// </value> | 123 | /// </value> |
123 | public const int ALL_SIDES = -1; | 124 | public const int ALL_SIDES = -1; |
124 | 125 | ||
126 | private const scriptEvents PhysicsNeededSubsEvents = ( | ||
127 | scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | | ||
128 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
129 | ); | ||
130 | private const scriptEvents PhyscicsPhantonSubsEvents = ( | ||
131 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
132 | ); | ||
133 | private const scriptEvents PhyscicsVolumeDtcSubsEvents = ( | ||
134 | scriptEvents.collision_start | scriptEvents.collision_end | ||
135 | ); | ||
136 | |||
125 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 137 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
126 | 138 | ||
127 | /// <value> | 139 | /// <value> |
@@ -132,7 +144,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
132 | /// </remarks> | 144 | /// </remarks> |
133 | public bool IsRoot | 145 | public bool IsRoot |
134 | { | 146 | { |
135 | get { return ParentGroup.RootPart == this; } | 147 | get { return Object.ReferenceEquals(ParentGroup.RootPart, this); } |
136 | } | 148 | } |
137 | 149 | ||
138 | /// <summary> | 150 | /// <summary> |
@@ -191,12 +203,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
191 | 203 | ||
192 | public double SoundRadius; | 204 | public double SoundRadius; |
193 | 205 | ||
206 | |||
194 | public uint TimeStampFull; | 207 | public uint TimeStampFull; |
195 | 208 | ||
196 | public uint TimeStampLastActivity; // Will be used for AutoReturn | 209 | public uint TimeStampLastActivity; // Will be used for AutoReturn |
197 | 210 | ||
198 | public uint TimeStampTerse; | 211 | public uint TimeStampTerse; |
199 | 212 | ||
213 | // The following two are to hold the attachment data | ||
214 | // while an object is inworld | ||
215 | [XmlIgnore] | ||
216 | public byte AttachPoint = 0; | ||
217 | |||
218 | [XmlIgnore] | ||
219 | public Vector3 AttachOffset = Vector3.Zero; | ||
220 | |||
221 | [XmlIgnore] | ||
222 | public Quaternion AttachRotation = Quaternion.Identity; | ||
223 | |||
224 | [XmlIgnore] | ||
200 | public int STATUS_ROTATE_X; | 225 | public int STATUS_ROTATE_X; |
201 | 226 | ||
202 | public int STATUS_ROTATE_Y; | 227 | public int STATUS_ROTATE_Y; |
@@ -223,8 +248,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
223 | 248 | ||
224 | public Vector3 RotationAxis = Vector3.One; | 249 | public Vector3 RotationAxis = Vector3.One; |
225 | 250 | ||
226 | public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this | 251 | public bool VolumeDetectActive; |
227 | // Certainly this must be a persistant setting finally | ||
228 | 252 | ||
229 | public bool IsWaitingForFirstSpinUpdatePacket; | 253 | public bool IsWaitingForFirstSpinUpdatePacket; |
230 | 254 | ||
@@ -264,10 +288,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 288 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
265 | private Vector3 m_sitTargetPosition; | 289 | private Vector3 m_sitTargetPosition; |
266 | private string m_sitAnimation = "SIT"; | 290 | private string m_sitAnimation = "SIT"; |
291 | private bool m_occupied; // KF if any av is sitting on this prim | ||
267 | private string m_text = String.Empty; | 292 | private string m_text = String.Empty; |
268 | private string m_touchName = String.Empty; | 293 | private string m_touchName = String.Empty; |
269 | private readonly List<UndoState> m_undo = new List<UndoState>(5); | 294 | private UndoRedoState m_UndoRedo = null; |
270 | private readonly List<UndoState> m_redo = new List<UndoState>(5); | ||
271 | 295 | ||
272 | private bool m_passTouches = false; | 296 | private bool m_passTouches = false; |
273 | private bool m_passCollisions = false; | 297 | private bool m_passCollisions = false; |
@@ -295,8 +319,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
295 | protected Vector3 m_lastVelocity; | 319 | protected Vector3 m_lastVelocity; |
296 | protected Vector3 m_lastAcceleration; | 320 | protected Vector3 m_lastAcceleration; |
297 | protected Vector3 m_lastAngularVelocity; | 321 | protected Vector3 m_lastAngularVelocity; |
298 | protected int m_lastTerseSent; | 322 | protected int m_lastUpdateSentTime; |
299 | 323 | protected float m_buoyancy = 0.0f; | |
324 | protected Vector3 m_force; | ||
325 | protected Vector3 m_torque; | ||
326 | |||
327 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; | ||
328 | protected float m_density = 1000.0f; // in kg/m^3 | ||
329 | protected float m_gravitymod = 1.0f; | ||
330 | protected float m_friction = 0.6f; // wood | ||
331 | protected float m_bounce = 0.5f; // wood | ||
332 | |||
333 | |||
334 | protected bool m_isSelected = false; | ||
335 | |||
300 | /// <summary> | 336 | /// <summary> |
301 | /// Stores media texture data | 337 | /// Stores media texture data |
302 | /// </summary> | 338 | /// </summary> |
@@ -308,10 +344,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
308 | private Vector3 m_cameraAtOffset; | 344 | private Vector3 m_cameraAtOffset; |
309 | private bool m_forceMouselook; | 345 | private bool m_forceMouselook; |
310 | 346 | ||
311 | // TODO: Collision sound should have default. | 347 | |
348 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
349 | private sbyte m_collisionSoundType; | ||
312 | private UUID m_collisionSound; | 350 | private UUID m_collisionSound; |
313 | private float m_collisionSoundVolume; | 351 | private float m_collisionSoundVolume; |
314 | 352 | ||
353 | private int LastColSoundSentTime; | ||
354 | |||
355 | |||
356 | private SOPVehicle m_vehicleParams = null; | ||
357 | |||
358 | private KeyframeMotion m_keyframeMotion = null; | ||
359 | |||
360 | public KeyframeMotion KeyframeMotion | ||
361 | { | ||
362 | get; set; | ||
363 | } | ||
364 | |||
365 | |||
315 | #endregion Fields | 366 | #endregion Fields |
316 | 367 | ||
317 | // ~SceneObjectPart() | 368 | // ~SceneObjectPart() |
@@ -340,6 +391,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
340 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 391 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
341 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 392 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
342 | m_inventory = new SceneObjectPartInventory(this); | 393 | m_inventory = new SceneObjectPartInventory(this); |
394 | LastColSoundSentTime = Util.EnvironmentTickCount(); | ||
343 | } | 395 | } |
344 | 396 | ||
345 | /// <summary> | 397 | /// <summary> |
@@ -354,7 +406,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
354 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 406 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
355 | Quaternion rotationOffset, Vector3 offsetPosition) : this() | 407 | Quaternion rotationOffset, Vector3 offsetPosition) : this() |
356 | { | 408 | { |
357 | m_name = "Primitive"; | 409 | m_name = "Object"; |
358 | 410 | ||
359 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 411 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
360 | LastOwnerID = CreatorID = OwnerID = ownerID; | 412 | LastOwnerID = CreatorID = OwnerID = ownerID; |
@@ -393,7 +445,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
393 | private uint _ownerMask = (uint)PermissionMask.All; | 445 | private uint _ownerMask = (uint)PermissionMask.All; |
394 | private uint _groupMask = (uint)PermissionMask.None; | 446 | private uint _groupMask = (uint)PermissionMask.None; |
395 | private uint _everyoneMask = (uint)PermissionMask.None; | 447 | private uint _everyoneMask = (uint)PermissionMask.None; |
396 | private uint _nextOwnerMask = (uint)PermissionMask.All; | 448 | private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); |
397 | private PrimFlags _flags = PrimFlags.None; | 449 | private PrimFlags _flags = PrimFlags.None; |
398 | private DateTime m_expires; | 450 | private DateTime m_expires; |
399 | private DateTime m_rezzed; | 451 | private DateTime m_rezzed; |
@@ -487,12 +539,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | } | 539 | } |
488 | 540 | ||
489 | /// <value> | 541 | /// <value> |
490 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 542 | /// Get the inventory list |
491 | /// </value> | 543 | /// </value> |
492 | public TaskInventoryDictionary TaskInventory | 544 | public TaskInventoryDictionary TaskInventory |
493 | { | 545 | { |
494 | get { return m_inventory.Items; } | 546 | get { |
495 | set { m_inventory.Items = value; } | 547 | return m_inventory.Items; |
548 | } | ||
549 | set { | ||
550 | m_inventory.Items = value; | ||
551 | } | ||
496 | } | 552 | } |
497 | 553 | ||
498 | /// <summary> | 554 | /// <summary> |
@@ -542,20 +598,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
542 | } | 598 | } |
543 | } | 599 | } |
544 | 600 | ||
545 | public byte Material | ||
546 | { | ||
547 | get { return (byte) m_material; } | ||
548 | set | ||
549 | { | ||
550 | m_material = (Material)value; | ||
551 | |||
552 | PhysicsActor pa = PhysActor; | ||
553 | |||
554 | if (pa != null) | ||
555 | pa.SetMaterial((int)value); | ||
556 | } | ||
557 | } | ||
558 | |||
559 | [XmlIgnore] | 601 | [XmlIgnore] |
560 | public bool PassTouches | 602 | public bool PassTouches |
561 | { | 603 | { |
@@ -581,6 +623,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
581 | } | 623 | } |
582 | } | 624 | } |
583 | 625 | ||
626 | public bool IsSelected | ||
627 | { | ||
628 | get { return m_isSelected; } | ||
629 | set | ||
630 | { | ||
631 | m_isSelected = value; | ||
632 | if (ParentGroup != null) | ||
633 | ParentGroup.PartSelectChanged(value); | ||
634 | } | ||
635 | } | ||
636 | |||
637 | |||
584 | public Dictionary<int, string> CollisionFilter | 638 | public Dictionary<int, string> CollisionFilter |
585 | { | 639 | { |
586 | get { return m_CollisionFilter; } | 640 | get { return m_CollisionFilter; } |
@@ -649,14 +703,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
649 | set { m_LoopSoundSlavePrims = value; } | 703 | set { m_LoopSoundSlavePrims = value; } |
650 | } | 704 | } |
651 | 705 | ||
652 | |||
653 | public Byte[] TextureAnimation | 706 | public Byte[] TextureAnimation |
654 | { | 707 | { |
655 | get { return m_TextureAnimation; } | 708 | get { return m_TextureAnimation; } |
656 | set { m_TextureAnimation = value; } | 709 | set { m_TextureAnimation = value; } |
657 | } | 710 | } |
658 | 711 | ||
659 | |||
660 | public Byte[] ParticleSystem | 712 | public Byte[] ParticleSystem |
661 | { | 713 | { |
662 | get { return m_particleSystem; } | 714 | get { return m_particleSystem; } |
@@ -693,9 +745,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
693 | { | 745 | { |
694 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 746 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
695 | PhysicsActor actor = PhysActor; | 747 | PhysicsActor actor = PhysActor; |
696 | // If physical and the root prim of a linkset, the position of the group is what physics thinks. | 748 | if (ParentID == 0) |
697 | if (actor != null && ParentID == 0) | 749 | { |
698 | m_groupPosition = actor.Position; | 750 | if (actor != null) |
751 | m_groupPosition = actor.Position; | ||
752 | return m_groupPosition; | ||
753 | } | ||
699 | 754 | ||
700 | // If I'm an attachment, my position is reported as the position of who I'm attached to | 755 | // If I'm an attachment, my position is reported as the position of who I'm attached to |
701 | if (ParentGroup.IsAttachment) | 756 | if (ParentGroup.IsAttachment) |
@@ -705,14 +760,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
705 | return sp.AbsolutePosition; | 760 | return sp.AbsolutePosition; |
706 | } | 761 | } |
707 | 762 | ||
763 | // use root prim's group position. Physics may have updated it | ||
764 | if (ParentGroup.RootPart != this) | ||
765 | m_groupPosition = ParentGroup.RootPart.GroupPosition; | ||
708 | return m_groupPosition; | 766 | return m_groupPosition; |
709 | } | 767 | } |
710 | set | 768 | set |
711 | { | 769 | { |
712 | m_groupPosition = value; | 770 | m_groupPosition = value; |
713 | |||
714 | PhysicsActor actor = PhysActor; | 771 | PhysicsActor actor = PhysActor; |
715 | if (actor != null) | 772 | if (actor != null && ParentGroup.Scene.PhysicsScene != null) |
716 | { | 773 | { |
717 | try | 774 | try |
718 | { | 775 | { |
@@ -736,16 +793,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
736 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); | 793 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); |
737 | } | 794 | } |
738 | } | 795 | } |
739 | |||
740 | // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too | ||
741 | if (SitTargetAvatar != UUID.Zero) | ||
742 | { | ||
743 | ScenePresence avatar; | ||
744 | if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar)) | ||
745 | { | ||
746 | avatar.ParentPosition = GetWorldPosition(); | ||
747 | } | ||
748 | } | ||
749 | } | 796 | } |
750 | } | 797 | } |
751 | 798 | ||
@@ -754,7 +801,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
754 | get { return m_offsetPosition; } | 801 | get { return m_offsetPosition; } |
755 | set | 802 | set |
756 | { | 803 | { |
757 | // StoreUndoState(); | 804 | Vector3 oldpos = m_offsetPosition; |
758 | m_offsetPosition = value; | 805 | m_offsetPosition = value; |
759 | 806 | ||
760 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 807 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -766,10 +813,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
766 | actor.Orientation = GetWorldRotation(); | 813 | actor.Orientation = GetWorldRotation(); |
767 | 814 | ||
768 | // Tell the physics engines that this prim changed. | 815 | // Tell the physics engines that this prim changed. |
769 | if (ParentGroup.Scene != null) | 816 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) |
770 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 817 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
771 | } | 818 | } |
819 | |||
820 | if (!m_parentGroup.m_dupeInProgress) | ||
821 | { | ||
822 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
823 | foreach (ScenePresence av in avs) | ||
824 | { | ||
825 | if (av.ParentID == m_localId) | ||
826 | { | ||
827 | Vector3 offset = (m_offsetPosition - oldpos); | ||
828 | av.AbsolutePosition += offset; | ||
829 | av.SendAvatarDataToAllAgents(); | ||
830 | } | ||
831 | } | ||
832 | } | ||
772 | } | 833 | } |
834 | TriggerScriptChangedEvent(Changed.POSITION); | ||
773 | } | 835 | } |
774 | } | 836 | } |
775 | 837 | ||
@@ -820,7 +882,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
820 | 882 | ||
821 | set | 883 | set |
822 | { | 884 | { |
823 | StoreUndoState(); | 885 | // StoreUndoState(); |
824 | m_rotationOffset = value; | 886 | m_rotationOffset = value; |
825 | 887 | ||
826 | PhysicsActor actor = PhysActor; | 888 | PhysicsActor actor = PhysActor; |
@@ -908,19 +970,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
908 | get | 970 | get |
909 | { | 971 | { |
910 | PhysicsActor actor = PhysActor; | 972 | PhysicsActor actor = PhysActor; |
911 | if ((actor != null) && actor.IsPhysical) | 973 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this) |
912 | { | 974 | { |
913 | m_angularVelocity = actor.RotationalVelocity; | 975 | m_angularVelocity = actor.RotationalVelocity; |
914 | } | 976 | } |
915 | return m_angularVelocity; | 977 | return m_angularVelocity; |
916 | } | 978 | } |
917 | set { m_angularVelocity = value; } | 979 | set |
980 | { | ||
981 | m_angularVelocity = value; | ||
982 | PhysicsActor actor = PhysActor; | ||
983 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE) | ||
984 | { | ||
985 | actor.RotationalVelocity = m_angularVelocity; | ||
986 | } | ||
987 | } | ||
918 | } | 988 | } |
919 | 989 | ||
920 | /// <summary></summary> | 990 | /// <summary></summary> |
921 | public Vector3 Acceleration | 991 | public Vector3 Acceleration |
922 | { | 992 | { |
923 | get { return m_acceleration; } | 993 | get |
994 | { | ||
995 | PhysicsActor actor = PhysActor; | ||
996 | if (actor != null) | ||
997 | { | ||
998 | m_acceleration = actor.Acceleration; | ||
999 | } | ||
1000 | return m_acceleration; | ||
1001 | } | ||
1002 | |||
924 | set { m_acceleration = value; } | 1003 | set { m_acceleration = value; } |
925 | } | 1004 | } |
926 | 1005 | ||
@@ -988,7 +1067,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
988 | public PrimitiveBaseShape Shape | 1067 | public PrimitiveBaseShape Shape |
989 | { | 1068 | { |
990 | get { return m_shape; } | 1069 | get { return m_shape; } |
991 | set { m_shape = value;} | 1070 | set |
1071 | { | ||
1072 | m_shape = value; | ||
1073 | } | ||
992 | } | 1074 | } |
993 | 1075 | ||
994 | /// <summary> | 1076 | /// <summary> |
@@ -1001,7 +1083,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1001 | { | 1083 | { |
1002 | if (m_shape != null) | 1084 | if (m_shape != null) |
1003 | { | 1085 | { |
1004 | StoreUndoState(); | ||
1005 | 1086 | ||
1006 | m_shape.Scale = value; | 1087 | m_shape.Scale = value; |
1007 | 1088 | ||
@@ -1028,6 +1109,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1028 | } | 1109 | } |
1029 | 1110 | ||
1030 | public UpdateRequired UpdateFlag { get; set; } | 1111 | public UpdateRequired UpdateFlag { get; set; } |
1112 | public bool UpdatePhysRequired { get; set; } | ||
1031 | 1113 | ||
1032 | /// <summary> | 1114 | /// <summary> |
1033 | /// Used for media on a prim. | 1115 | /// Used for media on a prim. |
@@ -1068,10 +1150,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1068 | { | 1150 | { |
1069 | get | 1151 | get |
1070 | { | 1152 | { |
1071 | if (ParentGroup.IsAttachment) | 1153 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); |
1072 | return GroupPosition; | ||
1073 | |||
1074 | return m_offsetPosition + m_groupPosition; | ||
1075 | } | 1154 | } |
1076 | } | 1155 | } |
1077 | 1156 | ||
@@ -1249,6 +1328,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1249 | _flags = value; | 1328 | _flags = value; |
1250 | } | 1329 | } |
1251 | } | 1330 | } |
1331 | |||
1332 | [XmlIgnore] | ||
1333 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1334 | { | ||
1335 | get { return m_occupied; } | ||
1336 | set { m_occupied = value; } | ||
1337 | } | ||
1252 | 1338 | ||
1253 | /// <summary> | 1339 | /// <summary> |
1254 | /// 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 | 1340 | /// 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 |
@@ -1299,12 +1385,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1299 | set { m_sitAnimation = value; } | 1385 | set { m_sitAnimation = value; } |
1300 | } | 1386 | } |
1301 | 1387 | ||
1388 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | ||
1389 | |||
1390 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
1391 | // runtime thing.. do not persist | ||
1392 | [XmlIgnore] | ||
1393 | public sbyte CollisionSoundType | ||
1394 | { | ||
1395 | get | ||
1396 | { | ||
1397 | return m_collisionSoundType; | ||
1398 | } | ||
1399 | set | ||
1400 | { | ||
1401 | m_collisionSoundType = value; | ||
1402 | if (value == -1) | ||
1403 | m_collisionSound = invalidCollisionSoundUUID; | ||
1404 | else if (value == 0) | ||
1405 | m_collisionSound = UUID.Zero; | ||
1406 | } | ||
1407 | } | ||
1408 | |||
1302 | public UUID CollisionSound | 1409 | public UUID CollisionSound |
1303 | { | 1410 | { |
1304 | get { return m_collisionSound; } | 1411 | get { return m_collisionSound; } |
1305 | set | 1412 | set |
1306 | { | 1413 | { |
1307 | m_collisionSound = value; | 1414 | m_collisionSound = value; |
1415 | |||
1416 | if (value == invalidCollisionSoundUUID) | ||
1417 | m_collisionSoundType = -1; | ||
1418 | else if (value == UUID.Zero) | ||
1419 | m_collisionSoundType = 0; | ||
1420 | else | ||
1421 | m_collisionSoundType = 1; | ||
1422 | |||
1308 | aggregateScriptEvents(); | 1423 | aggregateScriptEvents(); |
1309 | } | 1424 | } |
1310 | } | 1425 | } |
@@ -1315,6 +1430,324 @@ namespace OpenSim.Region.Framework.Scenes | |||
1315 | set { m_collisionSoundVolume = value; } | 1430 | set { m_collisionSoundVolume = value; } |
1316 | } | 1431 | } |
1317 | 1432 | ||
1433 | public float Buoyancy | ||
1434 | { | ||
1435 | get | ||
1436 | { | ||
1437 | if (ParentGroup.RootPart == this) | ||
1438 | return m_buoyancy; | ||
1439 | |||
1440 | return ParentGroup.RootPart.Buoyancy; | ||
1441 | } | ||
1442 | set | ||
1443 | { | ||
1444 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1445 | { | ||
1446 | ParentGroup.RootPart.Buoyancy = value; | ||
1447 | return; | ||
1448 | } | ||
1449 | m_buoyancy = value; | ||
1450 | if (PhysActor != null) | ||
1451 | PhysActor.Buoyancy = value; | ||
1452 | } | ||
1453 | } | ||
1454 | |||
1455 | public Vector3 Force | ||
1456 | { | ||
1457 | get | ||
1458 | { | ||
1459 | if (ParentGroup.RootPart == this) | ||
1460 | return m_force; | ||
1461 | |||
1462 | return ParentGroup.RootPart.Force; | ||
1463 | } | ||
1464 | |||
1465 | set | ||
1466 | { | ||
1467 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1468 | { | ||
1469 | ParentGroup.RootPart.Force = value; | ||
1470 | return; | ||
1471 | } | ||
1472 | m_force = value; | ||
1473 | if (PhysActor != null) | ||
1474 | PhysActor.Force = value; | ||
1475 | } | ||
1476 | } | ||
1477 | |||
1478 | public Vector3 Torque | ||
1479 | { | ||
1480 | get | ||
1481 | { | ||
1482 | if (ParentGroup.RootPart == this) | ||
1483 | return m_torque; | ||
1484 | |||
1485 | return ParentGroup.RootPart.Torque; | ||
1486 | } | ||
1487 | |||
1488 | set | ||
1489 | { | ||
1490 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1491 | { | ||
1492 | ParentGroup.RootPart.Torque = value; | ||
1493 | return; | ||
1494 | } | ||
1495 | m_torque = value; | ||
1496 | if (PhysActor != null) | ||
1497 | PhysActor.Torque = value; | ||
1498 | } | ||
1499 | } | ||
1500 | |||
1501 | public byte Material | ||
1502 | { | ||
1503 | get { return (byte)m_material; } | ||
1504 | set | ||
1505 | { | ||
1506 | if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) | ||
1507 | { | ||
1508 | bool update = false; | ||
1509 | |||
1510 | if (m_material != (Material)value) | ||
1511 | { | ||
1512 | update = true; | ||
1513 | m_material = (Material)value; | ||
1514 | } | ||
1515 | |||
1516 | if (m_friction != SOPMaterialData.friction(m_material)) | ||
1517 | { | ||
1518 | update = true; | ||
1519 | m_friction = SOPMaterialData.friction(m_material); | ||
1520 | } | ||
1521 | |||
1522 | if (m_bounce != SOPMaterialData.bounce(m_material)) | ||
1523 | { | ||
1524 | update = true; | ||
1525 | m_bounce = SOPMaterialData.bounce(m_material); | ||
1526 | } | ||
1527 | |||
1528 | if (update) | ||
1529 | { | ||
1530 | if (PhysActor != null) | ||
1531 | { | ||
1532 | PhysActor.SetMaterial((int)value); | ||
1533 | } | ||
1534 | if(ParentGroup != null) | ||
1535 | ParentGroup.HasGroupChanged = true; | ||
1536 | ScheduleFullUpdateIfNone(); | ||
1537 | UpdatePhysRequired = true; | ||
1538 | } | ||
1539 | } | ||
1540 | } | ||
1541 | } | ||
1542 | |||
1543 | // not a propriety to move to methods place later | ||
1544 | private bool HasMesh() | ||
1545 | { | ||
1546 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1547 | return true; | ||
1548 | return false; | ||
1549 | } | ||
1550 | |||
1551 | // not a propriety to move to methods place later | ||
1552 | public byte DefaultPhysicsShapeType() | ||
1553 | { | ||
1554 | byte type; | ||
1555 | |||
1556 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1557 | type = (byte)PhysShapeType.convex; | ||
1558 | else | ||
1559 | type = (byte)PhysShapeType.prim; | ||
1560 | |||
1561 | return type; | ||
1562 | } | ||
1563 | |||
1564 | [XmlIgnore] | ||
1565 | public bool UsesComplexCost | ||
1566 | { | ||
1567 | get | ||
1568 | { | ||
1569 | byte pst = PhysicsShapeType; | ||
1570 | if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh()) | ||
1571 | return true; | ||
1572 | return false; | ||
1573 | } | ||
1574 | } | ||
1575 | |||
1576 | [XmlIgnore] | ||
1577 | public float PhysicsCost | ||
1578 | { | ||
1579 | get | ||
1580 | { | ||
1581 | if(PhysicsShapeType == (byte)PhysShapeType.none) | ||
1582 | return 0; | ||
1583 | |||
1584 | float cost = 0.1f; | ||
1585 | if (PhysActor != null) | ||
1586 | cost = PhysActor.PhysicsCost; | ||
1587 | else | ||
1588 | cost = 0.1f; | ||
1589 | |||
1590 | if ((Flags & PrimFlags.Physics) != 0) | ||
1591 | cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 | ||
1592 | return cost; | ||
1593 | } | ||
1594 | } | ||
1595 | |||
1596 | [XmlIgnore] | ||
1597 | public float StreamingCost | ||
1598 | { | ||
1599 | get | ||
1600 | { | ||
1601 | float cost; | ||
1602 | if (PhysActor != null) | ||
1603 | cost = PhysActor.StreamCost; | ||
1604 | else | ||
1605 | cost = 1.0f; | ||
1606 | return 1.0f; | ||
1607 | } | ||
1608 | } | ||
1609 | |||
1610 | [XmlIgnore] | ||
1611 | public float SimulationCost | ||
1612 | { | ||
1613 | get | ||
1614 | { | ||
1615 | // ignoring scripts. Don't like considering them for this | ||
1616 | if((Flags & PrimFlags.Physics) != 0) | ||
1617 | return 1.0f; | ||
1618 | |||
1619 | return 0.5f; | ||
1620 | } | ||
1621 | } | ||
1622 | |||
1623 | public byte PhysicsShapeType | ||
1624 | { | ||
1625 | get { return m_physicsShapeType; } | ||
1626 | set | ||
1627 | { | ||
1628 | byte oldv = m_physicsShapeType; | ||
1629 | |||
1630 | if (value >= 0 && value <= (byte)PhysShapeType.convex) | ||
1631 | { | ||
1632 | if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this) | ||
1633 | m_physicsShapeType = DefaultPhysicsShapeType(); | ||
1634 | else | ||
1635 | m_physicsShapeType = value; | ||
1636 | } | ||
1637 | else | ||
1638 | m_physicsShapeType = DefaultPhysicsShapeType(); | ||
1639 | |||
1640 | if (m_physicsShapeType != oldv && ParentGroup != null) | ||
1641 | { | ||
1642 | if (m_physicsShapeType == (byte)PhysShapeType.none) | ||
1643 | { | ||
1644 | if (PhysActor != null) | ||
1645 | { | ||
1646 | Velocity = new Vector3(0, 0, 0); | ||
1647 | Acceleration = new Vector3(0, 0, 0); | ||
1648 | if (ParentGroup.RootPart == this) | ||
1649 | AngularVelocity = new Vector3(0, 0, 0); | ||
1650 | ParentGroup.Scene.RemovePhysicalPrim(1); | ||
1651 | RemoveFromPhysics(); | ||
1652 | } | ||
1653 | } | ||
1654 | else if (PhysActor == null) | ||
1655 | { | ||
1656 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); | ||
1657 | UpdatePhysicsSubscribedEvents(); | ||
1658 | } | ||
1659 | else | ||
1660 | { | ||
1661 | PhysActor.PhysicsShapeType = m_physicsShapeType; | ||
1662 | // if (Shape.SculptEntry) | ||
1663 | // CheckSculptAndLoad(); | ||
1664 | } | ||
1665 | |||
1666 | if (ParentGroup != null) | ||
1667 | ParentGroup.HasGroupChanged = true; | ||
1668 | } | ||
1669 | |||
1670 | if (m_physicsShapeType != value) | ||
1671 | { | ||
1672 | UpdatePhysRequired = true; | ||
1673 | } | ||
1674 | } | ||
1675 | } | ||
1676 | |||
1677 | public float Density // in kg/m^3 | ||
1678 | { | ||
1679 | get { return m_density; } | ||
1680 | set | ||
1681 | { | ||
1682 | if (value >=1 && value <= 22587.0) | ||
1683 | { | ||
1684 | m_density = value; | ||
1685 | UpdatePhysRequired = true; | ||
1686 | } | ||
1687 | |||
1688 | ScheduleFullUpdateIfNone(); | ||
1689 | |||
1690 | if (ParentGroup != null) | ||
1691 | ParentGroup.HasGroupChanged = true; | ||
1692 | } | ||
1693 | } | ||
1694 | |||
1695 | public float GravityModifier | ||
1696 | { | ||
1697 | get { return m_gravitymod; } | ||
1698 | set | ||
1699 | { | ||
1700 | if( value >= -1 && value <=28.0f) | ||
1701 | { | ||
1702 | m_gravitymod = value; | ||
1703 | UpdatePhysRequired = true; | ||
1704 | } | ||
1705 | |||
1706 | ScheduleFullUpdateIfNone(); | ||
1707 | |||
1708 | if (ParentGroup != null) | ||
1709 | ParentGroup.HasGroupChanged = true; | ||
1710 | |||
1711 | } | ||
1712 | } | ||
1713 | |||
1714 | public float Friction | ||
1715 | { | ||
1716 | get { return m_friction; } | ||
1717 | set | ||
1718 | { | ||
1719 | if (value >= 0 && value <= 255.0f) | ||
1720 | { | ||
1721 | m_friction = value; | ||
1722 | UpdatePhysRequired = true; | ||
1723 | } | ||
1724 | |||
1725 | ScheduleFullUpdateIfNone(); | ||
1726 | |||
1727 | if (ParentGroup != null) | ||
1728 | ParentGroup.HasGroupChanged = true; | ||
1729 | } | ||
1730 | } | ||
1731 | |||
1732 | public float Bounciness | ||
1733 | { | ||
1734 | get { return m_bounce; } | ||
1735 | set | ||
1736 | { | ||
1737 | if (value >= 0 && value <= 1.0f) | ||
1738 | { | ||
1739 | m_bounce = value; | ||
1740 | UpdatePhysRequired = true; | ||
1741 | } | ||
1742 | |||
1743 | ScheduleFullUpdateIfNone(); | ||
1744 | |||
1745 | if (ParentGroup != null) | ||
1746 | ParentGroup.HasGroupChanged = true; | ||
1747 | } | ||
1748 | } | ||
1749 | |||
1750 | |||
1318 | #endregion Public Properties with only Get | 1751 | #endregion Public Properties with only Get |
1319 | 1752 | ||
1320 | private uint ApplyMask(uint val, bool set, uint mask) | 1753 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1460,6 +1893,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1460 | } | 1893 | } |
1461 | } | 1894 | } |
1462 | 1895 | ||
1896 | // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future | ||
1897 | public void SetVelocity(Vector3 pVel, bool localGlobalTF) | ||
1898 | { | ||
1899 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1900 | return; | ||
1901 | |||
1902 | if (ParentGroup.IsAttachment) | ||
1903 | return; // don't work on attachments (for now ??) | ||
1904 | |||
1905 | SceneObjectPart root = ParentGroup.RootPart; | ||
1906 | |||
1907 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1908 | return; | ||
1909 | |||
1910 | PhysicsActor pa = root.PhysActor; | ||
1911 | |||
1912 | if (pa == null || !pa.IsPhysical) | ||
1913 | return; | ||
1914 | |||
1915 | if (localGlobalTF) | ||
1916 | { | ||
1917 | pVel = pVel * GetWorldRotation(); | ||
1918 | } | ||
1919 | |||
1920 | ParentGroup.Velocity = pVel; | ||
1921 | } | ||
1922 | |||
1923 | // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future | ||
1924 | public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF) | ||
1925 | { | ||
1926 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1927 | return; | ||
1928 | |||
1929 | if (ParentGroup.IsAttachment) | ||
1930 | return; // don't work on attachments (for now ??) | ||
1931 | |||
1932 | SceneObjectPart root = ParentGroup.RootPart; | ||
1933 | |||
1934 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1935 | return; | ||
1936 | |||
1937 | PhysicsActor pa = root.PhysActor; | ||
1938 | |||
1939 | if (pa == null || !pa.IsPhysical) | ||
1940 | return; | ||
1941 | |||
1942 | if (localGlobalTF) | ||
1943 | { | ||
1944 | pAngVel = pAngVel * GetWorldRotation(); | ||
1945 | } | ||
1946 | |||
1947 | root.AngularVelocity = pAngVel; | ||
1948 | } | ||
1949 | |||
1950 | |||
1463 | /// <summary> | 1951 | /// <summary> |
1464 | /// hook to the physics scene to apply angular impulse | 1952 | /// hook to the physics scene to apply angular impulse |
1465 | /// This is sent up to the group, which then finds the root prim | 1953 | /// This is sent up to the group, which then finds the root prim |
@@ -1480,7 +1968,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1480 | impulse = newimpulse; | 1968 | impulse = newimpulse; |
1481 | } | 1969 | } |
1482 | 1970 | ||
1483 | ParentGroup.applyAngularImpulse(impulse); | 1971 | ParentGroup.ApplyAngularImpulse(impulse); |
1484 | } | 1972 | } |
1485 | 1973 | ||
1486 | /// <summary> | 1974 | /// <summary> |
@@ -1490,20 +1978,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1490 | /// </summary> | 1978 | /// </summary> |
1491 | /// <param name="impulsei">Vector force</param> | 1979 | /// <param name="impulsei">Vector force</param> |
1492 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 1980 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1493 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 1981 | |
1982 | // this is actualy Set Torque.. keeping naming so not to edit lslapi also | ||
1983 | public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF) | ||
1494 | { | 1984 | { |
1495 | Vector3 impulse = impulsei; | 1985 | Vector3 torque = torquei; |
1496 | 1986 | ||
1497 | if (localGlobalTF) | 1987 | if (localGlobalTF) |
1498 | { | 1988 | { |
1989 | /* | ||
1499 | Quaternion grot = GetWorldRotation(); | 1990 | Quaternion grot = GetWorldRotation(); |
1500 | Quaternion AXgrot = grot; | 1991 | Quaternion AXgrot = grot; |
1501 | Vector3 AXimpulsei = impulsei; | 1992 | Vector3 AXimpulsei = impulsei; |
1502 | Vector3 newimpulse = AXimpulsei * AXgrot; | 1993 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1503 | impulse = newimpulse; | 1994 | */ |
1995 | torque *= GetWorldRotation(); | ||
1504 | } | 1996 | } |
1505 | 1997 | ||
1506 | ParentGroup.setAngularImpulse(impulse); | 1998 | Torque = torque; |
1507 | } | 1999 | } |
1508 | 2000 | ||
1509 | /// <summary> | 2001 | /// <summary> |
@@ -1511,17 +2003,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1511 | /// </summary> | 2003 | /// </summary> |
1512 | /// <param name="rootObjectFlags"></param> | 2004 | /// <param name="rootObjectFlags"></param> |
1513 | /// <param name="VolumeDetectActive"></param> | 2005 | /// <param name="VolumeDetectActive"></param> |
1514 | public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) | 2006 | /// <param name="building"></param> |
2007 | |||
2008 | public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) | ||
1515 | { | 2009 | { |
2010 | VolumeDetectActive = _VolumeDetectActive; | ||
2011 | |||
1516 | if (!ParentGroup.Scene.CollidablePrims) | 2012 | if (!ParentGroup.Scene.CollidablePrims) |
1517 | return; | 2013 | return; |
1518 | 2014 | ||
1519 | // m_log.DebugFormat( | 2015 | if (PhysicsShapeType == (byte)PhysShapeType.none) |
1520 | // "[SCENE OBJECT PART]: Applying physics to {0} {1}, m_physicalPrim {2}", | 2016 | return; |
1521 | // Name, LocalId, UUID, m_physicalPrim); | 2017 | |
2018 | bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; | ||
2019 | bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0; | ||
1522 | 2020 | ||
1523 | bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; | 2021 | if (_VolumeDetectActive) |
1524 | bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; | 2022 | isPhantom = true; |
1525 | 2023 | ||
1526 | if (IsJoint()) | 2024 | if (IsJoint()) |
1527 | { | 2025 | { |
@@ -1529,22 +2027,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1529 | } | 2027 | } |
1530 | else | 2028 | else |
1531 | { | 2029 | { |
1532 | // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored | 2030 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment |
1533 | if (VolumeDetectActive) | 2031 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1534 | isPhantom = false; | ||
1535 | |||
1536 | // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition | ||
1537 | // or flexible | ||
1538 | if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
1539 | { | 2032 | { |
1540 | // Added clarification.. since A rigid body is an object that you can kick around, etc. | 2033 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
1541 | bool rigidBody = isPhysical && !isPhantom; | 2034 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here |
1542 | |||
1543 | PhysicsActor pa = AddToPhysics(rigidBody); | ||
1544 | |||
1545 | if (pa != null) | ||
1546 | pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0); | ||
1547 | } | 2035 | } |
2036 | else | ||
2037 | PhysActor = null; // just to be sure | ||
1548 | } | 2038 | } |
1549 | } | 2039 | } |
1550 | 2040 | ||
@@ -1596,6 +2086,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1596 | dupe.Category = Category; | 2086 | dupe.Category = Category; |
1597 | dupe.m_rezzed = m_rezzed; | 2087 | dupe.m_rezzed = m_rezzed; |
1598 | 2088 | ||
2089 | dupe.m_UndoRedo = null; | ||
2090 | dupe.m_isSelected = false; | ||
2091 | |||
2092 | dupe.IgnoreUndoUpdate = false; | ||
2093 | dupe.Undoing = false; | ||
2094 | |||
1599 | dupe.m_inventory = new SceneObjectPartInventory(dupe); | 2095 | dupe.m_inventory = new SceneObjectPartInventory(dupe); |
1600 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); | 2096 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); |
1601 | 2097 | ||
@@ -1611,6 +2107,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1611 | 2107 | ||
1612 | // Move afterwards ResetIDs as it clears the localID | 2108 | // Move afterwards ResetIDs as it clears the localID |
1613 | dupe.LocalId = localID; | 2109 | dupe.LocalId = localID; |
2110 | |||
1614 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. | 2111 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. |
1615 | dupe.LastOwnerID = OwnerID; | 2112 | dupe.LastOwnerID = OwnerID; |
1616 | 2113 | ||
@@ -1618,6 +2115,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1618 | Array.Copy(Shape.ExtraParams, extraP, extraP.Length); | 2115 | Array.Copy(Shape.ExtraParams, extraP, extraP.Length); |
1619 | dupe.Shape.ExtraParams = extraP; | 2116 | dupe.Shape.ExtraParams = extraP; |
1620 | 2117 | ||
2118 | // safeguard actual copy is done in sog.copy | ||
2119 | dupe.KeyframeMotion = null; | ||
2120 | |||
1621 | if (userExposed) | 2121 | if (userExposed) |
1622 | { | 2122 | { |
1623 | /* | 2123 | /* |
@@ -1629,8 +2129,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1629 | */ | 2129 | */ |
1630 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); | 2130 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); |
1631 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); | 2131 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); |
2132 | // dupe.UpdatePhysicsSubscribedEvents(); // not sure... | ||
1632 | } | 2133 | } |
1633 | 2134 | ||
2135 | if (dupe.PhysActor != null) | ||
2136 | dupe.PhysActor.LocalID = localID; | ||
2137 | |||
1634 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); | 2138 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); |
1635 | 2139 | ||
1636 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); | 2140 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); |
@@ -1649,10 +2153,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1649 | { | 2153 | { |
1650 | if (asset != null) | 2154 | if (asset != null) |
1651 | SculptTextureCallback(asset); | 2155 | SculptTextureCallback(asset); |
1652 | else | 2156 | // else |
1653 | m_log.WarnFormat( | 2157 | // m_log.WarnFormat( |
1654 | "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", | 2158 | // "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", |
1655 | Name, UUID, id); | 2159 | // Name, UUID, id); |
1656 | } | 2160 | } |
1657 | */ | 2161 | */ |
1658 | /// <summary> | 2162 | /// <summary> |
@@ -1751,6 +2255,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1751 | 2255 | ||
1752 | /// <summary> | 2256 | /// <summary> |
1753 | /// Do a physics propery update for this part. | 2257 | /// Do a physics propery update for this part. |
2258 | /// now also updates phantom and volume detector | ||
1754 | /// </summary> | 2259 | /// </summary> |
1755 | /// <param name="UsePhysics"></param> | 2260 | /// <param name="UsePhysics"></param> |
1756 | /// <param name="isNew"></param> | 2261 | /// <param name="isNew"></param> |
@@ -1776,61 +2281,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1776 | { | 2281 | { |
1777 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 2282 | if (pa.IsPhysical) // implies UsePhysics==false for this block |
1778 | { | 2283 | { |
1779 | if (!isNew) | 2284 | if (!isNew) // implies UsePhysics==false for this block |
2285 | { | ||
1780 | ParentGroup.Scene.RemovePhysicalPrim(1); | 2286 | ParentGroup.Scene.RemovePhysicalPrim(1); |
1781 | 2287 | ||
1782 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 2288 | Velocity = new Vector3(0, 0, 0); |
1783 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 2289 | Acceleration = new Vector3(0, 0, 0); |
1784 | pa.delink(); | 2290 | if (ParentGroup.RootPart == this) |
2291 | AngularVelocity = new Vector3(0, 0, 0); | ||
1785 | 2292 | ||
1786 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 2293 | if (pa.Phantom && !VolumeDetectActive) |
1787 | { | 2294 | { |
1788 | // destroy all joints connected to this now deactivated body | 2295 | RemoveFromPhysics(); |
1789 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 2296 | return; |
1790 | } | 2297 | } |
1791 | 2298 | ||
1792 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 2299 | pa.IsPhysical = UsePhysics; |
1793 | // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, | 2300 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
1794 | // which stops client-side interpolation of deactivated joint proxy objects. | 2301 | pa.OnOutOfBounds -= PhysicsOutOfBounds; |
2302 | pa.delink(); | ||
2303 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | ||
2304 | { | ||
2305 | // destroy all joints connected to this now deactivated body | ||
2306 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | ||
2307 | } | ||
2308 | } | ||
1795 | } | 2309 | } |
1796 | 2310 | ||
1797 | if (!UsePhysics && !isNew) | 2311 | if (pa.IsPhysical != UsePhysics) |
1798 | { | 2312 | pa.IsPhysical = UsePhysics; |
1799 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the | ||
1800 | // prim still has velocity and continues to interpolate its position along the old | ||
1801 | // velocity-vector. | ||
1802 | Velocity = new Vector3(0, 0, 0); | ||
1803 | Acceleration = new Vector3(0, 0, 0); | ||
1804 | AngularVelocity = new Vector3(0, 0, 0); | ||
1805 | //RotationalVelocity = new Vector3(0, 0, 0); | ||
1806 | } | ||
1807 | 2313 | ||
1808 | pa.IsPhysical = UsePhysics; | 2314 | if (UsePhysics) |
2315 | { | ||
2316 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
2317 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2318 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2319 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
1809 | 2320 | ||
1810 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 2321 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
1811 | //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 2322 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
1812 | /// that's not wholesome. Had to make Scene public | ||
1813 | //PhysActor = null; | ||
1814 | 2323 | ||
1815 | if ((Flags & PrimFlags.Phantom) == 0) | 2324 | if (ParentID != 0 && ParentID != LocalId) |
1816 | { | ||
1817 | if (UsePhysics) | ||
1818 | { | 2325 | { |
1819 | ParentGroup.Scene.AddPhysicalPrim(1); | 2326 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
1820 | 2327 | ||
1821 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | 2328 | if (parentPa != null) |
1822 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
1823 | if (ParentID != 0 && ParentID != LocalId) | ||
1824 | { | 2329 | { |
1825 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | 2330 | pa.link(parentPa); |
1826 | |||
1827 | if (parentPa != null) | ||
1828 | { | ||
1829 | pa.link(parentPa); | ||
1830 | } | ||
1831 | } | 2331 | } |
1832 | } | 2332 | } |
1833 | } | 2333 | } |
2334 | } | ||
2335 | |||
2336 | bool phan = ((Flags & PrimFlags.Phantom) != 0); | ||
2337 | if (pa.Phantom != phan) | ||
2338 | pa.Phantom = phan; | ||
2339 | |||
2340 | // some engines dont' have this check still | ||
2341 | // if (VolumeDetectActive != pa.IsVolumeDtc) | ||
2342 | { | ||
2343 | if (VolumeDetectActive) | ||
2344 | pa.SetVolumeDetect(1); | ||
2345 | else | ||
2346 | pa.SetVolumeDetect(0); | ||
1834 | } | 2347 | } |
1835 | 2348 | ||
1836 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the | 2349 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the |
@@ -1949,42 +2462,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
1949 | 2462 | ||
1950 | public Vector3 GetGeometricCenter() | 2463 | public Vector3 GetGeometricCenter() |
1951 | { | 2464 | { |
2465 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
2466 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
2467 | // ignoring tortured prims details since sl also seems to ignore | ||
2468 | // so no real use in doing it on physics | ||
2469 | if (ParentGroup.IsDeleted) | ||
2470 | return new Vector3(0, 0, 0); | ||
2471 | |||
2472 | return ParentGroup.GetGeometricCenter(); | ||
2473 | } | ||
2474 | |||
2475 | public float GetMass() | ||
2476 | { | ||
1952 | PhysicsActor pa = PhysActor; | 2477 | PhysicsActor pa = PhysActor; |
1953 | 2478 | ||
1954 | if (pa != null) | 2479 | if (pa != null) |
1955 | return new Vector3(pa.GeometricCenter.X, pa.GeometricCenter.Y, pa.GeometricCenter.Z); | 2480 | return pa.Mass; |
1956 | else | 2481 | else |
1957 | return new Vector3(0, 0, 0); | 2482 | return 0; |
1958 | } | 2483 | } |
1959 | 2484 | ||
1960 | public Vector3 GetCenterOfMass() | 2485 | public Vector3 GetCenterOfMass() |
1961 | { | 2486 | { |
2487 | if (ParentGroup.RootPart == this) | ||
2488 | { | ||
2489 | if (ParentGroup.IsDeleted) | ||
2490 | return AbsolutePosition; | ||
2491 | return ParentGroup.GetCenterOfMass(); | ||
2492 | } | ||
2493 | |||
1962 | PhysicsActor pa = PhysActor; | 2494 | PhysicsActor pa = PhysActor; |
1963 | 2495 | ||
1964 | if (pa != null) | 2496 | if (pa != null) |
1965 | return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); | 2497 | { |
2498 | Vector3 tmp = pa.CenterOfMass; | ||
2499 | return tmp; | ||
2500 | } | ||
1966 | else | 2501 | else |
1967 | return new Vector3(0, 0, 0); | 2502 | return AbsolutePosition; |
1968 | } | 2503 | } |
1969 | 2504 | ||
1970 | public float GetMass() | 2505 | public Vector3 GetPartCenterOfMass() |
1971 | { | 2506 | { |
1972 | PhysicsActor pa = PhysActor; | 2507 | PhysicsActor pa = PhysActor; |
1973 | 2508 | ||
1974 | if (pa != null) | 2509 | if (pa != null) |
1975 | return pa.Mass; | 2510 | { |
2511 | Vector3 tmp = pa.CenterOfMass; | ||
2512 | return tmp; | ||
2513 | } | ||
1976 | else | 2514 | else |
1977 | return 0; | 2515 | return AbsolutePosition; |
1978 | } | 2516 | } |
1979 | 2517 | ||
2518 | |||
1980 | public Vector3 GetForce() | 2519 | public Vector3 GetForce() |
1981 | { | 2520 | { |
1982 | PhysicsActor pa = PhysActor; | 2521 | return Force; |
1983 | |||
1984 | if (pa != null) | ||
1985 | return pa.Force; | ||
1986 | else | ||
1987 | return Vector3.Zero; | ||
1988 | } | 2522 | } |
1989 | 2523 | ||
1990 | /// <summary> | 2524 | /// <summary> |
@@ -2199,15 +2733,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2199 | 2733 | ||
2200 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) | 2734 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) |
2201 | { | 2735 | { |
2202 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) | 2736 | bool sendToRoot = true; |
2203 | { | ||
2204 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2205 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2206 | |||
2207 | colliding.Add(CreateDetObjectForGround()); | ||
2208 | LandCollidingMessage.Colliders = colliding; | ||
2209 | 2737 | ||
2738 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2739 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2740 | |||
2741 | colliding.Add(CreateDetObjectForGround()); | ||
2742 | LandCollidingMessage.Colliders = colliding; | ||
2743 | |||
2744 | if (Inventory.ContainsScripts()) | ||
2745 | { | ||
2746 | if (!PassCollisions) | ||
2747 | sendToRoot = false; | ||
2748 | } | ||
2749 | if ((ScriptEvents & ev) != 0) | ||
2210 | notify(LocalId, LandCollidingMessage); | 2750 | notify(LocalId, LandCollidingMessage); |
2751 | |||
2752 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) | ||
2753 | { | ||
2754 | notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); | ||
2211 | } | 2755 | } |
2212 | } | 2756 | } |
2213 | 2757 | ||
@@ -2223,57 +2767,120 @@ namespace OpenSim.Region.Framework.Scenes | |||
2223 | List<uint> endedColliders = new List<uint>(); | 2767 | List<uint> endedColliders = new List<uint>(); |
2224 | List<uint> startedColliders = new List<uint>(); | 2768 | List<uint> startedColliders = new List<uint>(); |
2225 | 2769 | ||
2226 | // calculate things that started colliding this time | 2770 | if (collissionswith.Count == 0) |
2227 | // and build up list of colliders this time | ||
2228 | foreach (uint localid in collissionswith.Keys) | ||
2229 | { | 2771 | { |
2230 | thisHitColliders.Add(localid); | 2772 | if (m_lastColliders.Count == 0) |
2231 | if (!m_lastColliders.Contains(localid)) | 2773 | return; // nothing to do |
2232 | startedColliders.Add(localid); | ||
2233 | } | ||
2234 | 2774 | ||
2235 | // calculate things that ended colliding | 2775 | foreach (uint localID in m_lastColliders) |
2236 | foreach (uint localID in m_lastColliders) | 2776 | { |
2237 | { | ||
2238 | if (!thisHitColliders.Contains(localID)) | ||
2239 | endedColliders.Add(localID); | 2777 | endedColliders.Add(localID); |
2778 | } | ||
2779 | m_lastColliders.Clear(); | ||
2240 | } | 2780 | } |
2241 | 2781 | ||
2242 | //add the items that started colliding this time to the last colliders list. | 2782 | else |
2243 | foreach (uint localID in startedColliders) | 2783 | { |
2244 | m_lastColliders.Add(localID); | 2784 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); |
2785 | |||
2786 | // calculate things that started colliding this time | ||
2787 | // and build up list of colliders this time | ||
2788 | if (!VolumeDetectActive && CollisionSoundType >= 0) | ||
2789 | { | ||
2790 | CollisionForSoundInfo soundinfo; | ||
2791 | ContactPoint curcontact; | ||
2245 | 2792 | ||
2246 | // remove things that ended colliding from the last colliders list | 2793 | foreach (uint id in collissionswith.Keys) |
2247 | foreach (uint localID in endedColliders) | 2794 | { |
2248 | m_lastColliders.Remove(localID); | 2795 | thisHitColliders.Add(id); |
2796 | if (!m_lastColliders.Contains(id)) | ||
2797 | { | ||
2798 | startedColliders.Add(id); | ||
2249 | 2799 | ||
2250 | // play the sound. | 2800 | curcontact = collissionswith[id]; |
2251 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2801 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) |
2252 | { | 2802 | { |
2253 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | 2803 | soundinfo = new CollisionForSoundInfo(); |
2254 | if (soundModule != null) | 2804 | soundinfo.colliderID = id; |
2805 | soundinfo.position = curcontact.Position; | ||
2806 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2807 | soundinfolist.Add(soundinfo); | ||
2808 | } | ||
2809 | } | ||
2810 | } | ||
2811 | } | ||
2812 | else | ||
2255 | { | 2813 | { |
2256 | soundModule.SendSound(UUID, CollisionSound, | 2814 | foreach (uint id in collissionswith.Keys) |
2257 | CollisionSoundVolume, true, (byte)0, 0, false, | 2815 | { |
2258 | false); | 2816 | thisHitColliders.Add(id); |
2817 | if (!m_lastColliders.Contains(id)) | ||
2818 | startedColliders.Add(id); | ||
2819 | } | ||
2820 | } | ||
2821 | |||
2822 | // calculate things that ended colliding | ||
2823 | foreach (uint localID in m_lastColliders) | ||
2824 | { | ||
2825 | if (!thisHitColliders.Contains(localID)) | ||
2826 | endedColliders.Add(localID); | ||
2259 | } | 2827 | } |
2828 | |||
2829 | //add the items that started colliding this time to the last colliders list. | ||
2830 | foreach (uint localID in startedColliders) | ||
2831 | m_lastColliders.Add(localID); | ||
2832 | |||
2833 | // remove things that ended colliding from the last colliders list | ||
2834 | foreach (uint localID in endedColliders) | ||
2835 | m_lastColliders.Remove(localID); | ||
2836 | |||
2837 | // play sounds. | ||
2838 | if (soundinfolist.Count > 0) | ||
2839 | CollisionSounds.PartCollisionSound(this, soundinfolist); | ||
2260 | } | 2840 | } |
2261 | 2841 | ||
2262 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2842 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2263 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2843 | if (!VolumeDetectActive) |
2844 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2264 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2845 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2265 | 2846 | ||
2266 | if (startedColliders.Contains(0)) | 2847 | if (startedColliders.Contains(0)) |
2267 | { | 2848 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); |
2268 | if (m_lastColliders.Contains(0)) | 2849 | if (m_lastColliders.Contains(0)) |
2269 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); | 2850 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); |
2270 | else | ||
2271 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); | ||
2272 | } | ||
2273 | if (endedColliders.Contains(0)) | 2851 | if (endedColliders.Contains(0)) |
2274 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2852 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2275 | } | 2853 | } |
2276 | 2854 | ||
2855 | // The Collision sounds code calls this | ||
2856 | public void SendCollisionSound(UUID soundID, double volume, Vector3 position) | ||
2857 | { | ||
2858 | if (soundID == UUID.Zero) | ||
2859 | return; | ||
2860 | |||
2861 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
2862 | if (soundModule == null) | ||
2863 | return; | ||
2864 | |||
2865 | if (volume > 1) | ||
2866 | volume = 1; | ||
2867 | if (volume < 0) | ||
2868 | volume = 0; | ||
2869 | |||
2870 | int now = Util.EnvironmentTickCount(); | ||
2871 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) | ||
2872 | return; | ||
2873 | |||
2874 | LastColSoundSentTime = now; | ||
2875 | |||
2876 | UUID ownerID = OwnerID; | ||
2877 | UUID objectID = ParentGroup.RootPart.UUID; | ||
2878 | UUID parentID = ParentGroup.UUID; | ||
2879 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
2880 | |||
2881 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); | ||
2882 | } | ||
2883 | |||
2277 | public void PhysicsOutOfBounds(Vector3 pos) | 2884 | public void PhysicsOutOfBounds(Vector3 pos) |
2278 | { | 2885 | { |
2279 | // Note: This is only being called on the root prim at this time. | 2886 | // Note: This is only being called on the root prim at this time. |
@@ -2295,9 +2902,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2295 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2902 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); |
2296 | 2903 | ||
2297 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | 2904 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) |
2298 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | 2905 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) |
2299 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | 2906 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) |
2300 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | 2907 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) |
2301 | { | 2908 | { |
2302 | ParentGroup.AbsolutePosition = newpos; | 2909 | ParentGroup.AbsolutePosition = newpos; |
2303 | return; | 2910 | return; |
@@ -2424,6 +3031,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2424 | APIDTarget = Quaternion.Identity; | 3031 | APIDTarget = Quaternion.Identity; |
2425 | } | 3032 | } |
2426 | 3033 | ||
3034 | |||
3035 | |||
3036 | public void ScheduleFullUpdateIfNone() | ||
3037 | { | ||
3038 | if (ParentGroup == null) | ||
3039 | return; | ||
3040 | |||
3041 | // ??? ParentGroup.HasGroupChanged = true; | ||
3042 | |||
3043 | if (UpdateFlag != UpdateRequired.FULL) | ||
3044 | ScheduleFullUpdate(); | ||
3045 | } | ||
3046 | |||
2427 | /// <summary> | 3047 | /// <summary> |
2428 | /// Schedules this prim for a full update | 3048 | /// Schedules this prim for a full update |
2429 | /// </summary> | 3049 | /// </summary> |
@@ -2569,6 +3189,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2569 | if (ParentGroup == null) | 3189 | if (ParentGroup == null) |
2570 | return; | 3190 | return; |
2571 | 3191 | ||
3192 | // Update the "last" values | ||
3193 | m_lastPosition = OffsetPosition; | ||
3194 | m_lastRotation = RotationOffset; | ||
3195 | m_lastVelocity = Velocity; | ||
3196 | m_lastAcceleration = Acceleration; | ||
3197 | m_lastAngularVelocity = AngularVelocity; | ||
3198 | m_lastUpdateSentTime = Environment.TickCount; | ||
3199 | |||
2572 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 3200 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2573 | { | 3201 | { |
2574 | SendFullUpdate(avatar.ControllingClient); | 3202 | SendFullUpdate(avatar.ControllingClient); |
@@ -2627,8 +3255,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2627 | { | 3255 | { |
2628 | const float ROTATION_TOLERANCE = 0.01f; | 3256 | const float ROTATION_TOLERANCE = 0.01f; |
2629 | const float VELOCITY_TOLERANCE = 0.001f; | 3257 | const float VELOCITY_TOLERANCE = 0.001f; |
2630 | const float POSITION_TOLERANCE = 0.05f; | 3258 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2631 | const int TIME_MS_TOLERANCE = 3000; | 3259 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2632 | 3260 | ||
2633 | switch (UpdateFlag) | 3261 | switch (UpdateFlag) |
2634 | { | 3262 | { |
@@ -2642,17 +3270,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2642 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || | 3270 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || |
2643 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || | 3271 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || |
2644 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 3272 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
2645 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 3273 | Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) |
2646 | { | 3274 | { |
2647 | SendTerseUpdateToAllClients(); | 3275 | SendTerseUpdateToAllClients(); |
2648 | 3276 | ||
2649 | // Update the "last" values | ||
2650 | m_lastPosition = OffsetPosition; | ||
2651 | m_lastRotation = RotationOffset; | ||
2652 | m_lastVelocity = Velocity; | ||
2653 | m_lastAcceleration = Acceleration; | ||
2654 | m_lastAngularVelocity = AngularVelocity; | ||
2655 | m_lastTerseSent = Environment.TickCount; | ||
2656 | } | 3277 | } |
2657 | break; | 3278 | break; |
2658 | } | 3279 | } |
@@ -2670,6 +3291,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2670 | /// </summary> | 3291 | /// </summary> |
2671 | public void SendTerseUpdateToAllClients() | 3292 | public void SendTerseUpdateToAllClients() |
2672 | { | 3293 | { |
3294 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3295 | return; | ||
3296 | |||
3297 | // Update the "last" values | ||
3298 | m_lastPosition = OffsetPosition; | ||
3299 | m_lastRotation = RotationOffset; | ||
3300 | m_lastVelocity = Velocity; | ||
3301 | m_lastAcceleration = Acceleration; | ||
3302 | m_lastAngularVelocity = AngularVelocity; | ||
3303 | m_lastUpdateSentTime = Environment.TickCount; | ||
3304 | |||
2673 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3305 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
2674 | { | 3306 | { |
2675 | SendTerseUpdateToClient(client); | 3307 | SendTerseUpdateToClient(client); |
@@ -2693,10 +3325,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2693 | 3325 | ||
2694 | public void SetBuoyancy(float fvalue) | 3326 | public void SetBuoyancy(float fvalue) |
2695 | { | 3327 | { |
2696 | PhysicsActor pa = PhysActor; | 3328 | Buoyancy = fvalue; |
2697 | 3329 | /* | |
2698 | if (pa != null) | 3330 | if (PhysActor != null) |
2699 | pa.Buoyancy = fvalue; | 3331 | { |
3332 | PhysActor.Buoyancy = fvalue; | ||
3333 | } | ||
3334 | */ | ||
2700 | } | 3335 | } |
2701 | 3336 | ||
2702 | public void SetDieAtEdge(bool p) | 3337 | public void SetDieAtEdge(bool p) |
@@ -2712,47 +3347,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2712 | PhysicsActor pa = PhysActor; | 3347 | PhysicsActor pa = PhysActor; |
2713 | 3348 | ||
2714 | if (pa != null) | 3349 | if (pa != null) |
2715 | pa.FloatOnWater = floatYN == 1; | 3350 | pa.FloatOnWater = (floatYN == 1); |
2716 | } | 3351 | } |
2717 | 3352 | ||
2718 | public void SetForce(Vector3 force) | 3353 | public void SetForce(Vector3 force) |
2719 | { | 3354 | { |
2720 | PhysicsActor pa = PhysActor; | 3355 | Force = force; |
3356 | } | ||
2721 | 3357 | ||
2722 | if (pa != null) | 3358 | public SOPVehicle VehicleParams |
2723 | pa.Force = force; | 3359 | { |
3360 | get | ||
3361 | { | ||
3362 | return m_vehicleParams; | ||
3363 | } | ||
3364 | set | ||
3365 | { | ||
3366 | m_vehicleParams = value; | ||
3367 | } | ||
3368 | } | ||
3369 | |||
3370 | |||
3371 | public int VehicleType | ||
3372 | { | ||
3373 | get | ||
3374 | { | ||
3375 | if (m_vehicleParams == null) | ||
3376 | return (int)Vehicle.TYPE_NONE; | ||
3377 | else | ||
3378 | return (int)m_vehicleParams.Type; | ||
3379 | } | ||
3380 | set | ||
3381 | { | ||
3382 | SetVehicleType(value); | ||
3383 | } | ||
2724 | } | 3384 | } |
2725 | 3385 | ||
2726 | public void SetVehicleType(int type) | 3386 | public void SetVehicleType(int type) |
2727 | { | 3387 | { |
2728 | PhysicsActor pa = PhysActor; | 3388 | m_vehicleParams = null; |
3389 | |||
3390 | if (type == (int)Vehicle.TYPE_NONE) | ||
3391 | { | ||
3392 | if (_parentID ==0 && PhysActor != null) | ||
3393 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | ||
3394 | return; | ||
3395 | } | ||
3396 | m_vehicleParams = new SOPVehicle(); | ||
3397 | m_vehicleParams.ProcessTypeChange((Vehicle)type); | ||
3398 | { | ||
3399 | if (_parentID ==0 && PhysActor != null) | ||
3400 | PhysActor.VehicleType = type; | ||
3401 | return; | ||
3402 | } | ||
3403 | } | ||
2729 | 3404 | ||
2730 | if (pa != null) | 3405 | public void SetVehicleFlags(int param, bool remove) |
2731 | pa.VehicleType = type; | 3406 | { |
3407 | if (m_vehicleParams == null) | ||
3408 | return; | ||
3409 | |||
3410 | m_vehicleParams.ProcessVehicleFlags(param, remove); | ||
3411 | |||
3412 | if (_parentID ==0 && PhysActor != null) | ||
3413 | { | ||
3414 | PhysActor.VehicleFlags(param, remove); | ||
3415 | } | ||
2732 | } | 3416 | } |
2733 | 3417 | ||
2734 | public void SetVehicleFloatParam(int param, float value) | 3418 | public void SetVehicleFloatParam(int param, float value) |
2735 | { | 3419 | { |
2736 | PhysicsActor pa = PhysActor; | 3420 | if (m_vehicleParams == null) |
3421 | return; | ||
2737 | 3422 | ||
2738 | if (pa != null) | 3423 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
2739 | pa.VehicleFloatParam(param, value); | 3424 | |
3425 | if (_parentID == 0 && PhysActor != null) | ||
3426 | { | ||
3427 | PhysActor.VehicleFloatParam(param, value); | ||
3428 | } | ||
2740 | } | 3429 | } |
2741 | 3430 | ||
2742 | public void SetVehicleVectorParam(int param, Vector3 value) | 3431 | public void SetVehicleVectorParam(int param, Vector3 value) |
2743 | { | 3432 | { |
2744 | PhysicsActor pa = PhysActor; | 3433 | if (m_vehicleParams == null) |
3434 | return; | ||
2745 | 3435 | ||
2746 | if (pa != null) | 3436 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
2747 | pa.VehicleVectorParam(param, value); | 3437 | |
3438 | if (_parentID == 0 && PhysActor != null) | ||
3439 | { | ||
3440 | PhysActor.VehicleVectorParam(param, value); | ||
3441 | } | ||
2748 | } | 3442 | } |
2749 | 3443 | ||
2750 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3444 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
2751 | { | 3445 | { |
2752 | PhysicsActor pa = PhysActor; | 3446 | if (m_vehicleParams == null) |
3447 | return; | ||
2753 | 3448 | ||
2754 | if (pa != null) | 3449 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
2755 | pa.VehicleRotationParam(param, rotation); | 3450 | |
3451 | if (_parentID == 0 && PhysActor != null) | ||
3452 | { | ||
3453 | PhysActor.VehicleRotationParam(param, rotation); | ||
3454 | } | ||
2756 | } | 3455 | } |
2757 | 3456 | ||
2758 | /// <summary> | 3457 | /// <summary> |
@@ -2953,14 +3652,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2953 | hasProfileCut = hasDimple; // is it the same thing? | 3652 | hasProfileCut = hasDimple; // is it the same thing? |
2954 | } | 3653 | } |
2955 | 3654 | ||
2956 | public void SetVehicleFlags(int param, bool remove) | ||
2957 | { | ||
2958 | PhysicsActor pa = PhysActor; | ||
2959 | |||
2960 | if (pa != null) | ||
2961 | pa.VehicleFlags(param, remove); | ||
2962 | } | ||
2963 | |||
2964 | public void SetGroup(UUID groupID, IClientAPI client) | 3655 | public void SetGroup(UUID groupID, IClientAPI client) |
2965 | { | 3656 | { |
2966 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3657 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3060,71 +3751,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3060 | { | 3751 | { |
3061 | ParentGroup.stopMoveToTarget(); | 3752 | ParentGroup.stopMoveToTarget(); |
3062 | 3753 | ||
3063 | ParentGroup.ScheduleGroupForTerseUpdate(); | 3754 | // ParentGroup.ScheduleGroupForTerseUpdate(); |
3064 | //ParentGroup.ScheduleGroupForFullUpdate(); | 3755 | //ParentGroup.ScheduleGroupForFullUpdate(); |
3065 | } | 3756 | } |
3066 | 3757 | ||
3067 | public void StoreUndoState() | 3758 | public void StoreUndoState(ObjectChangeType change) |
3068 | { | ||
3069 | StoreUndoState(false); | ||
3070 | } | ||
3071 | |||
3072 | public void StoreUndoState(bool forGroup) | ||
3073 | { | 3759 | { |
3074 | if (ParentGroup == null || ParentGroup.Scene == null) | 3760 | if (m_UndoRedo == null) |
3075 | return; | 3761 | m_UndoRedo = new UndoRedoState(5); |
3076 | |||
3077 | if (Undoing) | ||
3078 | { | ||
3079 | // m_log.DebugFormat( | ||
3080 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | ||
3081 | return; | ||
3082 | } | ||
3083 | |||
3084 | if (IgnoreUndoUpdate) | ||
3085 | { | ||
3086 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | ||
3087 | return; | ||
3088 | } | ||
3089 | 3762 | ||
3090 | lock (m_undo) | 3763 | lock (m_UndoRedo) |
3091 | { | 3764 | { |
3092 | if (m_undo.Count > 0) | 3765 | if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended |
3093 | { | ||
3094 | UndoState last = m_undo[m_undo.Count - 1]; | ||
3095 | if (last != null) | ||
3096 | { | ||
3097 | // TODO: May need to fix for group comparison | ||
3098 | if (last.Compare(this)) | ||
3099 | { | ||
3100 | // m_log.DebugFormat( | ||
3101 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | ||
3102 | // Name, LocalId, m_undo.Count); | ||
3103 | |||
3104 | return; | ||
3105 | } | ||
3106 | } | ||
3107 | } | ||
3108 | |||
3109 | // m_log.DebugFormat( | ||
3110 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | ||
3111 | // Name, LocalId, forGroup, m_undo.Count); | ||
3112 | |||
3113 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3114 | { | 3766 | { |
3115 | UndoState nUndo = new UndoState(this, forGroup); | 3767 | m_UndoRedo.StoreUndo(this, change); |
3116 | |||
3117 | m_undo.Add(nUndo); | ||
3118 | |||
3119 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3120 | m_undo.RemoveAt(0); | ||
3121 | |||
3122 | if (m_redo.Count > 0) | ||
3123 | m_redo.Clear(); | ||
3124 | |||
3125 | // m_log.DebugFormat( | ||
3126 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | ||
3127 | // Name, LocalId, forGroup, m_undo.Count); | ||
3128 | } | 3768 | } |
3129 | } | 3769 | } |
3130 | } | 3770 | } |
@@ -3136,88 +3776,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3136 | { | 3776 | { |
3137 | get | 3777 | get |
3138 | { | 3778 | { |
3139 | lock (m_undo) | 3779 | if (m_UndoRedo == null) |
3140 | return m_undo.Count; | 3780 | return 0; |
3781 | return m_UndoRedo.Count; | ||
3141 | } | 3782 | } |
3142 | } | 3783 | } |
3143 | 3784 | ||
3144 | public void Undo() | 3785 | public void Undo() |
3145 | { | 3786 | { |
3146 | lock (m_undo) | 3787 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3147 | { | 3788 | return; |
3148 | // m_log.DebugFormat( | ||
3149 | // "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", | ||
3150 | // Name, LocalId, m_undo.Count); | ||
3151 | |||
3152 | if (m_undo.Count > 0) | ||
3153 | { | ||
3154 | UndoState goback = m_undo[m_undo.Count - 1]; | ||
3155 | m_undo.RemoveAt(m_undo.Count - 1); | ||
3156 | |||
3157 | UndoState nUndo = null; | ||
3158 | |||
3159 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3160 | { | ||
3161 | nUndo = new UndoState(this, goback.ForGroup); | ||
3162 | } | ||
3163 | |||
3164 | goback.PlaybackState(this); | ||
3165 | |||
3166 | if (nUndo != null) | ||
3167 | { | ||
3168 | m_redo.Add(nUndo); | ||
3169 | |||
3170 | if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3171 | m_redo.RemoveAt(0); | ||
3172 | } | ||
3173 | } | ||
3174 | 3789 | ||
3175 | // m_log.DebugFormat( | 3790 | lock (m_UndoRedo) |
3176 | // "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", | 3791 | { |
3177 | // Name, LocalId, m_undo.Count); | 3792 | Undoing = true; |
3793 | m_UndoRedo.Undo(this); | ||
3794 | Undoing = false; | ||
3178 | } | 3795 | } |
3179 | } | 3796 | } |
3180 | 3797 | ||
3181 | public void Redo() | 3798 | public void Redo() |
3182 | { | 3799 | { |
3183 | lock (m_undo) | 3800 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3184 | { | 3801 | return; |
3185 | // m_log.DebugFormat( | ||
3186 | // "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", | ||
3187 | // Name, LocalId, m_redo.Count); | ||
3188 | |||
3189 | if (m_redo.Count > 0) | ||
3190 | { | ||
3191 | UndoState gofwd = m_redo[m_redo.Count - 1]; | ||
3192 | m_redo.RemoveAt(m_redo.Count - 1); | ||
3193 | |||
3194 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3195 | { | ||
3196 | UndoState nUndo = new UndoState(this, gofwd.ForGroup); | ||
3197 | |||
3198 | m_undo.Add(nUndo); | ||
3199 | |||
3200 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3201 | m_undo.RemoveAt(0); | ||
3202 | } | ||
3203 | |||
3204 | gofwd.PlayfwdState(this); | ||
3205 | 3802 | ||
3206 | // m_log.DebugFormat( | 3803 | lock (m_UndoRedo) |
3207 | // "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", | 3804 | { |
3208 | // Name, LocalId, m_redo.Count); | 3805 | Undoing = true; |
3209 | } | 3806 | m_UndoRedo.Redo(this); |
3807 | Undoing = false; | ||
3210 | } | 3808 | } |
3211 | } | 3809 | } |
3212 | 3810 | ||
3213 | public void ClearUndoState() | 3811 | public void ClearUndoState() |
3214 | { | 3812 | { |
3215 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); | 3813 | if (m_UndoRedo == null || Undoing) |
3814 | return; | ||
3216 | 3815 | ||
3217 | lock (m_undo) | 3816 | lock (m_UndoRedo) |
3218 | { | 3817 | { |
3219 | m_undo.Clear(); | 3818 | m_UndoRedo.Clear(); |
3220 | m_redo.Clear(); | ||
3221 | } | 3819 | } |
3222 | } | 3820 | } |
3223 | 3821 | ||
@@ -3768,7 +4366,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3768 | if (god) | 4366 | if (god) |
3769 | { | 4367 | { |
3770 | BaseMask = ApplyMask(BaseMask, set, mask); | 4368 | BaseMask = ApplyMask(BaseMask, set, mask); |
3771 | Inventory.ApplyGodPermissions(_baseMask); | 4369 | Inventory.ApplyGodPermissions(BaseMask); |
3772 | } | 4370 | } |
3773 | 4371 | ||
3774 | break; | 4372 | break; |
@@ -3787,7 +4385,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3787 | case 16: | 4385 | case 16: |
3788 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & | 4386 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & |
3789 | baseMask; | 4387 | baseMask; |
3790 | // Prevent the client from creating no mod, no copy | 4388 | // Prevent the client from creating no copy, no transfer |
3791 | // objects | 4389 | // objects |
3792 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) | 4390 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) |
3793 | NextOwnerMask |= (uint)PermissionMask.Transfer; | 4391 | NextOwnerMask |= (uint)PermissionMask.Transfer; |
@@ -3805,20 +4403,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3805 | { | 4403 | { |
3806 | bool update = false; | 4404 | bool update = false; |
3807 | 4405 | ||
3808 | if (BaseMask != source.BaseMask || | 4406 | uint prevOwnerMask = OwnerMask; |
3809 | OwnerMask != source.OwnerMask || | 4407 | uint prevGroupMask = GroupMask; |
3810 | GroupMask != source.GroupMask || | 4408 | uint prevEveryoneMask = EveryoneMask; |
3811 | EveryoneMask != source.EveryoneMask || | 4409 | uint prevNextOwnerMask = NextOwnerMask; |
3812 | NextOwnerMask != source.NextOwnerMask) | ||
3813 | update = true; | ||
3814 | 4410 | ||
3815 | BaseMask = source.BaseMask; | 4411 | OwnerMask = source.OwnerMask & BaseMask; |
3816 | OwnerMask = source.OwnerMask; | 4412 | GroupMask = source.GroupMask & BaseMask; |
3817 | GroupMask = source.GroupMask; | 4413 | EveryoneMask = source.EveryoneMask & BaseMask; |
3818 | EveryoneMask = source.EveryoneMask; | 4414 | NextOwnerMask = source.NextOwnerMask & BaseMask; |
3819 | NextOwnerMask = source.NextOwnerMask; | ||
3820 | 4415 | ||
3821 | if (update) | 4416 | if (OwnerMask != prevOwnerMask || |
4417 | GroupMask != prevGroupMask || | ||
4418 | EveryoneMask != prevEveryoneMask || | ||
4419 | NextOwnerMask != prevNextOwnerMask) | ||
3822 | SendFullUpdateToAllClients(); | 4420 | SendFullUpdateToAllClients(); |
3823 | } | 4421 | } |
3824 | 4422 | ||
@@ -3869,6 +4467,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3869 | } | 4467 | } |
3870 | } | 4468 | } |
3871 | 4469 | ||
4470 | |||
4471 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) | ||
4472 | { | ||
4473 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) | ||
4474 | return; | ||
4475 | |||
4476 | if (PhysicsShapeType != (byte)physdata.PhysShapeType) | ||
4477 | { | ||
4478 | PhysicsShapeType = (byte)physdata.PhysShapeType; | ||
4479 | |||
4480 | } | ||
4481 | |||
4482 | if(Density != physdata.Density) | ||
4483 | Density = physdata.Density; | ||
4484 | if(GravityModifier != physdata.GravitationModifier) | ||
4485 | GravityModifier = physdata.GravitationModifier; | ||
4486 | if(Friction != physdata.Friction) | ||
4487 | Friction = physdata.Friction; | ||
4488 | if(Bounciness != physdata.Bounce) | ||
4489 | Bounciness = physdata.Bounce; | ||
4490 | } | ||
3872 | /// <summary> | 4491 | /// <summary> |
3873 | /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. | 4492 | /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. |
3874 | /// </summary> | 4493 | /// </summary> |
@@ -3876,7 +4495,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3876 | /// <param name="SetTemporary"></param> | 4495 | /// <param name="SetTemporary"></param> |
3877 | /// <param name="SetPhantom"></param> | 4496 | /// <param name="SetPhantom"></param> |
3878 | /// <param name="SetVD"></param> | 4497 | /// <param name="SetVD"></param> |
3879 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4498 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
3880 | { | 4499 | { |
3881 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4500 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
3882 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4501 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -3886,214 +4505,230 @@ namespace OpenSim.Region.Framework.Scenes | |||
3886 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4505 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
3887 | return; | 4506 | return; |
3888 | 4507 | ||
3889 | PhysicsActor pa = PhysActor; | 4508 | VolumeDetectActive = SetVD; |
3890 | |||
3891 | // Special cases for VD. VD can only be called from a script | ||
3892 | // and can't be combined with changes to other states. So we can rely | ||
3893 | // that... | ||
3894 | // ... if VD is changed, all others are not. | ||
3895 | // ... if one of the others is changed, VD is not. | ||
3896 | if (SetVD) // VD is active, special logic applies | ||
3897 | { | ||
3898 | // State machine logic for VolumeDetect | ||
3899 | // More logic below | ||
3900 | bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; | ||
3901 | |||
3902 | if (phanReset) // Phantom changes from on to off switch VD off too | ||
3903 | { | ||
3904 | SetVD = false; // Switch it of for the course of this routine | ||
3905 | VolumeDetectActive = false; // and also permanently | ||
3906 | |||
3907 | if (pa != null) | ||
3908 | pa.SetVolumeDetect(0); // Let physics know about it too | ||
3909 | } | ||
3910 | else | ||
3911 | { | ||
3912 | // If volumedetect is active we don't want phantom to be applied. | ||
3913 | // If this is a new call to VD out of the state "phantom" | ||
3914 | // this will also cause the prim to be visible to physics | ||
3915 | SetPhantom = false; | ||
3916 | } | ||
3917 | } | ||
3918 | 4509 | ||
3919 | if (UsePhysics && IsJoint()) | 4510 | // volume detector implies phantom |
3920 | { | 4511 | if (VolumeDetectActive) |
3921 | SetPhantom = true; | 4512 | SetPhantom = true; |
3922 | } | ||
3923 | 4513 | ||
3924 | if (UsePhysics) | 4514 | if (UsePhysics) |
3925 | { | ||
3926 | AddFlag(PrimFlags.Physics); | 4515 | AddFlag(PrimFlags.Physics); |
3927 | if (!wasUsingPhysics) | ||
3928 | { | ||
3929 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
3930 | } | ||
3931 | } | ||
3932 | else | 4516 | else |
3933 | { | ||
3934 | RemFlag(PrimFlags.Physics); | 4517 | RemFlag(PrimFlags.Physics); |
3935 | if (wasUsingPhysics) | ||
3936 | { | ||
3937 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
3938 | } | ||
3939 | } | ||
3940 | 4518 | ||
3941 | if (SetPhantom | 4519 | if (SetPhantom) |
3942 | || ParentGroup.IsAttachment | ||
3943 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | ||
3944 | { | ||
3945 | AddFlag(PrimFlags.Phantom); | 4520 | AddFlag(PrimFlags.Phantom); |
3946 | 4521 | else | |
3947 | if (PhysActor != null) | ||
3948 | { | ||
3949 | RemoveFromPhysics(); | ||
3950 | pa = null; | ||
3951 | } | ||
3952 | } | ||
3953 | else // Not phantom | ||
3954 | { | ||
3955 | RemFlag(PrimFlags.Phantom); | 4522 | RemFlag(PrimFlags.Phantom); |
3956 | 4523 | ||
3957 | if (ParentGroup.Scene == null) | 4524 | if (SetTemporary) |
3958 | return; | 4525 | AddFlag(PrimFlags.TemporaryOnRez); |
4526 | else | ||
4527 | RemFlag(PrimFlags.TemporaryOnRez); | ||
3959 | 4528 | ||
3960 | if (ParentGroup.Scene.CollidablePrims && pa == null) | ||
3961 | { | ||
3962 | pa = AddToPhysics(UsePhysics); | ||
3963 | 4529 | ||
3964 | if (pa != null) | 4530 | if (ParentGroup.Scene == null) |
3965 | { | 4531 | return; |
3966 | pa.SetMaterial(Material); | 4532 | |
3967 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4533 | PhysicsActor pa = PhysActor; |
3968 | |||
3969 | if ( | ||
3970 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
3971 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
3972 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
3973 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
3974 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
3975 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
3976 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
3977 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
3978 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
3979 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
3980 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
3981 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
3982 | (CollisionSound != UUID.Zero) | ||
3983 | ) | ||
3984 | { | ||
3985 | pa.OnCollisionUpdate += PhysicsCollision; | ||
3986 | pa.SubscribeEvents(1000); | ||
3987 | } | ||
3988 | } | ||
3989 | } | ||
3990 | else // it already has a physical representation | ||
3991 | { | ||
3992 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim | ||
3993 | } | ||
3994 | } | ||
3995 | 4534 | ||
3996 | if (SetVD) | 4535 | if (pa != null && building && pa.Building != building) |
4536 | pa.Building = building; | ||
4537 | |||
4538 | if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | ||
4539 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
3997 | { | 4540 | { |
3998 | // If the above logic worked (this is urgent candidate to unit tests!) | ||
3999 | // we now have a physicsactor. | ||
4000 | // Defensive programming calls for a check here. | ||
4001 | // Better would be throwing an exception that could be catched by a unit test as the internal | ||
4002 | // logic should make sure, this Physactor is always here. | ||
4003 | if (pa != null) | 4541 | if (pa != null) |
4004 | { | 4542 | { |
4005 | pa.SetVolumeDetect(1); | 4543 | if(wasUsingPhysics) |
4006 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4544 | ParentGroup.Scene.RemovePhysicalPrim(1); |
4007 | VolumeDetectActive = true; | 4545 | RemoveFromPhysics(); |
4008 | } | 4546 | } |
4547 | |||
4548 | Velocity = new Vector3(0, 0, 0); | ||
4549 | Acceleration = new Vector3(0, 0, 0); | ||
4550 | if (ParentGroup.RootPart == this) | ||
4551 | AngularVelocity = new Vector3(0, 0, 0); | ||
4009 | } | 4552 | } |
4010 | else if (SetVD != wasVD) | 4553 | else if (SetVD != wasVD) |
4011 | { | 4554 | { |
4012 | // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like | 4555 | if (ParentGroup.Scene.CollidablePrims) |
4013 | // (mumbles, well, at least if you have infinte CPU powers :-)) | 4556 | { |
4014 | if (pa != null) | 4557 | if (pa == null) |
4015 | pa.SetVolumeDetect(0); | 4558 | { |
4559 | AddToPhysics(UsePhysics, SetPhantom, building, false); | ||
4560 | pa = PhysActor; | ||
4561 | /* | ||
4562 | if (pa != null) | ||
4563 | { | ||
4564 | if ( | ||
4565 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4566 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4567 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4568 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4569 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4570 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4571 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4572 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4573 | (CollisionSound != UUID.Zero) | ||
4574 | ) | ||
4575 | { | ||
4576 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4577 | pa.SubscribeEvents(1000); | ||
4578 | } | ||
4579 | } | ||
4580 | */ | ||
4581 | } | ||
4582 | else // it already has a physical representation | ||
4583 | { | ||
4584 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | ||
4585 | /* moved into DoPhysicsPropertyUpdate | ||
4586 | if(VolumeDetectActive) | ||
4587 | pa.SetVolumeDetect(1); | ||
4588 | else | ||
4589 | pa.SetVolumeDetect(0); | ||
4590 | */ | ||
4016 | 4591 | ||
4017 | RemFlag(PrimFlags.Phantom); | 4592 | if (pa.Building != building) |
4018 | VolumeDetectActive = false; | 4593 | pa.Building = building; |
4019 | } | 4594 | } |
4020 | 4595 | ||
4021 | if (SetTemporary) | 4596 | UpdatePhysicsSubscribedEvents(); |
4022 | { | 4597 | } |
4023 | AddFlag(PrimFlags.TemporaryOnRez); | 4598 | } |
4024 | } | ||
4025 | else | ||
4026 | { | ||
4027 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4028 | } | ||
4029 | 4599 | ||
4030 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | 4600 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); |
4031 | 4601 | ||
4602 | // and last in case we have a new actor and not building | ||
4603 | |||
4032 | if (ParentGroup != null) | 4604 | if (ParentGroup != null) |
4033 | { | 4605 | { |
4034 | ParentGroup.HasGroupChanged = true; | 4606 | ParentGroup.HasGroupChanged = true; |
4035 | ScheduleFullUpdate(); | 4607 | ScheduleFullUpdate(); |
4036 | } | 4608 | } |
4037 | 4609 | ||
4038 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4610 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4039 | } | 4611 | } |
4040 | 4612 | ||
4041 | /// <summary> | 4613 | /// <summary> |
4042 | /// Adds this part to the physics scene. | 4614 | /// Adds this part to the physics scene. |
4615 | /// and sets the PhysActor property | ||
4043 | /// </summary> | 4616 | /// </summary> |
4044 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4617 | /// <param name="isPhysical">Add this prim as physical.</param> |
4045 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4618 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4046 | /// <returns> | 4619 | /// <param name="building">tells physics to delay full construction of object</param> |
4047 | /// The physics actor. null if there was a failure. | 4620 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4048 | /// </returns> | 4621 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4049 | private PhysicsActor AddToPhysics(bool rigidBody) | 4622 | { |
4050 | { | ||
4051 | PhysicsActor pa; | 4623 | PhysicsActor pa; |
4052 | 4624 | ||
4625 | Vector3 velocity = Velocity; | ||
4626 | Vector3 rotationalVelocity = AngularVelocity;; | ||
4627 | |||
4053 | try | 4628 | try |
4054 | { | 4629 | { |
4055 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4630 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4056 | string.Format("{0}/{1}", Name, UUID), | 4631 | string.Format("{0}/{1}", Name, UUID), |
4057 | Shape, | 4632 | Shape, |
4058 | AbsolutePosition, | 4633 | AbsolutePosition, |
4059 | Scale, | 4634 | Scale, |
4060 | RotationOffset, | 4635 | GetWorldRotation(), |
4061 | rigidBody, | 4636 | isPhysical, |
4062 | m_localId); | 4637 | isPhantom, |
4638 | PhysicsShapeType, | ||
4639 | m_localId); | ||
4063 | } | 4640 | } |
4064 | catch (Exception e) | 4641 | catch (Exception e) |
4065 | { | 4642 | { |
4066 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); | 4643 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); |
4067 | pa = null; | 4644 | pa = null; |
4068 | } | 4645 | } |
4069 | 4646 | ||
4070 | // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical | ||
4071 | // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor | ||
4072 | // being set. | ||
4073 | PhysActor = pa; | ||
4074 | |||
4075 | // Basic Physics can also return null as well as an exception catch. | ||
4076 | if (pa != null) | 4647 | if (pa != null) |
4077 | { | 4648 | { |
4078 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4649 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
4079 | pa.SetMaterial(Material); | 4650 | pa.SetMaterial(Material); |
4080 | DoPhysicsPropertyUpdate(rigidBody, true); | 4651 | |
4652 | if (VolumeDetectActive) // change if not the default only | ||
4653 | pa.SetVolumeDetect(1); | ||
4654 | |||
4655 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4656 | m_vehicleParams.SetVehicle(pa); | ||
4657 | |||
4658 | // we are going to tell rest of code about physics so better have this here | ||
4659 | PhysActor = pa; | ||
4660 | |||
4661 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4662 | // lets expand it here just with what it really needs to do | ||
4663 | |||
4664 | if (isPhysical) | ||
4665 | { | ||
4666 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
4667 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
4668 | ParentGroup.RootPart.KeyframeMotion = null; | ||
4669 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
4670 | |||
4671 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
4672 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
4673 | |||
4674 | if (ParentID != 0 && ParentID != LocalId) | ||
4675 | { | ||
4676 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
4677 | |||
4678 | if (parentPa != null) | ||
4679 | { | ||
4680 | pa.link(parentPa); | ||
4681 | } | ||
4682 | } | ||
4683 | } | ||
4684 | |||
4685 | if (applyDynamics) | ||
4686 | // do independent of isphysical so parameters get setted (at least some) | ||
4687 | { | ||
4688 | Velocity = velocity; | ||
4689 | AngularVelocity = rotationalVelocity; | ||
4690 | // pa.Velocity = velocity; | ||
4691 | pa.RotationalVelocity = rotationalVelocity; | ||
4692 | |||
4693 | // if not vehicle and root part apply force and torque | ||
4694 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) | ||
4695 | && LocalId == ParentGroup.RootPart.LocalId) | ||
4696 | { | ||
4697 | pa.Force = Force; | ||
4698 | pa.Torque = Torque; | ||
4699 | } | ||
4700 | } | ||
4701 | |||
4702 | // if (Shape.SculptEntry) | ||
4703 | // CheckSculptAndLoad(); | ||
4704 | // else | ||
4705 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
4706 | |||
4707 | if (!building) | ||
4708 | pa.Building = false; | ||
4081 | } | 4709 | } |
4082 | 4710 | ||
4083 | return pa; | 4711 | PhysActor = pa; |
4084 | } | 4712 | } |
4085 | 4713 | ||
4086 | /// <summary> | 4714 | /// <summary> |
4087 | /// This removes the part from the physics scene. | 4715 | /// This removes the part from the physics scene. |
4088 | /// </summary> | 4716 | /// </summary> |
4089 | /// <remarks> | 4717 | /// <remarks> |
4090 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4718 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4091 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 4719 | /// representation for collision detection. |
4092 | /// phantom. | ||
4093 | /// </remarks> | 4720 | /// </remarks> |
4094 | public void RemoveFromPhysics() | 4721 | public void RemoveFromPhysics() |
4095 | { | 4722 | { |
4096 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 4723 | PhysicsActor pa = PhysActor; |
4724 | if (pa != null) | ||
4725 | { | ||
4726 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4727 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
4728 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
4729 | |||
4730 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
4731 | } | ||
4097 | PhysActor = null; | 4732 | PhysActor = null; |
4098 | } | 4733 | } |
4099 | 4734 | ||
@@ -4225,6 +4860,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4225 | { | 4860 | { |
4226 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); | 4861 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); |
4227 | 4862 | ||
4863 | return; | ||
4864 | |||
4228 | if (ParentGroup.IsDeleted) | 4865 | if (ParentGroup.IsDeleted) |
4229 | return; | 4866 | return; |
4230 | 4867 | ||
@@ -4305,6 +4942,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
4305 | ScheduleFullUpdate(); | 4942 | ScheduleFullUpdate(); |
4306 | } | 4943 | } |
4307 | 4944 | ||
4945 | |||
4946 | private void UpdatePhysicsSubscribedEvents() | ||
4947 | { | ||
4948 | PhysicsActor pa = PhysActor; | ||
4949 | if (pa == null) | ||
4950 | return; | ||
4951 | |||
4952 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4953 | |||
4954 | bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); | ||
4955 | |||
4956 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
4957 | |||
4958 | // merge with root part | ||
4959 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
4960 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
4961 | |||
4962 | // submit to this part case | ||
4963 | if (VolumeDetectActive) | ||
4964 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
4965 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
4966 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
4967 | else | ||
4968 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
4969 | |||
4970 | if (hassound || CombinedEvents != 0) | ||
4971 | { | ||
4972 | // subscribe to physics updates. | ||
4973 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4974 | pa.SubscribeEvents(50); // 20 reports per second | ||
4975 | } | ||
4976 | else | ||
4977 | { | ||
4978 | pa.UnSubscribeEvents(); | ||
4979 | } | ||
4980 | } | ||
4981 | |||
4982 | |||
4308 | public void aggregateScriptEvents() | 4983 | public void aggregateScriptEvents() |
4309 | { | 4984 | { |
4310 | if (ParentGroup == null || ParentGroup.RootPart == null) | 4985 | if (ParentGroup == null || ParentGroup.RootPart == null) |
@@ -4341,40 +5016,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4341 | { | 5016 | { |
4342 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5017 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4343 | } | 5018 | } |
4344 | 5019 | /* | |
4345 | PhysicsActor pa = PhysActor; | 5020 | PhysicsActor pa = PhysActor; |
4346 | 5021 | if (pa != null) | |
4347 | if ( | ||
4348 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4349 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4350 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4351 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4352 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4353 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4354 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4355 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4356 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4357 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4358 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4359 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4360 | (CollisionSound != UUID.Zero) | ||
4361 | ) | ||
4362 | { | 5022 | { |
4363 | // subscribe to physics updates. | 5023 | if ( |
4364 | if (pa != null) | 5024 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || |
5025 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
5026 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
5027 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
5028 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
5029 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
5030 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
5031 | ) | ||
4365 | { | 5032 | { |
5033 | // subscribe to physics updates. | ||
4366 | pa.OnCollisionUpdate += PhysicsCollision; | 5034 | pa.OnCollisionUpdate += PhysicsCollision; |
4367 | pa.SubscribeEvents(1000); | 5035 | pa.SubscribeEvents(1000); |
4368 | } | 5036 | } |
4369 | } | 5037 | else |
4370 | else | ||
4371 | { | ||
4372 | if (pa != null) | ||
4373 | { | 5038 | { |
4374 | pa.UnSubscribeEvents(); | 5039 | pa.UnSubscribeEvents(); |
4375 | pa.OnCollisionUpdate -= PhysicsCollision; | 5040 | pa.OnCollisionUpdate -= PhysicsCollision; |
4376 | } | 5041 | } |
4377 | } | 5042 | } |
5043 | */ | ||
5044 | UpdatePhysicsSubscribedEvents(); | ||
4378 | 5045 | ||
4379 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 5046 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4380 | //{ | 5047 | //{ |
@@ -4505,6 +5172,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4505 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 5172 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4506 | } | 5173 | } |
4507 | 5174 | ||
5175 | public void ResetOwnerChangeFlag() | ||
5176 | { | ||
5177 | List<UUID> inv = Inventory.GetInventoryList(); | ||
5178 | |||
5179 | foreach (UUID itemID in inv) | ||
5180 | { | ||
5181 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
5182 | item.OwnerChanged = false; | ||
5183 | Inventory.UpdateInventoryItem(item, false, false); | ||
5184 | } | ||
5185 | } | ||
5186 | |||
4508 | /// <summary> | 5187 | /// <summary> |
4509 | /// Record an avatar sitting on this part. | 5188 | /// Record an avatar sitting on this part. |
4510 | /// </summary> | 5189 | /// </summary> |
@@ -4598,4 +5277,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
4598 | } | 5277 | } |
4599 | } | 5278 | } |
4600 | } | 5279 | } |
4601 | } \ No newline at end of file | 5280 | } |