diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 160 |
1 files changed, 87 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4629757..90ad34e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -1038,7 +1038,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1038 | { | 1038 | { |
1039 | actor.Size = m_shape.Scale; | 1039 | actor.Size = m_shape.Scale; |
1040 | 1040 | ||
1041 | if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh) | 1041 | if (Shape.SculptEntry) |
1042 | CheckSculptAndLoad(); | 1042 | CheckSculptAndLoad(); |
1043 | else | 1043 | else |
1044 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 1044 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
@@ -1751,96 +1751,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
1751 | return part; | 1751 | return part; |
1752 | } | 1752 | } |
1753 | 1753 | ||
1754 | public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) | 1754 | /// <summary> |
1755 | /// Do a physics property update for a NINJA joint. | ||
1756 | /// </summary> | ||
1757 | /// <param name="UsePhysics"></param> | ||
1758 | /// <param name="isNew"></param> | ||
1759 | protected void DoPhysicsPropertyUpdateForNinjaJoint(bool UsePhysics, bool isNew) | ||
1755 | { | 1760 | { |
1756 | if (IsJoint()) | 1761 | if (UsePhysics) |
1757 | { | 1762 | { |
1758 | if (UsePhysics) | 1763 | // by turning a joint proxy object physical, we cause creation of a joint in the ODE scene. |
1759 | { | 1764 | // note that, as a special case, joints have no bodies or geoms in the physics scene, even though they are physical. |
1760 | // by turning a joint proxy object physical, we cause creation of a joint in the ODE scene. | ||
1761 | // note that, as a special case, joints have no bodies or geoms in the physics scene, even though they are physical. | ||
1762 | 1765 | ||
1763 | PhysicsJointType jointType; | 1766 | PhysicsJointType jointType; |
1764 | if (IsHingeJoint()) | 1767 | if (IsHingeJoint()) |
1765 | { | 1768 | { |
1766 | jointType = PhysicsJointType.Hinge; | 1769 | jointType = PhysicsJointType.Hinge; |
1767 | } | 1770 | } |
1768 | else if (IsBallJoint()) | 1771 | else if (IsBallJoint()) |
1769 | { | 1772 | { |
1770 | jointType = PhysicsJointType.Ball; | 1773 | jointType = PhysicsJointType.Ball; |
1771 | } | 1774 | } |
1772 | else | 1775 | else |
1773 | { | 1776 | { |
1774 | jointType = PhysicsJointType.Ball; | 1777 | jointType = PhysicsJointType.Ball; |
1775 | } | 1778 | } |
1776 | 1779 | ||
1777 | List<string> bodyNames = new List<string>(); | 1780 | List<string> bodyNames = new List<string>(); |
1778 | string RawParams = Description; | 1781 | string RawParams = Description; |
1779 | string[] jointParams = RawParams.Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); | 1782 | string[] jointParams = RawParams.Split(" ".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); |
1780 | string trackedBodyName = null; | 1783 | string trackedBodyName = null; |
1781 | if (jointParams.Length >= 2) | 1784 | if (jointParams.Length >= 2) |
1785 | { | ||
1786 | for (int iBodyName = 0; iBodyName < 2; iBodyName++) | ||
1782 | { | 1787 | { |
1783 | for (int iBodyName = 0; iBodyName < 2; iBodyName++) | 1788 | string bodyName = jointParams[iBodyName]; |
1789 | bodyNames.Add(bodyName); | ||
1790 | if (bodyName != "NULL") | ||
1784 | { | 1791 | { |
1785 | string bodyName = jointParams[iBodyName]; | 1792 | if (trackedBodyName == null) |
1786 | bodyNames.Add(bodyName); | ||
1787 | if (bodyName != "NULL") | ||
1788 | { | 1793 | { |
1789 | if (trackedBodyName == null) | 1794 | trackedBodyName = bodyName; |
1790 | { | ||
1791 | trackedBodyName = bodyName; | ||
1792 | } | ||
1793 | } | 1795 | } |
1794 | } | 1796 | } |
1795 | } | 1797 | } |
1798 | } | ||
1796 | 1799 | ||
1797 | SceneObjectPart trackedBody = m_parentGroup.Scene.GetSceneObjectPart(trackedBodyName); // FIXME: causes a sequential lookup | 1800 | SceneObjectPart trackedBody = m_parentGroup.Scene.GetSceneObjectPart(trackedBodyName); // FIXME: causes a sequential lookup |
1798 | Quaternion localRotation = Quaternion.Identity; | 1801 | Quaternion localRotation = Quaternion.Identity; |
1799 | if (trackedBody != null) | 1802 | if (trackedBody != null) |
1800 | { | 1803 | { |
1801 | localRotation = Quaternion.Inverse(trackedBody.RotationOffset) * this.RotationOffset; | 1804 | localRotation = Quaternion.Inverse(trackedBody.RotationOffset) * this.RotationOffset; |
1802 | } | 1805 | } |
1803 | else | 1806 | else |
1804 | { | 1807 | { |
1805 | // error, output it below | 1808 | // error, output it below |
1806 | } | 1809 | } |
1807 | 1810 | ||
1808 | PhysicsJoint joint; | 1811 | PhysicsJoint joint; |
1809 | 1812 | ||
1810 | joint = m_parentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType, | 1813 | joint = m_parentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType, |
1811 | AbsolutePosition, | 1814 | AbsolutePosition, |
1812 | this.RotationOffset, | 1815 | this.RotationOffset, |
1813 | Description, | 1816 | Description, |
1814 | bodyNames, | 1817 | bodyNames, |
1815 | trackedBodyName, | 1818 | trackedBodyName, |
1816 | localRotation); | 1819 | localRotation); |
1817 | 1820 | ||
1818 | if (trackedBody == null) | 1821 | if (trackedBody == null) |
1819 | { | 1822 | { |
1820 | ParentGroup.Scene.jointErrorMessage(joint, "warning: tracked body name not found! joint location will not be updated properly. joint: " + Name); | 1823 | ParentGroup.Scene.jointErrorMessage(joint, "warning: tracked body name not found! joint location will not be updated properly. joint: " + Name); |
1821 | } | 1824 | } |
1825 | } | ||
1826 | else | ||
1827 | { | ||
1828 | if (isNew) | ||
1829 | { | ||
1830 | // if the joint proxy is new, and it is not physical, do nothing. There is no joint in ODE to | ||
1831 | // delete, and if we try to delete it, due to asynchronous processing, the deletion request | ||
1832 | // will get processed later at an indeterminate time, which could cancel a later-arriving | ||
1833 | // joint creation request. | ||
1822 | } | 1834 | } |
1823 | else | 1835 | else |
1824 | { | 1836 | { |
1825 | if (isNew) | 1837 | // here we turn off the joint object, so remove the joint from the physics scene |
1826 | { | 1838 | m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed? |
1827 | // if the joint proxy is new, and it is not physical, do nothing. There is no joint in ODE to | ||
1828 | // delete, and if we try to delete it, due to asynchronous processing, the deletion request | ||
1829 | // will get processed later at an indeterminate time, which could cancel a later-arriving | ||
1830 | // joint creation request. | ||
1831 | } | ||
1832 | else | ||
1833 | { | ||
1834 | // here we turn off the joint object, so remove the joint from the physics scene | ||
1835 | m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed? | ||
1836 | 1839 | ||
1837 | // make sure client isn't interpolating the joint proxy object | 1840 | // make sure client isn't interpolating the joint proxy object |
1838 | Velocity = Vector3.Zero; | 1841 | Velocity = Vector3.Zero; |
1839 | AngularVelocity = Vector3.Zero; | 1842 | AngularVelocity = Vector3.Zero; |
1840 | Acceleration = Vector3.Zero; | 1843 | Acceleration = Vector3.Zero; |
1841 | } | ||
1842 | } | 1844 | } |
1843 | } | 1845 | } |
1846 | } | ||
1847 | |||
1848 | /// <summary> | ||
1849 | /// Do a physics propery update for this part. | ||
1850 | /// </summary> | ||
1851 | /// <param name="UsePhysics"></param> | ||
1852 | /// <param name="isNew"></param> | ||
1853 | public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew) | ||
1854 | { | ||
1855 | if (IsJoint()) | ||
1856 | { | ||
1857 | DoPhysicsPropertyUpdateForNinjaJoint(UsePhysics, isNew); | ||
1858 | } | ||
1844 | else | 1859 | else |
1845 | { | 1860 | { |
1846 | if (PhysActor != null) | 1861 | if (PhysActor != null) |
@@ -1906,7 +1921,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1906 | 1921 | ||
1907 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the | 1922 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the |
1908 | // mesh data. | 1923 | // mesh data. |
1909 | if (((OpenMetaverse.SculptType)Shape.SculptType) == SculptType.Mesh) | 1924 | if (Shape.SculptEntry) |
1910 | CheckSculptAndLoad(); | 1925 | CheckSculptAndLoad(); |
1911 | else | 1926 | else |
1912 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 1927 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
@@ -4821,7 +4836,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4821 | { | 4836 | { |
4822 | PhysActor.OnCollisionUpdate += PhysicsCollision; | 4837 | PhysActor.OnCollisionUpdate += PhysicsCollision; |
4823 | PhysActor.SubscribeEvents(1000); | 4838 | PhysActor.SubscribeEvents(1000); |
4824 | |||
4825 | } | 4839 | } |
4826 | } | 4840 | } |
4827 | else | 4841 | else |