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 411dcc7..4ed3413 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>
@@ -3048,14 +3757,6 @@ namespace OpenSim.Region.Framework.Scenes
3048 hasProfileCut = hasDimple; // is it the same thing? 3757 hasProfileCut = hasDimple; // is it the same thing?
3049 } 3758 }
3050 3759
3051 public void SetVehicleFlags(int param, bool remove)
3052 {
3053 PhysicsActor pa = PhysActor;
3054
3055 if (pa != null)
3056 pa.VehicleFlags(param, remove);
3057 }
3058
3059 public void SetGroup(UUID groupID, IClientAPI client) 3760 public void SetGroup(UUID groupID, IClientAPI client)
3060 { 3761 {
3061 // Scene.AddNewPrims() calls with client == null so can't use this. 3762 // Scene.AddNewPrims() calls with client == null so can't use this.
@@ -3159,68 +3860,18 @@ namespace OpenSim.Region.Framework.Scenes
3159 //ParentGroup.ScheduleGroupForFullUpdate(); 3860 //ParentGroup.ScheduleGroupForFullUpdate();
3160 } 3861 }
3161 3862
3162 public void StoreUndoState() 3863 public void StoreUndoState(ObjectChangeType change)
3163 { 3864 {
3164 StoreUndoState(false); 3865 if (m_UndoRedo == null)
3165 } 3866 m_UndoRedo = new UndoRedoState(5);
3166 3867
3167 public void StoreUndoState(bool forGroup) 3868 lock (m_UndoRedo)
3168 {
3169 if (!Undoing)
3170 { 3869 {
3171 if (!IgnoreUndoUpdate) 3870 if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended
3172 { 3871 {
3173 if (ParentGroup != null) 3872 m_UndoRedo.StoreUndo(this, change);
3174 {
3175 lock (m_undo)
3176 {
3177 if (m_undo.Count > 0)
3178 {
3179 UndoState last = m_undo.Peek();
3180 if (last != null)
3181 {
3182 // TODO: May need to fix for group comparison
3183 if (last.Compare(this))
3184 {
3185 // m_log.DebugFormat(
3186 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3187 // Name, LocalId, m_undo.Count);
3188
3189 return;
3190 }
3191 }
3192 }
3193
3194 // m_log.DebugFormat(
3195 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3196 // Name, LocalId, forGroup, m_undo.Count);
3197
3198 if (ParentGroup.GetSceneMaxUndo() > 0)
3199 {
3200 UndoState nUndo = new UndoState(this, forGroup);
3201
3202 m_undo.Push(nUndo);
3203
3204 if (m_redo.Count > 0)
3205 m_redo.Clear();
3206
3207 // m_log.DebugFormat(
3208 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3209 // Name, LocalId, forGroup, m_undo.Count);
3210 }
3211 }
3212 }
3213 } 3873 }
3214// else
3215// {
3216// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3217// }
3218 } 3874 }
3219// else
3220// {
3221// m_log.DebugFormat(
3222// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3223// }
3224 } 3875 }
3225 3876
3226 /// <summary> 3877 /// <summary>
@@ -3230,84 +3881,46 @@ namespace OpenSim.Region.Framework.Scenes
3230 { 3881 {
3231 get 3882 get
3232 { 3883 {
3233 lock (m_undo) 3884 if (m_UndoRedo == null)
3234 return m_undo.Count; 3885 return 0;
3886 return m_UndoRedo.Count;
3235 } 3887 }
3236 } 3888 }
3237 3889
3238 public void Undo() 3890 public void Undo()
3239 { 3891 {
3240 lock (m_undo) 3892 if (m_UndoRedo == null || Undoing || ParentGroup == null)
3241 { 3893 return;
3242// m_log.DebugFormat(
3243// "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
3244// Name, LocalId, m_undo.Count);
3245
3246 if (m_undo.Count > 0)
3247 {
3248 UndoState goback = m_undo.Pop();
3249
3250 if (goback != null)
3251 {
3252 UndoState nUndo = null;
3253
3254 if (ParentGroup.GetSceneMaxUndo() > 0)
3255 {
3256 nUndo = new UndoState(this, goback.ForGroup);
3257 }
3258
3259 goback.PlaybackState(this);
3260
3261 if (nUndo != null)
3262 m_redo.Push(nUndo);
3263 }
3264 }
3265 3894
3266// m_log.DebugFormat( 3895 lock (m_UndoRedo)
3267// "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", 3896 {
3268// Name, LocalId, m_undo.Count); 3897 Undoing = true;
3898 m_UndoRedo.Undo(this);
3899 Undoing = false;
3269 } 3900 }
3270 } 3901 }
3271 3902
3272 public void Redo() 3903 public void Redo()
3273 { 3904 {
3274 lock (m_undo) 3905 if (m_UndoRedo == null || Undoing || ParentGroup == null)
3275 { 3906 return;
3276// m_log.DebugFormat(
3277// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
3278// Name, LocalId, m_redo.Count);
3279
3280 if (m_redo.Count > 0)
3281 {
3282 UndoState gofwd = m_redo.Pop();
3283
3284 if (gofwd != null)
3285 {
3286 if (ParentGroup.GetSceneMaxUndo() > 0)
3287 {
3288 UndoState nUndo = new UndoState(this, gofwd.ForGroup);
3289
3290 m_undo.Push(nUndo);
3291 }
3292
3293 gofwd.PlayfwdState(this);
3294 }
3295 3907
3296// m_log.DebugFormat( 3908 lock (m_UndoRedo)
3297// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", 3909 {
3298// Name, LocalId, m_redo.Count); 3910 Undoing = true;
3299 } 3911 m_UndoRedo.Redo(this);
3912 Undoing = false;
3300 } 3913 }
3301 } 3914 }
3302 3915
3303 public void ClearUndoState() 3916 public void ClearUndoState()
3304 { 3917 {
3305// m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); 3918 if (m_UndoRedo == null || Undoing)
3919 return;
3306 3920
3307 lock (m_undo) 3921 lock (m_UndoRedo)
3308 { 3922 {
3309 m_undo.Clear(); 3923 m_UndoRedo.Clear();
3310 m_redo.Clear();
3311 } 3924 }
3312 } 3925 }
3313 3926
@@ -3958,6 +4571,27 @@ namespace OpenSim.Region.Framework.Scenes
3958 } 4571 }
3959 } 4572 }
3960 4573
4574
4575 public void UpdateExtraPhysics(ExtraPhysicsData physdata)
4576 {
4577 if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null)
4578 return;
4579
4580 if (PhysicsShapeType != (byte)physdata.PhysShapeType)
4581 {
4582 PhysicsShapeType = (byte)physdata.PhysShapeType;
4583
4584 }
4585
4586 if(Density != physdata.Density)
4587 Density = physdata.Density;
4588 if(GravityModifier != physdata.GravitationModifier)
4589 GravityModifier = physdata.GravitationModifier;
4590 if(Friction != physdata.Friction)
4591 Friction = physdata.Friction;
4592 if(Bounciness != physdata.Bounce)
4593 Bounciness = physdata.Bounce;
4594 }
3961 /// <summary> 4595 /// <summary>
3962 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. 4596 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
3963 /// </summary> 4597 /// </summary>
@@ -3965,7 +4599,7 @@ namespace OpenSim.Region.Framework.Scenes
3965 /// <param name="SetTemporary"></param> 4599 /// <param name="SetTemporary"></param>
3966 /// <param name="SetPhantom"></param> 4600 /// <param name="SetPhantom"></param>
3967 /// <param name="SetVD"></param> 4601 /// <param name="SetVD"></param>
3968 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) 4602 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building)
3969 { 4603 {
3970 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); 4604 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0);
3971 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); 4605 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0);
@@ -3975,237 +4609,230 @@ namespace OpenSim.Region.Framework.Scenes
3975 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4609 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
3976 return; 4610 return;
3977 4611
3978 PhysicsActor pa = PhysActor; 4612 VolumeDetectActive = SetVD;
3979
3980 // Special cases for VD. VD can only be called from a script
3981 // and can't be combined with changes to other states. So we can rely
3982 // that...
3983 // ... if VD is changed, all others are not.
3984 // ... if one of the others is changed, VD is not.
3985 if (SetVD) // VD is active, special logic applies
3986 {
3987 // State machine logic for VolumeDetect
3988 // More logic below
3989 bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom;
3990
3991 if (phanReset) // Phantom changes from on to off switch VD off too
3992 {
3993 SetVD = false; // Switch it of for the course of this routine
3994 VolumeDetectActive = false; // and also permanently
3995
3996 if (pa != null)
3997 pa.SetVolumeDetect(0); // Let physics know about it too
3998 }
3999 else
4000 {
4001 // If volumedetect is active we don't want phantom to be applied.
4002 // If this is a new call to VD out of the state "phantom"
4003 // this will also cause the prim to be visible to physics
4004 SetPhantom = false;
4005 }
4006 }
4007 4613
4008 if (UsePhysics && IsJoint()) 4614 // volume detector implies phantom
4009 { 4615 if (VolumeDetectActive)
4010 SetPhantom = true; 4616 SetPhantom = true;
4011 }
4012 4617
4013 if (UsePhysics) 4618 if (UsePhysics)
4014 {
4015 AddFlag(PrimFlags.Physics); 4619 AddFlag(PrimFlags.Physics);
4016 if (!wasUsingPhysics)
4017 {
4018 DoPhysicsPropertyUpdate(UsePhysics, false);
4019
4020 if (!ParentGroup.IsDeleted)
4021 {
4022 if (LocalId == ParentGroup.RootPart.LocalId)
4023 {
4024 ParentGroup.CheckSculptAndLoad();
4025 }
4026 }
4027 }
4028 }
4029 else 4620 else
4030 {
4031 RemFlag(PrimFlags.Physics); 4621 RemFlag(PrimFlags.Physics);
4032 if (wasUsingPhysics)
4033 {
4034 DoPhysicsPropertyUpdate(UsePhysics, false);
4035 }
4036 }
4037 4622
4038 if (SetPhantom 4623 if (SetPhantom)
4039 || ParentGroup.IsAttachment
4040 || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints
4041 {
4042 AddFlag(PrimFlags.Phantom); 4624 AddFlag(PrimFlags.Phantom);
4625 else
4626 RemFlag(PrimFlags.Phantom);
4043 4627
4044 if (PhysActor != null) 4628 if (SetTemporary)
4629 AddFlag(PrimFlags.TemporaryOnRez);
4630 else
4631 RemFlag(PrimFlags.TemporaryOnRez);
4632
4633
4634 if (ParentGroup.Scene == null)
4635 return;
4636
4637 PhysicsActor pa = PhysActor;
4638
4639 if (pa != null && building && pa.Building != building)
4640 pa.Building = building;
4641
4642 if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none
4643 || (Shape.PathCurve == (byte)Extrusion.Flexible))
4644 {
4645 if (pa != null)
4045 { 4646 {
4647 if(wasUsingPhysics)
4648 ParentGroup.Scene.RemovePhysicalPrim(1);
4046 RemoveFromPhysics(); 4649 RemoveFromPhysics();
4047 pa = null;
4048 } 4650 }
4651
4652 Velocity = new Vector3(0, 0, 0);
4653 Acceleration = new Vector3(0, 0, 0);
4654 if (ParentGroup.RootPart == this)
4655 AngularVelocity = new Vector3(0, 0, 0);
4049 } 4656 }
4050 else // Not phantom 4657 else
4051 { 4658 {
4052 RemFlag(PrimFlags.Phantom); 4659 if (ParentGroup.Scene.CollidablePrims)
4053
4054 if (ParentGroup.Scene == null)
4055 return;
4056
4057 if (ParentGroup.Scene.CollidablePrims && pa == null)
4058 { 4660 {
4059 pa = AddToPhysics(UsePhysics); 4661 if (pa == null)
4060
4061 if (pa != null)
4062 { 4662 {
4063 pa.SetMaterial(Material); 4663 AddToPhysics(UsePhysics, SetPhantom, building, false);
4064 DoPhysicsPropertyUpdate(UsePhysics, true); 4664 pa = PhysActor;
4065 4665/*
4066 if (!ParentGroup.IsDeleted) 4666 if (pa != null)
4067 { 4667 {
4068 if (LocalId == ParentGroup.RootPart.LocalId) 4668 if (
4669// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4670// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4671// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4672// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4673// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4674// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4675 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4676 ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4677 (CollisionSound != UUID.Zero)
4678 )
4069 { 4679 {
4070 ParentGroup.CheckSculptAndLoad(); 4680 pa.OnCollisionUpdate += PhysicsCollision;
4681 pa.SubscribeEvents(1000);
4071 } 4682 }
4072 } 4683 }
4073 4684*/
4074 if (
4075 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4076 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4077 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4078 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4079 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4080 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4081 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) ||
4082 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4083 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4084 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4085 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4086 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4087 (CollisionSound != UUID.Zero)
4088 )
4089 {
4090 pa.OnCollisionUpdate += PhysicsCollision;
4091 pa.SubscribeEvents(1000);
4092 }
4093 } 4685 }
4094 } 4686 else // it already has a physical representation
4095 else // it already has a physical representation
4096 {
4097 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim
4098
4099 if (!ParentGroup.IsDeleted)
4100 { 4687 {
4101 if (LocalId == ParentGroup.RootPart.LocalId) 4688 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
4102 { 4689/* moved into DoPhysicsPropertyUpdate
4103 ParentGroup.CheckSculptAndLoad(); 4690 if(VolumeDetectActive)
4104 } 4691 pa.SetVolumeDetect(1);
4692 else
4693 pa.SetVolumeDetect(0);
4694*/
4695
4696 if (pa.Building != building)
4697 pa.Building = building;
4105 } 4698 }
4106 }
4107 }
4108 4699
4109 if (SetVD) 4700 UpdatePhysicsSubscribedEvents();
4110 {
4111 // If the above logic worked (this is urgent candidate to unit tests!)
4112 // we now have a physicsactor.
4113 // Defensive programming calls for a check here.
4114 // Better would be throwing an exception that could be catched by a unit test as the internal
4115 // logic should make sure, this Physactor is always here.
4116 if (pa != null)
4117 {
4118 pa.SetVolumeDetect(1);
4119 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
4120 VolumeDetectActive = true;
4121 } 4701 }
4122 } 4702 }
4123 else
4124 {
4125 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4126 // (mumbles, well, at least if you have infinte CPU powers :-))
4127 if (pa != null)
4128 pa.SetVolumeDetect(0);
4129
4130 VolumeDetectActive = false;
4131 }
4132
4133 if (SetTemporary)
4134 {
4135 AddFlag(PrimFlags.TemporaryOnRez);
4136 }
4137 else
4138 {
4139 RemFlag(PrimFlags.TemporaryOnRez);
4140 }
4141 4703
4142 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 4704 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
4143 4705
4706 // and last in case we have a new actor and not building
4707
4144 if (ParentGroup != null) 4708 if (ParentGroup != null)
4145 { 4709 {
4146 ParentGroup.HasGroupChanged = true; 4710 ParentGroup.HasGroupChanged = true;
4147 ScheduleFullUpdate(); 4711 ScheduleFullUpdate();
4148 } 4712 }
4149 4713
4150// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); 4714// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags);
4151 } 4715 }
4152 4716
4153 /// <summary> 4717 /// <summary>
4154 /// Adds this part to the physics scene. 4718 /// Adds this part to the physics scene.
4719 /// and sets the PhysActor property
4155 /// </summary> 4720 /// </summary>
4156 /// <remarks>This method also sets the PhysActor property.</remarks> 4721 /// <param name="isPhysical">Add this prim as physical.</param>
4157 /// <param name="rigidBody">Add this prim with a rigid body.</param> 4722 /// <param name="isPhantom">Add this prim as phantom.</param>
4158 /// <returns> 4723 /// <param name="building">tells physics to delay full construction of object</param>
4159 /// The physics actor. null if there was a failure. 4724 /// <param name="applyDynamics">applies velocities, force and torque</param>
4160 /// </returns> 4725 private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics)
4161 private PhysicsActor AddToPhysics(bool rigidBody) 4726 {
4162 {
4163 PhysicsActor pa; 4727 PhysicsActor pa;
4164 4728
4729 Vector3 velocity = Velocity;
4730 Vector3 rotationalVelocity = AngularVelocity;;
4731
4165 try 4732 try
4166 { 4733 {
4167 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( 4734 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape(
4168 string.Format("{0}/{1}", Name, UUID), 4735 string.Format("{0}/{1}", Name, UUID),
4169 Shape, 4736 Shape,
4170 AbsolutePosition, 4737 AbsolutePosition,
4171 Scale, 4738 Scale,
4172 RotationOffset, 4739 GetWorldRotation(),
4173 rigidBody, 4740 isPhysical,
4174 m_localId); 4741 isPhantom,
4742 PhysicsShapeType,
4743 m_localId);
4175 } 4744 }
4176 catch 4745 catch (Exception ex)
4177 { 4746 {
4178 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); 4747 m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message);
4179 pa = null; 4748 pa = null;
4180 } 4749 }
4181 4750
4182 // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical
4183 // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor
4184 // being set.
4185 PhysActor = pa;
4186
4187 // Basic Physics can also return null as well as an exception catch.
4188 if (pa != null) 4751 if (pa != null)
4189 { 4752 {
4190 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 4753 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
4191 pa.SetMaterial(Material); 4754 pa.SetMaterial(Material);
4192 DoPhysicsPropertyUpdate(rigidBody, true); 4755
4756 if (VolumeDetectActive) // change if not the default only
4757 pa.SetVolumeDetect(1);
4758
4759 if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId)
4760 m_vehicleParams.SetVehicle(pa);
4761
4762 // we are going to tell rest of code about physics so better have this here
4763 PhysActor = pa;
4764
4765 // DoPhysicsPropertyUpdate(isPhysical, true);
4766 // lets expand it here just with what it really needs to do
4767
4768 if (isPhysical)
4769 {
4770 if (ParentGroup.RootPart.KeyframeMotion != null)
4771 ParentGroup.RootPart.KeyframeMotion.Stop();
4772 ParentGroup.RootPart.KeyframeMotion = null;
4773 ParentGroup.Scene.AddPhysicalPrim(1);
4774
4775 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
4776 pa.OnOutOfBounds += PhysicsOutOfBounds;
4777
4778 if (ParentID != 0 && ParentID != LocalId)
4779 {
4780 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
4781
4782 if (parentPa != null)
4783 {
4784 pa.link(parentPa);
4785 }
4786 }
4787 }
4788
4789 if (applyDynamics)
4790 // do independent of isphysical so parameters get setted (at least some)
4791 {
4792 Velocity = velocity;
4793 AngularVelocity = rotationalVelocity;
4794// pa.Velocity = velocity;
4795 pa.RotationalVelocity = rotationalVelocity;
4796
4797 // if not vehicle and root part apply force and torque
4798 if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE)
4799 && LocalId == ParentGroup.RootPart.LocalId)
4800 {
4801 pa.Force = Force;
4802 pa.Torque = Torque;
4803 }
4804 }
4805
4806 if (Shape.SculptEntry)
4807 CheckSculptAndLoad();
4808 else
4809 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
4810
4811 if (!building)
4812 pa.Building = false;
4193 } 4813 }
4194 4814
4195 return pa; 4815 PhysActor = pa;
4196 } 4816 }
4197 4817
4198 /// <summary> 4818 /// <summary>
4199 /// This removes the part from the physics scene. 4819 /// This removes the part from the physics scene.
4200 /// </summary> 4820 /// </summary>
4201 /// <remarks> 4821 /// <remarks>
4202 /// This isn't the same as turning off physical, since even without being physical the prim has a physics 4822 /// This isn't the same as turning off physical, since even without being physical the prim has a physics
4203 /// representation for collision detection. Rather, this would be used in situations such as making a prim 4823 /// representation for collision detection.
4204 /// phantom.
4205 /// </remarks> 4824 /// </remarks>
4206 public void RemoveFromPhysics() 4825 public void RemoveFromPhysics()
4207 { 4826 {
4208 ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); 4827 PhysicsActor pa = PhysActor;
4828 if (pa != null)
4829 {
4830 pa.OnCollisionUpdate -= PhysicsCollision;
4831 pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
4832 pa.OnOutOfBounds -= PhysicsOutOfBounds;
4833
4834 ParentGroup.Scene.PhysicsScene.RemovePrim(pa);
4835 }
4209 PhysActor = null; 4836 PhysActor = null;
4210 } 4837 }
4211 4838
@@ -4416,6 +5043,44 @@ namespace OpenSim.Region.Framework.Scenes
4416 ScheduleFullUpdate(); 5043 ScheduleFullUpdate();
4417 } 5044 }
4418 5045
5046
5047 private void UpdatePhysicsSubscribedEvents()
5048 {
5049 PhysicsActor pa = PhysActor;
5050 if (pa == null)
5051 return;
5052
5053 pa.OnCollisionUpdate -= PhysicsCollision;
5054
5055 bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0));
5056
5057 scriptEvents CombinedEvents = AggregateScriptEvents;
5058
5059 // merge with root part
5060 if (ParentGroup != null && ParentGroup.RootPart != null)
5061 CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents;
5062
5063 // submit to this part case
5064 if (VolumeDetectActive)
5065 CombinedEvents &= PhyscicsVolumeDtcSubsEvents;
5066 else if ((Flags & PrimFlags.Phantom) != 0)
5067 CombinedEvents &= PhyscicsPhantonSubsEvents;
5068 else
5069 CombinedEvents &= PhysicsNeededSubsEvents;
5070
5071 if (hassound || CombinedEvents != 0)
5072 {
5073 // subscribe to physics updates.
5074 pa.OnCollisionUpdate += PhysicsCollision;
5075 pa.SubscribeEvents(50); // 20 reports per second
5076 }
5077 else
5078 {
5079 pa.UnSubscribeEvents();
5080 }
5081 }
5082
5083
4419 public void aggregateScriptEvents() 5084 public void aggregateScriptEvents()
4420 { 5085 {
4421 if (ParentGroup == null || ParentGroup.RootPart == null) 5086 if (ParentGroup == null || ParentGroup.RootPart == null)
@@ -4452,40 +5117,32 @@ namespace OpenSim.Region.Framework.Scenes
4452 { 5117 {
4453 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; 5118 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
4454 } 5119 }
4455 5120/*
4456 PhysicsActor pa = PhysActor; 5121 PhysicsActor pa = PhysActor;
4457 5122 if (pa != null)
4458 if (
4459 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4460 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4461 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4462 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4463 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4464 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4465 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) ||
4466 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4467 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4468 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4469 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4470 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4471 (CollisionSound != UUID.Zero)
4472 )
4473 { 5123 {
4474 // subscribe to physics updates. 5124 if (
4475 if (pa != null) 5125// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
5126// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
5127// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
5128// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
5129// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
5130// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
5131 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
5132 )
4476 { 5133 {
5134 // subscribe to physics updates.
4477 pa.OnCollisionUpdate += PhysicsCollision; 5135 pa.OnCollisionUpdate += PhysicsCollision;
4478 pa.SubscribeEvents(1000); 5136 pa.SubscribeEvents(1000);
4479 } 5137 }
4480 } 5138 else
4481 else
4482 {
4483 if (pa != null)
4484 { 5139 {
4485 pa.UnSubscribeEvents(); 5140 pa.UnSubscribeEvents();
4486 pa.OnCollisionUpdate -= PhysicsCollision; 5141 pa.OnCollisionUpdate -= PhysicsCollision;
4487 } 5142 }
4488 } 5143 }
5144 */
5145 UpdatePhysicsSubscribedEvents();
4489 5146
4490 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) 5147 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
4491 //{ 5148 //{
@@ -4615,6 +5272,18 @@ namespace OpenSim.Region.Framework.Scenes
4615 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 5272 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4616 } 5273 }
4617 5274
5275 public void ResetOwnerChangeFlag()
5276 {
5277 List<UUID> inv = Inventory.GetInventoryList();
5278
5279 foreach (UUID itemID in inv)
5280 {
5281 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
5282 item.OwnerChanged = false;
5283 Inventory.UpdateInventoryItem(item, false, false);
5284 }
5285 }
5286
4618 /// <summary> 5287 /// <summary>
4619 /// Record an avatar sitting on this part. 5288 /// Record an avatar sitting on this part.
4620 /// </summary> 5289 /// </summary>