aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs1701
1 files changed, 1185 insertions, 516 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 53b4f7e..593e1d3 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 Stack<UndoState> m_undo = new Stack<UndoState>(5); 294 private UndoRedoState m_UndoRedo = null;
270 private readonly Stack<UndoState> m_redo = new Stack<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,12 +760,14 @@ 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)
716 { 773 {
@@ -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,319 @@ 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.Cost;
1587
1588 if ((Flags & PrimFlags.Physics) != 0)
1589 cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3
1590 return cost;
1591 }
1592 }
1593
1594 [XmlIgnore]
1595 public float StreamingCost
1596 {
1597 get
1598 {
1599
1600
1601 return 0.1f;
1602 }
1603 }
1604
1605 [XmlIgnore]
1606 public float SimulationCost
1607 {
1608 get
1609 {
1610 // ignoring scripts. Don't like considering them for this
1611 if((Flags & PrimFlags.Physics) != 0)
1612 return 1.0f;
1613
1614 return 0.5f;
1615 }
1616 }
1617
1618 public byte PhysicsShapeType
1619 {
1620 get { return m_physicsShapeType; }
1621 set
1622 {
1623 byte oldv = m_physicsShapeType;
1624
1625 if (value >= 0 && value <= (byte)PhysShapeType.convex)
1626 {
1627 if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this)
1628 m_physicsShapeType = DefaultPhysicsShapeType();
1629 else
1630 m_physicsShapeType = value;
1631 }
1632 else
1633 m_physicsShapeType = DefaultPhysicsShapeType();
1634
1635 if (m_physicsShapeType != oldv && ParentGroup != null)
1636 {
1637 if (m_physicsShapeType == (byte)PhysShapeType.none)
1638 {
1639 if (PhysActor != null)
1640 {
1641 Velocity = new Vector3(0, 0, 0);
1642 Acceleration = new Vector3(0, 0, 0);
1643 if (ParentGroup.RootPart == this)
1644 AngularVelocity = new Vector3(0, 0, 0);
1645 ParentGroup.Scene.RemovePhysicalPrim(1);
1646 RemoveFromPhysics();
1647 }
1648 }
1649 else if (PhysActor == null)
1650 {
1651 ApplyPhysics((uint)Flags, VolumeDetectActive, false);
1652 UpdatePhysicsSubscribedEvents();
1653 }
1654 else
1655 {
1656 PhysActor.PhysicsShapeType = m_physicsShapeType;
1657 if (Shape.SculptEntry)
1658 CheckSculptAndLoad();
1659 }
1660
1661 if (ParentGroup != null)
1662 ParentGroup.HasGroupChanged = true;
1663 }
1664
1665 if (m_physicsShapeType != value)
1666 {
1667 UpdatePhysRequired = true;
1668 }
1669 }
1670 }
1671
1672 public float Density // in kg/m^3
1673 {
1674 get { return m_density; }
1675 set
1676 {
1677 if (value >=1 && value <= 22587.0)
1678 {
1679 m_density = value;
1680 UpdatePhysRequired = true;
1681 }
1682
1683 ScheduleFullUpdateIfNone();
1684
1685 if (ParentGroup != null)
1686 ParentGroup.HasGroupChanged = true;
1687 }
1688 }
1689
1690 public float GravityModifier
1691 {
1692 get { return m_gravitymod; }
1693 set
1694 {
1695 if( value >= -1 && value <=28.0f)
1696 {
1697 m_gravitymod = value;
1698 UpdatePhysRequired = true;
1699 }
1700
1701 ScheduleFullUpdateIfNone();
1702
1703 if (ParentGroup != null)
1704 ParentGroup.HasGroupChanged = true;
1705
1706 }
1707 }
1708
1709 public float Friction
1710 {
1711 get { return m_friction; }
1712 set
1713 {
1714 if (value >= 0 && value <= 255.0f)
1715 {
1716 m_friction = value;
1717 UpdatePhysRequired = true;
1718 }
1719
1720 ScheduleFullUpdateIfNone();
1721
1722 if (ParentGroup != null)
1723 ParentGroup.HasGroupChanged = true;
1724 }
1725 }
1726
1727 public float Bounciness
1728 {
1729 get { return m_bounce; }
1730 set
1731 {
1732 if (value >= 0 && value <= 1.0f)
1733 {
1734 m_bounce = value;
1735 UpdatePhysRequired = true;
1736 }
1737
1738 ScheduleFullUpdateIfNone();
1739
1740 if (ParentGroup != null)
1741 ParentGroup.HasGroupChanged = true;
1742 }
1743 }
1744
1745
1318 #endregion Public Properties with only Get 1746 #endregion Public Properties with only Get
1319 1747
1320 private uint ApplyMask(uint val, bool set, uint mask) 1748 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1460,6 +1888,61 @@ namespace OpenSim.Region.Framework.Scenes
1460 } 1888 }
1461 } 1889 }
1462 1890
1891 // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future
1892 public void SetVelocity(Vector3 pVel, bool localGlobalTF)
1893 {
1894 if (ParentGroup == null || ParentGroup.IsDeleted)
1895 return;
1896
1897 if (ParentGroup.IsAttachment)
1898 return; // don't work on attachments (for now ??)
1899
1900 SceneObjectPart root = ParentGroup.RootPart;
1901
1902 if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles
1903 return;
1904
1905 PhysicsActor pa = root.PhysActor;
1906
1907 if (pa == null || !pa.IsPhysical)
1908 return;
1909
1910 if (localGlobalTF)
1911 {
1912 pVel = pVel * GetWorldRotation();
1913 }
1914
1915 ParentGroup.Velocity = pVel;
1916 }
1917
1918 // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future
1919 public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF)
1920 {
1921 if (ParentGroup == null || ParentGroup.IsDeleted)
1922 return;
1923
1924 if (ParentGroup.IsAttachment)
1925 return; // don't work on attachments (for now ??)
1926
1927 SceneObjectPart root = ParentGroup.RootPart;
1928
1929 if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles
1930 return;
1931
1932 PhysicsActor pa = root.PhysActor;
1933
1934 if (pa == null || !pa.IsPhysical)
1935 return;
1936
1937 if (localGlobalTF)
1938 {
1939 pAngVel = pAngVel * GetWorldRotation();
1940 }
1941
1942 root.AngularVelocity = pAngVel;
1943 }
1944
1945
1463 /// <summary> 1946 /// <summary>
1464 /// hook to the physics scene to apply angular impulse 1947 /// hook to the physics scene to apply angular impulse
1465 /// This is sent up to the group, which then finds the root prim 1948 /// This is sent up to the group, which then finds the root prim
@@ -1480,7 +1963,7 @@ namespace OpenSim.Region.Framework.Scenes
1480 impulse = newimpulse; 1963 impulse = newimpulse;
1481 } 1964 }
1482 1965
1483 ParentGroup.applyAngularImpulse(impulse); 1966 ParentGroup.ApplyAngularImpulse(impulse);
1484 } 1967 }
1485 1968
1486 /// <summary> 1969 /// <summary>
@@ -1490,20 +1973,24 @@ namespace OpenSim.Region.Framework.Scenes
1490 /// </summary> 1973 /// </summary>
1491 /// <param name="impulsei">Vector force</param> 1974 /// <param name="impulsei">Vector force</param>
1492 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> 1975 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
1493 public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) 1976
1977 // this is actualy Set Torque.. keeping naming so not to edit lslapi also
1978 public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF)
1494 { 1979 {
1495 Vector3 impulse = impulsei; 1980 Vector3 torque = torquei;
1496 1981
1497 if (localGlobalTF) 1982 if (localGlobalTF)
1498 { 1983 {
1984/*
1499 Quaternion grot = GetWorldRotation(); 1985 Quaternion grot = GetWorldRotation();
1500 Quaternion AXgrot = grot; 1986 Quaternion AXgrot = grot;
1501 Vector3 AXimpulsei = impulsei; 1987 Vector3 AXimpulsei = impulsei;
1502 Vector3 newimpulse = AXimpulsei * AXgrot; 1988 Vector3 newimpulse = AXimpulsei * AXgrot;
1503 impulse = newimpulse; 1989 */
1990 torque *= GetWorldRotation();
1504 } 1991 }
1505 1992
1506 ParentGroup.setAngularImpulse(impulse); 1993 Torque = torque;
1507 } 1994 }
1508 1995
1509 /// <summary> 1996 /// <summary>
@@ -1511,17 +1998,23 @@ namespace OpenSim.Region.Framework.Scenes
1511 /// </summary> 1998 /// </summary>
1512 /// <param name="rootObjectFlags"></param> 1999 /// <param name="rootObjectFlags"></param>
1513 /// <param name="VolumeDetectActive"></param> 2000 /// <param name="VolumeDetectActive"></param>
1514 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) 2001 /// <param name="building"></param>
2002
2003 public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building)
1515 { 2004 {
2005 VolumeDetectActive = _VolumeDetectActive;
2006
1516 if (!ParentGroup.Scene.CollidablePrims) 2007 if (!ParentGroup.Scene.CollidablePrims)
1517 return; 2008 return;
1518 2009
1519// m_log.DebugFormat( 2010 if (PhysicsShapeType == (byte)PhysShapeType.none)
1520// "[SCENE OBJECT PART]: Applying physics to {0} {1}, m_physicalPrim {2}", 2011 return;
1521// Name, LocalId, UUID, m_physicalPrim); 2012
2013 bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0;
2014 bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0;
1522 2015
1523 bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; 2016 if (_VolumeDetectActive)
1524 bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; 2017 isPhantom = true;
1525 2018
1526 if (IsJoint()) 2019 if (IsJoint())
1527 { 2020 {
@@ -1529,22 +2022,14 @@ namespace OpenSim.Region.Framework.Scenes
1529 } 2022 }
1530 else 2023 else
1531 { 2024 {
1532 // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored 2025 if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment
1533 if (VolumeDetectActive) 2026 && !(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 { 2027 {
1540 // Added clarification.. since A rigid body is an object that you can kick around, etc. 2028 AddToPhysics(isPhysical, isPhantom, building, isPhysical);
1541 bool rigidBody = isPhysical && !isPhantom; 2029 UpdatePhysicsSubscribedEvents(); // not sure if appliable here
1542
1543 PhysicsActor pa = AddToPhysics(rigidBody);
1544
1545 if (pa != null)
1546 pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
1547 } 2030 }
2031 else
2032 PhysActor = null; // just to be sure
1548 } 2033 }
1549 } 2034 }
1550 2035
@@ -1596,6 +2081,12 @@ namespace OpenSim.Region.Framework.Scenes
1596 dupe.Category = Category; 2081 dupe.Category = Category;
1597 dupe.m_rezzed = m_rezzed; 2082 dupe.m_rezzed = m_rezzed;
1598 2083
2084 dupe.m_UndoRedo = null;
2085 dupe.m_isSelected = false;
2086
2087 dupe.IgnoreUndoUpdate = false;
2088 dupe.Undoing = false;
2089
1599 dupe.m_inventory = new SceneObjectPartInventory(dupe); 2090 dupe.m_inventory = new SceneObjectPartInventory(dupe);
1600 dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); 2091 dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone();
1601 2092
@@ -1611,6 +2102,7 @@ namespace OpenSim.Region.Framework.Scenes
1611 2102
1612 // Move afterwards ResetIDs as it clears the localID 2103 // Move afterwards ResetIDs as it clears the localID
1613 dupe.LocalId = localID; 2104 dupe.LocalId = localID;
2105
1614 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 2106 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1615 dupe.LastOwnerID = OwnerID; 2107 dupe.LastOwnerID = OwnerID;
1616 2108
@@ -1628,8 +2120,12 @@ namespace OpenSim.Region.Framework.Scenes
1628 2120
1629 bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); 2121 bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0);
1630 dupe.DoPhysicsPropertyUpdate(UsePhysics, true); 2122 dupe.DoPhysicsPropertyUpdate(UsePhysics, true);
2123// dupe.UpdatePhysicsSubscribedEvents(); // not sure...
1631 } 2124 }
1632 2125
2126 if (dupe.PhysActor != null)
2127 dupe.PhysActor.LocalID = localID;
2128
1633 ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); 2129 ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed);
1634 2130
1635// m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); 2131// m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID);
@@ -1749,6 +2245,7 @@ namespace OpenSim.Region.Framework.Scenes
1749 2245
1750 /// <summary> 2246 /// <summary>
1751 /// Do a physics propery update for this part. 2247 /// Do a physics propery update for this part.
2248 /// now also updates phantom and volume detector
1752 /// </summary> 2249 /// </summary>
1753 /// <param name="UsePhysics"></param> 2250 /// <param name="UsePhysics"></param>
1754 /// <param name="isNew"></param> 2251 /// <param name="isNew"></param>
@@ -1774,61 +2271,69 @@ namespace OpenSim.Region.Framework.Scenes
1774 { 2271 {
1775 if (pa.IsPhysical) // implies UsePhysics==false for this block 2272 if (pa.IsPhysical) // implies UsePhysics==false for this block
1776 { 2273 {
1777 if (!isNew) 2274 if (!isNew) // implies UsePhysics==false for this block
2275 {
1778 ParentGroup.Scene.RemovePhysicalPrim(1); 2276 ParentGroup.Scene.RemovePhysicalPrim(1);
1779 2277
1780 pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; 2278 Velocity = new Vector3(0, 0, 0);
1781 pa.OnOutOfBounds -= PhysicsOutOfBounds; 2279 Acceleration = new Vector3(0, 0, 0);
1782 pa.delink(); 2280 if (ParentGroup.RootPart == this)
2281 AngularVelocity = new Vector3(0, 0, 0);
1783 2282
1784 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) 2283 if (pa.Phantom && !VolumeDetectActive)
1785 { 2284 {
1786 // destroy all joints connected to this now deactivated body 2285 RemoveFromPhysics();
1787 ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); 2286 return;
1788 } 2287 }
1789 2288
1790 // stop client-side interpolation of all joint proxy objects that have just been deleted 2289 pa.IsPhysical = UsePhysics;
1791 // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, 2290 pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
1792 // which stops client-side interpolation of deactivated joint proxy objects. 2291 pa.OnOutOfBounds -= PhysicsOutOfBounds;
2292 pa.delink();
2293 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
2294 {
2295 // destroy all joints connected to this now deactivated body
2296 ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa);
2297 }
2298 }
1793 } 2299 }
1794 2300
1795 if (!UsePhysics && !isNew) 2301 if (pa.IsPhysical != UsePhysics)
1796 { 2302 pa.IsPhysical = UsePhysics;
1797 // reset velocity to 0 on physics switch-off. Without that, the client thinks the
1798 // prim still has velocity and continues to interpolate its position along the old
1799 // velocity-vector.
1800 Velocity = new Vector3(0, 0, 0);
1801 Acceleration = new Vector3(0, 0, 0);
1802 AngularVelocity = new Vector3(0, 0, 0);
1803 //RotationalVelocity = new Vector3(0, 0, 0);
1804 }
1805 2303
1806 pa.IsPhysical = UsePhysics; 2304 if (UsePhysics)
2305 {
2306 if (ParentGroup.RootPart.KeyframeMotion != null)
2307 ParentGroup.RootPart.KeyframeMotion.Stop();
2308 ParentGroup.RootPart.KeyframeMotion = null;
2309 ParentGroup.Scene.AddPhysicalPrim(1);
1807 2310
1808 // If we're not what we're supposed to be in the physics scene, recreate ourselves. 2311 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
1809 //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); 2312 PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
1810 /// that's not wholesome. Had to make Scene public
1811 //PhysActor = null;
1812 2313
1813 if ((Flags & PrimFlags.Phantom) == 0) 2314 if (ParentID != 0 && ParentID != LocalId)
1814 {
1815 if (UsePhysics)
1816 { 2315 {
1817 ParentGroup.Scene.AddPhysicalPrim(1); 2316 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
1818 2317
1819 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; 2318 if (parentPa != null)
1820 pa.OnOutOfBounds += PhysicsOutOfBounds;
1821 if (ParentID != 0 && ParentID != LocalId)
1822 { 2319 {
1823 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; 2320 pa.link(parentPa);
1824
1825 if (parentPa != null)
1826 {
1827 pa.link(parentPa);
1828 }
1829 } 2321 }
1830 } 2322 }
1831 } 2323 }
2324 }
2325
2326 bool phan = ((Flags & PrimFlags.Phantom) != 0);
2327 if (pa.Phantom != phan)
2328 pa.Phantom = phan;
2329
2330// some engines dont' have this check still
2331// if (VolumeDetectActive != pa.IsVolumeDtc)
2332 {
2333 if (VolumeDetectActive)
2334 pa.SetVolumeDetect(1);
2335 else
2336 pa.SetVolumeDetect(0);
1832 } 2337 }
1833 2338
1834 // If this part is a sculpt then delay the physics update until we've asynchronously loaded the 2339 // If this part is a sculpt then delay the physics update until we've asynchronously loaded the
@@ -1947,12 +2452,26 @@ namespace OpenSim.Region.Framework.Scenes
1947 2452
1948 public Vector3 GetGeometricCenter() 2453 public Vector3 GetGeometricCenter()
1949 { 2454 {
1950 PhysicsActor pa = PhysActor; 2455 // this is not real geometric center but a average of positions relative to root prim acording to
1951 2456 // http://wiki.secondlife.com/wiki/llGetGeometricCenter
1952 if (pa != null) 2457 // ignoring tortured prims details since sl also seems to ignore
1953 return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); 2458 // so no real use in doing it on physics
1954 else 2459 if (ParentGroup.IsDeleted)
1955 return new Vector3(0, 0, 0); 2460 return new Vector3(0, 0, 0);
2461
2462 return ParentGroup.GetGeometricCenter();
2463
2464 /*
2465 PhysicsActor pa = PhysActor;
2466
2467 if (pa != null)
2468 {
2469 Vector3 vtmp = pa.CenterOfMass;
2470 return vtmp;
2471 }
2472 else
2473 return new Vector3(0, 0, 0);
2474 */
1956 } 2475 }
1957 2476
1958 public float GetMass() 2477 public float GetMass()
@@ -1965,14 +2484,43 @@ namespace OpenSim.Region.Framework.Scenes
1965 return 0; 2484 return 0;
1966 } 2485 }
1967 2486
1968 public Vector3 GetForce() 2487 public Vector3 GetCenterOfMass()
1969 { 2488 {
2489 if (ParentGroup.RootPart == this)
2490 {
2491 if (ParentGroup.IsDeleted)
2492 return AbsolutePosition;
2493 return ParentGroup.GetCenterOfMass();
2494 }
2495
1970 PhysicsActor pa = PhysActor; 2496 PhysicsActor pa = PhysActor;
1971 2497
1972 if (pa != null) 2498 if (pa != null)
1973 return pa.Force; 2499 {
2500 Vector3 tmp = pa.CenterOfMass;
2501 return tmp;
2502 }
2503 else
2504 return AbsolutePosition;
2505 }
2506
2507 public Vector3 GetPartCenterOfMass()
2508 {
2509 PhysicsActor pa = PhysActor;
2510
2511 if (pa != null)
2512 {
2513 Vector3 tmp = pa.CenterOfMass;
2514 return tmp;
2515 }
1974 else 2516 else
1975 return Vector3.Zero; 2517 return AbsolutePosition;
2518 }
2519
2520
2521 public Vector3 GetForce()
2522 {
2523 return Force;
1976 } 2524 }
1977 2525
1978 /// <summary> 2526 /// <summary>
@@ -2187,15 +2735,25 @@ namespace OpenSim.Region.Framework.Scenes
2187 2735
2188 private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) 2736 private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify)
2189 { 2737 {
2190 if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) 2738 bool sendToRoot = true;
2191 { 2739
2192 ColliderArgs LandCollidingMessage = new ColliderArgs(); 2740 ColliderArgs LandCollidingMessage = new ColliderArgs();
2193 List<DetectedObject> colliding = new List<DetectedObject>(); 2741 List<DetectedObject> colliding = new List<DetectedObject>();
2194 2742
2195 colliding.Add(CreateDetObjectForGround()); 2743 colliding.Add(CreateDetObjectForGround());
2196 LandCollidingMessage.Colliders = colliding; 2744 LandCollidingMessage.Colliders = colliding;
2197 2745
2746 if (Inventory.ContainsScripts())
2747 {
2748 if (!PassCollisions)
2749 sendToRoot = false;
2750 }
2751 if ((ScriptEvents & ev) != 0)
2198 notify(LocalId, LandCollidingMessage); 2752 notify(LocalId, LandCollidingMessage);
2753
2754 if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot)
2755 {
2756 notify(ParentGroup.RootPart.LocalId, LandCollidingMessage);
2199 } 2757 }
2200 } 2758 }
2201 2759
@@ -2211,45 +2769,87 @@ namespace OpenSim.Region.Framework.Scenes
2211 List<uint> endedColliders = new List<uint>(); 2769 List<uint> endedColliders = new List<uint>();
2212 List<uint> startedColliders = new List<uint>(); 2770 List<uint> startedColliders = new List<uint>();
2213 2771
2214 // calculate things that started colliding this time 2772 if (collissionswith.Count == 0)
2215 // and build up list of colliders this time
2216 foreach (uint localid in collissionswith.Keys)
2217 { 2773 {
2218 thisHitColliders.Add(localid); 2774 if (m_lastColliders.Count == 0)
2219 if (!m_lastColliders.Contains(localid)) 2775 return; // nothing to do
2220 startedColliders.Add(localid);
2221 }
2222 2776
2223 // calculate things that ended colliding 2777 foreach (uint localID in m_lastColliders)
2224 foreach (uint localID in m_lastColliders) 2778 {
2225 {
2226 if (!thisHitColliders.Contains(localID))
2227 endedColliders.Add(localID); 2779 endedColliders.Add(localID);
2780 }
2781 m_lastColliders.Clear();
2228 } 2782 }
2229 2783
2230 //add the items that started colliding this time to the last colliders list. 2784 else
2231 foreach (uint localID in startedColliders) 2785 {
2232 m_lastColliders.Add(localID); 2786 List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>();
2787
2788 // calculate things that started colliding this time
2789 // and build up list of colliders this time
2790 if (!VolumeDetectActive && CollisionSoundType >= 0)
2791 {
2792 CollisionForSoundInfo soundinfo;
2793 ContactPoint curcontact;
2794
2795 foreach (uint id in collissionswith.Keys)
2796 {
2797 thisHitColliders.Add(id);
2798 if (!m_lastColliders.Contains(id))
2799 {
2800 startedColliders.Add(id);
2801
2802 curcontact = collissionswith[id];
2803 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
2804 {
2805 soundinfo = new CollisionForSoundInfo();
2806 soundinfo.colliderID = id;
2807 soundinfo.position = curcontact.Position;
2808 soundinfo.relativeVel = curcontact.RelativeSpeed;
2809 soundinfolist.Add(soundinfo);
2810 }
2811 }
2812 }
2813 }
2814 else
2815 {
2816 foreach (uint id in collissionswith.Keys)
2817 {
2818 thisHitColliders.Add(id);
2819 if (!m_lastColliders.Contains(id))
2820 startedColliders.Add(id);
2821 }
2822 }
2823
2824 // calculate things that ended colliding
2825 foreach (uint localID in m_lastColliders)
2826 {
2827 if (!thisHitColliders.Contains(localID))
2828 endedColliders.Add(localID);
2829 }
2830
2831 //add the items that started colliding this time to the last colliders list.
2832 foreach (uint localID in startedColliders)
2833 m_lastColliders.Add(localID);
2233 2834
2234 // remove things that ended colliding from the last colliders list 2835 // remove things that ended colliding from the last colliders list
2235 foreach (uint localID in endedColliders) 2836 foreach (uint localID in endedColliders)
2236 m_lastColliders.Remove(localID); 2837 m_lastColliders.Remove(localID);
2237 2838
2238 // play the sound. 2839 // play sounds.
2239 if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) 2840 if (soundinfolist.Count > 0)
2240 SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); 2841 CollisionSounds.PartCollisionSound(this, soundinfolist);
2842 }
2241 2843
2242 SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); 2844 SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart);
2243 SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); 2845 if (!VolumeDetectActive)
2846 SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding);
2244 SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); 2847 SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd);
2245 2848
2246 if (startedColliders.Contains(0)) 2849 if (startedColliders.Contains(0))
2247 { 2850 SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart);
2248 if (m_lastColliders.Contains(0)) 2851 if (m_lastColliders.Contains(0))
2249 SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); 2852 SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding);
2250 else
2251 SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart);
2252 }
2253 if (endedColliders.Contains(0)) 2853 if (endedColliders.Contains(0))
2254 SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); 2854 SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd);
2255 } 2855 }
@@ -2272,9 +2872,9 @@ namespace OpenSim.Region.Framework.Scenes
2272 Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); 2872 Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0);
2273 2873
2274 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) 2874 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N)
2275 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) 2875 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S)
2276 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) 2876 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E)
2277 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) 2877 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W))
2278 { 2878 {
2279 ParentGroup.AbsolutePosition = newpos; 2879 ParentGroup.AbsolutePosition = newpos;
2280 return; 2880 return;
@@ -2296,17 +2896,18 @@ namespace OpenSim.Region.Framework.Scenes
2296 //Trys to fetch sound id from prim's inventory. 2896 //Trys to fetch sound id from prim's inventory.
2297 //Prim's inventory doesn't support non script items yet 2897 //Prim's inventory doesn't support non script items yet
2298 2898
2299 lock (TaskInventory) 2899 TaskInventory.LockItemsForRead(true);
2900
2901 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2300 { 2902 {
2301 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2903 if (item.Value.Name == sound)
2302 { 2904 {
2303 if (item.Value.Name == sound) 2905 soundID = item.Value.ItemID;
2304 { 2906 break;
2305 soundID = item.Value.ItemID;
2306 break;
2307 }
2308 } 2907 }
2309 } 2908 }
2909
2910 TaskInventory.LockItemsForRead(false);
2310 } 2911 }
2311 2912
2312 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2913 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2428,6 +3029,19 @@ namespace OpenSim.Region.Framework.Scenes
2428 APIDTarget = Quaternion.Identity; 3029 APIDTarget = Quaternion.Identity;
2429 } 3030 }
2430 3031
3032
3033
3034 public void ScheduleFullUpdateIfNone()
3035 {
3036 if (ParentGroup == null)
3037 return;
3038
3039// ??? ParentGroup.HasGroupChanged = true;
3040
3041 if (UpdateFlag != UpdateRequired.FULL)
3042 ScheduleFullUpdate();
3043 }
3044
2431 /// <summary> 3045 /// <summary>
2432 /// Schedules this prim for a full update 3046 /// Schedules this prim for a full update
2433 /// </summary> 3047 /// </summary>
@@ -2630,8 +3244,8 @@ namespace OpenSim.Region.Framework.Scenes
2630 { 3244 {
2631 const float ROTATION_TOLERANCE = 0.01f; 3245 const float ROTATION_TOLERANCE = 0.01f;
2632 const float VELOCITY_TOLERANCE = 0.001f; 3246 const float VELOCITY_TOLERANCE = 0.001f;
2633 const float POSITION_TOLERANCE = 0.05f; 3247 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2634 const int TIME_MS_TOLERANCE = 3000; 3248 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2635 3249
2636 switch (UpdateFlag) 3250 switch (UpdateFlag)
2637 { 3251 {
@@ -2693,17 +3307,16 @@ namespace OpenSim.Region.Framework.Scenes
2693 if (!UUID.TryParse(sound, out soundID)) 3307 if (!UUID.TryParse(sound, out soundID))
2694 { 3308 {
2695 // search sound file from inventory 3309 // search sound file from inventory
2696 lock (TaskInventory) 3310 TaskInventory.LockItemsForRead(true);
3311 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2697 { 3312 {
2698 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3313 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2699 { 3314 {
2700 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3315 soundID = item.Value.ItemID;
2701 { 3316 break;
2702 soundID = item.Value.ItemID;
2703 break;
2704 }
2705 } 3317 }
2706 } 3318 }
3319 TaskInventory.LockItemsForRead(false);
2707 } 3320 }
2708 3321
2709 if (soundID == UUID.Zero) 3322 if (soundID == UUID.Zero)
@@ -2760,6 +3373,35 @@ namespace OpenSim.Region.Framework.Scenes
2760 } 3373 }
2761 } 3374 }
2762 3375
3376 public void SendCollisionSound(UUID soundID, double volume, Vector3 position)
3377 {
3378 if (soundID == UUID.Zero)
3379 return;
3380
3381 ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>();
3382 if (soundModule == null)
3383 return;
3384
3385 if (volume > 1)
3386 volume = 1;
3387 if (volume < 0)
3388 volume = 0;
3389
3390 int now = Util.EnvironmentTickCount();
3391 if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200)
3392 return;
3393
3394 LastColSoundSentTime = now;
3395
3396 UUID ownerID = OwnerID;
3397 UUID objectID = ParentGroup.RootPart.UUID;
3398 UUID parentID = ParentGroup.UUID;
3399 ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle;
3400
3401 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 );
3402 }
3403
3404
2763 /// <summary> 3405 /// <summary>
2764 /// Send a terse update to all clients 3406 /// Send a terse update to all clients
2765 /// </summary> 3407 /// </summary>
@@ -2788,10 +3430,13 @@ namespace OpenSim.Region.Framework.Scenes
2788 3430
2789 public void SetBuoyancy(float fvalue) 3431 public void SetBuoyancy(float fvalue)
2790 { 3432 {
2791 PhysicsActor pa = PhysActor; 3433 Buoyancy = fvalue;
2792 3434/*
2793 if (pa != null) 3435 if (PhysActor != null)
2794 pa.Buoyancy = fvalue; 3436 {
3437 PhysActor.Buoyancy = fvalue;
3438 }
3439 */
2795 } 3440 }
2796 3441
2797 public void SetDieAtEdge(bool p) 3442 public void SetDieAtEdge(bool p)
@@ -2807,47 +3452,111 @@ namespace OpenSim.Region.Framework.Scenes
2807 PhysicsActor pa = PhysActor; 3452 PhysicsActor pa = PhysActor;
2808 3453
2809 if (pa != null) 3454 if (pa != null)
2810 pa.FloatOnWater = floatYN == 1; 3455 pa.FloatOnWater = (floatYN == 1);
2811 } 3456 }
2812 3457
2813 public void SetForce(Vector3 force) 3458 public void SetForce(Vector3 force)
2814 { 3459 {
2815 PhysicsActor pa = PhysActor; 3460 Force = force;
3461 }
2816 3462
2817 if (pa != null) 3463 public SOPVehicle VehicleParams
2818 pa.Force = force; 3464 {
3465 get
3466 {
3467 return m_vehicleParams;
3468 }
3469 set
3470 {
3471 m_vehicleParams = value;
3472 }
3473 }
3474
3475
3476 public int VehicleType
3477 {
3478 get
3479 {
3480 if (m_vehicleParams == null)
3481 return (int)Vehicle.TYPE_NONE;
3482 else
3483 return (int)m_vehicleParams.Type;
3484 }
3485 set
3486 {
3487 SetVehicleType(value);
3488 }
2819 } 3489 }
2820 3490
2821 public void SetVehicleType(int type) 3491 public void SetVehicleType(int type)
2822 { 3492 {
2823 PhysicsActor pa = PhysActor; 3493 m_vehicleParams = null;
3494
3495 if (type == (int)Vehicle.TYPE_NONE)
3496 {
3497 if (_parentID ==0 && PhysActor != null)
3498 PhysActor.VehicleType = (int)Vehicle.TYPE_NONE;
3499 return;
3500 }
3501 m_vehicleParams = new SOPVehicle();
3502 m_vehicleParams.ProcessTypeChange((Vehicle)type);
3503 {
3504 if (_parentID ==0 && PhysActor != null)
3505 PhysActor.VehicleType = type;
3506 return;
3507 }
3508 }
2824 3509
2825 if (pa != null) 3510 public void SetVehicleFlags(int param, bool remove)
2826 pa.VehicleType = type; 3511 {
3512 if (m_vehicleParams == null)
3513 return;
3514
3515 m_vehicleParams.ProcessVehicleFlags(param, remove);
3516
3517 if (_parentID ==0 && PhysActor != null)
3518 {
3519 PhysActor.VehicleFlags(param, remove);
3520 }
2827 } 3521 }
2828 3522
2829 public void SetVehicleFloatParam(int param, float value) 3523 public void SetVehicleFloatParam(int param, float value)
2830 { 3524 {
2831 PhysicsActor pa = PhysActor; 3525 if (m_vehicleParams == null)
3526 return;
2832 3527
2833 if (pa != null) 3528 m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value);
2834 pa.VehicleFloatParam(param, value); 3529
3530 if (_parentID == 0 && PhysActor != null)
3531 {
3532 PhysActor.VehicleFloatParam(param, value);
3533 }
2835 } 3534 }
2836 3535
2837 public void SetVehicleVectorParam(int param, Vector3 value) 3536 public void SetVehicleVectorParam(int param, Vector3 value)
2838 { 3537 {
2839 PhysicsActor pa = PhysActor; 3538 if (m_vehicleParams == null)
3539 return;
2840 3540
2841 if (pa != null) 3541 m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value);
2842 pa.VehicleVectorParam(param, value); 3542
3543 if (_parentID == 0 && PhysActor != null)
3544 {
3545 PhysActor.VehicleVectorParam(param, value);
3546 }
2843 } 3547 }
2844 3548
2845 public void SetVehicleRotationParam(int param, Quaternion rotation) 3549 public void SetVehicleRotationParam(int param, Quaternion rotation)
2846 { 3550 {
2847 PhysicsActor pa = PhysActor; 3551 if (m_vehicleParams == null)
3552 return;
2848 3553
2849 if (pa != null) 3554 m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation);
2850 pa.VehicleRotationParam(param, rotation); 3555
3556 if (_parentID == 0 && PhysActor != null)
3557 {
3558 PhysActor.VehicleRotationParam(param, rotation);
3559 }
2851 } 3560 }
2852 3561
2853 /// <summary> 3562 /// <summary>
@@ -3031,14 +3740,6 @@ namespace OpenSim.Region.Framework.Scenes
3031 hasProfileCut = hasDimple; // is it the same thing? 3740 hasProfileCut = hasDimple; // is it the same thing?
3032 } 3741 }
3033 3742
3034 public void SetVehicleFlags(int param, bool remove)
3035 {
3036 PhysicsActor pa = PhysActor;
3037
3038 if (pa != null)
3039 pa.VehicleFlags(param, remove);
3040 }
3041
3042 public void SetGroup(UUID groupID, IClientAPI client) 3743 public void SetGroup(UUID groupID, IClientAPI client)
3043 { 3744 {
3044 // Scene.AddNewPrims() calls with client == null so can't use this. 3745 // Scene.AddNewPrims() calls with client == null so can't use this.
@@ -3142,68 +3843,18 @@ namespace OpenSim.Region.Framework.Scenes
3142 //ParentGroup.ScheduleGroupForFullUpdate(); 3843 //ParentGroup.ScheduleGroupForFullUpdate();
3143 } 3844 }
3144 3845
3145 public void StoreUndoState() 3846 public void StoreUndoState(ObjectChangeType change)
3146 { 3847 {
3147 StoreUndoState(false); 3848 if (m_UndoRedo == null)
3148 } 3849 m_UndoRedo = new UndoRedoState(5);
3149 3850
3150 public void StoreUndoState(bool forGroup) 3851 lock (m_UndoRedo)
3151 {
3152 if (!Undoing)
3153 { 3852 {
3154 if (!IgnoreUndoUpdate) 3853 if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended
3155 { 3854 {
3156 if (ParentGroup != null) 3855 m_UndoRedo.StoreUndo(this, change);
3157 {
3158 lock (m_undo)
3159 {
3160 if (m_undo.Count > 0)
3161 {
3162 UndoState last = m_undo.Peek();
3163 if (last != null)
3164 {
3165 // TODO: May need to fix for group comparison
3166 if (last.Compare(this))
3167 {
3168 // m_log.DebugFormat(
3169 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3170 // Name, LocalId, m_undo.Count);
3171
3172 return;
3173 }
3174 }
3175 }
3176
3177 // m_log.DebugFormat(
3178 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3179 // Name, LocalId, forGroup, m_undo.Count);
3180
3181 if (ParentGroup.GetSceneMaxUndo() > 0)
3182 {
3183 UndoState nUndo = new UndoState(this, forGroup);
3184
3185 m_undo.Push(nUndo);
3186
3187 if (m_redo.Count > 0)
3188 m_redo.Clear();
3189
3190 // m_log.DebugFormat(
3191 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3192 // Name, LocalId, forGroup, m_undo.Count);
3193 }
3194 }
3195 }
3196 } 3856 }
3197// else
3198// {
3199// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3200// }
3201 } 3857 }
3202// else
3203// {
3204// m_log.DebugFormat(
3205// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3206// }
3207 } 3858 }
3208 3859
3209 /// <summary> 3860 /// <summary>
@@ -3213,84 +3864,46 @@ namespace OpenSim.Region.Framework.Scenes
3213 { 3864 {
3214 get 3865 get
3215 { 3866 {
3216 lock (m_undo) 3867 if (m_UndoRedo == null)
3217 return m_undo.Count; 3868 return 0;
3869 return m_UndoRedo.Count;
3218 } 3870 }
3219 } 3871 }
3220 3872
3221 public void Undo() 3873 public void Undo()
3222 { 3874 {
3223 lock (m_undo) 3875 if (m_UndoRedo == null || Undoing || ParentGroup == null)
3224 { 3876 return;
3225// m_log.DebugFormat(
3226// "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
3227// Name, LocalId, m_undo.Count);
3228
3229 if (m_undo.Count > 0)
3230 {
3231 UndoState goback = m_undo.Pop();
3232
3233 if (goback != null)
3234 {
3235 UndoState nUndo = null;
3236
3237 if (ParentGroup.GetSceneMaxUndo() > 0)
3238 {
3239 nUndo = new UndoState(this, goback.ForGroup);
3240 }
3241
3242 goback.PlaybackState(this);
3243
3244 if (nUndo != null)
3245 m_redo.Push(nUndo);
3246 }
3247 }
3248 3877
3249// m_log.DebugFormat( 3878 lock (m_UndoRedo)
3250// "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", 3879 {
3251// Name, LocalId, m_undo.Count); 3880 Undoing = true;
3881 m_UndoRedo.Undo(this);
3882 Undoing = false;
3252 } 3883 }
3253 } 3884 }
3254 3885
3255 public void Redo() 3886 public void Redo()
3256 { 3887 {
3257 lock (m_undo) 3888 if (m_UndoRedo == null || Undoing || ParentGroup == null)
3258 { 3889 return;
3259// m_log.DebugFormat(
3260// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
3261// Name, LocalId, m_redo.Count);
3262
3263 if (m_redo.Count > 0)
3264 {
3265 UndoState gofwd = m_redo.Pop();
3266
3267 if (gofwd != null)
3268 {
3269 if (ParentGroup.GetSceneMaxUndo() > 0)
3270 {
3271 UndoState nUndo = new UndoState(this, gofwd.ForGroup);
3272
3273 m_undo.Push(nUndo);
3274 }
3275
3276 gofwd.PlayfwdState(this);
3277 }
3278 3890
3279// m_log.DebugFormat( 3891 lock (m_UndoRedo)
3280// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", 3892 {
3281// Name, LocalId, m_redo.Count); 3893 Undoing = true;
3282 } 3894 m_UndoRedo.Redo(this);
3895 Undoing = false;
3283 } 3896 }
3284 } 3897 }
3285 3898
3286 public void ClearUndoState() 3899 public void ClearUndoState()
3287 { 3900 {
3288// m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); 3901 if (m_UndoRedo == null || Undoing)
3902 return;
3289 3903
3290 lock (m_undo) 3904 lock (m_UndoRedo)
3291 { 3905 {
3292 m_undo.Clear(); 3906 m_UndoRedo.Clear();
3293 m_redo.Clear();
3294 } 3907 }
3295 } 3908 }
3296 3909
@@ -3920,6 +4533,27 @@ namespace OpenSim.Region.Framework.Scenes
3920 } 4533 }
3921 } 4534 }
3922 4535
4536
4537 public void UpdateExtraPhysics(ExtraPhysicsData physdata)
4538 {
4539 if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null)
4540 return;
4541
4542 if (PhysicsShapeType != (byte)physdata.PhysShapeType)
4543 {
4544 PhysicsShapeType = (byte)physdata.PhysShapeType;
4545
4546 }
4547
4548 if(Density != physdata.Density)
4549 Density = physdata.Density;
4550 if(GravityModifier != physdata.GravitationModifier)
4551 GravityModifier = physdata.GravitationModifier;
4552 if(Friction != physdata.Friction)
4553 Friction = physdata.Friction;
4554 if(Bounciness != physdata.Bounce)
4555 Bounciness = physdata.Bounce;
4556 }
3923 /// <summary> 4557 /// <summary>
3924 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. 4558 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
3925 /// </summary> 4559 /// </summary>
@@ -3927,7 +4561,7 @@ namespace OpenSim.Region.Framework.Scenes
3927 /// <param name="SetTemporary"></param> 4561 /// <param name="SetTemporary"></param>
3928 /// <param name="SetPhantom"></param> 4562 /// <param name="SetPhantom"></param>
3929 /// <param name="SetVD"></param> 4563 /// <param name="SetVD"></param>
3930 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) 4564 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building)
3931 { 4565 {
3932 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); 4566 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0);
3933 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); 4567 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0);
@@ -3937,237 +4571,230 @@ namespace OpenSim.Region.Framework.Scenes
3937 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4571 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
3938 return; 4572 return;
3939 4573
3940 PhysicsActor pa = PhysActor; 4574 VolumeDetectActive = SetVD;
3941
3942 // Special cases for VD. VD can only be called from a script
3943 // and can't be combined with changes to other states. So we can rely
3944 // that...
3945 // ... if VD is changed, all others are not.
3946 // ... if one of the others is changed, VD is not.
3947 if (SetVD) // VD is active, special logic applies
3948 {
3949 // State machine logic for VolumeDetect
3950 // More logic below
3951 bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom;
3952
3953 if (phanReset) // Phantom changes from on to off switch VD off too
3954 {
3955 SetVD = false; // Switch it of for the course of this routine
3956 VolumeDetectActive = false; // and also permanently
3957
3958 if (pa != null)
3959 pa.SetVolumeDetect(0); // Let physics know about it too
3960 }
3961 else
3962 {
3963 // If volumedetect is active we don't want phantom to be applied.
3964 // If this is a new call to VD out of the state "phantom"
3965 // this will also cause the prim to be visible to physics
3966 SetPhantom = false;
3967 }
3968 }
3969 4575
3970 if (UsePhysics && IsJoint()) 4576 // volume detector implies phantom
3971 { 4577 if (VolumeDetectActive)
3972 SetPhantom = true; 4578 SetPhantom = true;
3973 }
3974 4579
3975 if (UsePhysics) 4580 if (UsePhysics)
3976 {
3977 AddFlag(PrimFlags.Physics); 4581 AddFlag(PrimFlags.Physics);
3978 if (!wasUsingPhysics)
3979 {
3980 DoPhysicsPropertyUpdate(UsePhysics, false);
3981
3982 if (!ParentGroup.IsDeleted)
3983 {
3984 if (LocalId == ParentGroup.RootPart.LocalId)
3985 {
3986 ParentGroup.CheckSculptAndLoad();
3987 }
3988 }
3989 }
3990 }
3991 else 4582 else
3992 {
3993 RemFlag(PrimFlags.Physics); 4583 RemFlag(PrimFlags.Physics);
3994 if (wasUsingPhysics)
3995 {
3996 DoPhysicsPropertyUpdate(UsePhysics, false);
3997 }
3998 }
3999 4584
4000 if (SetPhantom 4585 if (SetPhantom)
4001 || ParentGroup.IsAttachment
4002 || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints
4003 {
4004 AddFlag(PrimFlags.Phantom); 4586 AddFlag(PrimFlags.Phantom);
4587 else
4588 RemFlag(PrimFlags.Phantom);
4005 4589
4006 if (PhysActor != null) 4590 if (SetTemporary)
4591 AddFlag(PrimFlags.TemporaryOnRez);
4592 else
4593 RemFlag(PrimFlags.TemporaryOnRez);
4594
4595
4596 if (ParentGroup.Scene == null)
4597 return;
4598
4599 PhysicsActor pa = PhysActor;
4600
4601 if (pa != null && building && pa.Building != building)
4602 pa.Building = building;
4603
4604 if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none
4605 || (Shape.PathCurve == (byte)Extrusion.Flexible))
4606 {
4607 if (pa != null)
4007 { 4608 {
4609 if(wasUsingPhysics)
4610 ParentGroup.Scene.RemovePhysicalPrim(1);
4008 RemoveFromPhysics(); 4611 RemoveFromPhysics();
4009 pa = null;
4010 } 4612 }
4613
4614 Velocity = new Vector3(0, 0, 0);
4615 Acceleration = new Vector3(0, 0, 0);
4616 if (ParentGroup.RootPart == this)
4617 AngularVelocity = new Vector3(0, 0, 0);
4011 } 4618 }
4012 else // Not phantom 4619 else
4013 { 4620 {
4014 RemFlag(PrimFlags.Phantom); 4621 if (ParentGroup.Scene.CollidablePrims)
4015
4016 if (ParentGroup.Scene == null)
4017 return;
4018
4019 if (ParentGroup.Scene.CollidablePrims && pa == null)
4020 { 4622 {
4021 pa = AddToPhysics(UsePhysics); 4623 if (pa == null)
4022
4023 if (pa != null)
4024 { 4624 {
4025 pa.SetMaterial(Material); 4625 AddToPhysics(UsePhysics, SetPhantom, building, false);
4026 DoPhysicsPropertyUpdate(UsePhysics, true); 4626 pa = PhysActor;
4027 4627/*
4028 if (!ParentGroup.IsDeleted) 4628 if (pa != null)
4029 { 4629 {
4030 if (LocalId == ParentGroup.RootPart.LocalId) 4630 if (
4631// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4632// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4633// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4634// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4635// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4636// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4637 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4638 ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4639 (CollisionSound != UUID.Zero)
4640 )
4031 { 4641 {
4032 ParentGroup.CheckSculptAndLoad(); 4642 pa.OnCollisionUpdate += PhysicsCollision;
4643 pa.SubscribeEvents(1000);
4033 } 4644 }
4034 } 4645 }
4035 4646*/
4036 if (
4037 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4038 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4039 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4040 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4041 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4042 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4043 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) ||
4044 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4045 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4046 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4047 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4048 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4049 (CollisionSound != UUID.Zero)
4050 )
4051 {
4052 pa.OnCollisionUpdate += PhysicsCollision;
4053 pa.SubscribeEvents(1000);
4054 }
4055 } 4647 }
4056 } 4648 else // it already has a physical representation
4057 else // it already has a physical representation
4058 {
4059 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim
4060
4061 if (!ParentGroup.IsDeleted)
4062 { 4649 {
4063 if (LocalId == ParentGroup.RootPart.LocalId) 4650 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
4064 { 4651/* moved into DoPhysicsPropertyUpdate
4065 ParentGroup.CheckSculptAndLoad(); 4652 if(VolumeDetectActive)
4066 } 4653 pa.SetVolumeDetect(1);
4654 else
4655 pa.SetVolumeDetect(0);
4656*/
4657
4658 if (pa.Building != building)
4659 pa.Building = building;
4067 } 4660 }
4068 }
4069 }
4070 4661
4071 if (SetVD) 4662 UpdatePhysicsSubscribedEvents();
4072 {
4073 // If the above logic worked (this is urgent candidate to unit tests!)
4074 // we now have a physicsactor.
4075 // Defensive programming calls for a check here.
4076 // Better would be throwing an exception that could be catched by a unit test as the internal
4077 // logic should make sure, this Physactor is always here.
4078 if (pa != null)
4079 {
4080 pa.SetVolumeDetect(1);
4081 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
4082 VolumeDetectActive = true;
4083 } 4663 }
4084 } 4664 }
4085 else
4086 {
4087 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4088 // (mumbles, well, at least if you have infinte CPU powers :-))
4089 if (pa != null)
4090 pa.SetVolumeDetect(0);
4091
4092 VolumeDetectActive = false;
4093 }
4094
4095 if (SetTemporary)
4096 {
4097 AddFlag(PrimFlags.TemporaryOnRez);
4098 }
4099 else
4100 {
4101 RemFlag(PrimFlags.TemporaryOnRez);
4102 }
4103 4665
4104 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 4666 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
4105 4667
4668 // and last in case we have a new actor and not building
4669
4106 if (ParentGroup != null) 4670 if (ParentGroup != null)
4107 { 4671 {
4108 ParentGroup.HasGroupChanged = true; 4672 ParentGroup.HasGroupChanged = true;
4109 ScheduleFullUpdate(); 4673 ScheduleFullUpdate();
4110 } 4674 }
4111 4675
4112// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); 4676// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags);
4113 } 4677 }
4114 4678
4115 /// <summary> 4679 /// <summary>
4116 /// Adds this part to the physics scene. 4680 /// Adds this part to the physics scene.
4681 /// and sets the PhysActor property
4117 /// </summary> 4682 /// </summary>
4118 /// <remarks>This method also sets the PhysActor property.</remarks> 4683 /// <param name="isPhysical">Add this prim as physical.</param>
4119 /// <param name="rigidBody">Add this prim with a rigid body.</param> 4684 /// <param name="isPhantom">Add this prim as phantom.</param>
4120 /// <returns> 4685 /// <param name="building">tells physics to delay full construction of object</param>
4121 /// The physics actor. null if there was a failure. 4686 /// <param name="applyDynamics">applies velocities, force and torque</param>
4122 /// </returns> 4687 private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics)
4123 private PhysicsActor AddToPhysics(bool rigidBody) 4688 {
4124 {
4125 PhysicsActor pa; 4689 PhysicsActor pa;
4126 4690
4691 Vector3 velocity = Velocity;
4692 Vector3 rotationalVelocity = AngularVelocity;;
4693
4127 try 4694 try
4128 { 4695 {
4129 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( 4696 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape(
4130 string.Format("{0}/{1}", Name, UUID), 4697 string.Format("{0}/{1}", Name, UUID),
4131 Shape, 4698 Shape,
4132 AbsolutePosition, 4699 AbsolutePosition,
4133 Scale, 4700 Scale,
4134 RotationOffset, 4701 GetWorldRotation(),
4135 rigidBody, 4702 isPhysical,
4136 m_localId); 4703 isPhantom,
4704 PhysicsShapeType,
4705 m_localId);
4137 } 4706 }
4138 catch 4707 catch (Exception ex)
4139 { 4708 {
4140 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); 4709 m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message);
4141 pa = null; 4710 pa = null;
4142 } 4711 }
4143 4712
4144 // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical
4145 // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor
4146 // being set.
4147 PhysActor = pa;
4148
4149 // Basic Physics can also return null as well as an exception catch.
4150 if (pa != null) 4713 if (pa != null)
4151 { 4714 {
4152 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 4715 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
4153 pa.SetMaterial(Material); 4716 pa.SetMaterial(Material);
4154 DoPhysicsPropertyUpdate(rigidBody, true); 4717
4718 if (VolumeDetectActive) // change if not the default only
4719 pa.SetVolumeDetect(1);
4720
4721 if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId)
4722 m_vehicleParams.SetVehicle(pa);
4723
4724 // we are going to tell rest of code about physics so better have this here
4725 PhysActor = pa;
4726
4727 // DoPhysicsPropertyUpdate(isPhysical, true);
4728 // lets expand it here just with what it really needs to do
4729
4730 if (isPhysical)
4731 {
4732 if (ParentGroup.RootPart.KeyframeMotion != null)
4733 ParentGroup.RootPart.KeyframeMotion.Stop();
4734 ParentGroup.RootPart.KeyframeMotion = null;
4735 ParentGroup.Scene.AddPhysicalPrim(1);
4736
4737 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
4738 pa.OnOutOfBounds += PhysicsOutOfBounds;
4739
4740 if (ParentID != 0 && ParentID != LocalId)
4741 {
4742 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
4743
4744 if (parentPa != null)
4745 {
4746 pa.link(parentPa);
4747 }
4748 }
4749 }
4750
4751 if (applyDynamics)
4752 // do independent of isphysical so parameters get setted (at least some)
4753 {
4754 Velocity = velocity;
4755 AngularVelocity = rotationalVelocity;
4756// pa.Velocity = velocity;
4757 pa.RotationalVelocity = rotationalVelocity;
4758
4759 // if not vehicle and root part apply force and torque
4760 if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE)
4761 && LocalId == ParentGroup.RootPart.LocalId)
4762 {
4763 pa.Force = Force;
4764 pa.Torque = Torque;
4765 }
4766 }
4767
4768 if (Shape.SculptEntry)
4769 CheckSculptAndLoad();
4770 else
4771 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
4772
4773 if (!building)
4774 pa.Building = false;
4155 } 4775 }
4156 4776
4157 return pa; 4777 PhysActor = pa;
4158 } 4778 }
4159 4779
4160 /// <summary> 4780 /// <summary>
4161 /// This removes the part from the physics scene. 4781 /// This removes the part from the physics scene.
4162 /// </summary> 4782 /// </summary>
4163 /// <remarks> 4783 /// <remarks>
4164 /// This isn't the same as turning off physical, since even without being physical the prim has a physics 4784 /// This isn't the same as turning off physical, since even without being physical the prim has a physics
4165 /// representation for collision detection. Rather, this would be used in situations such as making a prim 4785 /// representation for collision detection.
4166 /// phantom.
4167 /// </remarks> 4786 /// </remarks>
4168 public void RemoveFromPhysics() 4787 public void RemoveFromPhysics()
4169 { 4788 {
4170 ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); 4789 PhysicsActor pa = PhysActor;
4790 if (pa != null)
4791 {
4792 pa.OnCollisionUpdate -= PhysicsCollision;
4793 pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
4794 pa.OnOutOfBounds -= PhysicsOutOfBounds;
4795
4796 ParentGroup.Scene.PhysicsScene.RemovePrim(pa);
4797 }
4171 PhysActor = null; 4798 PhysActor = null;
4172 } 4799 }
4173 4800
@@ -4378,6 +5005,44 @@ namespace OpenSim.Region.Framework.Scenes
4378 ScheduleFullUpdate(); 5005 ScheduleFullUpdate();
4379 } 5006 }
4380 5007
5008
5009 private void UpdatePhysicsSubscribedEvents()
5010 {
5011 PhysicsActor pa = PhysActor;
5012 if (pa == null)
5013 return;
5014
5015 pa.OnCollisionUpdate -= PhysicsCollision;
5016
5017 bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0));
5018
5019 scriptEvents CombinedEvents = AggregateScriptEvents;
5020
5021 // merge with root part
5022 if (ParentGroup != null && ParentGroup.RootPart != null)
5023 CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents;
5024
5025 // submit to this part case
5026 if (VolumeDetectActive)
5027 CombinedEvents &= PhyscicsVolumeDtcSubsEvents;
5028 else if ((Flags & PrimFlags.Phantom) != 0)
5029 CombinedEvents &= PhyscicsPhantonSubsEvents;
5030 else
5031 CombinedEvents &= PhysicsNeededSubsEvents;
5032
5033 if (hassound || CombinedEvents != 0)
5034 {
5035 // subscribe to physics updates.
5036 pa.OnCollisionUpdate += PhysicsCollision;
5037 pa.SubscribeEvents(50); // 20 reports per second
5038 }
5039 else
5040 {
5041 pa.UnSubscribeEvents();
5042 }
5043 }
5044
5045
4381 public void aggregateScriptEvents() 5046 public void aggregateScriptEvents()
4382 { 5047 {
4383 if (ParentGroup == null || ParentGroup.RootPart == null) 5048 if (ParentGroup == null || ParentGroup.RootPart == null)
@@ -4414,40 +5079,32 @@ namespace OpenSim.Region.Framework.Scenes
4414 { 5079 {
4415 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; 5080 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
4416 } 5081 }
4417 5082/*
4418 PhysicsActor pa = PhysActor; 5083 PhysicsActor pa = PhysActor;
4419 5084 if (pa != null)
4420 if (
4421 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4422 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4423 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4424 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4425 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4426 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4427 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) ||
4428 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4429 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4430 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4431 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4432 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4433 (CollisionSound != UUID.Zero)
4434 )
4435 { 5085 {
4436 // subscribe to physics updates. 5086 if (
4437 if (pa != null) 5087// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
5088// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
5089// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
5090// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
5091// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
5092// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
5093 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
5094 )
4438 { 5095 {
5096 // subscribe to physics updates.
4439 pa.OnCollisionUpdate += PhysicsCollision; 5097 pa.OnCollisionUpdate += PhysicsCollision;
4440 pa.SubscribeEvents(1000); 5098 pa.SubscribeEvents(1000);
4441 } 5099 }
4442 } 5100 else
4443 else
4444 {
4445 if (pa != null)
4446 { 5101 {
4447 pa.UnSubscribeEvents(); 5102 pa.UnSubscribeEvents();
4448 pa.OnCollisionUpdate -= PhysicsCollision; 5103 pa.OnCollisionUpdate -= PhysicsCollision;
4449 } 5104 }
4450 } 5105 }
5106 */
5107 UpdatePhysicsSubscribedEvents();
4451 5108
4452 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) 5109 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
4453 //{ 5110 //{
@@ -4577,6 +5234,18 @@ namespace OpenSim.Region.Framework.Scenes
4577 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 5234 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4578 } 5235 }
4579 5236
5237 public void ResetOwnerChangeFlag()
5238 {
5239 List<UUID> inv = Inventory.GetInventoryList();
5240
5241 foreach (UUID itemID in inv)
5242 {
5243 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
5244 item.OwnerChanged = false;
5245 Inventory.UpdateInventoryItem(item, false, false);
5246 }
5247 }
5248
4580 /// <summary> 5249 /// <summary>
4581 /// Record an avatar sitting on this part. 5250 /// Record an avatar sitting on this part.
4582 /// </summary> 5251 /// </summary>