diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1739 |
1 files changed, 1220 insertions, 519 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 27ef4c9..248679b 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> |
@@ -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; |
@@ -296,7 +320,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
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_lastTerseSent; |
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) |
@@ -769,7 +816,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
769 | if (ParentGroup.Scene != null) | 816 | if (ParentGroup.Scene != 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,12 +2462,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1949 | 2462 | ||
1950 | public Vector3 GetGeometricCenter() | 2463 | public Vector3 GetGeometricCenter() |
1951 | { | 2464 | { |
1952 | PhysicsActor pa = PhysActor; | 2465 | // this is not real geometric center but a average of positions relative to root prim acording to |
1953 | 2466 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | |
1954 | if (pa != null) | 2467 | // ignoring tortured prims details since sl also seems to ignore |
1955 | return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); | 2468 | // so no real use in doing it on physics |
1956 | else | 2469 | if (ParentGroup.IsDeleted) |
1957 | return new Vector3(0, 0, 0); | 2470 | return new Vector3(0, 0, 0); |
2471 | |||
2472 | return ParentGroup.GetGeometricCenter(); | ||
2473 | |||
2474 | /* | ||
2475 | PhysicsActor pa = PhysActor; | ||
2476 | |||
2477 | if (pa != null) | ||
2478 | { | ||
2479 | Vector3 vtmp = pa.CenterOfMass; | ||
2480 | return vtmp; | ||
2481 | } | ||
2482 | else | ||
2483 | return new Vector3(0, 0, 0); | ||
2484 | */ | ||
1958 | } | 2485 | } |
1959 | 2486 | ||
1960 | public float GetMass() | 2487 | public float GetMass() |
@@ -1967,14 +2494,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1967 | return 0; | 2494 | return 0; |
1968 | } | 2495 | } |
1969 | 2496 | ||
1970 | public Vector3 GetForce() | 2497 | public Vector3 GetCenterOfMass() |
2498 | { | ||
2499 | if (ParentGroup.RootPart == this) | ||
2500 | { | ||
2501 | if (ParentGroup.IsDeleted) | ||
2502 | return AbsolutePosition; | ||
2503 | return ParentGroup.GetCenterOfMass(); | ||
2504 | } | ||
2505 | |||
2506 | PhysicsActor pa = PhysActor; | ||
2507 | |||
2508 | if (pa != null) | ||
2509 | { | ||
2510 | Vector3 tmp = pa.CenterOfMass; | ||
2511 | return tmp; | ||
2512 | } | ||
2513 | else | ||
2514 | return AbsolutePosition; | ||
2515 | } | ||
2516 | |||
2517 | public Vector3 GetPartCenterOfMass() | ||
1971 | { | 2518 | { |
1972 | PhysicsActor pa = PhysActor; | 2519 | PhysicsActor pa = PhysActor; |
1973 | 2520 | ||
1974 | if (pa != null) | 2521 | if (pa != null) |
1975 | return pa.Force; | 2522 | { |
2523 | Vector3 tmp = pa.CenterOfMass; | ||
2524 | return tmp; | ||
2525 | } | ||
1976 | else | 2526 | else |
1977 | return Vector3.Zero; | 2527 | return AbsolutePosition; |
2528 | } | ||
2529 | |||
2530 | |||
2531 | public Vector3 GetForce() | ||
2532 | { | ||
2533 | return Force; | ||
1978 | } | 2534 | } |
1979 | 2535 | ||
1980 | /// <summary> | 2536 | /// <summary> |
@@ -2189,15 +2745,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2189 | 2745 | ||
2190 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) | 2746 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) |
2191 | { | 2747 | { |
2192 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) | 2748 | bool sendToRoot = true; |
2193 | { | ||
2194 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2195 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2196 | |||
2197 | colliding.Add(CreateDetObjectForGround()); | ||
2198 | LandCollidingMessage.Colliders = colliding; | ||
2199 | 2749 | ||
2750 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2751 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2752 | |||
2753 | colliding.Add(CreateDetObjectForGround()); | ||
2754 | LandCollidingMessage.Colliders = colliding; | ||
2755 | |||
2756 | if (Inventory.ContainsScripts()) | ||
2757 | { | ||
2758 | if (!PassCollisions) | ||
2759 | sendToRoot = false; | ||
2760 | } | ||
2761 | if ((ScriptEvents & ev) != 0) | ||
2200 | notify(LocalId, LandCollidingMessage); | 2762 | notify(LocalId, LandCollidingMessage); |
2763 | |||
2764 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) | ||
2765 | { | ||
2766 | notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); | ||
2201 | } | 2767 | } |
2202 | } | 2768 | } |
2203 | 2769 | ||
@@ -2213,45 +2779,87 @@ namespace OpenSim.Region.Framework.Scenes | |||
2213 | List<uint> endedColliders = new List<uint>(); | 2779 | List<uint> endedColliders = new List<uint>(); |
2214 | List<uint> startedColliders = new List<uint>(); | 2780 | List<uint> startedColliders = new List<uint>(); |
2215 | 2781 | ||
2216 | // calculate things that started colliding this time | 2782 | if (collissionswith.Count == 0) |
2217 | // and build up list of colliders this time | ||
2218 | foreach (uint localid in collissionswith.Keys) | ||
2219 | { | 2783 | { |
2220 | thisHitColliders.Add(localid); | 2784 | if (m_lastColliders.Count == 0) |
2221 | if (!m_lastColliders.Contains(localid)) | 2785 | return; // nothing to do |
2222 | startedColliders.Add(localid); | ||
2223 | } | ||
2224 | 2786 | ||
2225 | // calculate things that ended colliding | 2787 | foreach (uint localID in m_lastColliders) |
2226 | foreach (uint localID in m_lastColliders) | 2788 | { |
2227 | { | ||
2228 | if (!thisHitColliders.Contains(localID)) | ||
2229 | endedColliders.Add(localID); | 2789 | endedColliders.Add(localID); |
2790 | } | ||
2791 | m_lastColliders.Clear(); | ||
2230 | } | 2792 | } |
2231 | 2793 | ||
2232 | //add the items that started colliding this time to the last colliders list. | 2794 | else |
2233 | foreach (uint localID in startedColliders) | 2795 | { |
2234 | m_lastColliders.Add(localID); | 2796 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); |
2797 | |||
2798 | // calculate things that started colliding this time | ||
2799 | // and build up list of colliders this time | ||
2800 | if (!VolumeDetectActive && CollisionSoundType >= 0) | ||
2801 | { | ||
2802 | CollisionForSoundInfo soundinfo; | ||
2803 | ContactPoint curcontact; | ||
2804 | |||
2805 | foreach (uint id in collissionswith.Keys) | ||
2806 | { | ||
2807 | thisHitColliders.Add(id); | ||
2808 | if (!m_lastColliders.Contains(id)) | ||
2809 | { | ||
2810 | startedColliders.Add(id); | ||
2811 | |||
2812 | curcontact = collissionswith[id]; | ||
2813 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2814 | { | ||
2815 | soundinfo = new CollisionForSoundInfo(); | ||
2816 | soundinfo.colliderID = id; | ||
2817 | soundinfo.position = curcontact.Position; | ||
2818 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2819 | soundinfolist.Add(soundinfo); | ||
2820 | } | ||
2821 | } | ||
2822 | } | ||
2823 | } | ||
2824 | else | ||
2825 | { | ||
2826 | foreach (uint id in collissionswith.Keys) | ||
2827 | { | ||
2828 | thisHitColliders.Add(id); | ||
2829 | if (!m_lastColliders.Contains(id)) | ||
2830 | startedColliders.Add(id); | ||
2831 | } | ||
2832 | } | ||
2833 | |||
2834 | // calculate things that ended colliding | ||
2835 | foreach (uint localID in m_lastColliders) | ||
2836 | { | ||
2837 | if (!thisHitColliders.Contains(localID)) | ||
2838 | endedColliders.Add(localID); | ||
2839 | } | ||
2840 | |||
2841 | //add the items that started colliding this time to the last colliders list. | ||
2842 | foreach (uint localID in startedColliders) | ||
2843 | m_lastColliders.Add(localID); | ||
2235 | 2844 | ||
2236 | // remove things that ended colliding from the last colliders list | 2845 | // remove things that ended colliding from the last colliders list |
2237 | foreach (uint localID in endedColliders) | 2846 | foreach (uint localID in endedColliders) |
2238 | m_lastColliders.Remove(localID); | 2847 | m_lastColliders.Remove(localID); |
2239 | 2848 | ||
2240 | // play the sound. | 2849 | // play sounds. |
2241 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2850 | if (soundinfolist.Count > 0) |
2242 | SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); | 2851 | CollisionSounds.PartCollisionSound(this, soundinfolist); |
2852 | } | ||
2243 | 2853 | ||
2244 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2854 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2245 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2855 | if (!VolumeDetectActive) |
2856 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2246 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2857 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2247 | 2858 | ||
2248 | if (startedColliders.Contains(0)) | 2859 | if (startedColliders.Contains(0)) |
2249 | { | 2860 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); |
2250 | if (m_lastColliders.Contains(0)) | 2861 | if (m_lastColliders.Contains(0)) |
2251 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); | 2862 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); |
2252 | else | ||
2253 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); | ||
2254 | } | ||
2255 | if (endedColliders.Contains(0)) | 2863 | if (endedColliders.Contains(0)) |
2256 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2864 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2257 | } | 2865 | } |
@@ -2274,9 +2882,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2274 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2882 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); |
2275 | 2883 | ||
2276 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | 2884 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) |
2277 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | 2885 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) |
2278 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | 2886 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) |
2279 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | 2887 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) |
2280 | { | 2888 | { |
2281 | ParentGroup.AbsolutePosition = newpos; | 2889 | ParentGroup.AbsolutePosition = newpos; |
2282 | return; | 2890 | return; |
@@ -2298,17 +2906,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2298 | //Trys to fetch sound id from prim's inventory. | 2906 | //Trys to fetch sound id from prim's inventory. |
2299 | //Prim's inventory doesn't support non script items yet | 2907 | //Prim's inventory doesn't support non script items yet |
2300 | 2908 | ||
2301 | lock (TaskInventory) | 2909 | TaskInventory.LockItemsForRead(true); |
2910 | |||
2911 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2302 | { | 2912 | { |
2303 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 2913 | if (item.Value.Name == sound) |
2304 | { | 2914 | { |
2305 | if (item.Value.Name == sound) | 2915 | soundID = item.Value.ItemID; |
2306 | { | 2916 | break; |
2307 | soundID = item.Value.ItemID; | ||
2308 | break; | ||
2309 | } | ||
2310 | } | 2917 | } |
2311 | } | 2918 | } |
2919 | |||
2920 | TaskInventory.LockItemsForRead(false); | ||
2312 | } | 2921 | } |
2313 | 2922 | ||
2314 | ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 2923 | ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
@@ -2434,6 +3043,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2434 | APIDTarget = Quaternion.Identity; | 3043 | APIDTarget = Quaternion.Identity; |
2435 | } | 3044 | } |
2436 | 3045 | ||
3046 | |||
3047 | |||
3048 | public void ScheduleFullUpdateIfNone() | ||
3049 | { | ||
3050 | if (ParentGroup == null) | ||
3051 | return; | ||
3052 | |||
3053 | // ??? ParentGroup.HasGroupChanged = true; | ||
3054 | |||
3055 | if (UpdateFlag != UpdateRequired.FULL) | ||
3056 | ScheduleFullUpdate(); | ||
3057 | } | ||
3058 | |||
2437 | /// <summary> | 3059 | /// <summary> |
2438 | /// Schedules this prim for a full update | 3060 | /// Schedules this prim for a full update |
2439 | /// </summary> | 3061 | /// </summary> |
@@ -2637,8 +3259,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2637 | { | 3259 | { |
2638 | const float ROTATION_TOLERANCE = 0.01f; | 3260 | const float ROTATION_TOLERANCE = 0.01f; |
2639 | const float VELOCITY_TOLERANCE = 0.001f; | 3261 | const float VELOCITY_TOLERANCE = 0.001f; |
2640 | const float POSITION_TOLERANCE = 0.05f; | 3262 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2641 | const int TIME_MS_TOLERANCE = 3000; | 3263 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2642 | 3264 | ||
2643 | switch (UpdateFlag) | 3265 | switch (UpdateFlag) |
2644 | { | 3266 | { |
@@ -2700,17 +3322,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2700 | if (!UUID.TryParse(sound, out soundID)) | 3322 | if (!UUID.TryParse(sound, out soundID)) |
2701 | { | 3323 | { |
2702 | // search sound file from inventory | 3324 | // search sound file from inventory |
2703 | lock (TaskInventory) | 3325 | TaskInventory.LockItemsForRead(true); |
3326 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2704 | { | 3327 | { |
2705 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 3328 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) |
2706 | { | 3329 | { |
2707 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) | 3330 | soundID = item.Value.ItemID; |
2708 | { | 3331 | break; |
2709 | soundID = item.Value.ItemID; | ||
2710 | break; | ||
2711 | } | ||
2712 | } | 3332 | } |
2713 | } | 3333 | } |
3334 | TaskInventory.LockItemsForRead(false); | ||
2714 | } | 3335 | } |
2715 | 3336 | ||
2716 | if (soundID == UUID.Zero) | 3337 | if (soundID == UUID.Zero) |
@@ -2767,11 +3388,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
2767 | } | 3388 | } |
2768 | } | 3389 | } |
2769 | 3390 | ||
3391 | public void SendCollisionSound(UUID soundID, double volume, Vector3 position) | ||
3392 | { | ||
3393 | if (soundID == UUID.Zero) | ||
3394 | return; | ||
3395 | |||
3396 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
3397 | if (soundModule == null) | ||
3398 | return; | ||
3399 | |||
3400 | if (volume > 1) | ||
3401 | volume = 1; | ||
3402 | if (volume < 0) | ||
3403 | volume = 0; | ||
3404 | |||
3405 | int now = Util.EnvironmentTickCount(); | ||
3406 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) | ||
3407 | return; | ||
3408 | |||
3409 | LastColSoundSentTime = now; | ||
3410 | |||
3411 | UUID ownerID = OwnerID; | ||
3412 | UUID objectID = ParentGroup.RootPart.UUID; | ||
3413 | UUID parentID = ParentGroup.UUID; | ||
3414 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
3415 | |||
3416 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); | ||
3417 | } | ||
3418 | |||
3419 | |||
2770 | /// <summary> | 3420 | /// <summary> |
2771 | /// Send a terse update to all clients | 3421 | /// Send a terse update to all clients |
2772 | /// </summary> | 3422 | /// </summary> |
2773 | public void SendTerseUpdateToAllClients() | 3423 | public void SendTerseUpdateToAllClients() |
2774 | { | 3424 | { |
3425 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3426 | return; | ||
3427 | |||
2775 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3428 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
2776 | { | 3429 | { |
2777 | SendTerseUpdateToClient(client); | 3430 | SendTerseUpdateToClient(client); |
@@ -2795,10 +3448,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2795 | 3448 | ||
2796 | public void SetBuoyancy(float fvalue) | 3449 | public void SetBuoyancy(float fvalue) |
2797 | { | 3450 | { |
2798 | PhysicsActor pa = PhysActor; | 3451 | Buoyancy = fvalue; |
2799 | 3452 | /* | |
2800 | if (pa != null) | 3453 | if (PhysActor != null) |
2801 | pa.Buoyancy = fvalue; | 3454 | { |
3455 | PhysActor.Buoyancy = fvalue; | ||
3456 | } | ||
3457 | */ | ||
2802 | } | 3458 | } |
2803 | 3459 | ||
2804 | public void SetDieAtEdge(bool p) | 3460 | public void SetDieAtEdge(bool p) |
@@ -2814,47 +3470,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2814 | PhysicsActor pa = PhysActor; | 3470 | PhysicsActor pa = PhysActor; |
2815 | 3471 | ||
2816 | if (pa != null) | 3472 | if (pa != null) |
2817 | pa.FloatOnWater = floatYN == 1; | 3473 | pa.FloatOnWater = (floatYN == 1); |
2818 | } | 3474 | } |
2819 | 3475 | ||
2820 | public void SetForce(Vector3 force) | 3476 | public void SetForce(Vector3 force) |
2821 | { | 3477 | { |
2822 | PhysicsActor pa = PhysActor; | 3478 | Force = force; |
3479 | } | ||
2823 | 3480 | ||
2824 | if (pa != null) | 3481 | public SOPVehicle VehicleParams |
2825 | pa.Force = force; | 3482 | { |
3483 | get | ||
3484 | { | ||
3485 | return m_vehicleParams; | ||
3486 | } | ||
3487 | set | ||
3488 | { | ||
3489 | m_vehicleParams = value; | ||
3490 | } | ||
3491 | } | ||
3492 | |||
3493 | |||
3494 | public int VehicleType | ||
3495 | { | ||
3496 | get | ||
3497 | { | ||
3498 | if (m_vehicleParams == null) | ||
3499 | return (int)Vehicle.TYPE_NONE; | ||
3500 | else | ||
3501 | return (int)m_vehicleParams.Type; | ||
3502 | } | ||
3503 | set | ||
3504 | { | ||
3505 | SetVehicleType(value); | ||
3506 | } | ||
2826 | } | 3507 | } |
2827 | 3508 | ||
2828 | public void SetVehicleType(int type) | 3509 | public void SetVehicleType(int type) |
2829 | { | 3510 | { |
2830 | PhysicsActor pa = PhysActor; | 3511 | m_vehicleParams = null; |
3512 | |||
3513 | if (type == (int)Vehicle.TYPE_NONE) | ||
3514 | { | ||
3515 | if (_parentID ==0 && PhysActor != null) | ||
3516 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | ||
3517 | return; | ||
3518 | } | ||
3519 | m_vehicleParams = new SOPVehicle(); | ||
3520 | m_vehicleParams.ProcessTypeChange((Vehicle)type); | ||
3521 | { | ||
3522 | if (_parentID ==0 && PhysActor != null) | ||
3523 | PhysActor.VehicleType = type; | ||
3524 | return; | ||
3525 | } | ||
3526 | } | ||
2831 | 3527 | ||
2832 | if (pa != null) | 3528 | public void SetVehicleFlags(int param, bool remove) |
2833 | pa.VehicleType = type; | 3529 | { |
3530 | if (m_vehicleParams == null) | ||
3531 | return; | ||
3532 | |||
3533 | m_vehicleParams.ProcessVehicleFlags(param, remove); | ||
3534 | |||
3535 | if (_parentID ==0 && PhysActor != null) | ||
3536 | { | ||
3537 | PhysActor.VehicleFlags(param, remove); | ||
3538 | } | ||
2834 | } | 3539 | } |
2835 | 3540 | ||
2836 | public void SetVehicleFloatParam(int param, float value) | 3541 | public void SetVehicleFloatParam(int param, float value) |
2837 | { | 3542 | { |
2838 | PhysicsActor pa = PhysActor; | 3543 | if (m_vehicleParams == null) |
3544 | return; | ||
2839 | 3545 | ||
2840 | if (pa != null) | 3546 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
2841 | pa.VehicleFloatParam(param, value); | 3547 | |
3548 | if (_parentID == 0 && PhysActor != null) | ||
3549 | { | ||
3550 | PhysActor.VehicleFloatParam(param, value); | ||
3551 | } | ||
2842 | } | 3552 | } |
2843 | 3553 | ||
2844 | public void SetVehicleVectorParam(int param, Vector3 value) | 3554 | public void SetVehicleVectorParam(int param, Vector3 value) |
2845 | { | 3555 | { |
2846 | PhysicsActor pa = PhysActor; | 3556 | if (m_vehicleParams == null) |
3557 | return; | ||
2847 | 3558 | ||
2848 | if (pa != null) | 3559 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
2849 | pa.VehicleVectorParam(param, value); | 3560 | |
3561 | if (_parentID == 0 && PhysActor != null) | ||
3562 | { | ||
3563 | PhysActor.VehicleVectorParam(param, value); | ||
3564 | } | ||
2850 | } | 3565 | } |
2851 | 3566 | ||
2852 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3567 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
2853 | { | 3568 | { |
2854 | PhysicsActor pa = PhysActor; | 3569 | if (m_vehicleParams == null) |
3570 | return; | ||
2855 | 3571 | ||
2856 | if (pa != null) | 3572 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
2857 | pa.VehicleRotationParam(param, rotation); | 3573 | |
3574 | if (_parentID == 0 && PhysActor != null) | ||
3575 | { | ||
3576 | PhysActor.VehicleRotationParam(param, rotation); | ||
3577 | } | ||
2858 | } | 3578 | } |
2859 | 3579 | ||
2860 | /// <summary> | 3580 | /// <summary> |
@@ -3055,14 +3775,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3055 | hasProfileCut = hasDimple; // is it the same thing? | 3775 | hasProfileCut = hasDimple; // is it the same thing? |
3056 | } | 3776 | } |
3057 | 3777 | ||
3058 | public void SetVehicleFlags(int param, bool remove) | ||
3059 | { | ||
3060 | PhysicsActor pa = PhysActor; | ||
3061 | |||
3062 | if (pa != null) | ||
3063 | pa.VehicleFlags(param, remove); | ||
3064 | } | ||
3065 | |||
3066 | public void SetGroup(UUID groupID, IClientAPI client) | 3778 | public void SetGroup(UUID groupID, IClientAPI client) |
3067 | { | 3779 | { |
3068 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3780 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3166,67 +3878,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3166 | //ParentGroup.ScheduleGroupForFullUpdate(); | 3878 | //ParentGroup.ScheduleGroupForFullUpdate(); |
3167 | } | 3879 | } |
3168 | 3880 | ||
3169 | public void StoreUndoState() | 3881 | public void StoreUndoState(ObjectChangeType change) |
3170 | { | ||
3171 | StoreUndoState(false); | ||
3172 | } | ||
3173 | |||
3174 | public void StoreUndoState(bool forGroup) | ||
3175 | { | 3882 | { |
3176 | if (ParentGroup == null || ParentGroup.Scene == null) | 3883 | if (m_UndoRedo == null) |
3177 | return; | 3884 | m_UndoRedo = new UndoRedoState(5); |
3178 | 3885 | ||
3179 | if (Undoing) | 3886 | lock (m_UndoRedo) |
3180 | { | 3887 | { |
3181 | // m_log.DebugFormat( | 3888 | if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended |
3182 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | ||
3183 | return; | ||
3184 | } | ||
3185 | |||
3186 | if (IgnoreUndoUpdate) | ||
3187 | { | ||
3188 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | ||
3189 | return; | ||
3190 | } | ||
3191 | |||
3192 | lock (m_undo) | ||
3193 | { | ||
3194 | if (m_undo.Count > 0) | ||
3195 | { | ||
3196 | UndoState last = m_undo[m_undo.Count - 1]; | ||
3197 | if (last != null) | ||
3198 | { | ||
3199 | // TODO: May need to fix for group comparison | ||
3200 | if (last.Compare(this)) | ||
3201 | { | ||
3202 | // m_log.DebugFormat( | ||
3203 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | ||
3204 | // Name, LocalId, m_undo.Count); | ||
3205 | |||
3206 | return; | ||
3207 | } | ||
3208 | } | ||
3209 | } | ||
3210 | |||
3211 | // m_log.DebugFormat( | ||
3212 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | ||
3213 | // Name, LocalId, forGroup, m_undo.Count); | ||
3214 | |||
3215 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3216 | { | 3889 | { |
3217 | UndoState nUndo = new UndoState(this, forGroup); | 3890 | m_UndoRedo.StoreUndo(this, change); |
3218 | |||
3219 | m_undo.Add(nUndo); | ||
3220 | |||
3221 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3222 | m_undo.RemoveAt(0); | ||
3223 | |||
3224 | if (m_redo.Count > 0) | ||
3225 | m_redo.Clear(); | ||
3226 | |||
3227 | // m_log.DebugFormat( | ||
3228 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | ||
3229 | // Name, LocalId, forGroup, m_undo.Count); | ||
3230 | } | 3891 | } |
3231 | } | 3892 | } |
3232 | } | 3893 | } |
@@ -3238,88 +3899,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3238 | { | 3899 | { |
3239 | get | 3900 | get |
3240 | { | 3901 | { |
3241 | lock (m_undo) | 3902 | if (m_UndoRedo == null) |
3242 | return m_undo.Count; | 3903 | return 0; |
3904 | return m_UndoRedo.Count; | ||
3243 | } | 3905 | } |
3244 | } | 3906 | } |
3245 | 3907 | ||
3246 | public void Undo() | 3908 | public void Undo() |
3247 | { | 3909 | { |
3248 | lock (m_undo) | 3910 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3249 | { | 3911 | return; |
3250 | // m_log.DebugFormat( | ||
3251 | // "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", | ||
3252 | // Name, LocalId, m_undo.Count); | ||
3253 | |||
3254 | if (m_undo.Count > 0) | ||
3255 | { | ||
3256 | UndoState goback = m_undo[m_undo.Count - 1]; | ||
3257 | m_undo.RemoveAt(m_undo.Count - 1); | ||
3258 | |||
3259 | UndoState nUndo = null; | ||
3260 | |||
3261 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3262 | { | ||
3263 | nUndo = new UndoState(this, goback.ForGroup); | ||
3264 | } | ||
3265 | |||
3266 | goback.PlaybackState(this); | ||
3267 | |||
3268 | if (nUndo != null) | ||
3269 | { | ||
3270 | m_redo.Add(nUndo); | ||
3271 | |||
3272 | if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3273 | m_redo.RemoveAt(0); | ||
3274 | } | ||
3275 | } | ||
3276 | 3912 | ||
3277 | // m_log.DebugFormat( | 3913 | lock (m_UndoRedo) |
3278 | // "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", | 3914 | { |
3279 | // Name, LocalId, m_undo.Count); | 3915 | Undoing = true; |
3916 | m_UndoRedo.Undo(this); | ||
3917 | Undoing = false; | ||
3280 | } | 3918 | } |
3281 | } | 3919 | } |
3282 | 3920 | ||
3283 | public void Redo() | 3921 | public void Redo() |
3284 | { | 3922 | { |
3285 | lock (m_undo) | 3923 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3286 | { | 3924 | return; |
3287 | // m_log.DebugFormat( | ||
3288 | // "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", | ||
3289 | // Name, LocalId, m_redo.Count); | ||
3290 | |||
3291 | if (m_redo.Count > 0) | ||
3292 | { | ||
3293 | UndoState gofwd = m_redo[m_redo.Count - 1]; | ||
3294 | m_redo.RemoveAt(m_redo.Count - 1); | ||
3295 | |||
3296 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3297 | { | ||
3298 | UndoState nUndo = new UndoState(this, gofwd.ForGroup); | ||
3299 | |||
3300 | m_undo.Add(nUndo); | ||
3301 | |||
3302 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3303 | m_undo.RemoveAt(0); | ||
3304 | } | ||
3305 | |||
3306 | gofwd.PlayfwdState(this); | ||
3307 | 3925 | ||
3308 | // m_log.DebugFormat( | 3926 | lock (m_UndoRedo) |
3309 | // "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", | 3927 | { |
3310 | // Name, LocalId, m_redo.Count); | 3928 | Undoing = true; |
3311 | } | 3929 | m_UndoRedo.Redo(this); |
3930 | Undoing = false; | ||
3312 | } | 3931 | } |
3313 | } | 3932 | } |
3314 | 3933 | ||
3315 | public void ClearUndoState() | 3934 | public void ClearUndoState() |
3316 | { | 3935 | { |
3317 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); | 3936 | if (m_UndoRedo == null || Undoing) |
3937 | return; | ||
3318 | 3938 | ||
3319 | lock (m_undo) | 3939 | lock (m_UndoRedo) |
3320 | { | 3940 | { |
3321 | m_undo.Clear(); | 3941 | m_UndoRedo.Clear(); |
3322 | m_redo.Clear(); | ||
3323 | } | 3942 | } |
3324 | } | 3943 | } |
3325 | 3944 | ||
@@ -3869,7 +4488,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3869 | if (god) | 4488 | if (god) |
3870 | { | 4489 | { |
3871 | BaseMask = ApplyMask(BaseMask, set, mask); | 4490 | BaseMask = ApplyMask(BaseMask, set, mask); |
3872 | Inventory.ApplyGodPermissions(_baseMask); | 4491 | Inventory.ApplyGodPermissions(BaseMask); |
3873 | } | 4492 | } |
3874 | 4493 | ||
3875 | break; | 4494 | break; |
@@ -3888,7 +4507,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3888 | case 16: | 4507 | case 16: |
3889 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & | 4508 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & |
3890 | baseMask; | 4509 | baseMask; |
3891 | // Prevent the client from creating no mod, no copy | 4510 | // Prevent the client from creating no copy, no transfer |
3892 | // objects | 4511 | // objects |
3893 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) | 4512 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) |
3894 | NextOwnerMask |= (uint)PermissionMask.Transfer; | 4513 | NextOwnerMask |= (uint)PermissionMask.Transfer; |
@@ -3906,20 +4525,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3906 | { | 4525 | { |
3907 | bool update = false; | 4526 | bool update = false; |
3908 | 4527 | ||
3909 | if (BaseMask != source.BaseMask || | 4528 | uint prevOwnerMask = OwnerMask; |
3910 | OwnerMask != source.OwnerMask || | 4529 | uint prevGroupMask = GroupMask; |
3911 | GroupMask != source.GroupMask || | 4530 | uint prevEveryoneMask = EveryoneMask; |
3912 | EveryoneMask != source.EveryoneMask || | 4531 | uint prevNextOwnerMask = NextOwnerMask; |
3913 | NextOwnerMask != source.NextOwnerMask) | ||
3914 | update = true; | ||
3915 | 4532 | ||
3916 | BaseMask = source.BaseMask; | 4533 | OwnerMask = source.OwnerMask & BaseMask; |
3917 | OwnerMask = source.OwnerMask; | 4534 | GroupMask = source.GroupMask & BaseMask; |
3918 | GroupMask = source.GroupMask; | 4535 | EveryoneMask = source.EveryoneMask & BaseMask; |
3919 | EveryoneMask = source.EveryoneMask; | 4536 | NextOwnerMask = source.NextOwnerMask & BaseMask; |
3920 | NextOwnerMask = source.NextOwnerMask; | ||
3921 | 4537 | ||
3922 | if (update) | 4538 | if (OwnerMask != prevOwnerMask || |
4539 | GroupMask != prevGroupMask || | ||
4540 | EveryoneMask != prevEveryoneMask || | ||
4541 | NextOwnerMask != prevNextOwnerMask) | ||
3923 | SendFullUpdateToAllClients(); | 4542 | SendFullUpdateToAllClients(); |
3924 | } | 4543 | } |
3925 | 4544 | ||
@@ -3970,6 +4589,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3970 | } | 4589 | } |
3971 | } | 4590 | } |
3972 | 4591 | ||
4592 | |||
4593 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) | ||
4594 | { | ||
4595 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) | ||
4596 | return; | ||
4597 | |||
4598 | if (PhysicsShapeType != (byte)physdata.PhysShapeType) | ||
4599 | { | ||
4600 | PhysicsShapeType = (byte)physdata.PhysShapeType; | ||
4601 | |||
4602 | } | ||
4603 | |||
4604 | if(Density != physdata.Density) | ||
4605 | Density = physdata.Density; | ||
4606 | if(GravityModifier != physdata.GravitationModifier) | ||
4607 | GravityModifier = physdata.GravitationModifier; | ||
4608 | if(Friction != physdata.Friction) | ||
4609 | Friction = physdata.Friction; | ||
4610 | if(Bounciness != physdata.Bounce) | ||
4611 | Bounciness = physdata.Bounce; | ||
4612 | } | ||
3973 | /// <summary> | 4613 | /// <summary> |
3974 | /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. | 4614 | /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. |
3975 | /// </summary> | 4615 | /// </summary> |
@@ -3977,7 +4617,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3977 | /// <param name="SetTemporary"></param> | 4617 | /// <param name="SetTemporary"></param> |
3978 | /// <param name="SetPhantom"></param> | 4618 | /// <param name="SetPhantom"></param> |
3979 | /// <param name="SetVD"></param> | 4619 | /// <param name="SetVD"></param> |
3980 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4620 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
3981 | { | 4621 | { |
3982 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4622 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
3983 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4623 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -3987,213 +4627,230 @@ namespace OpenSim.Region.Framework.Scenes | |||
3987 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4627 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
3988 | return; | 4628 | return; |
3989 | 4629 | ||
3990 | PhysicsActor pa = PhysActor; | 4630 | VolumeDetectActive = SetVD; |
3991 | |||
3992 | // Special cases for VD. VD can only be called from a script | ||
3993 | // and can't be combined with changes to other states. So we can rely | ||
3994 | // that... | ||
3995 | // ... if VD is changed, all others are not. | ||
3996 | // ... if one of the others is changed, VD is not. | ||
3997 | if (SetVD) // VD is active, special logic applies | ||
3998 | { | ||
3999 | // State machine logic for VolumeDetect | ||
4000 | // More logic below | ||
4001 | bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; | ||
4002 | |||
4003 | if (phanReset) // Phantom changes from on to off switch VD off too | ||
4004 | { | ||
4005 | SetVD = false; // Switch it of for the course of this routine | ||
4006 | VolumeDetectActive = false; // and also permanently | ||
4007 | |||
4008 | if (pa != null) | ||
4009 | pa.SetVolumeDetect(0); // Let physics know about it too | ||
4010 | } | ||
4011 | else | ||
4012 | { | ||
4013 | // If volumedetect is active we don't want phantom to be applied. | ||
4014 | // If this is a new call to VD out of the state "phantom" | ||
4015 | // this will also cause the prim to be visible to physics | ||
4016 | SetPhantom = false; | ||
4017 | } | ||
4018 | } | ||
4019 | 4631 | ||
4020 | if (UsePhysics && IsJoint()) | 4632 | // volume detector implies phantom |
4021 | { | 4633 | if (VolumeDetectActive) |
4022 | SetPhantom = true; | 4634 | SetPhantom = true; |
4023 | } | ||
4024 | 4635 | ||
4025 | if (UsePhysics) | 4636 | if (UsePhysics) |
4026 | { | ||
4027 | AddFlag(PrimFlags.Physics); | 4637 | AddFlag(PrimFlags.Physics); |
4028 | if (!wasUsingPhysics) | ||
4029 | { | ||
4030 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4031 | } | ||
4032 | } | ||
4033 | else | 4638 | else |
4034 | { | ||
4035 | RemFlag(PrimFlags.Physics); | 4639 | RemFlag(PrimFlags.Physics); |
4036 | if (wasUsingPhysics) | ||
4037 | { | ||
4038 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4039 | } | ||
4040 | } | ||
4041 | 4640 | ||
4042 | if (SetPhantom | 4641 | if (SetPhantom) |
4043 | || ParentGroup.IsAttachment | ||
4044 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | ||
4045 | { | ||
4046 | AddFlag(PrimFlags.Phantom); | 4642 | AddFlag(PrimFlags.Phantom); |
4047 | 4643 | else | |
4048 | if (PhysActor != null) | ||
4049 | { | ||
4050 | RemoveFromPhysics(); | ||
4051 | pa = null; | ||
4052 | } | ||
4053 | } | ||
4054 | else // Not phantom | ||
4055 | { | ||
4056 | RemFlag(PrimFlags.Phantom); | 4644 | RemFlag(PrimFlags.Phantom); |
4057 | 4645 | ||
4058 | if (ParentGroup.Scene == null) | 4646 | if (SetTemporary) |
4059 | return; | 4647 | AddFlag(PrimFlags.TemporaryOnRez); |
4648 | else | ||
4649 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4060 | 4650 | ||
4061 | if (ParentGroup.Scene.CollidablePrims && pa == null) | ||
4062 | { | ||
4063 | pa = AddToPhysics(UsePhysics); | ||
4064 | 4651 | ||
4065 | if (pa != null) | 4652 | if (ParentGroup.Scene == null) |
4066 | { | 4653 | return; |
4067 | pa.SetMaterial(Material); | 4654 | |
4068 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4655 | PhysicsActor pa = PhysActor; |
4069 | |||
4070 | if ( | ||
4071 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4072 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4073 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4074 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4075 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4076 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4077 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4078 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4079 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4080 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4081 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4082 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4083 | (CollisionSound != UUID.Zero) | ||
4084 | ) | ||
4085 | { | ||
4086 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4087 | pa.SubscribeEvents(1000); | ||
4088 | } | ||
4089 | } | ||
4090 | } | ||
4091 | else // it already has a physical representation | ||
4092 | { | ||
4093 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim | ||
4094 | } | ||
4095 | } | ||
4096 | 4656 | ||
4097 | if (SetVD) | 4657 | if (pa != null && building && pa.Building != building) |
4658 | pa.Building = building; | ||
4659 | |||
4660 | if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | ||
4661 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
4098 | { | 4662 | { |
4099 | // If the above logic worked (this is urgent candidate to unit tests!) | ||
4100 | // we now have a physicsactor. | ||
4101 | // Defensive programming calls for a check here. | ||
4102 | // Better would be throwing an exception that could be catched by a unit test as the internal | ||
4103 | // logic should make sure, this Physactor is always here. | ||
4104 | if (pa != null) | 4663 | if (pa != null) |
4105 | { | 4664 | { |
4106 | pa.SetVolumeDetect(1); | 4665 | if(wasUsingPhysics) |
4107 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4666 | ParentGroup.Scene.RemovePhysicalPrim(1); |
4108 | VolumeDetectActive = true; | 4667 | RemoveFromPhysics(); |
4109 | } | 4668 | } |
4669 | |||
4670 | Velocity = new Vector3(0, 0, 0); | ||
4671 | Acceleration = new Vector3(0, 0, 0); | ||
4672 | if (ParentGroup.RootPart == this) | ||
4673 | AngularVelocity = new Vector3(0, 0, 0); | ||
4110 | } | 4674 | } |
4111 | else | 4675 | else |
4112 | { | 4676 | { |
4113 | // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like | 4677 | if (ParentGroup.Scene.CollidablePrims) |
4114 | // (mumbles, well, at least if you have infinte CPU powers :-)) | 4678 | { |
4115 | if (pa != null) | 4679 | if (pa == null) |
4116 | pa.SetVolumeDetect(0); | 4680 | { |
4681 | AddToPhysics(UsePhysics, SetPhantom, building, false); | ||
4682 | pa = PhysActor; | ||
4683 | /* | ||
4684 | if (pa != null) | ||
4685 | { | ||
4686 | if ( | ||
4687 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4688 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4689 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4690 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4691 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4692 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4693 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4694 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4695 | (CollisionSound != UUID.Zero) | ||
4696 | ) | ||
4697 | { | ||
4698 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4699 | pa.SubscribeEvents(1000); | ||
4700 | } | ||
4701 | } | ||
4702 | */ | ||
4703 | } | ||
4704 | else // it already has a physical representation | ||
4705 | { | ||
4706 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | ||
4707 | /* moved into DoPhysicsPropertyUpdate | ||
4708 | if(VolumeDetectActive) | ||
4709 | pa.SetVolumeDetect(1); | ||
4710 | else | ||
4711 | pa.SetVolumeDetect(0); | ||
4712 | */ | ||
4117 | 4713 | ||
4118 | VolumeDetectActive = false; | 4714 | if (pa.Building != building) |
4119 | } | 4715 | pa.Building = building; |
4716 | } | ||
4120 | 4717 | ||
4121 | if (SetTemporary) | 4718 | UpdatePhysicsSubscribedEvents(); |
4122 | { | 4719 | } |
4123 | AddFlag(PrimFlags.TemporaryOnRez); | 4720 | } |
4124 | } | ||
4125 | else | ||
4126 | { | ||
4127 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4128 | } | ||
4129 | 4721 | ||
4130 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | 4722 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); |
4131 | 4723 | ||
4724 | // and last in case we have a new actor and not building | ||
4725 | |||
4132 | if (ParentGroup != null) | 4726 | if (ParentGroup != null) |
4133 | { | 4727 | { |
4134 | ParentGroup.HasGroupChanged = true; | 4728 | ParentGroup.HasGroupChanged = true; |
4135 | ScheduleFullUpdate(); | 4729 | ScheduleFullUpdate(); |
4136 | } | 4730 | } |
4137 | 4731 | ||
4138 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4732 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4139 | } | 4733 | } |
4140 | 4734 | ||
4141 | /// <summary> | 4735 | /// <summary> |
4142 | /// Adds this part to the physics scene. | 4736 | /// Adds this part to the physics scene. |
4737 | /// and sets the PhysActor property | ||
4143 | /// </summary> | 4738 | /// </summary> |
4144 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4739 | /// <param name="isPhysical">Add this prim as physical.</param> |
4145 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4740 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4146 | /// <returns> | 4741 | /// <param name="building">tells physics to delay full construction of object</param> |
4147 | /// The physics actor. null if there was a failure. | 4742 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4148 | /// </returns> | 4743 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4149 | private PhysicsActor AddToPhysics(bool rigidBody) | 4744 | { |
4150 | { | ||
4151 | PhysicsActor pa; | 4745 | PhysicsActor pa; |
4152 | 4746 | ||
4747 | Vector3 velocity = Velocity; | ||
4748 | Vector3 rotationalVelocity = AngularVelocity;; | ||
4749 | |||
4153 | try | 4750 | try |
4154 | { | 4751 | { |
4155 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4752 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4156 | string.Format("{0}/{1}", Name, UUID), | 4753 | string.Format("{0}/{1}", Name, UUID), |
4157 | Shape, | 4754 | Shape, |
4158 | AbsolutePosition, | 4755 | AbsolutePosition, |
4159 | Scale, | 4756 | Scale, |
4160 | RotationOffset, | 4757 | GetWorldRotation(), |
4161 | rigidBody, | 4758 | isPhysical, |
4162 | m_localId); | 4759 | isPhantom, |
4760 | PhysicsShapeType, | ||
4761 | m_localId); | ||
4163 | } | 4762 | } |
4164 | catch | 4763 | catch (Exception ex) |
4165 | { | 4764 | { |
4166 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); | 4765 | m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message); |
4167 | pa = null; | 4766 | pa = null; |
4168 | } | 4767 | } |
4169 | 4768 | ||
4170 | // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical | ||
4171 | // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor | ||
4172 | // being set. | ||
4173 | PhysActor = pa; | ||
4174 | |||
4175 | // Basic Physics can also return null as well as an exception catch. | ||
4176 | if (pa != null) | 4769 | if (pa != null) |
4177 | { | 4770 | { |
4178 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4771 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
4179 | pa.SetMaterial(Material); | 4772 | pa.SetMaterial(Material); |
4180 | DoPhysicsPropertyUpdate(rigidBody, true); | 4773 | |
4774 | if (VolumeDetectActive) // change if not the default only | ||
4775 | pa.SetVolumeDetect(1); | ||
4776 | |||
4777 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4778 | m_vehicleParams.SetVehicle(pa); | ||
4779 | |||
4780 | // we are going to tell rest of code about physics so better have this here | ||
4781 | PhysActor = pa; | ||
4782 | |||
4783 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4784 | // lets expand it here just with what it really needs to do | ||
4785 | |||
4786 | if (isPhysical) | ||
4787 | { | ||
4788 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
4789 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
4790 | ParentGroup.RootPart.KeyframeMotion = null; | ||
4791 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
4792 | |||
4793 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
4794 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
4795 | |||
4796 | if (ParentID != 0 && ParentID != LocalId) | ||
4797 | { | ||
4798 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
4799 | |||
4800 | if (parentPa != null) | ||
4801 | { | ||
4802 | pa.link(parentPa); | ||
4803 | } | ||
4804 | } | ||
4805 | } | ||
4806 | |||
4807 | if (applyDynamics) | ||
4808 | // do independent of isphysical so parameters get setted (at least some) | ||
4809 | { | ||
4810 | Velocity = velocity; | ||
4811 | AngularVelocity = rotationalVelocity; | ||
4812 | // pa.Velocity = velocity; | ||
4813 | pa.RotationalVelocity = rotationalVelocity; | ||
4814 | |||
4815 | // if not vehicle and root part apply force and torque | ||
4816 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) | ||
4817 | && LocalId == ParentGroup.RootPart.LocalId) | ||
4818 | { | ||
4819 | pa.Force = Force; | ||
4820 | pa.Torque = Torque; | ||
4821 | } | ||
4822 | } | ||
4823 | |||
4824 | // if (Shape.SculptEntry) | ||
4825 | // CheckSculptAndLoad(); | ||
4826 | // else | ||
4827 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
4828 | |||
4829 | if (!building) | ||
4830 | pa.Building = false; | ||
4181 | } | 4831 | } |
4182 | 4832 | ||
4183 | return pa; | 4833 | PhysActor = pa; |
4184 | } | 4834 | } |
4185 | 4835 | ||
4186 | /// <summary> | 4836 | /// <summary> |
4187 | /// This removes the part from the physics scene. | 4837 | /// This removes the part from the physics scene. |
4188 | /// </summary> | 4838 | /// </summary> |
4189 | /// <remarks> | 4839 | /// <remarks> |
4190 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4840 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4191 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 4841 | /// representation for collision detection. |
4192 | /// phantom. | ||
4193 | /// </remarks> | 4842 | /// </remarks> |
4194 | public void RemoveFromPhysics() | 4843 | public void RemoveFromPhysics() |
4195 | { | 4844 | { |
4196 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 4845 | PhysicsActor pa = PhysActor; |
4846 | if (pa != null) | ||
4847 | { | ||
4848 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4849 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
4850 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
4851 | |||
4852 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
4853 | } | ||
4197 | PhysActor = null; | 4854 | PhysActor = null; |
4198 | } | 4855 | } |
4199 | 4856 | ||
@@ -4325,6 +4982,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4325 | { | 4982 | { |
4326 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); | 4983 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); |
4327 | 4984 | ||
4985 | return; | ||
4986 | |||
4328 | if (ParentGroup.IsDeleted) | 4987 | if (ParentGroup.IsDeleted) |
4329 | return; | 4988 | return; |
4330 | 4989 | ||
@@ -4405,6 +5064,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
4405 | ScheduleFullUpdate(); | 5064 | ScheduleFullUpdate(); |
4406 | } | 5065 | } |
4407 | 5066 | ||
5067 | |||
5068 | private void UpdatePhysicsSubscribedEvents() | ||
5069 | { | ||
5070 | PhysicsActor pa = PhysActor; | ||
5071 | if (pa == null) | ||
5072 | return; | ||
5073 | |||
5074 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5075 | |||
5076 | bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); | ||
5077 | |||
5078 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
5079 | |||
5080 | // merge with root part | ||
5081 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
5082 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
5083 | |||
5084 | // submit to this part case | ||
5085 | if (VolumeDetectActive) | ||
5086 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
5087 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
5088 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
5089 | else | ||
5090 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
5091 | |||
5092 | if (hassound || CombinedEvents != 0) | ||
5093 | { | ||
5094 | // subscribe to physics updates. | ||
5095 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5096 | pa.SubscribeEvents(50); // 20 reports per second | ||
5097 | } | ||
5098 | else | ||
5099 | { | ||
5100 | pa.UnSubscribeEvents(); | ||
5101 | } | ||
5102 | } | ||
5103 | |||
5104 | |||
4408 | public void aggregateScriptEvents() | 5105 | public void aggregateScriptEvents() |
4409 | { | 5106 | { |
4410 | if (ParentGroup == null || ParentGroup.RootPart == null) | 5107 | if (ParentGroup == null || ParentGroup.RootPart == null) |
@@ -4441,40 +5138,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4441 | { | 5138 | { |
4442 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5139 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4443 | } | 5140 | } |
4444 | 5141 | /* | |
4445 | PhysicsActor pa = PhysActor; | 5142 | PhysicsActor pa = PhysActor; |
4446 | 5143 | if (pa != null) | |
4447 | if ( | ||
4448 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4449 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4450 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4451 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4452 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4453 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4454 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4455 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4456 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4457 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4458 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4459 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4460 | (CollisionSound != UUID.Zero) | ||
4461 | ) | ||
4462 | { | 5144 | { |
4463 | // subscribe to physics updates. | 5145 | if ( |
4464 | if (pa != null) | 5146 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || |
5147 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
5148 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
5149 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
5150 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
5151 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
5152 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
5153 | ) | ||
4465 | { | 5154 | { |
5155 | // subscribe to physics updates. | ||
4466 | pa.OnCollisionUpdate += PhysicsCollision; | 5156 | pa.OnCollisionUpdate += PhysicsCollision; |
4467 | pa.SubscribeEvents(1000); | 5157 | pa.SubscribeEvents(1000); |
4468 | } | 5158 | } |
4469 | } | 5159 | else |
4470 | else | ||
4471 | { | ||
4472 | if (pa != null) | ||
4473 | { | 5160 | { |
4474 | pa.UnSubscribeEvents(); | 5161 | pa.UnSubscribeEvents(); |
4475 | pa.OnCollisionUpdate -= PhysicsCollision; | 5162 | pa.OnCollisionUpdate -= PhysicsCollision; |
4476 | } | 5163 | } |
4477 | } | 5164 | } |
5165 | */ | ||
5166 | UpdatePhysicsSubscribedEvents(); | ||
4478 | 5167 | ||
4479 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 5168 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4480 | //{ | 5169 | //{ |
@@ -4605,6 +5294,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4605 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 5294 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4606 | } | 5295 | } |
4607 | 5296 | ||
5297 | public void ResetOwnerChangeFlag() | ||
5298 | { | ||
5299 | List<UUID> inv = Inventory.GetInventoryList(); | ||
5300 | |||
5301 | foreach (UUID itemID in inv) | ||
5302 | { | ||
5303 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
5304 | item.OwnerChanged = false; | ||
5305 | Inventory.UpdateInventoryItem(item, false, false); | ||
5306 | } | ||
5307 | } | ||
5308 | |||
4608 | /// <summary> | 5309 | /// <summary> |
4609 | /// Record an avatar sitting on this part. | 5310 | /// Record an avatar sitting on this part. |
4610 | /// </summary> | 5311 | /// </summary> |