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.cs439
1 files changed, 346 insertions, 93 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 65905a0..1c72b10 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.
@@ -184,6 +185,15 @@ namespace OpenSim.Region.Framework.Scenes
184 185
185 public UUID FromFolderID; 186 public UUID FromFolderID;
186 187
188 // The following two are to hold the attachment data
189 // while an object is inworld
190 [XmlIgnore]
191 public byte AttachPoint = 0;
192
193 [XmlIgnore]
194 public Vector3 AttachOffset = Vector3.Zero;
195
196 [XmlIgnore]
187 public int STATUS_ROTATE_X; 197 public int STATUS_ROTATE_X;
188 198
189 public int STATUS_ROTATE_Y; 199 public int STATUS_ROTATE_Y;
@@ -210,8 +220,7 @@ namespace OpenSim.Region.Framework.Scenes
210 220
211 public Vector3 RotationAxis = Vector3.One; 221 public Vector3 RotationAxis = Vector3.One;
212 222
213 public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this 223 public bool VolumeDetectActive;
214 // Certainly this must be a persistant setting finally
215 224
216 public bool IsWaitingForFirstSpinUpdatePacket; 225 public bool IsWaitingForFirstSpinUpdatePacket;
217 226
@@ -251,6 +260,7 @@ namespace OpenSim.Region.Framework.Scenes
251 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 260 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
252 private Vector3 m_sitTargetPosition; 261 private Vector3 m_sitTargetPosition;
253 private string m_sitAnimation = "SIT"; 262 private string m_sitAnimation = "SIT";
263 private bool m_occupied; // KF if any av is sitting on this prim
254 private string m_text = String.Empty; 264 private string m_text = String.Empty;
255 private string m_touchName = String.Empty; 265 private string m_touchName = String.Empty;
256 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); 266 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5);
@@ -283,6 +293,9 @@ namespace OpenSim.Region.Framework.Scenes
283 protected Vector3 m_lastAcceleration; 293 protected Vector3 m_lastAcceleration;
284 protected Vector3 m_lastAngularVelocity; 294 protected Vector3 m_lastAngularVelocity;
285 protected int m_lastTerseSent; 295 protected int m_lastTerseSent;
296 protected float m_buoyancy = 0.0f;
297 protected Vector3 m_force;
298 protected Vector3 m_torque;
286 299
287 /// <summary> 300 /// <summary>
288 /// Stores media texture data 301 /// Stores media texture data
@@ -299,6 +312,17 @@ namespace OpenSim.Region.Framework.Scenes
299 private UUID m_collisionSound; 312 private UUID m_collisionSound;
300 private float m_collisionSoundVolume; 313 private float m_collisionSoundVolume;
301 314
315
316 private SOPVehicle m_vehicle = null;
317
318 private KeyframeMotion m_keyframeMotion = null;
319
320 public KeyframeMotion KeyframeMotion
321 {
322 get; set;
323 }
324
325
302 #endregion Fields 326 #endregion Fields
303 327
304// ~SceneObjectPart() 328// ~SceneObjectPart()
@@ -341,7 +365,7 @@ namespace OpenSim.Region.Framework.Scenes
341 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 365 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
342 Quaternion rotationOffset, Vector3 offsetPosition) : this() 366 Quaternion rotationOffset, Vector3 offsetPosition) : this()
343 { 367 {
344 m_name = "Primitive"; 368 m_name = "Object";
345 369
346 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 370 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
347 LastOwnerID = CreatorID = OwnerID = ownerID; 371 LastOwnerID = CreatorID = OwnerID = ownerID;
@@ -381,7 +405,7 @@ namespace OpenSim.Region.Framework.Scenes
381 private uint _ownerMask = (uint)PermissionMask.All; 405 private uint _ownerMask = (uint)PermissionMask.All;
382 private uint _groupMask = (uint)PermissionMask.None; 406 private uint _groupMask = (uint)PermissionMask.None;
383 private uint _everyoneMask = (uint)PermissionMask.None; 407 private uint _everyoneMask = (uint)PermissionMask.None;
384 private uint _nextOwnerMask = (uint)PermissionMask.All; 408 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
385 private PrimFlags _flags = PrimFlags.None; 409 private PrimFlags _flags = PrimFlags.None;
386 private DateTime m_expires; 410 private DateTime m_expires;
387 private DateTime m_rezzed; 411 private DateTime m_rezzed;
@@ -475,12 +499,16 @@ namespace OpenSim.Region.Framework.Scenes
475 } 499 }
476 500
477 /// <value> 501 /// <value>
478 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 502 /// Get the inventory list
479 /// </value> 503 /// </value>
480 public TaskInventoryDictionary TaskInventory 504 public TaskInventoryDictionary TaskInventory
481 { 505 {
482 get { return m_inventory.Items; } 506 get {
483 set { m_inventory.Items = value; } 507 return m_inventory.Items;
508 }
509 set {
510 m_inventory.Items = value;
511 }
484 } 512 }
485 513
486 /// <summary> 514 /// <summary>
@@ -624,14 +652,12 @@ namespace OpenSim.Region.Framework.Scenes
624 set { m_LoopSoundSlavePrims = value; } 652 set { m_LoopSoundSlavePrims = value; }
625 } 653 }
626 654
627
628 public Byte[] TextureAnimation 655 public Byte[] TextureAnimation
629 { 656 {
630 get { return m_TextureAnimation; } 657 get { return m_TextureAnimation; }
631 set { m_TextureAnimation = value; } 658 set { m_TextureAnimation = value; }
632 } 659 }
633 660
634
635 public Byte[] ParticleSystem 661 public Byte[] ParticleSystem
636 { 662 {
637 get { return m_particleSystem; } 663 get { return m_particleSystem; }
@@ -668,9 +694,11 @@ namespace OpenSim.Region.Framework.Scenes
668 { 694 {
669 // If this is a linkset, we don't want the physics engine mucking up our group position here. 695 // If this is a linkset, we don't want the physics engine mucking up our group position here.
670 PhysicsActor actor = PhysActor; 696 PhysicsActor actor = PhysActor;
671 if (actor != null && ParentID == 0) 697 if (ParentID == 0)
672 { 698 {
673 m_groupPosition = actor.Position; 699 if (actor != null)
700 m_groupPosition = actor.Position;
701 return m_groupPosition;
674 } 702 }
675 703
676 if (ParentGroup.IsAttachment) 704 if (ParentGroup.IsAttachment)
@@ -680,12 +708,14 @@ namespace OpenSim.Region.Framework.Scenes
680 return sp.AbsolutePosition; 708 return sp.AbsolutePosition;
681 } 709 }
682 710
711 // use root prim's group position. Physics may have updated it
712 if (ParentGroup.RootPart != this)
713 m_groupPosition = ParentGroup.RootPart.GroupPosition;
683 return m_groupPosition; 714 return m_groupPosition;
684 } 715 }
685 set 716 set
686 { 717 {
687 m_groupPosition = value; 718 m_groupPosition = value;
688
689 PhysicsActor actor = PhysActor; 719 PhysicsActor actor = PhysActor;
690 if (actor != null) 720 if (actor != null)
691 { 721 {
@@ -711,16 +741,6 @@ namespace OpenSim.Region.Framework.Scenes
711 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 741 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
712 } 742 }
713 } 743 }
714
715 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
716 if (SitTargetAvatar != UUID.Zero)
717 {
718 ScenePresence avatar;
719 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
720 {
721 avatar.ParentPosition = GetWorldPosition();
722 }
723 }
724 } 744 }
725 } 745 }
726 746
@@ -729,7 +749,7 @@ namespace OpenSim.Region.Framework.Scenes
729 get { return m_offsetPosition; } 749 get { return m_offsetPosition; }
730 set 750 set
731 { 751 {
732// StoreUndoState(); 752 Vector3 oldpos = m_offsetPosition;
733 m_offsetPosition = value; 753 m_offsetPosition = value;
734 754
735 if (ParentGroup != null && !ParentGroup.IsDeleted) 755 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -744,7 +764,22 @@ namespace OpenSim.Region.Framework.Scenes
744 if (ParentGroup.Scene != null) 764 if (ParentGroup.Scene != null)
745 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 765 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
746 } 766 }
767
768 if (!m_parentGroup.m_dupeInProgress)
769 {
770 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
771 foreach (ScenePresence av in avs)
772 {
773 if (av.ParentID == m_localId)
774 {
775 Vector3 offset = (m_offsetPosition - oldpos);
776 av.AbsolutePosition += offset;
777 av.SendAvatarDataToAllAgents();
778 }
779 }
780 }
747 } 781 }
782 TriggerScriptChangedEvent(Changed.POSITION);
748 } 783 }
749 } 784 }
750 785
@@ -881,7 +916,7 @@ namespace OpenSim.Region.Framework.Scenes
881 get 916 get
882 { 917 {
883 PhysicsActor actor = PhysActor; 918 PhysicsActor actor = PhysActor;
884 if ((actor != null) && actor.IsPhysical) 919 if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this)
885 { 920 {
886 m_angularVelocity = actor.RotationalVelocity; 921 m_angularVelocity = actor.RotationalVelocity;
887 } 922 }
@@ -893,7 +928,16 @@ namespace OpenSim.Region.Framework.Scenes
893 /// <summary></summary> 928 /// <summary></summary>
894 public Vector3 Acceleration 929 public Vector3 Acceleration
895 { 930 {
896 get { return m_acceleration; } 931 get
932 {
933 PhysicsActor actor = PhysActor;
934 if (actor != null)
935 {
936 m_acceleration = actor.Acceleration;
937 }
938 return m_acceleration;
939 }
940
897 set { m_acceleration = value; } 941 set { m_acceleration = value; }
898 } 942 }
899 943
@@ -1030,10 +1074,7 @@ namespace OpenSim.Region.Framework.Scenes
1030 { 1074 {
1031 get 1075 get
1032 { 1076 {
1033 if (ParentGroup.IsAttachment) 1077 return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset);
1034 return GroupPosition;
1035
1036 return m_offsetPosition + m_groupPosition;
1037 } 1078 }
1038 } 1079 }
1039 1080
@@ -1203,6 +1244,13 @@ namespace OpenSim.Region.Framework.Scenes
1203 _flags = value; 1244 _flags = value;
1204 } 1245 }
1205 } 1246 }
1247
1248 [XmlIgnore]
1249 public bool IsOccupied // KF If an av is sittingon this prim
1250 {
1251 get { return m_occupied; }
1252 set { m_occupied = value; }
1253 }
1206 1254
1207 /// <summary> 1255 /// <summary>
1208 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1256 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1262,6 +1310,74 @@ namespace OpenSim.Region.Framework.Scenes
1262 set { m_collisionSoundVolume = value; } 1310 set { m_collisionSoundVolume = value; }
1263 } 1311 }
1264 1312
1313 public float Buoyancy
1314 {
1315 get
1316 {
1317 if (ParentGroup.RootPart == this)
1318 return m_buoyancy;
1319
1320 return ParentGroup.RootPart.Buoyancy;
1321 }
1322 set
1323 {
1324 if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this)
1325 {
1326 ParentGroup.RootPart.Buoyancy = value;
1327 return;
1328 }
1329 m_buoyancy = value;
1330 if (PhysActor != null)
1331 PhysActor.Buoyancy = value;
1332 }
1333 }
1334
1335 public Vector3 Force
1336 {
1337 get
1338 {
1339 if (ParentGroup.RootPart == this)
1340 return m_force;
1341
1342 return ParentGroup.RootPart.Force;
1343 }
1344
1345 set
1346 {
1347 if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this)
1348 {
1349 ParentGroup.RootPart.Force = value;
1350 return;
1351 }
1352 m_force = value;
1353 if (PhysActor != null)
1354 PhysActor.Force = value;
1355 }
1356 }
1357
1358 public Vector3 Torque
1359 {
1360 get
1361 {
1362 if (ParentGroup.RootPart == this)
1363 return m_torque;
1364
1365 return ParentGroup.RootPart.Torque;
1366 }
1367
1368 set
1369 {
1370 if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this)
1371 {
1372 ParentGroup.RootPart.Torque = value;
1373 return;
1374 }
1375 m_torque = value;
1376 if (PhysActor != null)
1377 PhysActor.Torque = value;
1378 }
1379 }
1380
1265 #endregion Public Properties with only Get 1381 #endregion Public Properties with only Get
1266 1382
1267 private uint ApplyMask(uint val, bool set, uint mask) 1383 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1437,20 +1553,24 @@ namespace OpenSim.Region.Framework.Scenes
1437 /// </summary> 1553 /// </summary>
1438 /// <param name="impulsei">Vector force</param> 1554 /// <param name="impulsei">Vector force</param>
1439 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> 1555 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
1440 public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) 1556
1557 // this is actualy Set Torque.. keeping naming so not to edit lslapi also
1558 public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF)
1441 { 1559 {
1442 Vector3 impulse = impulsei; 1560 Vector3 torque = torquei;
1443 1561
1444 if (localGlobalTF) 1562 if (localGlobalTF)
1445 { 1563 {
1564/*
1446 Quaternion grot = GetWorldRotation(); 1565 Quaternion grot = GetWorldRotation();
1447 Quaternion AXgrot = grot; 1566 Quaternion AXgrot = grot;
1448 Vector3 AXimpulsei = impulsei; 1567 Vector3 AXimpulsei = impulsei;
1449 Vector3 newimpulse = AXimpulsei * AXgrot; 1568 Vector3 newimpulse = AXimpulsei * AXgrot;
1450 impulse = newimpulse; 1569 */
1570 torque *= GetWorldRotation();
1451 } 1571 }
1452 1572
1453 ParentGroup.setAngularImpulse(impulse); 1573 Torque = torque;
1454 } 1574 }
1455 1575
1456 /// <summary> 1576 /// <summary>
@@ -1458,7 +1578,8 @@ namespace OpenSim.Region.Framework.Scenes
1458 /// </summary> 1578 /// </summary>
1459 /// <param name="rootObjectFlags"></param> 1579 /// <param name="rootObjectFlags"></param>
1460 /// <param name="VolumeDetectActive"></param> 1580 /// <param name="VolumeDetectActive"></param>
1461 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) 1581// public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive)
1582 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive, bool building)
1462 { 1583 {
1463 if (!ParentGroup.Scene.CollidablePrims) 1584 if (!ParentGroup.Scene.CollidablePrims)
1464 return; 1585 return;
@@ -1487,6 +1608,8 @@ namespace OpenSim.Region.Framework.Scenes
1487 // or flexible 1608 // or flexible
1488 if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) 1609 if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1489 { 1610 {
1611 Vector3 velocity = Velocity;
1612 Vector3 rotationalVelocity = AngularVelocity;
1490 try 1613 try
1491 { 1614 {
1492 PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape( 1615 PhysActor = ParentGroup.Scene.PhysicsScene.AddPrimShape(
@@ -1494,7 +1617,8 @@ namespace OpenSim.Region.Framework.Scenes
1494 Shape, 1617 Shape,
1495 AbsolutePosition, 1618 AbsolutePosition,
1496 Scale, 1619 Scale,
1497 RotationOffset, 1620// RotationOffset,
1621 GetWorldRotation(), // physics wants world rotation
1498 RigidBody, 1622 RigidBody,
1499 m_localId); 1623 m_localId);
1500 } 1624 }
@@ -1509,8 +1633,29 @@ namespace OpenSim.Region.Framework.Scenes
1509 { 1633 {
1510 PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 1634 PhysActor.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
1511 PhysActor.SetMaterial(Material); 1635 PhysActor.SetMaterial(Material);
1636
1637 // if root part apply vehicle
1638 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
1639 m_vehicle.SetVehicle(PhysActor);
1640
1512 DoPhysicsPropertyUpdate(RigidBody, true); 1641 DoPhysicsPropertyUpdate(RigidBody, true);
1513 PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); 1642 PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
1643
1644 if (!building)
1645 PhysActor.Building = false;
1646
1647 Velocity = velocity;
1648 AngularVelocity = rotationalVelocity;
1649 PhysActor.Velocity = velocity;
1650 PhysActor.RotationalVelocity = rotationalVelocity;
1651
1652 // if not vehicle and root part apply force and torque
1653 if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE)
1654 && LocalId == ParentGroup.RootPart.LocalId)
1655 {
1656 PhysActor.Force = Force;
1657 PhysActor.Torque = Torque;
1658 }
1514 } 1659 }
1515 } 1660 }
1516 } 1661 }
@@ -1582,6 +1727,9 @@ namespace OpenSim.Region.Framework.Scenes
1582 1727
1583 // Move afterwards ResetIDs as it clears the localID 1728 // Move afterwards ResetIDs as it clears the localID
1584 dupe.LocalId = localID; 1729 dupe.LocalId = localID;
1730 if(dupe.PhysActor != null)
1731 dupe.PhysActor.LocalID = localID;
1732
1585 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1733 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1586 dupe.LastOwnerID = OwnerID; 1734 dupe.LastOwnerID = OwnerID;
1587 1735
@@ -1743,6 +1891,11 @@ namespace OpenSim.Region.Framework.Scenes
1743 if (!isNew) 1891 if (!isNew)
1744 ParentGroup.Scene.RemovePhysicalPrim(1); 1892 ParentGroup.Scene.RemovePhysicalPrim(1);
1745 1893
1894 Velocity = new Vector3(0, 0, 0);
1895 Acceleration = new Vector3(0, 0, 0);
1896 if (ParentGroup.RootPart == this)
1897 AngularVelocity = new Vector3(0, 0, 0);
1898
1746 PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; 1899 PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
1747 PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; 1900 PhysActor.OnOutOfBounds -= PhysicsOutOfBounds;
1748 PhysActor.delink(); 1901 PhysActor.delink();
@@ -1765,7 +1918,8 @@ namespace OpenSim.Region.Framework.Scenes
1765 // velocity-vector. 1918 // velocity-vector.
1766 Velocity = new Vector3(0, 0, 0); 1919 Velocity = new Vector3(0, 0, 0);
1767 Acceleration = new Vector3(0, 0, 0); 1920 Acceleration = new Vector3(0, 0, 0);
1768 AngularVelocity = new Vector3(0, 0, 0); 1921 if (ParentGroup.RootPart == this)
1922 AngularVelocity = new Vector3(0, 0, 0);
1769 //RotationalVelocity = new Vector3(0, 0, 0); 1923 //RotationalVelocity = new Vector3(0, 0, 0);
1770 } 1924 }
1771 1925
@@ -1780,6 +1934,9 @@ namespace OpenSim.Region.Framework.Scenes
1780 { 1934 {
1781 if (UsePhysics) 1935 if (UsePhysics)
1782 { 1936 {
1937 if (ParentGroup.RootPart.KeyframeMotion != null)
1938 ParentGroup.RootPart.KeyframeMotion.Stop();
1939 ParentGroup.RootPart.KeyframeMotion = null;
1783 ParentGroup.Scene.AddPhysicalPrim(1); 1940 ParentGroup.Scene.AddPhysicalPrim(1);
1784 1941
1785 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; 1942 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
@@ -1927,10 +2084,7 @@ namespace OpenSim.Region.Framework.Scenes
1927 2084
1928 public Vector3 GetForce() 2085 public Vector3 GetForce()
1929 { 2086 {
1930 if (PhysActor != null) 2087 return Force;
1931 return PhysActor.Force;
1932 else
1933 return Vector3.Zero;
1934 } 2088 }
1935 2089
1936 /// <summary> 2090 /// <summary>
@@ -2564,9 +2718,9 @@ namespace OpenSim.Region.Framework.Scenes
2564 Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); 2718 Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0);
2565 2719
2566 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) 2720 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N)
2567 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) 2721 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S)
2568 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) 2722 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E)
2569 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) 2723 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W))
2570 { 2724 {
2571 ParentGroup.AbsolutePosition = newpos; 2725 ParentGroup.AbsolutePosition = newpos;
2572 return; 2726 return;
@@ -2587,17 +2741,18 @@ namespace OpenSim.Region.Framework.Scenes
2587 //Trys to fetch sound id from prim's inventory. 2741 //Trys to fetch sound id from prim's inventory.
2588 //Prim's inventory doesn't support non script items yet 2742 //Prim's inventory doesn't support non script items yet
2589 2743
2590 lock (TaskInventory) 2744 TaskInventory.LockItemsForRead(true);
2745
2746 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2591 { 2747 {
2592 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2748 if (item.Value.Name == sound)
2593 { 2749 {
2594 if (item.Value.Name == sound) 2750 soundID = item.Value.ItemID;
2595 { 2751 break;
2596 soundID = item.Value.ItemID;
2597 break;
2598 }
2599 } 2752 }
2600 } 2753 }
2754
2755 TaskInventory.LockItemsForRead(false);
2601 } 2756 }
2602 2757
2603 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2758 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2917,8 +3072,8 @@ namespace OpenSim.Region.Framework.Scenes
2917 { 3072 {
2918 const float ROTATION_TOLERANCE = 0.01f; 3073 const float ROTATION_TOLERANCE = 0.01f;
2919 const float VELOCITY_TOLERANCE = 0.001f; 3074 const float VELOCITY_TOLERANCE = 0.001f;
2920 const float POSITION_TOLERANCE = 0.05f; 3075 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2921 const int TIME_MS_TOLERANCE = 3000; 3076 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2922 3077
2923 switch (UpdateFlag) 3078 switch (UpdateFlag)
2924 { 3079 {
@@ -2980,17 +3135,16 @@ namespace OpenSim.Region.Framework.Scenes
2980 if (!UUID.TryParse(sound, out soundID)) 3135 if (!UUID.TryParse(sound, out soundID))
2981 { 3136 {
2982 // search sound file from inventory 3137 // search sound file from inventory
2983 lock (TaskInventory) 3138 TaskInventory.LockItemsForRead(true);
3139 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2984 { 3140 {
2985 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3141 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2986 { 3142 {
2987 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3143 soundID = item.Value.ItemID;
2988 { 3144 break;
2989 soundID = item.Value.ItemID;
2990 break;
2991 }
2992 } 3145 }
2993 } 3146 }
3147 TaskInventory.LockItemsForRead(false);
2994 } 3148 }
2995 3149
2996 if (soundID == UUID.Zero) 3150 if (soundID == UUID.Zero)
@@ -3075,10 +3229,13 @@ namespace OpenSim.Region.Framework.Scenes
3075 3229
3076 public void SetBuoyancy(float fvalue) 3230 public void SetBuoyancy(float fvalue)
3077 { 3231 {
3232 Buoyancy = fvalue;
3233/*
3078 if (PhysActor != null) 3234 if (PhysActor != null)
3079 { 3235 {
3080 PhysActor.Buoyancy = fvalue; 3236 PhysActor.Buoyancy = fvalue;
3081 } 3237 }
3238 */
3082 } 3239 }
3083 3240
3084 public void SetDieAtEdge(bool p) 3241 public void SetDieAtEdge(bool p)
@@ -3106,23 +3263,83 @@ namespace OpenSim.Region.Framework.Scenes
3106 3263
3107 public void SetForce(Vector3 force) 3264 public void SetForce(Vector3 force)
3108 { 3265 {
3266 Force = force;
3267/*
3109 if (PhysActor != null) 3268 if (PhysActor != null)
3110 { 3269 {
3111 PhysActor.Force = force; 3270 PhysActor.Force = force;
3112 } 3271 }
3272 */
3273 }
3274
3275 public SOPVehicle sopVehicle
3276 {
3277 get
3278 {
3279 return m_vehicle;
3280 }
3281 set
3282 {
3283 m_vehicle = value;
3284 }
3285 }
3286
3287
3288 public int VehicleType
3289 {
3290 get
3291 {
3292 if (m_vehicle == null)
3293 return (int)Vehicle.TYPE_NONE;
3294 else
3295 return (int)m_vehicle.Type;
3296 }
3297 set
3298 {
3299 SetVehicleType(value);
3300 }
3113 } 3301 }
3114 3302
3115 public void SetVehicleType(int type) 3303 public void SetVehicleType(int type)
3116 { 3304 {
3117 if (PhysActor != null) 3305 m_vehicle = null;
3306
3307 if (type == (int)Vehicle.TYPE_NONE)
3308 {
3309 if (_parentID ==0 && PhysActor != null)
3310 PhysActor.VehicleType = (int)Vehicle.TYPE_NONE;
3311 return;
3312 }
3313 m_vehicle = new SOPVehicle();
3314 m_vehicle.ProcessTypeChange((Vehicle)type);
3315 {
3316 if (_parentID ==0 && PhysActor != null)
3317 PhysActor.VehicleType = type;
3318 return;
3319 }
3320 }
3321
3322 public void SetVehicleFlags(int param, bool remove)
3323 {
3324 if (m_vehicle == null)
3325 return;
3326
3327 m_vehicle.ProcessVehicleFlags(param, remove);
3328
3329 if (_parentID ==0 && PhysActor != null)
3118 { 3330 {
3119 PhysActor.VehicleType = type; 3331 PhysActor.VehicleFlags(param, remove);
3120 } 3332 }
3121 } 3333 }
3122 3334
3123 public void SetVehicleFloatParam(int param, float value) 3335 public void SetVehicleFloatParam(int param, float value)
3124 { 3336 {
3125 if (PhysActor != null) 3337 if (m_vehicle == null)
3338 return;
3339
3340 m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value);
3341
3342 if (_parentID == 0 && PhysActor != null)
3126 { 3343 {
3127 PhysActor.VehicleFloatParam(param, value); 3344 PhysActor.VehicleFloatParam(param, value);
3128 } 3345 }
@@ -3130,7 +3347,12 @@ namespace OpenSim.Region.Framework.Scenes
3130 3347
3131 public void SetVehicleVectorParam(int param, Vector3 value) 3348 public void SetVehicleVectorParam(int param, Vector3 value)
3132 { 3349 {
3133 if (PhysActor != null) 3350 if (m_vehicle == null)
3351 return;
3352
3353 m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value);
3354
3355 if (_parentID == 0 && PhysActor != null)
3134 { 3356 {
3135 PhysActor.VehicleVectorParam(param, value); 3357 PhysActor.VehicleVectorParam(param, value);
3136 } 3358 }
@@ -3138,7 +3360,12 @@ namespace OpenSim.Region.Framework.Scenes
3138 3360
3139 public void SetVehicleRotationParam(int param, Quaternion rotation) 3361 public void SetVehicleRotationParam(int param, Quaternion rotation)
3140 { 3362 {
3141 if (PhysActor != null) 3363 if (m_vehicle == null)
3364 return;
3365
3366 m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation);
3367
3368 if (_parentID == 0 && PhysActor != null)
3142 { 3369 {
3143 PhysActor.VehicleRotationParam(param, rotation); 3370 PhysActor.VehicleRotationParam(param, rotation);
3144 } 3371 }
@@ -3325,13 +3552,6 @@ namespace OpenSim.Region.Framework.Scenes
3325 hasProfileCut = hasDimple; // is it the same thing? 3552 hasProfileCut = hasDimple; // is it the same thing?
3326 } 3553 }
3327 3554
3328 public void SetVehicleFlags(int param, bool remove)
3329 {
3330 if (PhysActor != null)
3331 {
3332 PhysActor.VehicleFlags(param, remove);
3333 }
3334 }
3335 3555
3336 public void SetGroup(UUID groupID, IClientAPI client) 3556 public void SetGroup(UUID groupID, IClientAPI client)
3337 { 3557 {
@@ -3457,10 +3677,10 @@ namespace OpenSim.Region.Framework.Scenes
3457 // TODO: May need to fix for group comparison 3677 // TODO: May need to fix for group comparison
3458 if (last.Compare(this)) 3678 if (last.Compare(this))
3459 { 3679 {
3460 // m_log.DebugFormat( 3680 // m_log.DebugFormat(
3461 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", 3681 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3462 // Name, LocalId, m_undo.Count); 3682 // Name, LocalId, m_undo.Count);
3463 3683
3464 return; 3684 return;
3465 } 3685 }
3466 } 3686 }
@@ -3473,29 +3693,29 @@ namespace OpenSim.Region.Framework.Scenes
3473 if (ParentGroup.GetSceneMaxUndo() > 0) 3693 if (ParentGroup.GetSceneMaxUndo() > 0)
3474 { 3694 {
3475 UndoState nUndo = new UndoState(this, forGroup); 3695 UndoState nUndo = new UndoState(this, forGroup);
3476 3696
3477 m_undo.Push(nUndo); 3697 m_undo.Push(nUndo);
3478 3698
3479 if (m_redo.Count > 0) 3699 if (m_redo.Count > 0)
3480 m_redo.Clear(); 3700 m_redo.Clear();
3481 3701
3482 // m_log.DebugFormat( 3702 // m_log.DebugFormat(
3483 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3703 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3484 // Name, LocalId, forGroup, m_undo.Count); 3704 // Name, LocalId, forGroup, m_undo.Count);
3485 } 3705 }
3486 } 3706 }
3487 } 3707 }
3488 } 3708 }
3489// else 3709 // else
3490// { 3710 // {
3491// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); 3711 // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3492// } 3712 // }
3493 } 3713 }
3494// else 3714 // else
3495// { 3715 // {
3496// m_log.DebugFormat( 3716 // m_log.DebugFormat(
3497// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); 3717 // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3498// } 3718 // }
3499 } 3719 }
3500 3720
3501 /// <summary> 3721 /// <summary>
@@ -4219,13 +4439,17 @@ namespace OpenSim.Region.Framework.Scenes
4219 /// <param name="SetTemporary"></param> 4439 /// <param name="SetTemporary"></param>
4220 /// <param name="SetPhantom"></param> 4440 /// <param name="SetPhantom"></param>
4221 /// <param name="SetVD"></param> 4441 /// <param name="SetVD"></param>
4222 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) 4442// public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD)
4443 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building)
4223 { 4444 {
4224 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); 4445 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0);
4225 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); 4446 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0);
4226 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0); 4447 bool wasPhantom = ((Flags & PrimFlags.Phantom) != 0);
4227 bool wasVD = VolumeDetectActive; 4448 bool wasVD = VolumeDetectActive;
4228 4449
4450// m_log.DebugFormat("[SOP]: Old states: phys: {0} temp: {1} phan: {2} vd: {3}", wasUsingPhysics, wasTemporary, wasPhantom, wasVD);
4451// m_log.DebugFormat("[SOP]: New states: phys: {0} temp: {1} phan: {2} vd: {3}", UsePhysics, SetTemporary, SetPhantom, SetVD);
4452
4229 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4453 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4230 return; 4454 return;
4231 4455
@@ -4234,6 +4458,9 @@ namespace OpenSim.Region.Framework.Scenes
4234 // that... 4458 // that...
4235 // ... if VD is changed, all others are not. 4459 // ... if VD is changed, all others are not.
4236 // ... if one of the others is changed, VD is not. 4460 // ... if one of the others is changed, VD is not.
4461 // do this first
4462 if (building && PhysActor != null && PhysActor.Building != building)
4463 PhysActor.Building = building;
4237 if (SetVD) // VD is active, special logic applies 4464 if (SetVD) // VD is active, special logic applies
4238 { 4465 {
4239 // State machine logic for VolumeDetect 4466 // State machine logic for VolumeDetect
@@ -4255,6 +4482,11 @@ namespace OpenSim.Region.Framework.Scenes
4255 SetPhantom = false; 4482 SetPhantom = false;
4256 } 4483 }
4257 } 4484 }
4485 else if (wasVD)
4486 {
4487 // Correspondingly, if VD is turned off, also turn off phantom
4488 SetPhantom = false;
4489 }
4258 4490
4259 if (UsePhysics && IsJoint()) 4491 if (UsePhysics && IsJoint())
4260 { 4492 {
@@ -4310,11 +4542,17 @@ namespace OpenSim.Region.Framework.Scenes
4310 Shape, 4542 Shape,
4311 AbsolutePosition, 4543 AbsolutePosition,
4312 Scale, 4544 Scale,
4313 RotationOffset, 4545// RotationOffset,
4546 GetWorldRotation(), //physics wants world rotation like all other functions send
4314 UsePhysics, 4547 UsePhysics,
4315 m_localId); 4548 m_localId);
4316 4549
4317 PhysActor.SetMaterial(Material); 4550 PhysActor.SetMaterial(Material);
4551
4552 // if root part apply vehicle
4553 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
4554 m_vehicle.SetVehicle(PhysActor);
4555
4318 DoPhysicsPropertyUpdate(UsePhysics, true); 4556 DoPhysicsPropertyUpdate(UsePhysics, true);
4319 4557
4320 if (!ParentGroup.IsDeleted) 4558 if (!ParentGroup.IsDeleted)
@@ -4390,6 +4628,9 @@ namespace OpenSim.Region.Framework.Scenes
4390 } 4628 }
4391 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 4629 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
4392 4630
4631 // and last in case we have a new actor and not building
4632 if (PhysActor != null && PhysActor.Building != building)
4633 PhysActor.Building = building;
4393 if (ParentGroup != null) 4634 if (ParentGroup != null)
4394 { 4635 {
4395 ParentGroup.HasGroupChanged = true; 4636 ParentGroup.HasGroupChanged = true;
@@ -4753,5 +4994,17 @@ namespace OpenSim.Region.Framework.Scenes
4753 Color color = Color; 4994 Color color = Color;
4754 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 4995 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4755 } 4996 }
4997
4998 public void ResetOwnerChangeFlag()
4999 {
5000 List<UUID> inv = Inventory.GetInventoryList();
5001
5002 foreach (UUID itemID in inv)
5003 {
5004 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
5005 item.OwnerChanged = false;
5006 Inventory.UpdateInventoryItem(item, false, false);
5007 }
5008 }
4756 } 5009 }
4757} 5010}