aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorUbitUmarov2018-12-06 18:50:42 +0000
committerUbitUmarov2018-12-06 18:50:42 +0000
commit66f46c6846b3d110eb01c963921a7ca014d00f68 (patch)
tree5462da33ee87d2f3039bca9f4a579557f04d45db
parentGetAssets: only throttle mesh and texture (diff)
downloadopensim-SC-66f46c6846b3d110eb01c963921a7ca014d00f68.zip
opensim-SC-66f46c6846b3d110eb01c963921a7ca014d00f68.tar.gz
opensim-SC-66f46c6846b3d110eb01c963921a7ca014d00f68.tar.bz2
opensim-SC-66f46c6846b3d110eb01c963921a7ca014d00f68.tar.xz
ubOde: slow down collision events to attachments
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs64
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs13
2 files changed, 52 insertions, 25 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
index 9d60d0b..5242399 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs
@@ -86,6 +86,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
86 public float m_density = 60f; 86 public float m_density = 60f;
87 private bool m_pidControllerActive = true; 87 private bool m_pidControllerActive = true;
88 88
89 public int m_bodydisablecontrol = 0;
90
89 const float basePID_D = 0.55f; // scaled for unit mass unit time (2200 /(50*80)) 91 const float basePID_D = 0.55f; // scaled for unit mass unit time (2200 /(50*80))
90 const float basePID_P = 0.225f; // scaled for unit mass unit time (900 /(50*80)) 92 const float basePID_P = 0.225f; // scaled for unit mass unit time (900 /(50*80))
91 public float PID_D; 93 public float PID_D;
@@ -803,6 +805,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
803 { 805 {
804 m_pidControllerActive = true; 806 m_pidControllerActive = true;
805 _acceleration = accel; 807 _acceleration = accel;
808 if (Body != IntPtr.Zero)
809 SafeNativeMethods.BodyEnable(Body);
806 } 810 }
807 811
808 /// <summary> 812 /// <summary>
@@ -894,7 +898,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
894 898
895 _velocity = Vector3.Zero; 899 _velocity = Vector3.Zero;
896 900
897 SafeNativeMethods.BodySetAutoDisableFlag(Body,false); 901 // SafeNativeMethods.BodySetAutoDisableFlag(Body,false);
902 SafeNativeMethods.BodySetAutoDisableFlag(Body, true);
903 m_bodydisablecontrol = 0;
904
898 SafeNativeMethods.BodySetPosition(Body,npositionX,npositionY,npositionZ); 905 SafeNativeMethods.BodySetPosition(Body,npositionX,npositionY,npositionZ);
899 906
900 _position.X = npositionX; 907 _position.X = npositionX;
@@ -973,7 +980,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
973 980
974 if(collider != IntPtr.Zero) 981 if(collider != IntPtr.Zero)
975 { 982 {
976 m_parent_scene.actor_name_map.Remove(collider);
977 SafeNativeMethods.SpaceDestroy(collider); 983 SafeNativeMethods.SpaceDestroy(collider);
978 collider = IntPtr.Zero; 984 collider = IntPtr.Zero;
979 } 985 }
@@ -1142,6 +1148,20 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1142 if(Body == IntPtr.Zero) 1148 if(Body == IntPtr.Zero)
1143 return; 1149 return;
1144 1150
1151 if (!SafeNativeMethods.BodyIsEnabled(Body))
1152 {
1153 if (++m_bodydisablecontrol < 50)
1154 return;
1155
1156 // clear residuals
1157 SafeNativeMethods.BodySetAngularVel(Body, 0f, 0f, 0f);
1158 SafeNativeMethods.BodySetLinearVel(Body, 0f, 0f, 0f);
1159 _zeroFlag = true;
1160 SafeNativeMethods.BodyEnable(Body);
1161 }
1162
1163 m_bodydisablecontrol = 0;
1164
1145 SafeNativeMethods.Vector3 dtmp = SafeNativeMethods.BodyGetPosition(Body); 1165 SafeNativeMethods.Vector3 dtmp = SafeNativeMethods.BodyGetPosition(Body);
1146 Vector3 localpos = new Vector3(dtmp.X,dtmp.Y,dtmp.Z); 1166 Vector3 localpos = new Vector3(dtmp.X,dtmp.Y,dtmp.Z);
1147 1167
@@ -1780,6 +1800,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1780 if(m_cureventsubscription < m_eventsubscription) 1800 if(m_cureventsubscription < m_eventsubscription)
1781 return; 1801 return;
1782 1802
1803 if(Body != IntPtr.Zero && !SafeNativeMethods.BodyIsEnabled(Body))
1804 return;
1805
1783 lock(CollisionEventsThisFrame) 1806 lock(CollisionEventsThisFrame)
1784 { 1807 {
1785 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count; 1808 int ncolisions = CollisionEventsThisFrame.m_objCollisionList.Count;
@@ -1820,7 +1843,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1820 1843
1821 AvatarGeomAndBodyCreation(_position.X,_position.Y,_position.Z); 1844 AvatarGeomAndBodyCreation(_position.X,_position.Y,_position.Z);
1822 1845
1823 m_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
1824 m_parent_scene.actor_name_map[capsule] = (PhysicsActor)this; 1846 m_parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
1825 m_parent_scene.AddCharacter(this); 1847 m_parent_scene.AddCharacter(this);
1826 } 1848 }
@@ -1874,7 +1896,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1874 // Velocity = Vector3.Zero; 1896 // Velocity = Vector3.Zero;
1875 m_targetVelocity = Vector3.Zero; 1897 m_targetVelocity = Vector3.Zero;
1876 1898
1877 m_parent_scene.actor_name_map[collider] = (PhysicsActor)this;
1878 m_parent_scene.actor_name_map[capsule] = (PhysicsActor)this; 1899 m_parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
1879 } 1900 }
1880 m_freemove = false; 1901 m_freemove = false;
@@ -1889,7 +1910,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1889 private void changePosition(Vector3 newPos) 1910 private void changePosition(Vector3 newPos)
1890 { 1911 {
1891 if(Body != IntPtr.Zero) 1912 if(Body != IntPtr.Zero)
1892 SafeNativeMethods.BodySetPosition(Body,newPos.X,newPos.Y,newPos.Z); 1913 {
1914 SafeNativeMethods.BodySetPosition(Body, newPos.X, newPos.Y, newPos.Z);
1915 SafeNativeMethods.BodyEnable(Body);
1916 }
1917
1893 _position = newPos; 1918 _position = newPos;
1894 m_freemove = false; 1919 m_freemove = false;
1895 m_pidControllerActive = true; 1920 m_pidControllerActive = true;
@@ -1920,12 +1945,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1920 m_orientation2D.Y = 0f; 1945 m_orientation2D.Y = 0f;
1921 m_orientation2D.X = 0f; 1946 m_orientation2D.X = 0f;
1922 1947
1923 SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion(); 1948 if (Body != IntPtr.Zero)
1924 myrot.X = m_orientation2D.X; 1949 {
1925 myrot.Y = m_orientation2D.Y; 1950 SafeNativeMethods.Quaternion myrot = new SafeNativeMethods.Quaternion();
1926 myrot.Z = m_orientation2D.Z; 1951 myrot.X = m_orientation2D.X;
1927 myrot.W = m_orientation2D.W; 1952 myrot.Y = m_orientation2D.Y;
1928 SafeNativeMethods.BodySetQuaternion(Body,ref myrot); 1953 myrot.Z = m_orientation2D.Z;
1954 myrot.W = m_orientation2D.W;
1955 SafeNativeMethods.BodySetQuaternion(Body,ref myrot);
1956 SafeNativeMethods.BodyEnable(Body);
1957 }
1929 } 1958 }
1930 } 1959 }
1931 1960
@@ -1934,8 +1963,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1934 _velocity = newVel; 1963 _velocity = newVel;
1935 setFreeMove(); 1964 setFreeMove();
1936 1965
1937 if(Body != IntPtr.Zero) 1966 if (Body != IntPtr.Zero)
1938 SafeNativeMethods.BodySetLinearVel(Body,newVel.X,newVel.Y,newVel.Z); 1967 {
1968 SafeNativeMethods.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z);
1969 SafeNativeMethods.BodyEnable(Body);
1970 }
1939 } 1971 }
1940 1972
1941 private void changeTargetVelocity(Vector3 newVel) 1973 private void changeTargetVelocity(Vector3 newVel)
@@ -1943,6 +1975,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1943 m_pidControllerActive = true; 1975 m_pidControllerActive = true;
1944 m_freemove = false; 1976 m_freemove = false;
1945 _target_velocity = newVel; 1977 _target_velocity = newVel;
1978 if (Body != IntPtr.Zero)
1979 SafeNativeMethods.BodyEnable(Body);
1946 } 1980 }
1947 1981
1948 private void changeSetTorque(Vector3 newTorque) 1982 private void changeSetTorque(Vector3 newTorque)
@@ -2006,6 +2040,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2006 { 2040 {
2007 if(newForce.X != 0f || newForce.Y != 0f || newForce.Z != 0) 2041 if(newForce.X != 0f || newForce.Y != 0f || newForce.Z != 0)
2008 SafeNativeMethods.BodyAddForce(Body,newForce.X,newForce.Y,newForce.Z); 2042 SafeNativeMethods.BodyAddForce(Body,newForce.X,newForce.Y,newForce.Z);
2043 SafeNativeMethods.BodyEnable(Body);
2009 } 2044 }
2010 } 2045 }
2011 2046
@@ -2016,7 +2051,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2016 setFreeMove(); 2051 setFreeMove();
2017 2052
2018 if(Body != IntPtr.Zero) 2053 if(Body != IntPtr.Zero)
2054 {
2019 SafeNativeMethods.BodySetLinearVel(Body,newmomentum.X,newmomentum.Y,newmomentum.Z); 2055 SafeNativeMethods.BodySetLinearVel(Body,newmomentum.X,newmomentum.Y,newmomentum.Z);
2056 SafeNativeMethods.BodyEnable(Body);
2057 }
2020 } 2058 }
2021 2059
2022 private void changePIDHoverHeight(float val) 2060 private void changePIDHoverHeight(float val)
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
index cdade00..567de23 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
@@ -221,7 +221,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
221 public float bodyPIDD = 35f; 221 public float bodyPIDD = 35f;
222 public float bodyPIDG = 25; 222 public float bodyPIDG = 25;
223 223
224 public int bodyFramesAutoDisable = 5; 224 public int bodyFramesAutoDisable = 10;
225 225
226 private SafeNativeMethods.NearCallback nearCallback; 226 private SafeNativeMethods.NearCallback nearCallback;
227 227
@@ -1858,17 +1858,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1858 return fps; 1858 return fps;
1859 } 1859 }
1860 1860
1861 /// <summary>
1862 public override void GetResults()
1863 {
1864 }
1865
1866 public override bool IsThreaded
1867 {
1868 // for now we won't be multithreaded
1869 get { return (false); }
1870 }
1871
1872 public float GetTerrainHeightAtXY(float x, float y) 1861 public float GetTerrainHeightAtXY(float x, float y)
1873 { 1862 {
1874 if (m_terrainGeom == IntPtr.Zero) 1863 if (m_terrainGeom == IntPtr.Zero)