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.cs1320
1 files changed, 852 insertions, 468 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 4bec2d4..0f7959d 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,6 +122,11 @@ 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;
125
126 private const scriptEvents PhyscicsNeededSubsEvents = (
127 scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end |
128 scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end
129 );
124 130
125 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 131 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
126 132
@@ -182,6 +188,15 @@ namespace OpenSim.Region.Framework.Scenes
182 188
183 public uint TimeStampTerse; 189 public uint TimeStampTerse;
184 190
191 // The following two are to hold the attachment data
192 // while an object is inworld
193 [XmlIgnore]
194 public byte AttachPoint = 0;
195
196 [XmlIgnore]
197 public Vector3 AttachOffset = Vector3.Zero;
198
199 [XmlIgnore]
185 public int STATUS_ROTATE_X; 200 public int STATUS_ROTATE_X;
186 201
187 public int STATUS_ROTATE_Y; 202 public int STATUS_ROTATE_Y;
@@ -208,8 +223,7 @@ namespace OpenSim.Region.Framework.Scenes
208 223
209 public Vector3 RotationAxis = Vector3.One; 224 public Vector3 RotationAxis = Vector3.One;
210 225
211 public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this 226 public bool VolumeDetectActive;
212 // Certainly this must be a persistant setting finally
213 227
214 public bool IsWaitingForFirstSpinUpdatePacket; 228 public bool IsWaitingForFirstSpinUpdatePacket;
215 229
@@ -249,10 +263,10 @@ namespace OpenSim.Region.Framework.Scenes
249 private Quaternion m_sitTargetOrientation = Quaternion.Identity; 263 private Quaternion m_sitTargetOrientation = Quaternion.Identity;
250 private Vector3 m_sitTargetPosition; 264 private Vector3 m_sitTargetPosition;
251 private string m_sitAnimation = "SIT"; 265 private string m_sitAnimation = "SIT";
266 private bool m_occupied; // KF if any av is sitting on this prim
252 private string m_text = String.Empty; 267 private string m_text = String.Empty;
253 private string m_touchName = String.Empty; 268 private string m_touchName = String.Empty;
254 private readonly Stack<UndoState> m_undo = new Stack<UndoState>(5); 269 private UndoRedoState m_UndoRedo = null;
255 private readonly Stack<UndoState> m_redo = new Stack<UndoState>(5);
256 270
257 private bool m_passTouches; 271 private bool m_passTouches;
258 272
@@ -280,7 +294,16 @@ namespace OpenSim.Region.Framework.Scenes
280 protected Vector3 m_lastAcceleration; 294 protected Vector3 m_lastAcceleration;
281 protected Vector3 m_lastAngularVelocity; 295 protected Vector3 m_lastAngularVelocity;
282 protected int m_lastTerseSent; 296 protected int m_lastTerseSent;
283 297 protected float m_buoyancy = 0.0f;
298 protected Vector3 m_force;
299 protected Vector3 m_torque;
300
301 protected byte m_physicsShapeType = (byte)PhysShapeType.prim;
302 protected float m_density = 1000.0f; // in kg/m^3
303 protected float m_gravitymod = 1.0f;
304 protected float m_friction = 0.6f; // wood
305 protected float m_bounce = 0.5f; // wood
306
284 /// <summary> 307 /// <summary>
285 /// Stores media texture data 308 /// Stores media texture data
286 /// </summary> 309 /// </summary>
@@ -296,6 +319,17 @@ namespace OpenSim.Region.Framework.Scenes
296 private UUID m_collisionSound; 319 private UUID m_collisionSound;
297 private float m_collisionSoundVolume; 320 private float m_collisionSoundVolume;
298 321
322
323 private SOPVehicle m_vehicle = null;
324
325 private KeyframeMotion m_keyframeMotion = null;
326
327 public KeyframeMotion KeyframeMotion
328 {
329 get; set;
330 }
331
332
299 #endregion Fields 333 #endregion Fields
300 334
301// ~SceneObjectPart() 335// ~SceneObjectPart()
@@ -338,7 +372,7 @@ namespace OpenSim.Region.Framework.Scenes
338 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, 372 UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
339 Quaternion rotationOffset, Vector3 offsetPosition) : this() 373 Quaternion rotationOffset, Vector3 offsetPosition) : this()
340 { 374 {
341 m_name = "Primitive"; 375 m_name = "Object";
342 376
343 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); 377 CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
344 LastOwnerID = CreatorID = OwnerID = ownerID; 378 LastOwnerID = CreatorID = OwnerID = ownerID;
@@ -378,7 +412,7 @@ namespace OpenSim.Region.Framework.Scenes
378 private uint _ownerMask = (uint)PermissionMask.All; 412 private uint _ownerMask = (uint)PermissionMask.All;
379 private uint _groupMask = (uint)PermissionMask.None; 413 private uint _groupMask = (uint)PermissionMask.None;
380 private uint _everyoneMask = (uint)PermissionMask.None; 414 private uint _everyoneMask = (uint)PermissionMask.None;
381 private uint _nextOwnerMask = (uint)PermissionMask.All; 415 private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer);
382 private PrimFlags _flags = PrimFlags.None; 416 private PrimFlags _flags = PrimFlags.None;
383 private DateTime m_expires; 417 private DateTime m_expires;
384 private DateTime m_rezzed; 418 private DateTime m_rezzed;
@@ -472,12 +506,16 @@ namespace OpenSim.Region.Framework.Scenes
472 } 506 }
473 507
474 /// <value> 508 /// <value>
475 /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes 509 /// Get the inventory list
476 /// </value> 510 /// </value>
477 public TaskInventoryDictionary TaskInventory 511 public TaskInventoryDictionary TaskInventory
478 { 512 {
479 get { return m_inventory.Items; } 513 get {
480 set { m_inventory.Items = value; } 514 return m_inventory.Items;
515 }
516 set {
517 m_inventory.Items = value;
518 }
481 } 519 }
482 520
483 /// <summary> 521 /// <summary>
@@ -527,20 +565,6 @@ namespace OpenSim.Region.Framework.Scenes
527 } 565 }
528 } 566 }
529 567
530 public byte Material
531 {
532 get { return (byte) m_material; }
533 set
534 {
535 m_material = (Material)value;
536
537 PhysicsActor pa = PhysActor;
538
539 if (pa != null)
540 pa.SetMaterial((int)value);
541 }
542 }
543
544 public bool PassTouches 568 public bool PassTouches
545 { 569 {
546 get { return m_passTouches; } 570 get { return m_passTouches; }
@@ -623,14 +647,12 @@ namespace OpenSim.Region.Framework.Scenes
623 set { m_LoopSoundSlavePrims = value; } 647 set { m_LoopSoundSlavePrims = value; }
624 } 648 }
625 649
626
627 public Byte[] TextureAnimation 650 public Byte[] TextureAnimation
628 { 651 {
629 get { return m_TextureAnimation; } 652 get { return m_TextureAnimation; }
630 set { m_TextureAnimation = value; } 653 set { m_TextureAnimation = value; }
631 } 654 }
632 655
633
634 public Byte[] ParticleSystem 656 public Byte[] ParticleSystem
635 { 657 {
636 get { return m_particleSystem; } 658 get { return m_particleSystem; }
@@ -667,8 +689,12 @@ namespace OpenSim.Region.Framework.Scenes
667 { 689 {
668 // If this is a linkset, we don't want the physics engine mucking up our group position here. 690 // If this is a linkset, we don't want the physics engine mucking up our group position here.
669 PhysicsActor actor = PhysActor; 691 PhysicsActor actor = PhysActor;
670 if (actor != null && ParentID == 0) 692 if (ParentID == 0)
671 m_groupPosition = actor.Position; 693 {
694 if (actor != null)
695 m_groupPosition = actor.Position;
696 return m_groupPosition;
697 }
672 698
673 if (ParentGroup.IsAttachment) 699 if (ParentGroup.IsAttachment)
674 { 700 {
@@ -677,12 +703,14 @@ namespace OpenSim.Region.Framework.Scenes
677 return sp.AbsolutePosition; 703 return sp.AbsolutePosition;
678 } 704 }
679 705
706 // use root prim's group position. Physics may have updated it
707 if (ParentGroup.RootPart != this)
708 m_groupPosition = ParentGroup.RootPart.GroupPosition;
680 return m_groupPosition; 709 return m_groupPosition;
681 } 710 }
682 set 711 set
683 { 712 {
684 m_groupPosition = value; 713 m_groupPosition = value;
685
686 PhysicsActor actor = PhysActor; 714 PhysicsActor actor = PhysActor;
687 if (actor != null) 715 if (actor != null)
688 { 716 {
@@ -708,16 +736,6 @@ namespace OpenSim.Region.Framework.Scenes
708 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 736 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message);
709 } 737 }
710 } 738 }
711
712 // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too
713 if (SitTargetAvatar != UUID.Zero)
714 {
715 ScenePresence avatar;
716 if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar))
717 {
718 avatar.ParentPosition = GetWorldPosition();
719 }
720 }
721 } 739 }
722 } 740 }
723 741
@@ -726,7 +744,7 @@ namespace OpenSim.Region.Framework.Scenes
726 get { return m_offsetPosition; } 744 get { return m_offsetPosition; }
727 set 745 set
728 { 746 {
729// StoreUndoState(); 747 Vector3 oldpos = m_offsetPosition;
730 m_offsetPosition = value; 748 m_offsetPosition = value;
731 749
732 if (ParentGroup != null && !ParentGroup.IsDeleted) 750 if (ParentGroup != null && !ParentGroup.IsDeleted)
@@ -741,7 +759,22 @@ namespace OpenSim.Region.Framework.Scenes
741 if (ParentGroup.Scene != null) 759 if (ParentGroup.Scene != null)
742 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); 760 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
743 } 761 }
762
763 if (!m_parentGroup.m_dupeInProgress)
764 {
765 List<ScenePresence> avs = ParentGroup.GetLinkedAvatars();
766 foreach (ScenePresence av in avs)
767 {
768 if (av.ParentID == m_localId)
769 {
770 Vector3 offset = (m_offsetPosition - oldpos);
771 av.AbsolutePosition += offset;
772 av.SendAvatarDataToAllAgents();
773 }
774 }
775 }
744 } 776 }
777 TriggerScriptChangedEvent(Changed.POSITION);
745 } 778 }
746 } 779 }
747 780
@@ -790,7 +823,7 @@ namespace OpenSim.Region.Framework.Scenes
790 823
791 set 824 set
792 { 825 {
793 StoreUndoState(); 826// StoreUndoState();
794 m_rotationOffset = value; 827 m_rotationOffset = value;
795 828
796 PhysicsActor actor = PhysActor; 829 PhysicsActor actor = PhysActor;
@@ -878,7 +911,7 @@ namespace OpenSim.Region.Framework.Scenes
878 get 911 get
879 { 912 {
880 PhysicsActor actor = PhysActor; 913 PhysicsActor actor = PhysActor;
881 if ((actor != null) && actor.IsPhysical) 914 if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this)
882 { 915 {
883 m_angularVelocity = actor.RotationalVelocity; 916 m_angularVelocity = actor.RotationalVelocity;
884 } 917 }
@@ -890,7 +923,16 @@ namespace OpenSim.Region.Framework.Scenes
890 /// <summary></summary> 923 /// <summary></summary>
891 public Vector3 Acceleration 924 public Vector3 Acceleration
892 { 925 {
893 get { return m_acceleration; } 926 get
927 {
928 PhysicsActor actor = PhysActor;
929 if (actor != null)
930 {
931 m_acceleration = actor.Acceleration;
932 }
933 return m_acceleration;
934 }
935
894 set { m_acceleration = value; } 936 set { m_acceleration = value; }
895 } 937 }
896 938
@@ -947,7 +989,10 @@ namespace OpenSim.Region.Framework.Scenes
947 public PrimitiveBaseShape Shape 989 public PrimitiveBaseShape Shape
948 { 990 {
949 get { return m_shape; } 991 get { return m_shape; }
950 set { m_shape = value;} 992 set
993 {
994 m_shape = value;
995 }
951 } 996 }
952 997
953 /// <summary> 998 /// <summary>
@@ -960,7 +1005,6 @@ namespace OpenSim.Region.Framework.Scenes
960 { 1005 {
961 if (m_shape != null) 1006 if (m_shape != null)
962 { 1007 {
963 StoreUndoState();
964 1008
965 m_shape.Scale = value; 1009 m_shape.Scale = value;
966 1010
@@ -987,6 +1031,7 @@ namespace OpenSim.Region.Framework.Scenes
987 } 1031 }
988 1032
989 public UpdateRequired UpdateFlag { get; set; } 1033 public UpdateRequired UpdateFlag { get; set; }
1034 public bool UpdatePhysRequired { get; set; }
990 1035
991 /// <summary> 1036 /// <summary>
992 /// Used for media on a prim. 1037 /// Used for media on a prim.
@@ -1027,10 +1072,7 @@ namespace OpenSim.Region.Framework.Scenes
1027 { 1072 {
1028 get 1073 get
1029 { 1074 {
1030 if (ParentGroup.IsAttachment) 1075 return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset);
1031 return GroupPosition;
1032
1033 return m_offsetPosition + m_groupPosition;
1034 } 1076 }
1035 } 1077 }
1036 1078
@@ -1208,6 +1250,13 @@ namespace OpenSim.Region.Framework.Scenes
1208 _flags = value; 1250 _flags = value;
1209 } 1251 }
1210 } 1252 }
1253
1254 [XmlIgnore]
1255 public bool IsOccupied // KF If an av is sittingon this prim
1256 {
1257 get { return m_occupied; }
1258 set { m_occupied = value; }
1259 }
1211 1260
1212 /// <summary> 1261 /// <summary>
1213 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero 1262 /// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
@@ -1267,6 +1316,316 @@ namespace OpenSim.Region.Framework.Scenes
1267 set { m_collisionSoundVolume = value; } 1316 set { m_collisionSoundVolume = value; }
1268 } 1317 }
1269 1318
1319 public float Buoyancy
1320 {
1321 get
1322 {
1323 if (ParentGroup.RootPart == this)
1324 return m_buoyancy;
1325
1326 return ParentGroup.RootPart.Buoyancy;
1327 }
1328 set
1329 {
1330 if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this)
1331 {
1332 ParentGroup.RootPart.Buoyancy = value;
1333 return;
1334 }
1335 m_buoyancy = value;
1336 if (PhysActor != null)
1337 PhysActor.Buoyancy = value;
1338 }
1339 }
1340
1341 public Vector3 Force
1342 {
1343 get
1344 {
1345 if (ParentGroup.RootPart == this)
1346 return m_force;
1347
1348 return ParentGroup.RootPart.Force;
1349 }
1350
1351 set
1352 {
1353 if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this)
1354 {
1355 ParentGroup.RootPart.Force = value;
1356 return;
1357 }
1358 m_force = value;
1359 if (PhysActor != null)
1360 PhysActor.Force = value;
1361 }
1362 }
1363
1364 public Vector3 Torque
1365 {
1366 get
1367 {
1368 if (ParentGroup.RootPart == this)
1369 return m_torque;
1370
1371 return ParentGroup.RootPart.Torque;
1372 }
1373
1374 set
1375 {
1376 if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this)
1377 {
1378 ParentGroup.RootPart.Torque = value;
1379 return;
1380 }
1381 m_torque = value;
1382 if (PhysActor != null)
1383 PhysActor.Torque = value;
1384 }
1385 }
1386
1387 public byte Material
1388 {
1389 get { return (byte)m_material; }
1390 set
1391 {
1392 if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial)
1393 {
1394 bool update = false;
1395
1396 if (m_material != (Material)value)
1397 {
1398 update = true;
1399 m_material = (Material)value;
1400 }
1401
1402 if (m_friction != SOPMaterialData.friction(m_material))
1403 {
1404 update = true;
1405 m_friction = SOPMaterialData.friction(m_material);
1406 }
1407
1408 if (m_bounce != SOPMaterialData.bounce(m_material))
1409 {
1410 update = true;
1411 m_bounce = SOPMaterialData.bounce(m_material);
1412 }
1413
1414 if (update)
1415 {
1416 if (PhysActor != null)
1417 {
1418 PhysActor.SetMaterial((int)value);
1419 }
1420 if(ParentGroup != null)
1421 ParentGroup.HasGroupChanged = true;
1422 ScheduleFullUpdateIfNone();
1423 UpdatePhysRequired = true;
1424 }
1425 }
1426 }
1427 }
1428
1429 // not a propriety to move to methods place later
1430 private bool HasMesh()
1431 {
1432 if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh))
1433 return true;
1434 return false;
1435 }
1436
1437 // not a propriety to move to methods place later
1438 public byte DefaultPhysicsShapeType()
1439 {
1440 byte type;
1441
1442 if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh))
1443 type = (byte)PhysShapeType.convex;
1444 else
1445 type = (byte)PhysShapeType.prim;
1446
1447 return type;
1448 }
1449
1450 [XmlIgnore]
1451 public bool UsesComplexCost
1452 {
1453 get
1454 {
1455 byte pst = PhysicsShapeType;
1456 if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh())
1457 return true;
1458 return false;
1459 }
1460 }
1461
1462 [XmlIgnore]
1463 public float PhysicsCost
1464 {
1465 get
1466 {
1467 if(PhysicsShapeType == (byte)PhysShapeType.none)
1468 return 0;
1469
1470 float cost = 0.1f;
1471 if (PhysActor != null)
1472// cost += PhysActor.Cost;
1473
1474 if ((Flags & PrimFlags.Physics) != 0)
1475 cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3
1476 return cost;
1477 }
1478 }
1479
1480 [XmlIgnore]
1481 public float StreamingCost
1482 {
1483 get
1484 {
1485
1486
1487 return 0.1f;
1488 }
1489 }
1490
1491 [XmlIgnore]
1492 public float SimulationCost
1493 {
1494 get
1495 {
1496 // ignoring scripts. Don't like considering them for this
1497 if((Flags & PrimFlags.Physics) != 0)
1498 return 1.0f;
1499
1500 return 0.5f;
1501 }
1502 }
1503
1504 public byte PhysicsShapeType
1505 {
1506 get { return m_physicsShapeType; }
1507 set
1508 {
1509 byte oldv = m_physicsShapeType;
1510
1511 if (value >= 0 && value <= (byte)PhysShapeType.convex)
1512 {
1513 if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this)
1514 m_physicsShapeType = DefaultPhysicsShapeType();
1515 else
1516 m_physicsShapeType = value;
1517 }
1518 else
1519 m_physicsShapeType = DefaultPhysicsShapeType();
1520
1521 if (m_physicsShapeType != oldv && ParentGroup != null)
1522 {
1523 if (m_physicsShapeType == (byte)PhysShapeType.none)
1524 {
1525 if (PhysActor != null)
1526 {
1527 Velocity = new Vector3(0, 0, 0);
1528 Acceleration = new Vector3(0, 0, 0);
1529 if (ParentGroup.RootPart == this)
1530 AngularVelocity = new Vector3(0, 0, 0);
1531 ParentGroup.Scene.RemovePhysicalPrim(1);
1532 RemoveFromPhysics();
1533 }
1534 }
1535 else if (PhysActor == null)
1536 ApplyPhysics((uint)Flags, VolumeDetectActive, false);
1537 else
1538 {
1539 PhysActor.PhysicsShapeType = m_physicsShapeType;
1540 if (Shape.SculptEntry)
1541 CheckSculptAndLoad();
1542 }
1543
1544 if (ParentGroup != null)
1545 ParentGroup.HasGroupChanged = true;
1546 }
1547
1548 if (m_physicsShapeType != value)
1549 {
1550 UpdatePhysRequired = true;
1551 }
1552 }
1553 }
1554
1555 public float Density // in kg/m^3
1556 {
1557 get { return m_density; }
1558 set
1559 {
1560 if (value >=1 && value <= 22587.0)
1561 {
1562 m_density = value;
1563 UpdatePhysRequired = true;
1564 }
1565
1566 ScheduleFullUpdateIfNone();
1567
1568 if (ParentGroup != null)
1569 ParentGroup.HasGroupChanged = true;
1570 }
1571 }
1572
1573 public float GravityModifier
1574 {
1575 get { return m_gravitymod; }
1576 set
1577 {
1578 if( value >= -1 && value <=28.0f)
1579 {
1580 m_gravitymod = value;
1581 UpdatePhysRequired = true;
1582 }
1583
1584 ScheduleFullUpdateIfNone();
1585
1586 if (ParentGroup != null)
1587 ParentGroup.HasGroupChanged = true;
1588
1589 }
1590 }
1591
1592 public float Friction
1593 {
1594 get { return m_friction; }
1595 set
1596 {
1597 if (value >= 0 && value <= 255.0f)
1598 {
1599 m_friction = value;
1600 UpdatePhysRequired = true;
1601 }
1602
1603 ScheduleFullUpdateIfNone();
1604
1605 if (ParentGroup != null)
1606 ParentGroup.HasGroupChanged = true;
1607 }
1608 }
1609
1610 public float Bounciness
1611 {
1612 get { return m_bounce; }
1613 set
1614 {
1615 if (value >= 0 && value <= 1.0f)
1616 {
1617 m_bounce = value;
1618 UpdatePhysRequired = true;
1619 }
1620
1621 ScheduleFullUpdateIfNone();
1622
1623 if (ParentGroup != null)
1624 ParentGroup.HasGroupChanged = true;
1625 }
1626 }
1627
1628
1270 #endregion Public Properties with only Get 1629 #endregion Public Properties with only Get
1271 1630
1272 private uint ApplyMask(uint val, bool set, uint mask) 1631 private uint ApplyMask(uint val, bool set, uint mask)
@@ -1432,7 +1791,7 @@ namespace OpenSim.Region.Framework.Scenes
1432 impulse = newimpulse; 1791 impulse = newimpulse;
1433 } 1792 }
1434 1793
1435 ParentGroup.applyAngularImpulse(impulse); 1794 ParentGroup.ApplyAngularImpulse(impulse);
1436 } 1795 }
1437 1796
1438 /// <summary> 1797 /// <summary>
@@ -1442,20 +1801,24 @@ namespace OpenSim.Region.Framework.Scenes
1442 /// </summary> 1801 /// </summary>
1443 /// <param name="impulsei">Vector force</param> 1802 /// <param name="impulsei">Vector force</param>
1444 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> 1803 /// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
1445 public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) 1804
1805 // this is actualy Set Torque.. keeping naming so not to edit lslapi also
1806 public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF)
1446 { 1807 {
1447 Vector3 impulse = impulsei; 1808 Vector3 torque = torquei;
1448 1809
1449 if (localGlobalTF) 1810 if (localGlobalTF)
1450 { 1811 {
1812/*
1451 Quaternion grot = GetWorldRotation(); 1813 Quaternion grot = GetWorldRotation();
1452 Quaternion AXgrot = grot; 1814 Quaternion AXgrot = grot;
1453 Vector3 AXimpulsei = impulsei; 1815 Vector3 AXimpulsei = impulsei;
1454 Vector3 newimpulse = AXimpulsei * AXgrot; 1816 Vector3 newimpulse = AXimpulsei * AXgrot;
1455 impulse = newimpulse; 1817 */
1818 torque *= GetWorldRotation();
1456 } 1819 }
1457 1820
1458 ParentGroup.setAngularImpulse(impulse); 1821 Torque = torque;
1459 } 1822 }
1460 1823
1461 /// <summary> 1824 /// <summary>
@@ -1463,17 +1826,23 @@ namespace OpenSim.Region.Framework.Scenes
1463 /// </summary> 1826 /// </summary>
1464 /// <param name="rootObjectFlags"></param> 1827 /// <param name="rootObjectFlags"></param>
1465 /// <param name="VolumeDetectActive"></param> 1828 /// <param name="VolumeDetectActive"></param>
1466 public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) 1829 /// <param name="building"></param>
1830
1831 public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building)
1467 { 1832 {
1833 VolumeDetectActive = _VolumeDetectActive;
1834
1468 if (!ParentGroup.Scene.CollidablePrims) 1835 if (!ParentGroup.Scene.CollidablePrims)
1469 return; 1836 return;
1470 1837
1471// m_log.DebugFormat( 1838 if (PhysicsShapeType == (byte)PhysShapeType.none)
1472// "[SCENE OBJECT PART]: Applying physics to {0} {1}, m_physicalPrim {2}", 1839 return;
1473// Name, LocalId, UUID, m_physicalPrim); 1840
1841 bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0;
1842 bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0;
1474 1843
1475 bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; 1844 if (_VolumeDetectActive)
1476 bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; 1845 isPhantom = true;
1477 1846
1478 if (IsJoint()) 1847 if (IsJoint())
1479 { 1848 {
@@ -1481,22 +1850,11 @@ namespace OpenSim.Region.Framework.Scenes
1481 } 1850 }
1482 else 1851 else
1483 { 1852 {
1484 // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored 1853 if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment
1485 if (VolumeDetectActive) 1854 && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1486 isPhantom = false; 1855 AddToPhysics(isPhysical, isPhantom, building, true);
1487 1856 else
1488 // 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 1857 PhysActor = null; // just to be sure
1489 // or flexible
1490 if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible))
1491 {
1492 // Added clarification.. since A rigid body is an object that you can kick around, etc.
1493 bool rigidBody = isPhysical && !isPhantom;
1494
1495 PhysicsActor pa = AddToPhysics(rigidBody);
1496
1497 if (pa != null)
1498 pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
1499 }
1500 } 1858 }
1501 } 1859 }
1502 1860
@@ -1548,6 +1906,11 @@ namespace OpenSim.Region.Framework.Scenes
1548 dupe.Category = Category; 1906 dupe.Category = Category;
1549 dupe.m_rezzed = m_rezzed; 1907 dupe.m_rezzed = m_rezzed;
1550 1908
1909 dupe.m_UndoRedo = null;
1910
1911 dupe.IgnoreUndoUpdate = false;
1912 dupe.Undoing = false;
1913
1551 dupe.m_inventory = new SceneObjectPartInventory(dupe); 1914 dupe.m_inventory = new SceneObjectPartInventory(dupe);
1552 dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); 1915 dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone();
1553 1916
@@ -1563,6 +1926,7 @@ namespace OpenSim.Region.Framework.Scenes
1563 1926
1564 // Move afterwards ResetIDs as it clears the localID 1927 // Move afterwards ResetIDs as it clears the localID
1565 dupe.LocalId = localID; 1928 dupe.LocalId = localID;
1929
1566 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. 1930 // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated.
1567 dupe.LastOwnerID = OwnerID; 1931 dupe.LastOwnerID = OwnerID;
1568 1932
@@ -1582,6 +1946,9 @@ namespace OpenSim.Region.Framework.Scenes
1582 dupe.DoPhysicsPropertyUpdate(UsePhysics, true); 1946 dupe.DoPhysicsPropertyUpdate(UsePhysics, true);
1583 } 1947 }
1584 1948
1949 if (dupe.PhysActor != null)
1950 dupe.PhysActor.LocalID = localID;
1951
1585 ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); 1952 ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed);
1586 1953
1587// m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); 1954// m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID);
@@ -1701,6 +2068,7 @@ namespace OpenSim.Region.Framework.Scenes
1701 2068
1702 /// <summary> 2069 /// <summary>
1703 /// Do a physics propery update for this part. 2070 /// Do a physics propery update for this part.
2071 /// now also updates phantom and volume detector
1704 /// </summary> 2072 /// </summary>
1705 /// <param name="UsePhysics"></param> 2073 /// <param name="UsePhysics"></param>
1706 /// <param name="isNew"></param> 2074 /// <param name="isNew"></param>
@@ -1726,61 +2094,69 @@ namespace OpenSim.Region.Framework.Scenes
1726 { 2094 {
1727 if (pa.IsPhysical) // implies UsePhysics==false for this block 2095 if (pa.IsPhysical) // implies UsePhysics==false for this block
1728 { 2096 {
1729 if (!isNew) 2097 if (!isNew) // implies UsePhysics==false for this block
2098 {
1730 ParentGroup.Scene.RemovePhysicalPrim(1); 2099 ParentGroup.Scene.RemovePhysicalPrim(1);
1731 2100
1732 pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; 2101 Velocity = new Vector3(0, 0, 0);
1733 pa.OnOutOfBounds -= PhysicsOutOfBounds; 2102 Acceleration = new Vector3(0, 0, 0);
1734 pa.delink(); 2103 if (ParentGroup.RootPart == this)
2104 AngularVelocity = new Vector3(0, 0, 0);
1735 2105
1736 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) 2106 if (pa.Phantom && !VolumeDetectActive)
1737 { 2107 {
1738 // destroy all joints connected to this now deactivated body 2108 RemoveFromPhysics();
1739 ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); 2109 return;
1740 } 2110 }
1741 2111
1742 // stop client-side interpolation of all joint proxy objects that have just been deleted 2112 pa.IsPhysical = UsePhysics;
1743 // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, 2113 pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate;
1744 // which stops client-side interpolation of deactivated joint proxy objects. 2114 pa.OnOutOfBounds -= PhysicsOutOfBounds;
2115 pa.delink();
2116 if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints)
2117 {
2118 // destroy all joints connected to this now deactivated body
2119 ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa);
2120 }
2121 }
1745 } 2122 }
1746 2123
1747 if (!UsePhysics && !isNew) 2124 if (pa.IsPhysical != UsePhysics)
1748 { 2125 pa.IsPhysical = UsePhysics;
1749 // reset velocity to 0 on physics switch-off. Without that, the client thinks the
1750 // prim still has velocity and continues to interpolate its position along the old
1751 // velocity-vector.
1752 Velocity = new Vector3(0, 0, 0);
1753 Acceleration = new Vector3(0, 0, 0);
1754 AngularVelocity = new Vector3(0, 0, 0);
1755 //RotationalVelocity = new Vector3(0, 0, 0);
1756 }
1757 2126
1758 pa.IsPhysical = UsePhysics; 2127 if (UsePhysics)
2128 {
2129 if (ParentGroup.RootPart.KeyframeMotion != null)
2130 ParentGroup.RootPart.KeyframeMotion.Stop();
2131 ParentGroup.RootPart.KeyframeMotion = null;
2132 ParentGroup.Scene.AddPhysicalPrim(1);
1759 2133
1760 // If we're not what we're supposed to be in the physics scene, recreate ourselves. 2134 PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
1761 //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); 2135 PhysActor.OnOutOfBounds += PhysicsOutOfBounds;
1762 /// that's not wholesome. Had to make Scene public
1763 //PhysActor = null;
1764 2136
1765 if ((Flags & PrimFlags.Phantom) == 0) 2137 if (ParentID != 0 && ParentID != LocalId)
1766 {
1767 if (UsePhysics)
1768 { 2138 {
1769 ParentGroup.Scene.AddPhysicalPrim(1); 2139 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
1770 2140
1771 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; 2141 if (parentPa != null)
1772 pa.OnOutOfBounds += PhysicsOutOfBounds;
1773 if (ParentID != 0 && ParentID != LocalId)
1774 { 2142 {
1775 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; 2143 pa.link(parentPa);
1776
1777 if (parentPa != null)
1778 {
1779 pa.link(parentPa);
1780 }
1781 } 2144 }
1782 } 2145 }
1783 } 2146 }
2147 }
2148
2149 bool phan = ((Flags & PrimFlags.Phantom) != 0);
2150 if (pa.Phantom != phan)
2151 pa.Phantom = phan;
2152
2153// some engines dont' have this check still
2154// if (VolumeDetectActive != pa.IsVolumeDtc)
2155 {
2156 if (VolumeDetectActive)
2157 pa.SetVolumeDetect(1);
2158 else
2159 pa.SetVolumeDetect(0);
1784 } 2160 }
1785 2161
1786 // If this part is a sculpt then delay the physics update until we've asynchronously loaded the 2162 // If this part is a sculpt then delay the physics update until we've asynchronously loaded the
@@ -1899,15 +2275,29 @@ namespace OpenSim.Region.Framework.Scenes
1899 2275
1900 public Vector3 GetGeometricCenter() 2276 public Vector3 GetGeometricCenter()
1901 { 2277 {
1902 PhysicsActor pa = PhysActor; 2278 // this is not real geometric center but a average of positions relative to root prim acording to
1903 2279 // http://wiki.secondlife.com/wiki/llGetGeometricCenter
1904 if (pa != null) 2280 // ignoring tortured prims details since sl also seems to ignore
1905 return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); 2281 // so no real use in doing it on physics
1906 else 2282 if (ParentGroup.IsDeleted)
1907 return new Vector3(0, 0, 0); 2283 return new Vector3(0, 0, 0);
2284
2285 return ParentGroup.GetGeometricCenter();
2286
2287 /*
2288 PhysicsActor pa = PhysActor;
2289
2290 if (pa != null)
2291 {
2292 Vector3 vtmp = pa.CenterOfMass;
2293 return vtmp;
2294 }
2295 else
2296 return new Vector3(0, 0, 0);
2297 */
1908 } 2298 }
1909 2299
1910 public float GetMass() 2300 public float GetMass()
1911 { 2301 {
1912 PhysicsActor pa = PhysActor; 2302 PhysicsActor pa = PhysActor;
1913 2303
@@ -1919,12 +2309,7 @@ namespace OpenSim.Region.Framework.Scenes
1919 2309
1920 public Vector3 GetForce() 2310 public Vector3 GetForce()
1921 { 2311 {
1922 PhysicsActor pa = PhysActor; 2312 return Force;
1923
1924 if (pa != null)
1925 return pa.Force;
1926 else
1927 return Vector3.Zero;
1928 } 2313 }
1929 2314
1930 /// <summary> 2315 /// <summary>
@@ -2560,9 +2945,9 @@ namespace OpenSim.Region.Framework.Scenes
2560 Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); 2945 Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0);
2561 2946
2562 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) 2947 if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N)
2563 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) 2948 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S)
2564 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) 2949 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E)
2565 | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) 2950 || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W))
2566 { 2951 {
2567 ParentGroup.AbsolutePosition = newpos; 2952 ParentGroup.AbsolutePosition = newpos;
2568 return; 2953 return;
@@ -2584,17 +2969,18 @@ namespace OpenSim.Region.Framework.Scenes
2584 //Trys to fetch sound id from prim's inventory. 2969 //Trys to fetch sound id from prim's inventory.
2585 //Prim's inventory doesn't support non script items yet 2970 //Prim's inventory doesn't support non script items yet
2586 2971
2587 lock (TaskInventory) 2972 TaskInventory.LockItemsForRead(true);
2973
2974 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2588 { 2975 {
2589 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 2976 if (item.Value.Name == sound)
2590 { 2977 {
2591 if (item.Value.Name == sound) 2978 soundID = item.Value.ItemID;
2592 { 2979 break;
2593 soundID = item.Value.ItemID;
2594 break;
2595 }
2596 } 2980 }
2597 } 2981 }
2982
2983 TaskInventory.LockItemsForRead(false);
2598 } 2984 }
2599 2985
2600 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) 2986 ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp)
@@ -2717,6 +3103,19 @@ namespace OpenSim.Region.Framework.Scenes
2717 APIDTarget = Quaternion.Identity; 3103 APIDTarget = Quaternion.Identity;
2718 } 3104 }
2719 3105
3106
3107
3108 public void ScheduleFullUpdateIfNone()
3109 {
3110 if (ParentGroup == null)
3111 return;
3112
3113// ??? ParentGroup.HasGroupChanged = true;
3114
3115 if (UpdateFlag != UpdateRequired.FULL)
3116 ScheduleFullUpdate();
3117 }
3118
2720 /// <summary> 3119 /// <summary>
2721 /// Schedules this prim for a full update 3120 /// Schedules this prim for a full update
2722 /// </summary> 3121 /// </summary>
@@ -2918,8 +3317,8 @@ namespace OpenSim.Region.Framework.Scenes
2918 { 3317 {
2919 const float ROTATION_TOLERANCE = 0.01f; 3318 const float ROTATION_TOLERANCE = 0.01f;
2920 const float VELOCITY_TOLERANCE = 0.001f; 3319 const float VELOCITY_TOLERANCE = 0.001f;
2921 const float POSITION_TOLERANCE = 0.05f; 3320 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
2922 const int TIME_MS_TOLERANCE = 3000; 3321 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
2923 3322
2924 switch (UpdateFlag) 3323 switch (UpdateFlag)
2925 { 3324 {
@@ -2981,17 +3380,16 @@ namespace OpenSim.Region.Framework.Scenes
2981 if (!UUID.TryParse(sound, out soundID)) 3380 if (!UUID.TryParse(sound, out soundID))
2982 { 3381 {
2983 // search sound file from inventory 3382 // search sound file from inventory
2984 lock (TaskInventory) 3383 TaskInventory.LockItemsForRead(true);
3384 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
2985 { 3385 {
2986 foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) 3386 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
2987 { 3387 {
2988 if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) 3388 soundID = item.Value.ItemID;
2989 { 3389 break;
2990 soundID = item.Value.ItemID;
2991 break;
2992 }
2993 } 3390 }
2994 } 3391 }
3392 TaskInventory.LockItemsForRead(false);
2995 } 3393 }
2996 3394
2997 if (soundID == UUID.Zero) 3395 if (soundID == UUID.Zero)
@@ -3076,10 +3474,13 @@ namespace OpenSim.Region.Framework.Scenes
3076 3474
3077 public void SetBuoyancy(float fvalue) 3475 public void SetBuoyancy(float fvalue)
3078 { 3476 {
3079 PhysicsActor pa = PhysActor; 3477 Buoyancy = fvalue;
3080 3478/*
3081 if (pa != null) 3479 if (PhysActor != null)
3082 pa.Buoyancy = fvalue; 3480 {
3481 PhysActor.Buoyancy = fvalue;
3482 }
3483 */
3083 } 3484 }
3084 3485
3085 public void SetDieAtEdge(bool p) 3486 public void SetDieAtEdge(bool p)
@@ -3095,47 +3496,111 @@ namespace OpenSim.Region.Framework.Scenes
3095 PhysicsActor pa = PhysActor; 3496 PhysicsActor pa = PhysActor;
3096 3497
3097 if (pa != null) 3498 if (pa != null)
3098 pa.FloatOnWater = floatYN == 1; 3499 pa.FloatOnWater = (floatYN == 1);
3099 } 3500 }
3100 3501
3101 public void SetForce(Vector3 force) 3502 public void SetForce(Vector3 force)
3102 { 3503 {
3103 PhysicsActor pa = PhysActor; 3504 Force = force;
3505 }
3104 3506
3105 if (pa != null) 3507 public SOPVehicle sopVehicle
3106 pa.Force = force; 3508 {
3509 get
3510 {
3511 return m_vehicle;
3512 }
3513 set
3514 {
3515 m_vehicle = value;
3516 }
3517 }
3518
3519
3520 public int VehicleType
3521 {
3522 get
3523 {
3524 if (m_vehicle == null)
3525 return (int)Vehicle.TYPE_NONE;
3526 else
3527 return (int)m_vehicle.Type;
3528 }
3529 set
3530 {
3531 SetVehicleType(value);
3532 }
3107 } 3533 }
3108 3534
3109 public void SetVehicleType(int type) 3535 public void SetVehicleType(int type)
3110 { 3536 {
3111 PhysicsActor pa = PhysActor; 3537 m_vehicle = null;
3538
3539 if (type == (int)Vehicle.TYPE_NONE)
3540 {
3541 if (_parentID ==0 && PhysActor != null)
3542 PhysActor.VehicleType = (int)Vehicle.TYPE_NONE;
3543 return;
3544 }
3545 m_vehicle = new SOPVehicle();
3546 m_vehicle.ProcessTypeChange((Vehicle)type);
3547 {
3548 if (_parentID ==0 && PhysActor != null)
3549 PhysActor.VehicleType = type;
3550 return;
3551 }
3552 }
3112 3553
3113 if (pa != null) 3554 public void SetVehicleFlags(int param, bool remove)
3114 pa.VehicleType = type; 3555 {
3556 if (m_vehicle == null)
3557 return;
3558
3559 m_vehicle.ProcessVehicleFlags(param, remove);
3560
3561 if (_parentID ==0 && PhysActor != null)
3562 {
3563 PhysActor.VehicleFlags(param, remove);
3564 }
3115 } 3565 }
3116 3566
3117 public void SetVehicleFloatParam(int param, float value) 3567 public void SetVehicleFloatParam(int param, float value)
3118 { 3568 {
3119 PhysicsActor pa = PhysActor; 3569 if (m_vehicle == null)
3570 return;
3120 3571
3121 if (pa != null) 3572 m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value);
3122 pa.VehicleFloatParam(param, value); 3573
3574 if (_parentID == 0 && PhysActor != null)
3575 {
3576 PhysActor.VehicleFloatParam(param, value);
3577 }
3123 } 3578 }
3124 3579
3125 public void SetVehicleVectorParam(int param, Vector3 value) 3580 public void SetVehicleVectorParam(int param, Vector3 value)
3126 { 3581 {
3127 PhysicsActor pa = PhysActor; 3582 if (m_vehicle == null)
3583 return;
3128 3584
3129 if (pa != null) 3585 m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value);
3130 pa.VehicleVectorParam(param, value); 3586
3587 if (_parentID == 0 && PhysActor != null)
3588 {
3589 PhysActor.VehicleVectorParam(param, value);
3590 }
3131 } 3591 }
3132 3592
3133 public void SetVehicleRotationParam(int param, Quaternion rotation) 3593 public void SetVehicleRotationParam(int param, Quaternion rotation)
3134 { 3594 {
3135 PhysicsActor pa = PhysActor; 3595 if (m_vehicle == null)
3596 return;
3136 3597
3137 if (pa != null) 3598 m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation);
3138 pa.VehicleRotationParam(param, rotation); 3599
3600 if (_parentID == 0 && PhysActor != null)
3601 {
3602 PhysActor.VehicleRotationParam(param, rotation);
3603 }
3139 } 3604 }
3140 3605
3141 /// <summary> 3606 /// <summary>
@@ -3319,13 +3784,6 @@ namespace OpenSim.Region.Framework.Scenes
3319 hasProfileCut = hasDimple; // is it the same thing? 3784 hasProfileCut = hasDimple; // is it the same thing?
3320 } 3785 }
3321 3786
3322 public void SetVehicleFlags(int param, bool remove)
3323 {
3324 if (PhysActor != null)
3325 {
3326 PhysActor.VehicleFlags(param, remove);
3327 }
3328 }
3329 3787
3330 public void SetGroup(UUID groupID, IClientAPI client) 3788 public void SetGroup(UUID groupID, IClientAPI client)
3331 { 3789 {
@@ -3428,68 +3886,18 @@ namespace OpenSim.Region.Framework.Scenes
3428 //ParentGroup.ScheduleGroupForFullUpdate(); 3886 //ParentGroup.ScheduleGroupForFullUpdate();
3429 } 3887 }
3430 3888
3431 public void StoreUndoState() 3889 public void StoreUndoState(ObjectChangeType change)
3432 { 3890 {
3433 StoreUndoState(false); 3891 if (m_UndoRedo == null)
3434 } 3892 m_UndoRedo = new UndoRedoState(5);
3435 3893
3436 public void StoreUndoState(bool forGroup) 3894 lock (m_UndoRedo)
3437 {
3438 if (!Undoing)
3439 { 3895 {
3440 if (!IgnoreUndoUpdate) 3896 if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended
3441 { 3897 {
3442 if (ParentGroup != null) 3898 m_UndoRedo.StoreUndo(this, change);
3443 {
3444 lock (m_undo)
3445 {
3446 if (m_undo.Count > 0)
3447 {
3448 UndoState last = m_undo.Peek();
3449 if (last != null)
3450 {
3451 // TODO: May need to fix for group comparison
3452 if (last.Compare(this))
3453 {
3454 // m_log.DebugFormat(
3455 // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}",
3456 // Name, LocalId, m_undo.Count);
3457
3458 return;
3459 }
3460 }
3461 }
3462
3463 // m_log.DebugFormat(
3464 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3465 // Name, LocalId, forGroup, m_undo.Count);
3466
3467 if (ParentGroup.GetSceneMaxUndo() > 0)
3468 {
3469 UndoState nUndo = new UndoState(this, forGroup);
3470
3471 m_undo.Push(nUndo);
3472
3473 if (m_redo.Count > 0)
3474 m_redo.Clear();
3475
3476 // m_log.DebugFormat(
3477 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3478 // Name, LocalId, forGroup, m_undo.Count);
3479 }
3480 }
3481 }
3482 } 3899 }
3483// else
3484// {
3485// m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId);
3486// }
3487 } 3900 }
3488// else
3489// {
3490// m_log.DebugFormat(
3491// "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId);
3492// }
3493 } 3901 }
3494 3902
3495 /// <summary> 3903 /// <summary>
@@ -3499,84 +3907,46 @@ namespace OpenSim.Region.Framework.Scenes
3499 { 3907 {
3500 get 3908 get
3501 { 3909 {
3502 lock (m_undo) 3910 if (m_UndoRedo == null)
3503 return m_undo.Count; 3911 return 0;
3912 return m_UndoRedo.Count;
3504 } 3913 }
3505 } 3914 }
3506 3915
3507 public void Undo() 3916 public void Undo()
3508 { 3917 {
3509 lock (m_undo) 3918 if (m_UndoRedo == null || Undoing || ParentGroup == null)
3510 { 3919 return;
3511// m_log.DebugFormat(
3512// "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}",
3513// Name, LocalId, m_undo.Count);
3514
3515 if (m_undo.Count > 0)
3516 {
3517 UndoState goback = m_undo.Pop();
3518
3519 if (goback != null)
3520 {
3521 UndoState nUndo = null;
3522
3523 if (ParentGroup.GetSceneMaxUndo() > 0)
3524 {
3525 nUndo = new UndoState(this, goback.ForGroup);
3526 }
3527
3528 goback.PlaybackState(this);
3529
3530 if (nUndo != null)
3531 m_redo.Push(nUndo);
3532 }
3533 }
3534 3920
3535// m_log.DebugFormat( 3921 lock (m_UndoRedo)
3536// "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", 3922 {
3537// Name, LocalId, m_undo.Count); 3923 Undoing = true;
3924 m_UndoRedo.Undo(this);
3925 Undoing = false;
3538 } 3926 }
3539 } 3927 }
3540 3928
3541 public void Redo() 3929 public void Redo()
3542 { 3930 {
3543 lock (m_undo) 3931 if (m_UndoRedo == null || Undoing || ParentGroup == null)
3544 { 3932 return;
3545// m_log.DebugFormat(
3546// "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}",
3547// Name, LocalId, m_redo.Count);
3548
3549 if (m_redo.Count > 0)
3550 {
3551 UndoState gofwd = m_redo.Pop();
3552
3553 if (gofwd != null)
3554 {
3555 if (ParentGroup.GetSceneMaxUndo() > 0)
3556 {
3557 UndoState nUndo = new UndoState(this, gofwd.ForGroup);
3558
3559 m_undo.Push(nUndo);
3560 }
3561
3562 gofwd.PlayfwdState(this);
3563 }
3564 3933
3565// m_log.DebugFormat( 3934 lock (m_UndoRedo)
3566// "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", 3935 {
3567// Name, LocalId, m_redo.Count); 3936 Undoing = true;
3568 } 3937 m_UndoRedo.Redo(this);
3938 Undoing = false;
3569 } 3939 }
3570 } 3940 }
3571 3941
3572 public void ClearUndoState() 3942 public void ClearUndoState()
3573 { 3943 {
3574// m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); 3944 if (m_UndoRedo == null || Undoing)
3945 return;
3575 3946
3576 lock (m_undo) 3947 lock (m_UndoRedo)
3577 { 3948 {
3578 m_undo.Clear(); 3949 m_UndoRedo.Clear();
3579 m_redo.Clear();
3580 } 3950 }
3581 } 3951 }
3582 3952
@@ -4206,6 +4576,27 @@ namespace OpenSim.Region.Framework.Scenes
4206 } 4576 }
4207 } 4577 }
4208 4578
4579
4580 public void UpdateExtraPhysics(ExtraPhysicsData physdata)
4581 {
4582 if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null)
4583 return;
4584
4585 if (PhysicsShapeType != (byte)physdata.PhysShapeType)
4586 {
4587 PhysicsShapeType = (byte)physdata.PhysShapeType;
4588
4589 }
4590
4591 if(Density != physdata.Density)
4592 Density = physdata.Density;
4593 if(GravityModifier != physdata.GravitationModifier)
4594 GravityModifier = physdata.GravitationModifier;
4595 if(Friction != physdata.Friction)
4596 Friction = physdata.Friction;
4597 if(Bounciness != physdata.Bounce)
4598 Bounciness = physdata.Bounce;
4599 }
4209 /// <summary> 4600 /// <summary>
4210 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. 4601 /// Update the flags on this prim. This covers properties such as phantom, physics and temporary.
4211 /// </summary> 4602 /// </summary>
@@ -4213,7 +4604,7 @@ namespace OpenSim.Region.Framework.Scenes
4213 /// <param name="SetTemporary"></param> 4604 /// <param name="SetTemporary"></param>
4214 /// <param name="SetPhantom"></param> 4605 /// <param name="SetPhantom"></param>
4215 /// <param name="SetVD"></param> 4606 /// <param name="SetVD"></param>
4216 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) 4607 public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building)
4217 { 4608 {
4218 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); 4609 bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0);
4219 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); 4610 bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0);
@@ -4223,219 +4614,205 @@ namespace OpenSim.Region.Framework.Scenes
4223 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) 4614 if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD))
4224 return; 4615 return;
4225 4616
4226 PhysicsActor pa = PhysActor; 4617 VolumeDetectActive = SetVD;
4227
4228 // Special cases for VD. VD can only be called from a script
4229 // and can't be combined with changes to other states. So we can rely
4230 // that...
4231 // ... if VD is changed, all others are not.
4232 // ... if one of the others is changed, VD is not.
4233 if (SetVD) // VD is active, special logic applies
4234 {
4235 // State machine logic for VolumeDetect
4236 // More logic below
4237 bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom;
4238 4618
4239 if (phanReset) // Phantom changes from on to off switch VD off too 4619 // volume detector implies phantom
4240 { 4620 if (VolumeDetectActive)
4241 SetVD = false; // Switch it of for the course of this routine
4242 VolumeDetectActive = false; // and also permanently
4243
4244 if (pa != null)
4245 pa.SetVolumeDetect(0); // Let physics know about it too
4246 }
4247 else
4248 {
4249 // If volumedetect is active we don't want phantom to be applied.
4250 // If this is a new call to VD out of the state "phantom"
4251 // this will also cause the prim to be visible to physics
4252 SetPhantom = false;
4253 }
4254 }
4255
4256 if (UsePhysics && IsJoint())
4257 {
4258 SetPhantom = true; 4621 SetPhantom = true;
4259 }
4260 4622
4261 if (UsePhysics) 4623 if (UsePhysics)
4262 {
4263 AddFlag(PrimFlags.Physics); 4624 AddFlag(PrimFlags.Physics);
4264 if (!wasUsingPhysics)
4265 {
4266 DoPhysicsPropertyUpdate(UsePhysics, false);
4267
4268 if (!ParentGroup.IsDeleted)
4269 {
4270 if (LocalId == ParentGroup.RootPart.LocalId)
4271 {
4272 ParentGroup.CheckSculptAndLoad();
4273 }
4274 }
4275 }
4276 }
4277 else 4625 else
4278 {
4279 RemFlag(PrimFlags.Physics); 4626 RemFlag(PrimFlags.Physics);
4280 if (wasUsingPhysics)
4281 {
4282 DoPhysicsPropertyUpdate(UsePhysics, false);
4283 }
4284 }
4285 4627
4286 if (SetPhantom 4628 if (SetPhantom)
4287 || ParentGroup.IsAttachment
4288 || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints
4289 {
4290 AddFlag(PrimFlags.Phantom); 4629 AddFlag(PrimFlags.Phantom);
4630 else
4631 RemFlag(PrimFlags.Phantom);
4291 4632
4292 if (PhysActor != null) 4633 if (SetTemporary)
4634 AddFlag(PrimFlags.TemporaryOnRez);
4635 else
4636 RemFlag(PrimFlags.TemporaryOnRez);
4637
4638
4639 if (ParentGroup.Scene == null)
4640 return;
4641
4642 PhysicsActor pa = PhysActor;
4643
4644 if (pa != null && building && pa.Building != building)
4645 pa.Building = building;
4646
4647 if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none
4648 || (Shape.PathCurve == (byte)Extrusion.Flexible))
4649 {
4650 if (pa != null)
4293 { 4651 {
4652 ParentGroup.Scene.RemovePhysicalPrim(1);
4294 RemoveFromPhysics(); 4653 RemoveFromPhysics();
4295 pa = null;
4296 } 4654 }
4655
4656 Velocity = new Vector3(0, 0, 0);
4657 Acceleration = new Vector3(0, 0, 0);
4658 if (ParentGroup.RootPart == this)
4659 AngularVelocity = new Vector3(0, 0, 0);
4297 } 4660 }
4298 else // Not phantom 4661 else
4299 { 4662 {
4300 RemFlag(PrimFlags.Phantom); 4663 if (ParentGroup.Scene.CollidablePrims)
4301
4302 if (ParentGroup.Scene == null)
4303 return;
4304
4305 if (ParentGroup.Scene.CollidablePrims && pa == null)
4306 { 4664 {
4307 pa = AddToPhysics(UsePhysics); 4665 if (pa == null)
4308
4309 if (pa != null)
4310 { 4666 {
4311 pa.SetMaterial(Material); 4667 AddToPhysics(UsePhysics, SetPhantom, building , false);
4312 DoPhysicsPropertyUpdate(UsePhysics, true); 4668 pa = PhysActor;
4313 4669
4314 if (!ParentGroup.IsDeleted) 4670 if (pa != null)
4315 { 4671 {
4316 if (LocalId == ParentGroup.RootPart.LocalId) 4672 if (
4673// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4674// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4675// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4676// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4677// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4678// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4679 ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
4680// (CollisionSound != UUID.Zero)
4681 )
4317 { 4682 {
4318 ParentGroup.CheckSculptAndLoad(); 4683 pa.OnCollisionUpdate += PhysicsCollision;
4684 pa.SubscribeEvents(1000);
4319 } 4685 }
4320 } 4686 }
4321
4322 if (
4323 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4324 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4325 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4326 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4327 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4328 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4329 (CollisionSound != UUID.Zero)
4330 )
4331 {
4332 pa.OnCollisionUpdate += PhysicsCollision;
4333 pa.SubscribeEvents(1000);
4334 }
4335 } 4687 }
4336 } 4688 else // it already has a physical representation
4337 else // it already has a physical representation
4338 {
4339 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim
4340
4341 if (!ParentGroup.IsDeleted)
4342 { 4689 {
4343 if (LocalId == ParentGroup.RootPart.LocalId) 4690 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
4344 { 4691 /* moved into DoPhysicsPropertyUpdate
4345 ParentGroup.CheckSculptAndLoad(); 4692 if(VolumeDetectActive)
4346 } 4693 pa.SetVolumeDetect(1);
4694 else
4695 pa.SetVolumeDetect(0);
4696 */
4697 if (pa.Building != building)
4698 pa.Building = building;
4347 } 4699 }
4348 } 4700 }
4349 } 4701 }
4350
4351 if (SetVD)
4352 {
4353 // If the above logic worked (this is urgent candidate to unit tests!)
4354 // we now have a physicsactor.
4355 // Defensive programming calls for a check here.
4356 // Better would be throwing an exception that could be catched by a unit test as the internal
4357 // logic should make sure, this Physactor is always here.
4358 if (pa != null)
4359 {
4360 pa.SetVolumeDetect(1);
4361 AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
4362 VolumeDetectActive = true;
4363 }
4364 }
4365 else
4366 {
4367 // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
4368 // (mumbles, well, at least if you have infinte CPU powers :-))
4369 if (pa != null)
4370 pa.SetVolumeDetect(0);
4371
4372 VolumeDetectActive = false;
4373 }
4374
4375 if (SetTemporary)
4376 {
4377 AddFlag(PrimFlags.TemporaryOnRez);
4378 }
4379 else
4380 {
4381 RemFlag(PrimFlags.TemporaryOnRez);
4382 }
4383 4702
4384 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); 4703 // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
4385 4704
4705 // and last in case we have a new actor and not building
4706
4386 if (ParentGroup != null) 4707 if (ParentGroup != null)
4387 { 4708 {
4388 ParentGroup.HasGroupChanged = true; 4709 ParentGroup.HasGroupChanged = true;
4389 ScheduleFullUpdate(); 4710 ScheduleFullUpdate();
4390 } 4711 }
4391 4712
4392// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); 4713// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags);
4393 } 4714 }
4394 4715
4395 /// <summary> 4716 /// <summary>
4396 /// Adds this part to the physics scene. 4717 /// Adds this part to the physics scene.
4718 /// and sets the PhysActor property
4397 /// </summary> 4719 /// </summary>
4398 /// <remarks>This method also sets the PhysActor property.</remarks> 4720 /// <param name="isPhysical">Add this prim as physical.</param>
4399 /// <param name="rigidBody">Add this prim with a rigid body.</param> 4721 /// <param name="isPhantom">Add this prim as phantom.</param>
4400 /// <returns> 4722 /// <param name="building">tells physics to delay full construction of object</param>
4401 /// The physics actor. null if there was a failure. 4723 /// <param name="applyDynamics">applies velocities, force and torque</param>
4402 /// </returns> 4724 private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics)
4403 private PhysicsActor AddToPhysics(bool rigidBody) 4725 {
4404 {
4405 PhysicsActor pa; 4726 PhysicsActor pa;
4406 4727
4728 Vector3 velocity = Velocity;
4729 Vector3 rotationalVelocity = AngularVelocity;;
4730
4407 try 4731 try
4408 { 4732 {
4409 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( 4733 pa = ParentGroup.Scene.PhysicsScene.AddPrimShape(
4410 string.Format("{0}/{1}", Name, UUID), 4734 string.Format("{0}/{1}", Name, UUID),
4411 Shape, 4735 Shape,
4412 AbsolutePosition, 4736 AbsolutePosition,
4413 Scale, 4737 Scale,
4414 RotationOffset, 4738 GetWorldRotation(),
4415 rigidBody, 4739 isPhysical,
4416 m_localId); 4740 isPhantom,
4741 PhysicsShapeType,
4742 m_localId);
4417 } 4743 }
4418 catch 4744 catch (Exception ex)
4419 { 4745 {
4420 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); 4746 m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message);
4421 pa = null; 4747 pa = null;
4422 } 4748 }
4423 4749
4424 // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical
4425 // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor
4426 // being set.
4427 PhysActor = pa;
4428
4429 // Basic Physics can also return null as well as an exception catch.
4430 if (pa != null) 4750 if (pa != null)
4431 { 4751 {
4432 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info 4752 pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info
4433 pa.SetMaterial(Material); 4753 pa.SetMaterial(Material);
4434 DoPhysicsPropertyUpdate(rigidBody, true); 4754
4755 if (VolumeDetectActive) // change if not the default only
4756 pa.SetVolumeDetect(1);
4757
4758 if (m_vehicle != null && LocalId == ParentGroup.RootPart.LocalId)
4759 m_vehicle.SetVehicle(pa);
4760
4761 // we are going to tell rest of code about physics so better have this here
4762 PhysActor = pa;
4763
4764 // DoPhysicsPropertyUpdate(isPhysical, true);
4765 // lets expand it here just with what it really needs to do
4766
4767 if (isPhysical)
4768 {
4769 if (ParentGroup.RootPart.KeyframeMotion != null)
4770 ParentGroup.RootPart.KeyframeMotion.Stop();
4771 ParentGroup.RootPart.KeyframeMotion = null;
4772 ParentGroup.Scene.AddPhysicalPrim(1);
4773
4774 pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate;
4775 pa.OnOutOfBounds += PhysicsOutOfBounds;
4776
4777 if (ParentID != 0 && ParentID != LocalId)
4778 {
4779 PhysicsActor parentPa = ParentGroup.RootPart.PhysActor;
4780
4781 if (parentPa != null)
4782 {
4783 pa.link(parentPa);
4784 }
4785 }
4786 }
4787
4788 if (applyDynamics)
4789 // do independent of isphysical so parameters get setted (at least some)
4790 {
4791 Velocity = velocity;
4792 AngularVelocity = rotationalVelocity;
4793 pa.Velocity = velocity;
4794 pa.RotationalVelocity = rotationalVelocity;
4795
4796 // if not vehicle and root part apply force and torque
4797 if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE)
4798 && LocalId == ParentGroup.RootPart.LocalId)
4799 {
4800 pa.Force = Force;
4801 pa.Torque = Torque;
4802 }
4803 }
4804
4805 if (Shape.SculptEntry)
4806 CheckSculptAndLoad();
4807 else
4808 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa);
4809
4810 if (!building)
4811 pa.Building = false;
4435 } 4812 }
4436 4813
4437 return pa; 4814 PhysActor = pa;
4438 } 4815 }
4439 4816
4440 /// <summary> 4817 /// <summary>
4441 /// This removes the part from the physics scene. 4818 /// This removes the part from the physics scene.
@@ -4642,33 +5019,28 @@ namespace OpenSim.Region.Framework.Scenes
4642 } 5019 }
4643 5020
4644 PhysicsActor pa = PhysActor; 5021 PhysicsActor pa = PhysActor;
4645 5022 if (pa != null)
4646 if (
4647 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4648 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4649 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4650 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4651 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4652 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4653 (CollisionSound != UUID.Zero)
4654 )
4655 { 5023 {
4656 // subscribe to physics updates. 5024 if (
4657 if (pa != null) 5025// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
5026// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
5027// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
5028// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
5029// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
5030// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
5031 ((AggregateScriptEvents & PhyscicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
5032 )
4658 { 5033 {
5034 // subscribe to physics updates.
4659 pa.OnCollisionUpdate += PhysicsCollision; 5035 pa.OnCollisionUpdate += PhysicsCollision;
4660 pa.SubscribeEvents(1000); 5036 pa.SubscribeEvents(1000);
4661 } 5037 }
4662 } 5038 else
4663 else
4664 {
4665 if (pa != null)
4666 { 5039 {
4667 pa.UnSubscribeEvents(); 5040 pa.UnSubscribeEvents();
4668 pa.OnCollisionUpdate -= PhysicsCollision; 5041 pa.OnCollisionUpdate -= PhysicsCollision;
4669 } 5042 }
4670 } 5043 }
4671
4672 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) 5044 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
4673 //{ 5045 //{
4674 // ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting; 5046 // ParentGroup.Scene.EventManager.OnScriptTimerEvent += handleTimerAccounting;
@@ -4795,5 +5167,17 @@ namespace OpenSim.Region.Framework.Scenes
4795 Color color = Color; 5167 Color color = Color;
4796 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); 5168 return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A));
4797 } 5169 }
5170
5171 public void ResetOwnerChangeFlag()
5172 {
5173 List<UUID> inv = Inventory.GetInventoryList();
5174
5175 foreach (UUID itemID in inv)
5176 {
5177 TaskInventoryItem item = Inventory.GetInventoryItem(itemID);
5178 item.OwnerChanged = false;
5179 Inventory.UpdateInventoryItem(item, false, false);
5180 }
5181 }
4798 } 5182 }
4799} 5183}