aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-07-31 02:50:50 +0100
committerJustin Clark-Casey (justincc)2011-07-31 02:50:50 +0100
commitaea700753361621f25a3e22f4176fcd2cc981b9f (patch)
tree368bec72a70834b35485a50707e4488977885fc2 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
parentIn the packetpool, if we encounter a data block that somehow wasn't retrieved... (diff)
downloadopensim-SC_OLD-aea700753361621f25a3e22f4176fcd2cc981b9f.zip
opensim-SC_OLD-aea700753361621f25a3e22f4176fcd2cc981b9f.tar.gz
opensim-SC_OLD-aea700753361621f25a3e22f4176fcd2cc981b9f.tar.bz2
opensim-SC_OLD-aea700753361621f25a3e22f4176fcd2cc981b9f.tar.xz
refactor: split out ninja joint part of SOP.DoPhysicsPropertyUpdate() so that we don't have to look at it if it's not relevant
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs157
1 files changed, 86 insertions, 71 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 58fc6fc..7c9636a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -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)
@@ -4699,7 +4714,7 @@ namespace OpenSim.Region.Framework.Scenes
4699 /// </remarks> 4714 /// </remarks>
4700 public void CheckSculptAndLoad() 4715 public void CheckSculptAndLoad()
4701 { 4716 {
4702// m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); 4717 m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId);
4703 4718
4704 if (ParentGroup.IsDeleted) 4719 if (ParentGroup.IsDeleted)
4705 return; 4720 return;