diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 253 |
1 files changed, 107 insertions, 146 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 801a7db..23a7021 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -415,10 +415,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
415 | set | 415 | set |
416 | { | 416 | { |
417 | m_name = value; | 417 | m_name = value; |
418 | PhysicsActor pa = PhysActor; | 418 | if (PhysActor != null) |
419 | if (pa != null) | ||
420 | { | 419 | { |
421 | pa.SOPName = value; | 420 | PhysActor.SOPName = value; |
422 | } | 421 | } |
423 | } | 422 | } |
424 | } | 423 | } |
@@ -428,11 +427,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
428 | get { return (byte) m_material; } | 427 | get { return (byte) m_material; } |
429 | set | 428 | set |
430 | { | 429 | { |
431 | PhysicsActor pa = PhysActor; | ||
432 | m_material = (Material)value; | 430 | m_material = (Material)value; |
433 | if (pa != null) | 431 | if (PhysActor != null) |
434 | { | 432 | { |
435 | pa.SetMaterial((int)value); | 433 | PhysActor.SetMaterial((int)value); |
436 | } | 434 | } |
437 | } | 435 | } |
438 | } | 436 | } |
@@ -503,12 +501,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
503 | get | 501 | get |
504 | { | 502 | { |
505 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 503 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
506 | PhysicsActor pa = PhysActor; | 504 | if (PhysActor != null && _parentID == 0) |
507 | if (pa != null && _parentID == 0) | ||
508 | { | 505 | { |
509 | m_groupPosition.X = pa.Position.X; | 506 | m_groupPosition.X = PhysActor.Position.X; |
510 | m_groupPosition.Y = pa.Position.Y; | 507 | m_groupPosition.Y = PhysActor.Position.Y; |
511 | m_groupPosition.Z = pa.Position.Z; | 508 | m_groupPosition.Z = PhysActor.Position.Z; |
512 | } | 509 | } |
513 | 510 | ||
514 | if (IsAttachment) | 511 | if (IsAttachment) |
@@ -528,27 +525,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
528 | 525 | ||
529 | m_groupPosition = value; | 526 | m_groupPosition = value; |
530 | 527 | ||
531 | PhysicsActor pa = PhysActor; | 528 | if (PhysActor != null) |
532 | if (pa != null) | ||
533 | { | 529 | { |
534 | try | 530 | try |
535 | { | 531 | { |
536 | // Root prim actually goes at Position | 532 | // Root prim actually goes at Position |
537 | if (_parentID == 0) | 533 | if (_parentID == 0) |
538 | { | 534 | { |
539 | pa.Position = new PhysicsVector(value.X, value.Y, value.Z); | 535 | PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); |
540 | } | 536 | } |
541 | else | 537 | else |
542 | { | 538 | { |
543 | // To move the child prim in respect to the group position and rotation we have to calculate | 539 | // To move the child prim in respect to the group position and rotation we have to calculate |
544 | Vector3 resultingposition = GetWorldPosition(); | 540 | Vector3 resultingposition = GetWorldPosition(); |
545 | pa.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); | 541 | PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); |
546 | Quaternion resultingrot = GetWorldRotation(); | 542 | Quaternion resultingrot = GetWorldRotation(); |
547 | pa.Orientation = resultingrot; | 543 | PhysActor.Orientation = resultingrot; |
548 | } | 544 | } |
549 | 545 | ||
550 | // Tell the physics engines that this prim changed. | 546 | // Tell the physics engines that this prim changed. |
551 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 547 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
552 | } | 548 | } |
553 | catch (Exception e) | 549 | catch (Exception e) |
554 | { | 550 | { |
@@ -581,16 +577,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
581 | 577 | ||
582 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 578 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
583 | { | 579 | { |
584 | PhysicsActor pa = PhysActor; | 580 | if (_parentID != 0 && PhysActor != null) |
585 | if (_parentID != 0 && pa != null) | ||
586 | { | 581 | { |
587 | Vector3 resultingposition = GetWorldPosition(); | 582 | Vector3 resultingposition = GetWorldPosition(); |
588 | pa.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); | 583 | PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); |
589 | Quaternion resultingrot = GetWorldRotation(); | 584 | Quaternion resultingrot = GetWorldRotation(); |
590 | pa.Orientation = resultingrot; | 585 | PhysActor.Orientation = resultingrot; |
591 | 586 | ||
592 | // Tell the physics engines that this prim changed. | 587 | // Tell the physics engines that this prim changed. |
593 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 588 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
594 | } | 589 | } |
595 | } | 590 | } |
596 | } | 591 | } |
@@ -600,14 +595,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
600 | { | 595 | { |
601 | get | 596 | get |
602 | { | 597 | { |
603 | PhysicsActor pa = PhysActor; | ||
604 | // We don't want the physics engine mucking up the rotations in a linkset | 598 | // We don't want the physics engine mucking up the rotations in a linkset |
605 | if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (pa != null)) | 599 | if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (PhysActor != null)) |
606 | { | 600 | { |
607 | if (pa.Orientation.X != 0 || pa.Orientation.Y != 0 | 601 | if (PhysActor.Orientation.X != 0 || PhysActor.Orientation.Y != 0 |
608 | || pa.Orientation.Z != 0 || pa.Orientation.W != 0) | 602 | || PhysActor.Orientation.Z != 0 || PhysActor.Orientation.W != 0) |
609 | { | 603 | { |
610 | m_rotationOffset = pa.Orientation; | 604 | m_rotationOffset = PhysActor.Orientation; |
611 | } | 605 | } |
612 | } | 606 | } |
613 | 607 | ||
@@ -616,28 +610,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
616 | 610 | ||
617 | set | 611 | set |
618 | { | 612 | { |
619 | PhysicsActor pa = PhysActor; | ||
620 | StoreUndoState(); | 613 | StoreUndoState(); |
621 | m_rotationOffset = value; | 614 | m_rotationOffset = value; |
622 | 615 | ||
623 | if (pa != null) | 616 | if (PhysActor != null) |
624 | { | 617 | { |
625 | try | 618 | try |
626 | { | 619 | { |
627 | // Root prim gets value directly | 620 | // Root prim gets value directly |
628 | if (_parentID == 0) | 621 | if (_parentID == 0) |
629 | { | 622 | { |
630 | pa.Orientation = value; | 623 | PhysActor.Orientation = value; |
631 | //m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString()); | 624 | //m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString()); |
632 | } | 625 | } |
633 | else | 626 | else |
634 | { | 627 | { |
635 | // Child prim we have to calculate it's world rotationwel | 628 | // Child prim we have to calculate it's world rotationwel |
636 | Quaternion resultingrotation = GetWorldRotation(); | 629 | Quaternion resultingrotation = GetWorldRotation(); |
637 | pa.Orientation = resultingrotation; | 630 | PhysActor.Orientation = resultingrotation; |
638 | //m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString()); | 631 | //m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString()); |
639 | } | 632 | } |
640 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 633 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
641 | //} | 634 | //} |
642 | } | 635 | } |
643 | catch (Exception ex) | 636 | catch (Exception ex) |
@@ -657,14 +650,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
657 | //if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0 | 650 | //if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0 |
658 | //|| PhysActor.Velocity.Z != 0) | 651 | //|| PhysActor.Velocity.Z != 0) |
659 | //{ | 652 | //{ |
660 | PhysicsActor pa = PhysActor; | 653 | if (PhysActor != null) |
661 | if (pa != null) | ||
662 | { | 654 | { |
663 | if (pa.IsPhysical) | 655 | if (PhysActor.IsPhysical) |
664 | { | 656 | { |
665 | m_velocity.X = pa.Velocity.X; | 657 | m_velocity.X = PhysActor.Velocity.X; |
666 | m_velocity.Y = pa.Velocity.Y; | 658 | m_velocity.Y = PhysActor.Velocity.Y; |
667 | m_velocity.Z = pa.Velocity.Z; | 659 | m_velocity.Z = PhysActor.Velocity.Z; |
668 | } | 660 | } |
669 | } | 661 | } |
670 | 662 | ||
@@ -674,13 +666,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
674 | set | 666 | set |
675 | { | 667 | { |
676 | m_velocity = value; | 668 | m_velocity = value; |
677 | PhysicsActor pa = PhysActor; | 669 | if (PhysActor != null) |
678 | if (pa != null) | ||
679 | { | 670 | { |
680 | if (pa.IsPhysical) | 671 | if (PhysActor.IsPhysical) |
681 | { | 672 | { |
682 | pa.Velocity = new PhysicsVector(value.X, value.Y, value.Z); | 673 | PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); |
683 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 674 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
684 | } | 675 | } |
685 | } | 676 | } |
686 | } | 677 | } |
@@ -697,10 +688,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
697 | { | 688 | { |
698 | get | 689 | get |
699 | { | 690 | { |
700 | PhysicsActor pa = PhysActor; | 691 | if ((PhysActor != null) && PhysActor.IsPhysical) |
701 | if ((pa != null) && pa.IsPhysical) | ||
702 | { | 692 | { |
703 | m_angularVelocity.FromBytes(pa.RotationalVelocity.GetBytes(), 0); | 693 | m_angularVelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0); |
704 | } | 694 | } |
705 | return m_angularVelocity; | 695 | return m_angularVelocity; |
706 | } | 696 | } |
@@ -719,11 +709,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
719 | get { return m_description; } | 709 | get { return m_description; } |
720 | set | 710 | set |
721 | { | 711 | { |
722 | PhysicsActor pa = PhysActor; | ||
723 | m_description = value; | 712 | m_description = value; |
724 | if (pa != null) | 713 | if (PhysActor != null) |
725 | { | 714 | { |
726 | pa.SOPDescription = value; | 715 | PhysActor.SOPDescription = value; |
727 | } | 716 | } |
728 | } | 717 | } |
729 | } | 718 | } |
@@ -817,15 +806,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
817 | if (m_shape != null) { | 806 | if (m_shape != null) { |
818 | m_shape.Scale = value; | 807 | m_shape.Scale = value; |
819 | 808 | ||
820 | PhysicsActor pa = PhysActor; | 809 | if (PhysActor != null && m_parentGroup != null) |
821 | if (pa != null && m_parentGroup != null) | ||
822 | { | 810 | { |
823 | if (m_parentGroup.Scene != null) | 811 | if (m_parentGroup.Scene != null) |
824 | { | 812 | { |
825 | if (m_parentGroup.Scene.PhysicsScene != null) | 813 | if (m_parentGroup.Scene.PhysicsScene != null) |
826 | { | 814 | { |
827 | pa.Size = new PhysicsVector(m_shape.Scale.X, m_shape.Scale.Y, m_shape.Scale.Z); | 815 | PhysActor.Size = new PhysicsVector(m_shape.Scale.X, m_shape.Scale.Y, m_shape.Scale.Z); |
828 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 816 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
829 | } | 817 | } |
830 | } | 818 | } |
831 | } | 819 | } |
@@ -1356,14 +1344,13 @@ if (m_shape != null) { | |||
1356 | RigidBody); | 1344 | RigidBody); |
1357 | 1345 | ||
1358 | // Basic Physics returns null.. joy joy joy. | 1346 | // Basic Physics returns null.. joy joy joy. |
1359 | PhysicsActor pa = PhysActor; | 1347 | if (PhysActor != null) |
1360 | if (pa != null) | ||
1361 | { | 1348 | { |
1362 | pa.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info | 1349 | PhysActor.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info |
1363 | pa.SOPDescription = this.Description; | 1350 | PhysActor.SOPDescription = this.Description; |
1364 | pa.LocalID = LocalId; | 1351 | PhysActor.LocalID = LocalId; |
1365 | DoPhysicsPropertyUpdate(RigidBody, true); | 1352 | DoPhysicsPropertyUpdate(RigidBody, true); |
1366 | pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0); | 1353 | PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); |
1367 | } | 1354 | } |
1368 | } | 1355 | } |
1369 | } | 1356 | } |
@@ -1577,24 +1564,23 @@ if (m_shape != null) { | |||
1577 | } | 1564 | } |
1578 | else | 1565 | else |
1579 | { | 1566 | { |
1580 | PhysicsActor pa = PhysActor; | 1567 | if (PhysActor != null) |
1581 | if (pa != null) | ||
1582 | { | 1568 | { |
1583 | if (UsePhysics != pa.IsPhysical || isNew) | 1569 | if (UsePhysics != PhysActor.IsPhysical || isNew) |
1584 | { | 1570 | { |
1585 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 1571 | if (PhysActor.IsPhysical) // implies UsePhysics==false for this block |
1586 | { | 1572 | { |
1587 | if (!isNew) | 1573 | if (!isNew) |
1588 | ParentGroup.Scene.RemovePhysicalPrim(1); | 1574 | ParentGroup.Scene.RemovePhysicalPrim(1); |
1589 | 1575 | ||
1590 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 1576 | PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
1591 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 1577 | PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; |
1592 | pa.delink(); | 1578 | PhysActor.delink(); |
1593 | 1579 | ||
1594 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 1580 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) |
1595 | { | 1581 | { |
1596 | // destroy all joints connected to this now deactivated body | 1582 | // destroy all joints connected to this now deactivated body |
1597 | m_parentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 1583 | m_parentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor); |
1598 | } | 1584 | } |
1599 | 1585 | ||
1600 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 1586 | // stop client-side interpolation of all joint proxy objects that have just been deleted |
@@ -1613,7 +1599,7 @@ if (m_shape != null) { | |||
1613 | //RotationalVelocity = new Vector3(0, 0, 0); | 1599 | //RotationalVelocity = new Vector3(0, 0, 0); |
1614 | } | 1600 | } |
1615 | 1601 | ||
1616 | pa.IsPhysical = UsePhysics; | 1602 | PhysActor.IsPhysical = UsePhysics; |
1617 | 1603 | ||
1618 | 1604 | ||
1619 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 1605 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. |
@@ -1627,19 +1613,19 @@ if (m_shape != null) { | |||
1627 | { | 1613 | { |
1628 | ParentGroup.Scene.AddPhysicalPrim(1); | 1614 | ParentGroup.Scene.AddPhysicalPrim(1); |
1629 | 1615 | ||
1630 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | 1616 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
1631 | pa.OnOutOfBounds += PhysicsOutOfBounds; | 1617 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
1632 | if (_parentID != 0 && _parentID != LocalId) | 1618 | if (_parentID != 0 && _parentID != LocalId) |
1633 | { | 1619 | { |
1634 | if (ParentGroup.RootPart.PhysActor != null) | 1620 | if (ParentGroup.RootPart.PhysActor != null) |
1635 | { | 1621 | { |
1636 | pa.link(ParentGroup.RootPart.PhysActor); | 1622 | PhysActor.link(ParentGroup.RootPart.PhysActor); |
1637 | } | 1623 | } |
1638 | } | 1624 | } |
1639 | } | 1625 | } |
1640 | } | 1626 | } |
1641 | } | 1627 | } |
1642 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 1628 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
1643 | } | 1629 | } |
1644 | } | 1630 | } |
1645 | } | 1631 | } |
@@ -1705,10 +1691,9 @@ if (m_shape != null) { | |||
1705 | 1691 | ||
1706 | public Vector3 GetGeometricCenter() | 1692 | public Vector3 GetGeometricCenter() |
1707 | { | 1693 | { |
1708 | PhysicsActor pa = PhysActor; | 1694 | if (PhysActor != null) |
1709 | if (pa != null) | ||
1710 | { | 1695 | { |
1711 | return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); | 1696 | return new Vector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z); |
1712 | } | 1697 | } |
1713 | else | 1698 | else |
1714 | { | 1699 | { |
@@ -1718,10 +1703,9 @@ if (m_shape != null) { | |||
1718 | 1703 | ||
1719 | public float GetMass() | 1704 | public float GetMass() |
1720 | { | 1705 | { |
1721 | PhysicsActor pa = PhysActor; | 1706 | if (PhysActor != null) |
1722 | if (pa != null) | ||
1723 | { | 1707 | { |
1724 | return pa.Mass; | 1708 | return PhysActor.Mass; |
1725 | } | 1709 | } |
1726 | else | 1710 | else |
1727 | { | 1711 | { |
@@ -1731,9 +1715,8 @@ if (m_shape != null) { | |||
1731 | 1715 | ||
1732 | public PhysicsVector GetForce() | 1716 | public PhysicsVector GetForce() |
1733 | { | 1717 | { |
1734 | PhysicsActor pa = PhysActor; | 1718 | if (PhysActor != null) |
1735 | if (pa != null) | 1719 | return PhysActor.Force; |
1736 | return pa.Force; | ||
1737 | else | 1720 | else |
1738 | return new PhysicsVector(); | 1721 | return new PhysicsVector(); |
1739 | } | 1722 | } |
@@ -2112,15 +2095,11 @@ if (m_shape != null) { | |||
2112 | 2095 | ||
2113 | public void PhysicsRequestingTerseUpdate() | 2096 | public void PhysicsRequestingTerseUpdate() |
2114 | { | 2097 | { |
2115 | PhysicsActor pa = PhysActor; | 2098 | if (PhysActor != null) |
2116 | if (pa != null) | ||
2117 | { | 2099 | { |
2118 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2100 | Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); |
2119 | 2101 | ||
2120 | if (m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | | 2102 | if (m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) |
2121 | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | | ||
2122 | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | | ||
2123 | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | ||
2124 | { | 2103 | { |
2125 | m_parentGroup.AbsolutePosition = newpos; | 2104 | m_parentGroup.AbsolutePosition = newpos; |
2126 | return; | 2105 | return; |
@@ -2316,15 +2295,14 @@ if (m_shape != null) { | |||
2316 | if (texture != null) | 2295 | if (texture != null) |
2317 | m_shape.SculptData = texture.Data; | 2296 | m_shape.SculptData = texture.Data; |
2318 | 2297 | ||
2319 | PhysicsActor pa = PhysActor; | 2298 | if (PhysActor != null) |
2320 | if (pa != null) | ||
2321 | { | 2299 | { |
2322 | // Tricks physics engine into thinking we've changed the part shape. | 2300 | // Tricks physics engine into thinking we've changed the part shape. |
2323 | PrimitiveBaseShape m_newshape = m_shape.Copy(); | 2301 | PrimitiveBaseShape m_newshape = m_shape.Copy(); |
2324 | pa.Shape = m_newshape; | 2302 | PhysActor.Shape = m_newshape; |
2325 | m_shape = m_newshape; | 2303 | m_shape = m_newshape; |
2326 | 2304 | ||
2327 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2305 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
2328 | } | 2306 | } |
2329 | } | 2307 | } |
2330 | } | 2308 | } |
@@ -2543,10 +2521,9 @@ if (m_shape != null) { | |||
2543 | 2521 | ||
2544 | public void SetBuoyancy(float fvalue) | 2522 | public void SetBuoyancy(float fvalue) |
2545 | { | 2523 | { |
2546 | PhysicsActor pa = PhysActor; | 2524 | if (PhysActor != null) |
2547 | if (pa != null) | ||
2548 | { | 2525 | { |
2549 | pa.Buoyancy = fvalue; | 2526 | PhysActor.Buoyancy = fvalue; |
2550 | } | 2527 | } |
2551 | } | 2528 | } |
2552 | 2529 | ||
@@ -2562,62 +2539,56 @@ if (m_shape != null) { | |||
2562 | 2539 | ||
2563 | public void SetFloatOnWater(int floatYN) | 2540 | public void SetFloatOnWater(int floatYN) |
2564 | { | 2541 | { |
2565 | PhysicsActor pa = PhysActor; | 2542 | if (PhysActor != null) |
2566 | if (pa != null) | ||
2567 | { | 2543 | { |
2568 | if (floatYN == 1) | 2544 | if (floatYN == 1) |
2569 | { | 2545 | { |
2570 | pa.FloatOnWater = true; | 2546 | PhysActor.FloatOnWater = true; |
2571 | } | 2547 | } |
2572 | else | 2548 | else |
2573 | { | 2549 | { |
2574 | pa.FloatOnWater = false; | 2550 | PhysActor.FloatOnWater = false; |
2575 | } | 2551 | } |
2576 | } | 2552 | } |
2577 | } | 2553 | } |
2578 | 2554 | ||
2579 | public void SetForce(PhysicsVector force) | 2555 | public void SetForce(PhysicsVector force) |
2580 | { | 2556 | { |
2581 | PhysicsActor pa = PhysActor; | 2557 | if (PhysActor != null) |
2582 | if (pa != null) | ||
2583 | { | 2558 | { |
2584 | pa.Force = force; | 2559 | PhysActor.Force = force; |
2585 | } | 2560 | } |
2586 | } | 2561 | } |
2587 | 2562 | ||
2588 | public void SetVehicleType(int type) | 2563 | public void SetVehicleType(int type) |
2589 | { | 2564 | { |
2590 | PhysicsActor pa = PhysActor; | 2565 | if (PhysActor != null) |
2591 | if (pa != null) | ||
2592 | { | 2566 | { |
2593 | pa.VehicleType = type; | 2567 | PhysActor.VehicleType = type; |
2594 | } | 2568 | } |
2595 | } | 2569 | } |
2596 | 2570 | ||
2597 | public void SetVehicleFloatParam(int param, float value) | 2571 | public void SetVehicleFloatParam(int param, float value) |
2598 | { | 2572 | { |
2599 | PhysicsActor pa = PhysActor; | 2573 | if (PhysActor != null) |
2600 | if (pa != null) | ||
2601 | { | 2574 | { |
2602 | pa.VehicleFloatParam(param, value); | 2575 | PhysActor.VehicleFloatParam(param, value); |
2603 | } | 2576 | } |
2604 | } | 2577 | } |
2605 | 2578 | ||
2606 | public void SetVehicleVectorParam(int param, PhysicsVector value) | 2579 | public void SetVehicleVectorParam(int param, PhysicsVector value) |
2607 | { | 2580 | { |
2608 | PhysicsActor pa = PhysActor; | 2581 | if (PhysActor != null) |
2609 | if (pa != null) | ||
2610 | { | 2582 | { |
2611 | pa.VehicleVectorParam(param, value); | 2583 | PhysActor.VehicleVectorParam(param, value); |
2612 | } | 2584 | } |
2613 | } | 2585 | } |
2614 | 2586 | ||
2615 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 2587 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
2616 | { | 2588 | { |
2617 | PhysicsActor pa = PhysActor; | 2589 | if (PhysActor != null) |
2618 | if (pa != null) | ||
2619 | { | 2590 | { |
2620 | pa.VehicleRotationParam(param, rotation); | 2591 | PhysActor.VehicleRotationParam(param, rotation); |
2621 | } | 2592 | } |
2622 | } | 2593 | } |
2623 | 2594 | ||
@@ -2645,11 +2616,10 @@ if (m_shape != null) { | |||
2645 | 2616 | ||
2646 | public void SetPhysicsAxisRotation() | 2617 | public void SetPhysicsAxisRotation() |
2647 | { | 2618 | { |
2648 | PhysicsActor pa = PhysActor; | 2619 | if (PhysActor != null) |
2649 | if (pa != null) | ||
2650 | { | 2620 | { |
2651 | pa.LockAngularMotion(RotationAxis); | 2621 | PhysActor.LockAngularMotion(RotationAxis); |
2652 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2622 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
2653 | } | 2623 | } |
2654 | } | 2624 | } |
2655 | 2625 | ||
@@ -3381,9 +3351,8 @@ if (m_shape != null) { | |||
3381 | { | 3351 | { |
3382 | IsVD = false; // Switch it of for the course of this routine | 3352 | IsVD = false; // Switch it of for the course of this routine |
3383 | VolumeDetectActive = false; // and also permanently | 3353 | VolumeDetectActive = false; // and also permanently |
3384 | PhysicsActor pa = PhysActor; | 3354 | if (PhysActor != null) |
3385 | if (pa != null) | 3355 | PhysActor.SetVolumeDetect(0); // Let physics know about it too |
3386 | pa.SetVolumeDetect(0); // Let physics know about it too | ||
3387 | } | 3356 | } |
3388 | else | 3357 | else |
3389 | { | 3358 | { |
@@ -3431,19 +3400,17 @@ if (m_shape != null) { | |||
3431 | if (IsPhantom || IsAttachment || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | 3400 | if (IsPhantom || IsAttachment || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints |
3432 | { | 3401 | { |
3433 | AddFlag(PrimFlags.Phantom); | 3402 | AddFlag(PrimFlags.Phantom); |
3434 | PhysicsActor pa = PhysActor; | 3403 | if (PhysActor != null) |
3435 | if (pa != null) | ||
3436 | { | 3404 | { |
3437 | m_parentGroup.Scene.PhysicsScene.RemovePrim(pa); | 3405 | m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); |
3438 | /// that's not wholesome. Had to make Scene public | 3406 | /// that's not wholesome. Had to make Scene public |
3439 | pa = null; | 3407 | PhysActor = null; |
3440 | } | 3408 | } |
3441 | } | 3409 | } |
3442 | else // Not phantom | 3410 | else // Not phantom |
3443 | { | 3411 | { |
3444 | RemFlag(PrimFlags.Phantom); | 3412 | RemFlag(PrimFlags.Phantom); |
3445 | 3413 | ||
3446 | // This is NOT safe!! | ||
3447 | PhysicsActor pa = PhysActor; | 3414 | PhysicsActor pa = PhysActor; |
3448 | if (pa == null) | 3415 | if (pa == null) |
3449 | { | 3416 | { |
@@ -3478,8 +3445,8 @@ if (m_shape != null) { | |||
3478 | (CollisionSound != UUID.Zero) | 3445 | (CollisionSound != UUID.Zero) |
3479 | ) | 3446 | ) |
3480 | { | 3447 | { |
3481 | pa.OnCollisionUpdate += PhysicsCollision; | 3448 | PhysActor.OnCollisionUpdate += PhysicsCollision; |
3482 | pa.SubscribeEvents(1000); | 3449 | PhysActor.SubscribeEvents(1000); |
3483 | } | 3450 | } |
3484 | } | 3451 | } |
3485 | } | 3452 | } |
@@ -3508,10 +3475,9 @@ if (m_shape != null) { | |||
3508 | // Defensive programming calls for a check here. | 3475 | // Defensive programming calls for a check here. |
3509 | // Better would be throwing an exception that could be catched by a unit test as the internal | 3476 | // Better would be throwing an exception that could be catched by a unit test as the internal |
3510 | // logic should make sure, this Physactor is always here. | 3477 | // logic should make sure, this Physactor is always here. |
3511 | PhysicsActor pa = this.PhysActor; | 3478 | if (this.PhysActor != null) |
3512 | if (pa != null) | ||
3513 | { | 3479 | { |
3514 | pa.SetVolumeDetect(1); | 3480 | PhysActor.SetVolumeDetect(1); |
3515 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 3481 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active |
3516 | this.VolumeDetectActive = true; | 3482 | this.VolumeDetectActive = true; |
3517 | } | 3483 | } |
@@ -3522,7 +3488,7 @@ if (m_shape != null) { | |||
3522 | PhysicsActor pa = this.PhysActor; | 3488 | PhysicsActor pa = this.PhysActor; |
3523 | if (pa != null) | 3489 | if (pa != null) |
3524 | { | 3490 | { |
3525 | pa.SetVolumeDetect(0); | 3491 | PhysActor.SetVolumeDetect(0); |
3526 | } | 3492 | } |
3527 | this.VolumeDetectActive = false; | 3493 | this.VolumeDetectActive = false; |
3528 | } | 3494 | } |
@@ -3580,11 +3546,10 @@ if (m_shape != null) { | |||
3580 | m_shape.PathTaperY = shapeBlock.PathTaperY; | 3546 | m_shape.PathTaperY = shapeBlock.PathTaperY; |
3581 | m_shape.PathTwist = shapeBlock.PathTwist; | 3547 | m_shape.PathTwist = shapeBlock.PathTwist; |
3582 | m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; | 3548 | m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; |
3583 | PhysicsActor pa = PhysActor; | 3549 | if (PhysActor != null) |
3584 | if (pa != null) | ||
3585 | { | 3550 | { |
3586 | pa.Shape = m_shape; | 3551 | PhysActor.Shape = m_shape; |
3587 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 3552 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
3588 | } | 3553 | } |
3589 | 3554 | ||
3590 | // This is what makes vehicle trailers work | 3555 | // This is what makes vehicle trailers work |
@@ -3685,21 +3650,19 @@ if (m_shape != null) { | |||
3685 | ) | 3650 | ) |
3686 | { | 3651 | { |
3687 | // subscribe to physics updates. | 3652 | // subscribe to physics updates. |
3688 | PhysicsActor pa = PhysActor; | 3653 | if (PhysActor != null) |
3689 | if (pa != null) | ||
3690 | { | 3654 | { |
3691 | pa.OnCollisionUpdate += PhysicsCollision; | 3655 | PhysActor.OnCollisionUpdate += PhysicsCollision; |
3692 | pa.SubscribeEvents(1000); | 3656 | PhysActor.SubscribeEvents(1000); |
3693 | 3657 | ||
3694 | } | 3658 | } |
3695 | } | 3659 | } |
3696 | else | 3660 | else |
3697 | { | 3661 | { |
3698 | PhysicsActor pa = PhysActor; | 3662 | if (PhysActor != null) |
3699 | if (pa != null) | ||
3700 | { | 3663 | { |
3701 | pa.UnSubscribeEvents(); | 3664 | PhysActor.UnSubscribeEvents(); |
3702 | pa.OnCollisionUpdate -= PhysicsCollision; | 3665 | PhysActor.OnCollisionUpdate -= PhysicsCollision; |
3703 | } | 3666 | } |
3704 | } | 3667 | } |
3705 | 3668 | ||
@@ -3802,8 +3765,6 @@ if (m_shape != null) { | |||
3802 | lPos = AbsolutePosition; | 3765 | lPos = AbsolutePosition; |
3803 | } | 3766 | } |
3804 | 3767 | ||
3805 | // Causes this thread to dig into the Client Thread Data. | ||
3806 | // Remember your locking here! | ||
3807 | remoteClient.SendPrimTerseUpdate(m_regionHandle, | 3768 | remoteClient.SendPrimTerseUpdate(m_regionHandle, |
3808 | (ushort)(m_parentGroup.GetTimeDilation() * | 3769 | (ushort)(m_parentGroup.GetTimeDilation() * |
3809 | (float)ushort.MaxValue), LocalId, lPos, | 3770 | (float)ushort.MaxValue), LocalId, lPos, |