diff options
author | John Hurliman | 2009-10-22 11:07:43 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-22 11:07:43 -0700 |
commit | 11013ad2956a87a5641ee2245fe81e5f3dfec268 (patch) | |
tree | 0a0a1cc7019c21e6083d80454228729d55e0ee40 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |
parent | Terrible typo in the previous commit! (diff) | |
parent | Correct version number after merge (diff) | |
download | opensim-SC_OLD-11013ad2956a87a5641ee2245fe81e5f3dfec268.zip opensim-SC_OLD-11013ad2956a87a5641ee2245fe81e5f3dfec268.tar.gz opensim-SC_OLD-11013ad2956a87a5641ee2245fe81e5f3dfec268.tar.bz2 opensim-SC_OLD-11013ad2956a87a5641ee2245fe81e5f3dfec268.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 251 |
1 files changed, 107 insertions, 144 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a078b3d..32171a0 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 | } |
@@ -1346,14 +1334,13 @@ if (m_shape != null) { | |||
1346 | RigidBody); | 1334 | RigidBody); |
1347 | 1335 | ||
1348 | // Basic Physics returns null.. joy joy joy. | 1336 | // Basic Physics returns null.. joy joy joy. |
1349 | PhysicsActor pa = PhysActor; | 1337 | if (PhysActor != null) |
1350 | if (pa != null) | ||
1351 | { | 1338 | { |
1352 | pa.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info | 1339 | PhysActor.SOPName = this.Name; // save object name and desc into the PhysActor so ODE internals know the joint/body info |
1353 | pa.SOPDescription = this.Description; | 1340 | PhysActor.SOPDescription = this.Description; |
1354 | pa.LocalID = LocalId; | 1341 | PhysActor.LocalID = LocalId; |
1355 | DoPhysicsPropertyUpdate(RigidBody, true); | 1342 | DoPhysicsPropertyUpdate(RigidBody, true); |
1356 | pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0); | 1343 | PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0); |
1357 | } | 1344 | } |
1358 | } | 1345 | } |
1359 | } | 1346 | } |
@@ -1567,24 +1554,23 @@ if (m_shape != null) { | |||
1567 | } | 1554 | } |
1568 | else | 1555 | else |
1569 | { | 1556 | { |
1570 | PhysicsActor pa = PhysActor; | 1557 | if (PhysActor != null) |
1571 | if (pa != null) | ||
1572 | { | 1558 | { |
1573 | if (UsePhysics != pa.IsPhysical || isNew) | 1559 | if (UsePhysics != PhysActor.IsPhysical || isNew) |
1574 | { | 1560 | { |
1575 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 1561 | if (PhysActor.IsPhysical) // implies UsePhysics==false for this block |
1576 | { | 1562 | { |
1577 | if (!isNew) | 1563 | if (!isNew) |
1578 | ParentGroup.Scene.RemovePhysicalPrim(1); | 1564 | ParentGroup.Scene.RemovePhysicalPrim(1); |
1579 | 1565 | ||
1580 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 1566 | PhysActor.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
1581 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 1567 | PhysActor.OnOutOfBounds -= PhysicsOutOfBounds; |
1582 | pa.delink(); | 1568 | PhysActor.delink(); |
1583 | 1569 | ||
1584 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 1570 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) |
1585 | { | 1571 | { |
1586 | // destroy all joints connected to this now deactivated body | 1572 | // destroy all joints connected to this now deactivated body |
1587 | m_parentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 1573 | m_parentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(PhysActor); |
1588 | } | 1574 | } |
1589 | 1575 | ||
1590 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 1576 | // stop client-side interpolation of all joint proxy objects that have just been deleted |
@@ -1603,7 +1589,7 @@ if (m_shape != null) { | |||
1603 | //RotationalVelocity = new Vector3(0, 0, 0); | 1589 | //RotationalVelocity = new Vector3(0, 0, 0); |
1604 | } | 1590 | } |
1605 | 1591 | ||
1606 | pa.IsPhysical = UsePhysics; | 1592 | PhysActor.IsPhysical = UsePhysics; |
1607 | 1593 | ||
1608 | 1594 | ||
1609 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 1595 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. |
@@ -1617,19 +1603,19 @@ if (m_shape != null) { | |||
1617 | { | 1603 | { |
1618 | ParentGroup.Scene.AddPhysicalPrim(1); | 1604 | ParentGroup.Scene.AddPhysicalPrim(1); |
1619 | 1605 | ||
1620 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | 1606 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
1621 | pa.OnOutOfBounds += PhysicsOutOfBounds; | 1607 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
1622 | if (_parentID != 0 && _parentID != LocalId) | 1608 | if (_parentID != 0 && _parentID != LocalId) |
1623 | { | 1609 | { |
1624 | if (ParentGroup.RootPart.PhysActor != null) | 1610 | if (ParentGroup.RootPart.PhysActor != null) |
1625 | { | 1611 | { |
1626 | pa.link(ParentGroup.RootPart.PhysActor); | 1612 | PhysActor.link(ParentGroup.RootPart.PhysActor); |
1627 | } | 1613 | } |
1628 | } | 1614 | } |
1629 | } | 1615 | } |
1630 | } | 1616 | } |
1631 | } | 1617 | } |
1632 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 1618 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
1633 | } | 1619 | } |
1634 | } | 1620 | } |
1635 | } | 1621 | } |
@@ -1695,10 +1681,9 @@ if (m_shape != null) { | |||
1695 | 1681 | ||
1696 | public Vector3 GetGeometricCenter() | 1682 | public Vector3 GetGeometricCenter() |
1697 | { | 1683 | { |
1698 | PhysicsActor pa = PhysActor; | 1684 | if (PhysActor != null) |
1699 | if (pa != null) | ||
1700 | { | 1685 | { |
1701 | return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); | 1686 | return new Vector3(PhysActor.CenterOfMass.X, PhysActor.CenterOfMass.Y, PhysActor.CenterOfMass.Z); |
1702 | } | 1687 | } |
1703 | else | 1688 | else |
1704 | { | 1689 | { |
@@ -1708,10 +1693,9 @@ if (m_shape != null) { | |||
1708 | 1693 | ||
1709 | public float GetMass() | 1694 | public float GetMass() |
1710 | { | 1695 | { |
1711 | PhysicsActor pa = PhysActor; | 1696 | if (PhysActor != null) |
1712 | if (pa != null) | ||
1713 | { | 1697 | { |
1714 | return pa.Mass; | 1698 | return PhysActor.Mass; |
1715 | } | 1699 | } |
1716 | else | 1700 | else |
1717 | { | 1701 | { |
@@ -1721,9 +1705,8 @@ if (m_shape != null) { | |||
1721 | 1705 | ||
1722 | public PhysicsVector GetForce() | 1706 | public PhysicsVector GetForce() |
1723 | { | 1707 | { |
1724 | PhysicsActor pa = PhysActor; | 1708 | if (PhysActor != null) |
1725 | if (pa != null) | 1709 | return PhysActor.Force; |
1726 | return pa.Force; | ||
1727 | else | 1710 | else |
1728 | return new PhysicsVector(); | 1711 | return new PhysicsVector(); |
1729 | } | 1712 | } |
@@ -2102,15 +2085,11 @@ if (m_shape != null) { | |||
2102 | 2085 | ||
2103 | public void PhysicsRequestingTerseUpdate() | 2086 | public void PhysicsRequestingTerseUpdate() |
2104 | { | 2087 | { |
2105 | PhysicsActor pa = PhysActor; | 2088 | if (PhysActor != null) |
2106 | if (pa != null) | ||
2107 | { | 2089 | { |
2108 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2090 | Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0); |
2109 | 2091 | ||
2110 | if (m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | | 2092 | 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)) |
2111 | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | | ||
2112 | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | | ||
2113 | m_parentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | ||
2114 | { | 2093 | { |
2115 | m_parentGroup.AbsolutePosition = newpos; | 2094 | m_parentGroup.AbsolutePosition = newpos; |
2116 | return; | 2095 | return; |
@@ -2306,15 +2285,14 @@ if (m_shape != null) { | |||
2306 | if (texture != null) | 2285 | if (texture != null) |
2307 | m_shape.SculptData = texture.Data; | 2286 | m_shape.SculptData = texture.Data; |
2308 | 2287 | ||
2309 | PhysicsActor pa = PhysActor; | 2288 | if (PhysActor != null) |
2310 | if (pa != null) | ||
2311 | { | 2289 | { |
2312 | // Tricks physics engine into thinking we've changed the part shape. | 2290 | // Tricks physics engine into thinking we've changed the part shape. |
2313 | PrimitiveBaseShape m_newshape = m_shape.Copy(); | 2291 | PrimitiveBaseShape m_newshape = m_shape.Copy(); |
2314 | pa.Shape = m_newshape; | 2292 | PhysActor.Shape = m_newshape; |
2315 | m_shape = m_newshape; | 2293 | m_shape = m_newshape; |
2316 | 2294 | ||
2317 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2295 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
2318 | } | 2296 | } |
2319 | } | 2297 | } |
2320 | } | 2298 | } |
@@ -2533,10 +2511,9 @@ if (m_shape != null) { | |||
2533 | 2511 | ||
2534 | public void SetBuoyancy(float fvalue) | 2512 | public void SetBuoyancy(float fvalue) |
2535 | { | 2513 | { |
2536 | PhysicsActor pa = PhysActor; | 2514 | if (PhysActor != null) |
2537 | if (pa != null) | ||
2538 | { | 2515 | { |
2539 | pa.Buoyancy = fvalue; | 2516 | PhysActor.Buoyancy = fvalue; |
2540 | } | 2517 | } |
2541 | } | 2518 | } |
2542 | 2519 | ||
@@ -2552,62 +2529,56 @@ if (m_shape != null) { | |||
2552 | 2529 | ||
2553 | public void SetFloatOnWater(int floatYN) | 2530 | public void SetFloatOnWater(int floatYN) |
2554 | { | 2531 | { |
2555 | PhysicsActor pa = PhysActor; | 2532 | if (PhysActor != null) |
2556 | if (pa != null) | ||
2557 | { | 2533 | { |
2558 | if (floatYN == 1) | 2534 | if (floatYN == 1) |
2559 | { | 2535 | { |
2560 | pa.FloatOnWater = true; | 2536 | PhysActor.FloatOnWater = true; |
2561 | } | 2537 | } |
2562 | else | 2538 | else |
2563 | { | 2539 | { |
2564 | pa.FloatOnWater = false; | 2540 | PhysActor.FloatOnWater = false; |
2565 | } | 2541 | } |
2566 | } | 2542 | } |
2567 | } | 2543 | } |
2568 | 2544 | ||
2569 | public void SetForce(PhysicsVector force) | 2545 | public void SetForce(PhysicsVector force) |
2570 | { | 2546 | { |
2571 | PhysicsActor pa = PhysActor; | 2547 | if (PhysActor != null) |
2572 | if (pa != null) | ||
2573 | { | 2548 | { |
2574 | pa.Force = force; | 2549 | PhysActor.Force = force; |
2575 | } | 2550 | } |
2576 | } | 2551 | } |
2577 | 2552 | ||
2578 | public void SetVehicleType(int type) | 2553 | public void SetVehicleType(int type) |
2579 | { | 2554 | { |
2580 | PhysicsActor pa = PhysActor; | 2555 | if (PhysActor != null) |
2581 | if (pa != null) | ||
2582 | { | 2556 | { |
2583 | pa.VehicleType = type; | 2557 | PhysActor.VehicleType = type; |
2584 | } | 2558 | } |
2585 | } | 2559 | } |
2586 | 2560 | ||
2587 | public void SetVehicleFloatParam(int param, float value) | 2561 | public void SetVehicleFloatParam(int param, float value) |
2588 | { | 2562 | { |
2589 | PhysicsActor pa = PhysActor; | 2563 | if (PhysActor != null) |
2590 | if (pa != null) | ||
2591 | { | 2564 | { |
2592 | pa.VehicleFloatParam(param, value); | 2565 | PhysActor.VehicleFloatParam(param, value); |
2593 | } | 2566 | } |
2594 | } | 2567 | } |
2595 | 2568 | ||
2596 | public void SetVehicleVectorParam(int param, PhysicsVector value) | 2569 | public void SetVehicleVectorParam(int param, PhysicsVector value) |
2597 | { | 2570 | { |
2598 | PhysicsActor pa = PhysActor; | 2571 | if (PhysActor != null) |
2599 | if (pa != null) | ||
2600 | { | 2572 | { |
2601 | pa.VehicleVectorParam(param, value); | 2573 | PhysActor.VehicleVectorParam(param, value); |
2602 | } | 2574 | } |
2603 | } | 2575 | } |
2604 | 2576 | ||
2605 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 2577 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
2606 | { | 2578 | { |
2607 | PhysicsActor pa = PhysActor; | 2579 | if (PhysActor != null) |
2608 | if (pa != null) | ||
2609 | { | 2580 | { |
2610 | pa.VehicleRotationParam(param, rotation); | 2581 | PhysActor.VehicleRotationParam(param, rotation); |
2611 | } | 2582 | } |
2612 | } | 2583 | } |
2613 | 2584 | ||
@@ -2635,11 +2606,10 @@ if (m_shape != null) { | |||
2635 | 2606 | ||
2636 | public void SetPhysicsAxisRotation() | 2607 | public void SetPhysicsAxisRotation() |
2637 | { | 2608 | { |
2638 | PhysicsActor pa = PhysActor; | 2609 | if (PhysActor != null) |
2639 | if (pa != null) | ||
2640 | { | 2610 | { |
2641 | pa.LockAngularMotion(RotationAxis); | 2611 | PhysActor.LockAngularMotion(RotationAxis); |
2642 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2612 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
2643 | } | 2613 | } |
2644 | } | 2614 | } |
2645 | 2615 | ||
@@ -3371,9 +3341,8 @@ if (m_shape != null) { | |||
3371 | { | 3341 | { |
3372 | IsVD = false; // Switch it of for the course of this routine | 3342 | IsVD = false; // Switch it of for the course of this routine |
3373 | VolumeDetectActive = false; // and also permanently | 3343 | VolumeDetectActive = false; // and also permanently |
3374 | PhysicsActor pa = PhysActor; | 3344 | if (PhysActor != null) |
3375 | if (pa != null) | 3345 | PhysActor.SetVolumeDetect(0); // Let physics know about it too |
3376 | pa.SetVolumeDetect(0); // Let physics know about it too | ||
3377 | } | 3346 | } |
3378 | else | 3347 | else |
3379 | { | 3348 | { |
@@ -3421,19 +3390,17 @@ if (m_shape != null) { | |||
3421 | if (IsPhantom || IsAttachment || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | 3390 | if (IsPhantom || IsAttachment || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints |
3422 | { | 3391 | { |
3423 | AddFlag(PrimFlags.Phantom); | 3392 | AddFlag(PrimFlags.Phantom); |
3424 | PhysicsActor pa = PhysActor; | 3393 | if (PhysActor != null) |
3425 | if (pa != null) | ||
3426 | { | 3394 | { |
3427 | m_parentGroup.Scene.PhysicsScene.RemovePrim(pa); | 3395 | m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); |
3428 | /// that's not wholesome. Had to make Scene public | 3396 | /// that's not wholesome. Had to make Scene public |
3429 | pa = null; | 3397 | PhysActor = null; |
3430 | } | 3398 | } |
3431 | } | 3399 | } |
3432 | else // Not phantom | 3400 | else // Not phantom |
3433 | { | 3401 | { |
3434 | RemFlag(PrimFlags.Phantom); | 3402 | RemFlag(PrimFlags.Phantom); |
3435 | 3403 | ||
3436 | // This is NOT safe!! | ||
3437 | PhysicsActor pa = PhysActor; | 3404 | PhysicsActor pa = PhysActor; |
3438 | if (pa == null) | 3405 | if (pa == null) |
3439 | { | 3406 | { |
@@ -3468,8 +3435,8 @@ if (m_shape != null) { | |||
3468 | (CollisionSound != UUID.Zero) | 3435 | (CollisionSound != UUID.Zero) |
3469 | ) | 3436 | ) |
3470 | { | 3437 | { |
3471 | pa.OnCollisionUpdate += PhysicsCollision; | 3438 | PhysActor.OnCollisionUpdate += PhysicsCollision; |
3472 | pa.SubscribeEvents(1000); | 3439 | PhysActor.SubscribeEvents(1000); |
3473 | } | 3440 | } |
3474 | } | 3441 | } |
3475 | } | 3442 | } |
@@ -3498,10 +3465,9 @@ if (m_shape != null) { | |||
3498 | // Defensive programming calls for a check here. | 3465 | // Defensive programming calls for a check here. |
3499 | // Better would be throwing an exception that could be catched by a unit test as the internal | 3466 | // Better would be throwing an exception that could be catched by a unit test as the internal |
3500 | // logic should make sure, this Physactor is always here. | 3467 | // logic should make sure, this Physactor is always here. |
3501 | PhysicsActor pa = this.PhysActor; | 3468 | if (this.PhysActor != null) |
3502 | if (pa != null) | ||
3503 | { | 3469 | { |
3504 | pa.SetVolumeDetect(1); | 3470 | PhysActor.SetVolumeDetect(1); |
3505 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 3471 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active |
3506 | this.VolumeDetectActive = true; | 3472 | this.VolumeDetectActive = true; |
3507 | } | 3473 | } |
@@ -3512,7 +3478,7 @@ if (m_shape != null) { | |||
3512 | PhysicsActor pa = this.PhysActor; | 3478 | PhysicsActor pa = this.PhysActor; |
3513 | if (pa != null) | 3479 | if (pa != null) |
3514 | { | 3480 | { |
3515 | pa.SetVolumeDetect(0); | 3481 | PhysActor.SetVolumeDetect(0); |
3516 | } | 3482 | } |
3517 | this.VolumeDetectActive = false; | 3483 | this.VolumeDetectActive = false; |
3518 | } | 3484 | } |
@@ -3570,11 +3536,10 @@ if (m_shape != null) { | |||
3570 | m_shape.PathTaperY = shapeBlock.PathTaperY; | 3536 | m_shape.PathTaperY = shapeBlock.PathTaperY; |
3571 | m_shape.PathTwist = shapeBlock.PathTwist; | 3537 | m_shape.PathTwist = shapeBlock.PathTwist; |
3572 | m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; | 3538 | m_shape.PathTwistBegin = shapeBlock.PathTwistBegin; |
3573 | PhysicsActor pa = PhysActor; | 3539 | if (PhysActor != null) |
3574 | if (pa != null) | ||
3575 | { | 3540 | { |
3576 | pa.Shape = m_shape; | 3541 | PhysActor.Shape = m_shape; |
3577 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 3542 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
3578 | } | 3543 | } |
3579 | 3544 | ||
3580 | // This is what makes vehicle trailers work | 3545 | // This is what makes vehicle trailers work |
@@ -3675,21 +3640,19 @@ if (m_shape != null) { | |||
3675 | ) | 3640 | ) |
3676 | { | 3641 | { |
3677 | // subscribe to physics updates. | 3642 | // subscribe to physics updates. |
3678 | PhysicsActor pa = PhysActor; | 3643 | if (PhysActor != null) |
3679 | if (pa != null) | ||
3680 | { | 3644 | { |
3681 | pa.OnCollisionUpdate += PhysicsCollision; | 3645 | PhysActor.OnCollisionUpdate += PhysicsCollision; |
3682 | pa.SubscribeEvents(1000); | 3646 | PhysActor.SubscribeEvents(1000); |
3683 | 3647 | ||
3684 | } | 3648 | } |
3685 | } | 3649 | } |
3686 | else | 3650 | else |
3687 | { | 3651 | { |
3688 | PhysicsActor pa = PhysActor; | 3652 | if (PhysActor != null) |
3689 | if (pa != null) | ||
3690 | { | 3653 | { |
3691 | pa.UnSubscribeEvents(); | 3654 | PhysActor.UnSubscribeEvents(); |
3692 | pa.OnCollisionUpdate -= PhysicsCollision; | 3655 | PhysActor.OnCollisionUpdate -= PhysicsCollision; |
3693 | } | 3656 | } |
3694 | } | 3657 | } |
3695 | 3658 | ||