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 4b2fede..bd11cde 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.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 793 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
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)
@@ -2429,6 +3030,19 @@ namespace OpenSim.Region.Framework.Scenes
2429 APIDTarget = Quaternion.Identity; 3030 APIDTarget = Quaternion.Identity;
2430 } 3031 }
2431 3032
3033
3034
3035 public void ScheduleFullUpdateIfNone()
3036 {
3037 if (ParentGroup == null)
3038 return;
3039
3040// ??? ParentGroup.HasGroupChanged = true;
3041
3042 if (UpdateFlag != UpdateRequired.FULL)
3043 ScheduleFullUpdate();
3044 }
3045
2432 /// <summary> 3046 /// <summary>
2433 /// Schedules this prim for a full update 3047 /// Schedules this prim for a full update
2434 /// </summary> 3048 /// </summary>
@@ -2631,8 +3245,8 @@ namespace OpenSim.Region.Framework.Scenes
2631 { 3245 {
2632 const float ROTATION_TOLERANCE = 0.01f; 3246 const float ROTATION_TOLERANCE = 0.01f;
2633 const float VELOCITY_TOLERANCE = 0.001f; 3247 const float VELOCITY_TOLERANCE = 0.001f;
2634 const float POSITION_TOLERANCE = 0.05f; 3248 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2635 const int TIME_MS_TOLERANCE = 3000; 3249 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2636 3250
2637 switch (UpdateFlag) 3251 switch (UpdateFlag)
2638 { 3252 {
@@ -2694,17 +3308,16 @@ namespace OpenSim.Region.Framework.Scenes
2694 if (!UUID.TryParse(sound, out soundID)) 3308 if (!UUID.TryParse(sound, out soundID))
2695 { 3309 {
2696 // search sound file from inventory 3310 // search sound file from inventory
2697 lock (TaskInventory) 3311 TaskInventory.LockItemsForRead(true);
3312 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2698 { 3313 {
2699 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3314 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2700 { 3315 {
2701 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3316 soundID = item.Value.ItemID;
2702 { 3317 break;
2703 soundID = item.Value.ItemID;
2704 break;
2705 }
2706 } 3318 }
2707 } 3319 }
3320 TaskInventory.LockItemsForRead(false);
2708 } 3321 }
2709 3322
2710 if (soundID == UUID.Zero) 3323 if (soundID == UUID.Zero)
@@ -2761,6 +3374,35 @@ namespace OpenSim.Region.Framework.Scenes
2761 } 3374 }
2762 } 3375 }
2763 3376
3377 public void SendCollisionSound(UUID soundID, double volume, Vector3 position)
3378 {
3379 if (soundID == UUID.Zero)
3380 return;
3381
3382 ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>();
3383 if (soundModule == null)
3384 return;
3385
3386 if (volume > 1)
3387 volume = 1;
3388 if (volume < 0)
3389 volume = 0;
3390
3391 int now = Util.EnvironmentTickCount();
3392 if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200)
3393 return;
3394
3395 LastColSoundSentTime = now;
3396
3397 UUID ownerID = OwnerID;
3398 UUID objectID = ParentGroup.RootPart.UUID;
3399 UUID parentID = ParentGroup.UUID;
3400 ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle;
3401
3402 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 );
3403 }
3404
3405
2764 /// <summary> 3406 /// <summary>
2765 /// Send a terse update to all clients 3407 /// Send a terse update to all clients
2766 /// </summary> 3408 /// </summary>
@@ -2789,10 +3431,13 @@ namespace OpenSim.Region.Framework.Scenes
2789 3431
2790 public void SetBuoyancy(float fvalue) 3432 public void SetBuoyancy(float fvalue)
2791 { 3433 {
2792 PhysicsActor pa = PhysActor; 3434 Buoyancy = fvalue;
2793 3435/*
2794 if (pa != null) 3436 if (PhysActor != null)
2795 pa.Buoyancy = fvalue; 3437 {
3438 PhysActor.Buoyancy = fvalue;
3439 }
3440 */
2796 } 3441 }
2797 3442
2798 public void SetDieAtEdge(bool p) 3443 public void SetDieAtEdge(bool p)
@@ -2808,47 +3453,111 @@ namespace OpenSim.Region.Framework.Scenes
2808 PhysicsActor pa = PhysActor; 3453 PhysicsActor pa = PhysActor;
2809 3454
2810 if (pa != null) 3455 if (pa != null)
2811 pa.FloatOnWater = floatYN == 1; 3456 pa.FloatOnWater = (floatYN == 1);
2812 } 3457 }
2813 3458
2814 public void SetForce(Vector3 force) 3459 public void SetForce(Vector3 force)
2815 { 3460 {
2816 PhysicsActor pa = PhysActor; 3461 Force = force;
3462 }
2817 3463
2818 if (pa != null) 3464 public SOPVehicle VehicleParams
2819 pa.Force = force; 3465 {
3466 get
3467 {
3468 return m_vehicleParams;
3469 }
3470 set
3471 {
3472 m_vehicleParams = value;
3473 }
3474 }
3475
3476
3477 public int VehicleType
3478 {
3479 get
3480 {
3481 if (m_vehicleParams == null)
3482 return (int)Vehicle.TYPE_NONE;
3483 else
3484 return (int)m_vehicleParams.Type;
3485 }
3486 set
3487 {
3488 SetVehicleType(value);
3489 }
2820 } 3490 }
2821 3491
2822 public void SetVehicleType(int type) 3492 public void SetVehicleType(int type)
2823 { 3493 {
2824 PhysicsActor pa = PhysActor; 3494 m_vehicleParams = null;
3495
3496 if (type == (int)Vehicle.TYPE_NONE)
3497 {
3498 if (_parentID ==0 && PhysActor != null)
3499 PhysActor.VehicleType = (int)Vehicle.TYPE_NONE;
3500 return;
3501 }
3502 m_vehicleParams = new SOPVehicle();
3503 m_vehicleParams.ProcessTypeChange((Vehicle)type);
3504 {
3505 if (_parentID ==0 && PhysActor != null)
3506 PhysActor.VehicleType = type;
3507 return;
3508 }
3509 }
2825 3510
2826 if (pa != null) 3511 public void SetVehicleFlags(int param, bool remove)
2827 pa.VehicleType = type; 3512 {
3513 if (m_vehicleParams == null)
3514 return;
3515
3516 m_vehicleParams.ProcessVehicleFlags(param, remove);
3517
3518 if (_parentID ==0 && PhysActor != null)
3519 {
3520 PhysActor.VehicleFlags(param, remove);
3521 }
2828 } 3522 }
2829 3523
2830 public void SetVehicleFloatParam(int param, float value) 3524 public void SetVehicleFloatParam(int param, float value)
2831 { 3525 {
2832 PhysicsActor pa = PhysActor; 3526 if (m_vehicleParams == null)
3527 return;
2833 3528
2834 if (pa != null) 3529 m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value);
2835 pa.VehicleFloatParam(param, value); 3530
3531 if (_parentID == 0 && PhysActor != null)
3532 {
3533 PhysActor.VehicleFloatParam(param, value);
3534 }
2836 } 3535 }
2837 3536
2838 public void SetVehicleVectorParam(int param, Vector3 value) 3537 public void SetVehicleVectorParam(int param, Vector3 value)
2839 { 3538 {
2840 PhysicsActor pa = PhysActor; 3539 if (m_vehicleParams == null)
3540 return;
2841 3541
2842 if (pa != null) 3542 m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value);
2843 pa.VehicleVectorParam(param, value); 3543
3544 if (_parentID == 0 && PhysActor != null)
3545 {
3546 PhysActor.VehicleVectorParam(param, value);
3547 }
2844 } 3548 }
2845 3549
2846 public void SetVehicleRotationParam(int param, Quaternion rotation) 3550 public void SetVehicleRotationParam(int param, Quaternion rotation)
2847 { 3551 {
2848 PhysicsActor pa = PhysActor; 3552 if (m_vehicleParams == null)
3553 return;
2849 3554
2850 if (pa != null) 3555 m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation);
2851 pa.VehicleRotationParam(param, rotation); 3556
3557 if (_parentID == 0 && PhysActor != null)
3558 {
3559 PhysActor.VehicleRotationParam(param, rotation);
3560 }
2852 } 3561 }
2853 3562
2854 /// <summary> 3563 /// <summary>
@@ -3032,14 +3741,6 @@ namespace OpenSim.Region.Framework.Scenes
3032 hasProfileCut = hasDimple; // is it the same thing? 3741 hasProfileCut = hasDimple; // is it the same thing?
3033 } 3742 }
3034 3743
3035 public void SetVehicleFlags(int param, bool remove)
3036 {
3037 PhysicsActor pa = PhysActor;
3038
3039 if (pa != null)
3040 pa.VehicleFlags(param, remove);
3041 }
3042
3043 public void SetGroup(UUID groupID, IClientAPI client) 3744 public void SetGroup(UUID groupID, IClientAPI client)
3044 { 3745 {
3045 // Scene.AddNewPrims() calls with client == null so can't use this. 3746 // Scene.AddNewPrims() calls with client == null so can't use this.
@@ -3143,68 +3844,18 @@ namespace OpenSim.Region.Framework.Scenes
3143 //ParentGroup.ScheduleGroupForFullUpdate(); 3844 //ParentGroup.ScheduleGroupForFullUpdate();
3144 } 3845 }
3145 3846
3146 public void StoreUndoState() 3847 public void StoreUndoState(ObjectChangeType change)
3147 { 3848 {
3148 StoreUndoState(false); 3849 if (m_UndoRedo == null)
3149 } 3850 m_UndoRedo = new UndoRedoState(5);
3150 3851
3151 public void StoreUndoState(bool forGroup) 3852 lock (m_UndoRedo)
3152 {
3153 if (!Undoing)
3154 { 3853 {
3155 if (!IgnoreUndoUpdate) 3854 if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended
3156 { 3855 {
3157 if (ParentGroup != null) 3856 m_UndoRedo.StoreUndo(this, change);
3158 {
3159 lock (m_undo)
3160 {
3161 if (m_undo.Count > 0)
3162 {
3163 UndoState last = m_undo.Peek();
3164 if (last != null)
3165 {
3166 // TODO: May need to fix for group comparison
3167 if (last.Compare(this))
3168 {
3169 // m_log.DebugFormat(
3170 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3171 // Name, LocalId, m_undo.Count);
3172
3173 return;
3174 }
3175 }
3176 }
3177
3178 // m_log.DebugFormat(
3179 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3180 // Name, LocalId, forGroup, m_undo.Count);
3181
3182 if (ParentGroup.GetSceneMaxUndo() > 0)
3183 {
3184 UndoState nUndo = new UndoState(this, forGroup);
3185
3186 m_undo.Push(nUndo);
3187
3188 if (m_redo.Count > 0)
3189 m_redo.Clear();
3190
3191 // m_log.DebugFormat(
3192 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3193 // Name, LocalId, forGroup, m_undo.Count);
3194 }
3195 }
3196 }
3197 } 3857 }
3198// else
3199// {
3200// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3201// }
3202 } 3858 }
3203// else
3204// {
3205// m_log.DebugFormat(
3206// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3207// }
3208 } 3859 }
3209 3860
3210 /// <summary> 3861 /// <summary>
@@ -3214,84 +3865,46 @@ namespace OpenSim.Region.Framework.Scenes
3214 { 3865 {
3215 get 3866 get
3216 { 3867 {
3217 lock (m_undo) 3868 if (m_UndoRedo == null)
3218 return m_undo.Count; 3869 return 0;
3870 return m_UndoRedo.Count;
3219 } 3871 }
3220 } 3872 }
3221 3873
3222 public void Undo() 3874 public void Undo()
3223 { 3875 {
3224 lock (m_undo) 3876 if (m_UndoRedo == null || Undoing || ParentGroup == null)
3225 { 3877 return;
3226// m_log.DebugFormat(
3227// "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
3228// Name, LocalId, m_undo.Count);
3229
3230 if (m_undo.Count > 0)
3231 {
3232 UndoState goback = m_undo.Pop();
3233
3234 if (goback != null)
3235 {
3236 UndoState nUndo = null;
3237
3238 if (ParentGroup.GetSceneMaxUndo() > 0)
3239 {
3240 nUndo = new UndoState(this, goback.ForGroup);
3241 }
3242
3243 goback.PlaybackState(this);
3244
3245 if (nUndo != null)
3246 m_redo.Push(nUndo);
3247 }
3248 }
3249 3878
3250// m_log.DebugFormat( 3879 lock (m_UndoRedo)
3251// "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", 3880 {
3252// Name, LocalId, m_undo.Count); 3881 Undoing = true;
3882 m_UndoRedo.Undo(this);
3883 Undoing = false;
3253 } 3884 }
3254 } 3885 }
3255 3886
3256 public void Redo() 3887 public void Redo()
3257 { 3888 {
3258 lock (m_undo) 3889 if (m_UndoRedo == null || Undoing || ParentGroup == null)
3259 { 3890 return;
3260// m_log.DebugFormat(
3261// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
3262// Name, LocalId, m_redo.Count);
3263
3264 if (m_redo.Count > 0)
3265 {
3266 UndoState gofwd = m_redo.Pop();
3267
3268 if (gofwd != null)
3269 {
3270 if (ParentGroup.GetSceneMaxUndo() > 0)
3271 {
3272 UndoState nUndo = new UndoState(this, gofwd.ForGroup);
3273
3274 m_undo.Push(nUndo);
3275 }
3276
3277 gofwd.PlayfwdState(this);
3278 }
3279 3891
3280// m_log.DebugFormat( 3892 lock (m_UndoRedo)
3281// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", 3893 {
3282// Name, LocalId, m_redo.Count); 3894 Undoing = true;
3283 } 3895 m_UndoRedo.Redo(this);
3896 Undoing = false;
3284 } 3897 }
3285 } 3898 }
3286 3899
3287 public void ClearUndoState() 3900 public void ClearUndoState()
3288 { 3901 {
3289// m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); 3902 if (m_UndoRedo == null || Undoing)
3903 return;
3290 3904
3291 lock (m_undo) 3905 lock (m_UndoRedo)
3292 { 3906 {
3293 m_undo.Clear(); 3907 m_UndoRedo.Clear();
3294 m_redo.Clear();
3295 } 3908 }
3296 } 3909 }
3297 3910
@@ -3921,6 +4534,27 @@ namespace OpenSim.Region.Framework.Scenes
3921 } 4534 }
3922 } 4535 }
3923 4536
4537
4538 public void UpdateExtraPhysics(ExtraPhysicsData physdata)
4539 {
4540 if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null)
4541 return;
4542
4543 if (PhysicsShapeType != (byte)physdata.PhysShapeType)
4544 {
4545 PhysicsShapeType = (byte)physdata.PhysShapeType;
4546
4547 }
4548
4549 if(Density != physdata.Density)
4550 Density = physdata.Density;
4551 if(GravityModifier != physdata.GravitationModifier)
4552 GravityModifier = physdata.GravitationModifier;
4553 if(Friction != physdata.Friction)
4554 Friction = physdata.Friction;
4555 if(Bounciness != physdata.Bounce)
4556 Bounciness = physdata.Bounce;
4557 }
3924 /// <summary> 4558 /// <summary>
3925 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. 4559 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
3926 /// </summary> 4560 /// </summary>
@@ -3928,7 +4562,7 @@ namespace OpenSim.Region.Framework.Scenes
3928 /// <param name="SetTemporary"></param> 4562 /// <param name="SetTemporary"></param>
3929 /// <param name="SetPhantom"></param> 4563 /// <param name="SetPhantom"></param>
3930 /// <param name="SetVD"></param> 4564 /// <param name="SetVD"></param>
3931 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) 4565 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building)
3932 { 4566 {
3933 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); 4567 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0);
3934 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); 4568 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0);
@@ -3938,237 +4572,230 @@ namespace OpenSim.Region.Framework.Scenes
3938 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4572 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
3939 return; 4573 return;
3940 4574
3941 PhysicsActor pa = PhysActor; 4575 VolumeDetectActive = SetVD;
3942
3943 // Special cases for VD. VD can only be called from a script
3944 // and can't be combined with changes to other states. So we can rely
3945 // that...
3946 // ... if VD is changed, all others are not.
3947 // ... if one of the others is changed, VD is not.
3948 if (SetVD) // VD is active, special logic applies
3949 {
3950 // State machine logic for VolumeDetect
3951 // More logic below
3952 bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom;
3953
3954 if (phanReset) // Phantom changes from on to off switch VD off too
3955 {
3956 SetVD = false; // Switch it of for the course of this routine
3957 VolumeDetectActive = false; // and also permanently
3958
3959 if (pa != null)
3960 pa.SetVolumeDetect(0); // Let physics know about it too
3961 }
3962 else
3963 {
3964 // If volumedetect is active we don't want phantom to be applied.
3965 // If this is a new call to VD out of the state "phantom"
3966 // this will also cause the prim to be visible to physics
3967 SetPhantom = false;
3968 }
3969 }
3970 4576
3971 if (UsePhysics && IsJoint()) 4577 // volume detector implies phantom
3972 { 4578 if (VolumeDetectActive)
3973 SetPhantom = true; 4579 SetPhantom = true;
3974 }
3975 4580
3976 if (UsePhysics) 4581 if (UsePhysics)
3977 {
3978 AddFlag(PrimFlags.Physics); 4582 AddFlag(PrimFlags.Physics);
3979 if (!wasUsingPhysics)
3980 {
3981 DoPhysicsPropertyUpdate(UsePhysics, false);
3982
3983 if (!ParentGroup.IsDeleted)
3984 {
3985 if (LocalId == ParentGroup.RootPart.LocalId)
3986 {
3987 ParentGroup.CheckSculptAndLoad();
3988 }
3989 }
3990 }
3991 }
3992 else 4583 else
3993 {
3994 RemFlag(PrimFlags.Physics); 4584 RemFlag(PrimFlags.Physics);
3995 if (wasUsingPhysics)
3996 {
3997 DoPhysicsPropertyUpdate(UsePhysics, false);
3998 }
3999 }
4000 4585
4001 if (SetPhantom 4586 if (SetPhantom)
4002 || ParentGroup.IsAttachment
4003 || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints
4004 {
4005 AddFlag(PrimFlags.Phantom); 4587 AddFlag(PrimFlags.Phantom);
4588 else
4589 RemFlag(PrimFlags.Phantom);
4006 4590
4007 if (PhysActor != null) 4591 if (SetTemporary)
4592 AddFlag(PrimFlags.TemporaryOnRez);
4593 else
4594 RemFlag(PrimFlags.TemporaryOnRez);
4595
4596
4597 if (ParentGroup.Scene == null)
4598 return;
4599
4600 PhysicsActor pa = PhysActor;
4601
4602 if (pa != null && building && pa.Building != building)
4603 pa.Building = building;
4604
4605 if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none
4606 || (Shape.PathCurve == (byte)Extrusion.Flexible))
4607 {
4608 if (pa != null)
4008 { 4609 {
4610 if(wasUsingPhysics)
4611 ParentGroup.Scene.RemovePhysicalPrim(1);
4009 RemoveFromPhysics(); 4612 RemoveFromPhysics();
4010 pa = null;
4011 } 4613 }
4614
4615 Velocity = new Vector3(0, 0, 0);
4616 Acceleration = new Vector3(0, 0, 0);
4617 if (ParentGroup.RootPart == this)
4618 AngularVelocity = new Vector3(0, 0, 0);
4012 } 4619 }
4013 else // Not phantom 4620 else
4014 { 4621 {
4015 RemFlag(PrimFlags.Phantom); 4622 if (ParentGroup.Scene.CollidablePrims)
4016
4017 if (ParentGroup.Scene == null)
4018 return;
4019
4020 if (ParentGroup.Scene.CollidablePrims && pa == null)
4021 { 4623 {
4022 pa = AddToPhysics(UsePhysics); 4624 if (pa == null)
4023
4024 if (pa != null)
4025 { 4625 {
4026 pa.SetMaterial(Material); 4626 AddToPhysics(UsePhysics, SetPhantom, building, false);
4027 DoPhysicsPropertyUpdate(UsePhysics, true); 4627 pa = PhysActor;
4028 4628/*
4029 if (!ParentGroup.IsDeleted) 4629 if (pa != null)
4030 { 4630 {
4031 if (LocalId == ParentGroup.RootPart.LocalId) 4631 if (
4632// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4633// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4634// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4635// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4636// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4637// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4638 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4639 ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4640 (CollisionSound != UUID.Zero)
4641 )
4032 { 4642 {
4033 ParentGroup.CheckSculptAndLoad(); 4643 pa.OnCollisionUpdate += PhysicsCollision;
4644 pa.SubscribeEvents(1000);
4034 } 4645 }
4035 } 4646 }
4036 4647*/
4037 if (
4038 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4039 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4040 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4041 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4042 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4043 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4044 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) ||
4045 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4046 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4047 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4048 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4049 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4050 (CollisionSound != UUID.Zero)
4051 )
4052 {
4053 pa.OnCollisionUpdate += PhysicsCollision;
4054 pa.SubscribeEvents(1000);
4055 }
4056 } 4648 }
4057 } 4649 else // it already has a physical representation
4058 else // it already has a physical representation
4059 {
4060 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim
4061
4062 if (!ParentGroup.IsDeleted)
4063 { 4650 {
4064 if (LocalId == ParentGroup.RootPart.LocalId) 4651 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
4065 { 4652/* moved into DoPhysicsPropertyUpdate
4066 ParentGroup.CheckSculptAndLoad(); 4653 if(VolumeDetectActive)
4067 } 4654 pa.SetVolumeDetect(1);
4655 else
4656 pa.SetVolumeDetect(0);
4657*/
4658
4659 if (pa.Building != building)
4660 pa.Building = building;
4068 } 4661 }
4069 }
4070 }
4071 4662
4072 if (SetVD) 4663 UpdatePhysicsSubscribedEvents();
4073 {
4074 // If the above logic worked (this is urgent candidate to unit tests!)
4075 // we now have a physicsactor.
4076 // Defensive programming calls for a check here.
4077 // Better would be throwing an exception that could be catched by a unit test as the internal
4078 // logic should make sure, this Physactor is always here.
4079 if (pa != null)
4080 {
4081 pa.SetVolumeDetect(1);
4082 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
4083 VolumeDetectActive = true;
4084 } 4664 }
4085 } 4665 }
4086 else
4087 {
4088 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4089 // (mumbles, well, at least if you have infinte CPU powers :-))
4090 if (pa != null)
4091 pa.SetVolumeDetect(0);
4092
4093 VolumeDetectActive = false;
4094 }
4095
4096 if (SetTemporary)
4097 {
4098 AddFlag(PrimFlags.TemporaryOnRez);
4099 }
4100 else
4101 {
4102 RemFlag(PrimFlags.TemporaryOnRez);
4103 }
4104 4666
4105 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 4667 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
4106 4668
4669 // and last in case we have a new actor and not building
4670
4107 if (ParentGroup != null) 4671 if (ParentGroup != null)
4108 { 4672 {
4109 ParentGroup.HasGroupChanged = true; 4673 ParentGroup.HasGroupChanged = true;
4110 ScheduleFullUpdate(); 4674 ScheduleFullUpdate();
4111 } 4675 }
4112 4676
4113// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); 4677// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags);
4114 } 4678 }
4115 4679
4116 /// <summary> 4680 /// <summary>
4117 /// Adds this part to the physics scene. 4681 /// Adds this part to the physics scene.
4682 /// and sets the PhysActor property
4118 /// </summary> 4683 /// </summary>
4119 /// <remarks>This method also sets the PhysActor property.</remarks> 4684 /// <param name="isPhysical">Add this prim as physical.</param>
4120 /// <param name="rigidBody">Add this prim with a rigid body.</param> 4685 /// <param name="isPhantom">Add this prim as phantom.</param>
4121 /// <returns> 4686 /// <param name="building">tells physics to delay full construction of object</param>
4122 /// The physics actor. null if there was a failure. 4687 /// <param name="applyDynamics">applies velocities, force and torque</param>
4123 /// </returns> 4688 private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics)
4124 private PhysicsActor AddToPhysics(bool rigidBody) 4689 {
4125 {
4126 PhysicsActor pa; 4690 PhysicsActor pa;
4127 4691
4692 Vector3 velocity = Velocity;
4693 Vector3 rotationalVelocity = AngularVelocity;;
4694
4128 try 4695 try
4129 { 4696 {
4130 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( 4697 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape(
4131 string.Format("{0}/{1}", Name, UUID), 4698 string.Format("{0}/{1}", Name, UUID),
4132 Shape, 4699 Shape,
4133 AbsolutePosition, 4700 AbsolutePosition,
4134 Scale, 4701 Scale,
4135 RotationOffset, 4702 GetWorldRotation(),
4136 rigidBody, 4703 isPhysical,
4137 m_localId); 4704 isPhantom,
4705 PhysicsShapeType,
4706 m_localId);
4138 } 4707 }
4139 catch 4708 catch (Exception ex)
4140 { 4709 {
4141 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); 4710 m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message);
4142 pa = null; 4711 pa = null;
4143 } 4712 }
4144 4713
4145 // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical
4146 // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor
4147 // being set.
4148 PhysActor = pa;
4149
4150 // Basic Physics can also return null as well as an exception catch.
4151 if (pa != null) 4714 if (pa != null)
4152 { 4715 {
4153 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 4716 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
4154 pa.SetMaterial(Material); 4717 pa.SetMaterial(Material);
4155 DoPhysicsPropertyUpdate(rigidBody, true); 4718
4719 if (VolumeDetectActive) // change if not the default only
4720 pa.SetVolumeDetect(1);
4721
4722 if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId)
4723 m_vehicleParams.SetVehicle(pa);
4724
4725 // we are going to tell rest of code about physics so better have this here
4726 PhysActor = pa;
4727
4728 // DoPhysicsPropertyUpdate(isPhysical, true);
4729 // lets expand it here just with what it really needs to do
4730
4731 if (isPhysical)
4732 {
4733 if (ParentGroup.RootPart.KeyframeMotion != null)
4734 ParentGroup.RootPart.KeyframeMotion.Stop();
4735 ParentGroup.RootPart.KeyframeMotion = null;
4736 ParentGroup.Scene.AddPhysicalPrim(1);
4737
4738 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
4739 pa.OnOutOfBounds += PhysicsOutOfBounds;
4740
4741 if (ParentID != 0 && ParentID != LocalId)
4742 {
4743 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
4744
4745 if (parentPa != null)
4746 {
4747 pa.link(parentPa);
4748 }
4749 }
4750 }
4751
4752 if (applyDynamics)
4753 // do independent of isphysical so parameters get setted (at least some)
4754 {
4755 Velocity = velocity;
4756 AngularVelocity = rotationalVelocity;
4757// pa.Velocity = velocity;
4758 pa.RotationalVelocity = rotationalVelocity;
4759
4760 // if not vehicle and root part apply force and torque
4761 if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE)
4762 && LocalId == ParentGroup.RootPart.LocalId)
4763 {
4764 pa.Force = Force;
4765 pa.Torque = Torque;
4766 }
4767 }
4768
4769 if (Shape.SculptEntry)
4770 CheckSculptAndLoad();
4771 else
4772 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
4773
4774 if (!building)
4775 pa.Building = false;
4156 } 4776 }
4157 4777
4158 return pa; 4778 PhysActor = pa;
4159 } 4779 }
4160 4780
4161 /// <summary> 4781 /// <summary>
4162 /// This removes the part from the physics scene. 4782 /// This removes the part from the physics scene.
4163 /// </summary> 4783 /// </summary>
4164 /// <remarks> 4784 /// <remarks>
4165 /// This isn't the same as turning off physical, since even without being physical the prim has a physics 4785 /// This isn't the same as turning off physical, since even without being physical the prim has a physics
4166 /// representation for collision detection. Rather, this would be used in situations such as making a prim 4786 /// representation for collision detection.
4167 /// phantom.
4168 /// </remarks> 4787 /// </remarks>
4169 public void RemoveFromPhysics() 4788 public void RemoveFromPhysics()
4170 { 4789 {
4171 ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); 4790 PhysicsActor pa = PhysActor;
4791 if (pa != null)
4792 {
4793 pa.OnCollisionUpdate -= PhysicsCollision;
4794 pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
4795 pa.OnOutOfBounds -= PhysicsOutOfBounds;
4796
4797 ParentGroup.Scene.PhysicsScene.RemovePrim(pa);
4798 }
4172 PhysActor = null; 4799 PhysActor = null;
4173 } 4800 }
4174 4801
@@ -4328,6 +4955,44 @@ namespace OpenSim.Region.Framework.Scenes
4328 ScheduleFullUpdate(); 4955 ScheduleFullUpdate();
4329 } 4956 }
4330 4957
4958
4959 private void UpdatePhysicsSubscribedEvents()
4960 {
4961 PhysicsActor pa = PhysActor;
4962 if (pa == null)
4963 return;
4964
4965 pa.OnCollisionUpdate -= PhysicsCollision;
4966
4967 bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0));
4968
4969 scriptEvents CombinedEvents = AggregateScriptEvents;
4970
4971 // merge with root part
4972 if (ParentGroup != null && ParentGroup.RootPart != null)
4973 CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents;
4974
4975 // submit to this part case
4976 if (VolumeDetectActive)
4977 CombinedEvents &= PhyscicsVolumeDtcSubsEvents;
4978 else if ((Flags & PrimFlags.Phantom) != 0)
4979 CombinedEvents &= PhyscicsPhantonSubsEvents;
4980 else
4981 CombinedEvents &= PhysicsNeededSubsEvents;
4982
4983 if (hassound || CombinedEvents != 0)
4984 {
4985 // subscribe to physics updates.
4986 pa.OnCollisionUpdate += PhysicsCollision;
4987 pa.SubscribeEvents(50); // 20 reports per second
4988 }
4989 else
4990 {
4991 pa.UnSubscribeEvents();
4992 }
4993 }
4994
4995
4331 public void aggregateScriptEvents() 4996 public void aggregateScriptEvents()
4332 { 4997 {
4333 if (ParentGroup == null || ParentGroup.RootPart == null) 4998 if (ParentGroup == null || ParentGroup.RootPart == null)
@@ -4364,40 +5029,32 @@ namespace OpenSim.Region.Framework.Scenes
4364 { 5029 {
4365 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; 5030 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
4366 } 5031 }
4367 5032/*
4368 PhysicsActor pa = PhysActor; 5033 PhysicsActor pa = PhysActor;
4369 5034 if (pa != null)
4370 if (
4371 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4372 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4373 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4374 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4375 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4376 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4377 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) ||
4378 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4379 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4380 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4381 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4382 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4383 (CollisionSound != UUID.Zero)
4384 )
4385 { 5035 {
4386 // subscribe to physics updates. 5036 if (
4387 if (pa != null) 5037// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
5038// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
5039// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
5040// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
5041// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
5042// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
5043 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
5044 )
4388 { 5045 {
5046 // subscribe to physics updates.
4389 pa.OnCollisionUpdate += PhysicsCollision; 5047 pa.OnCollisionUpdate += PhysicsCollision;
4390 pa.SubscribeEvents(1000); 5048 pa.SubscribeEvents(1000);
4391 } 5049 }
4392 } 5050 else
4393 else
4394 {
4395 if (pa != null)
4396 { 5051 {
4397 pa.UnSubscribeEvents(); 5052 pa.UnSubscribeEvents();
4398 pa.OnCollisionUpdate -= PhysicsCollision; 5053 pa.OnCollisionUpdate -= PhysicsCollision;
4399 } 5054 }
4400 } 5055 }
5056 */
5057 UpdatePhysicsSubscribedEvents();
4401 5058
4402 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) 5059 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
4403 //{ 5060 //{
@@ -4527,6 +5184,18 @@ namespace OpenSim.Region.Framework.Scenes
4527 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 5184 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4528 } 5185 }
4529 5186
5187 public void ResetOwnerChangeFlag()
5188 {
5189 List<UUID> inv = Inventory.GetInventoryList();
5190
5191 foreach (UUID itemID in inv)
5192 {
5193 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
5194 item.OwnerChanged = false;
5195 Inventory.UpdateInventoryItem(item, false, false);
5196 }
5197 }
5198
4530 /// <summary> 5199 /// <summary>
4531 /// Record an avatar sitting on this part. 5200 /// Record an avatar sitting on this part.
4532 /// </summary> 5201 /// </summary>