aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODEPrim.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs90
1 files changed, 53 insertions, 37 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index f1886e4..1f9a6b6 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -65,6 +65,13 @@ namespace OpenSim.Region.Physics.OdePlugin
65 65
66 private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0); 66 private PhysicsVector m_PIDTarget = new PhysicsVector(0, 0, 0);
67 private float m_PIDTau = 0f; 67 private float m_PIDTau = 0f;
68 private float PID_D = 35f;
69 private float PID_G = 25f;
70 private float m_tensor = 5f;
71 private int body_autodisable_frames = 20;
72
73
74
68 private bool m_usePID = false; 75 private bool m_usePID = false;
69 76
70 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom 77 private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom
@@ -94,7 +101,7 @@ namespace OpenSim.Region.Physics.OdePlugin
94 101
95 public uint m_localID = 0; 102 public uint m_localID = 0;
96 103
97 public GCHandle gc; 104 //public GCHandle gc;
98 private CollisionLocker ode; 105 private CollisionLocker ode;
99 106
100 private bool m_taintforce = false; 107 private bool m_taintforce = false;
@@ -147,11 +154,16 @@ namespace OpenSim.Region.Physics.OdePlugin
147 { 154 {
148 155
149 _target_velocity = new PhysicsVector(0, 0, 0); 156 _target_velocity = new PhysicsVector(0, 0, 0);
150 gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); 157 //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned);
151 ode = dode; 158 ode = dode;
152 _velocity = new PhysicsVector(); 159 _velocity = new PhysicsVector();
153 _position = pos; 160 _position = pos;
154 m_taintposition = pos; 161 m_taintposition = pos;
162 PID_D = parent_scene.bodyPIDD;
163 PID_G = parent_scene.bodyPIDG;
164 m_density = parent_scene.geomDefaultDensity;
165 m_tensor = parent_scene.bodyMotorJointMaxforceTensor;
166 body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
155 //if (_position.X > 257) 167 //if (_position.X > 257)
156 //{ 168 //{
157 //_position.X = 257; 169 //_position.X = 257;
@@ -306,7 +318,7 @@ namespace OpenSim.Region.Physics.OdePlugin
306 318
307 319
308 d.BodySetAutoDisableFlag(Body, true); 320 d.BodySetAutoDisableFlag(Body, true);
309 d.BodySetAutoDisableSteps(Body, 20); 321 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
310 322
311 m_interpenetrationcount = 0; 323 m_interpenetrationcount = 0;
312 m_collisionscore = 0; 324 m_collisionscore = 0;
@@ -677,6 +689,7 @@ namespace OpenSim.Region.Physics.OdePlugin
677 689
678 Thread.Sleep(10); 690 Thread.Sleep(10);
679 691
692
680 //Kill Body so that mesh can re-make the geom 693 //Kill Body so that mesh can re-make the geom
681 if (IsPhysical && Body != (IntPtr) 0) 694 if (IsPhysical && Body != (IntPtr) 0)
682 { 695 {
@@ -799,7 +812,7 @@ namespace OpenSim.Region.Physics.OdePlugin
799 { 812 {
800 d.JointDestroy(Amotor); 813 d.JointDestroy(Amotor);
801 Amotor = (IntPtr)0; 814 Amotor = (IntPtr)0;
802 } 815 }
803 } 816 }
804 } 817 }
805 } 818 }
@@ -951,7 +964,7 @@ namespace OpenSim.Region.Physics.OdePlugin
951 if (_parent_scene.needsMeshing(_pbs)) 964 if (_parent_scene.needsMeshing(_pbs))
952 { 965 {
953 // Don't need to re-enable body.. it's done in SetMesh 966 // Don't need to re-enable body.. it's done in SetMesh
954 _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size); 967 _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD);
955 // createmesh returns null when it's a shape that isn't a cube. 968 // createmesh returns null when it's a shape that isn't a cube.
956 } 969 }
957 } 970 }
@@ -1138,7 +1151,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1138 1151
1139 if (IsPhysical && Body != (IntPtr)0 && !m_isSelected) 1152 if (IsPhysical && Body != (IntPtr)0 && !m_isSelected)
1140 { 1153 {
1141 float PID_D = 2200.0f; 1154
1142 //float PID_P = 900.0f; 1155 //float PID_P = 900.0f;
1143 1156
1144 1157
@@ -1177,21 +1190,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1177 1190
1178 // If the PID Controller isn't active then we set our force 1191 // If the PID Controller isn't active then we set our force
1179 // calculating base velocity to the current position 1192 // calculating base velocity to the current position
1180 if (Environment.OSVersion.Platform == PlatformID.Unix) 1193
1181 { 1194
1182 PID_D = 3200.0f;
1183 //PID_P = 1400.0f;
1184 }
1185 else
1186 {
1187 PID_D = 2200.0f;
1188 //PID_P = 900.0f;
1189 }
1190 PID_D = 35f;
1191
1192
1193 //PID_P = 1.0f;
1194 float PID_G = 25;
1195 1195
1196 if ((m_PIDTau < 1)) 1196 if ((m_PIDTau < 1))
1197 { 1197 {
@@ -1333,13 +1333,27 @@ namespace OpenSim.Region.Physics.OdePlugin
1333 { 1333 {
1334 if (Body == (IntPtr)0) 1334 if (Body == (IntPtr)0)
1335 { 1335 {
1336 enableBody(); 1336 if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
1337 {
1338 changeshape(2f);
1339 }
1340 else
1341 {
1342 enableBody();
1343 }
1337 } 1344 }
1338 } 1345 }
1339 else 1346 else
1340 { 1347 {
1341 if (Body != (IntPtr)0) 1348 if (Body != (IntPtr)0)
1342 { 1349 {
1350 if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
1351 {
1352 if (prim_geom != IntPtr.Zero)
1353 d.GeomDestroy(prim_geom);
1354
1355 changeadd(2f);
1356 }
1343 disableBody(); 1357 disableBody();
1344 } 1358 }
1345 } 1359 }
@@ -1386,8 +1400,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1386 // Construction of new prim 1400 // Construction of new prim
1387 if (_parent_scene.needsMeshing(_pbs)) 1401 if (_parent_scene.needsMeshing(_pbs))
1388 { 1402 {
1403 float meshlod = _parent_scene.meshSculptLOD;
1404
1405 if (IsPhysical)
1406 meshlod = _parent_scene.MeshSculptphysicalLOD;
1389 // Don't need to re-enable body.. it's done in SetMesh 1407 // Don't need to re-enable body.. it's done in SetMesh
1390 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); 1408 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod);
1391 // createmesh returns null when it's a shape that isn't a cube. 1409 // createmesh returns null when it's a shape that isn't a cube.
1392 if (mesh != null) 1410 if (mesh != null)
1393 { 1411 {
@@ -1556,10 +1574,16 @@ namespace OpenSim.Region.Physics.OdePlugin
1556 if (_size.Y <= 0) _size.Y = 0.01f; 1574 if (_size.Y <= 0) _size.Y = 0.01f;
1557 if (_size.Z <= 0) _size.Z = 0.01f; 1575 if (_size.Z <= 0) _size.Z = 0.01f;
1558 // Construction of new prim 1576 // Construction of new prim
1577
1559 if (_parent_scene.needsMeshing(_pbs)) 1578 if (_parent_scene.needsMeshing(_pbs))
1560 { 1579 {
1561 // Don't need to re-enable body.. it's done in SetMesh 1580 // Don't need to re-enable body.. it's done in SetMesh
1562 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size); 1581 float meshlod = _parent_scene.meshSculptLOD;
1582
1583 if (IsPhysical)
1584 meshlod = _parent_scene.MeshSculptphysicalLOD;
1585
1586 IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod);
1563 // createmesh returns null when it's a shape that isn't a cube. 1587 // createmesh returns null when it's a shape that isn't a cube.
1564 if (mesh != null) 1588 if (mesh != null)
1565 { 1589 {
@@ -1910,12 +1934,12 @@ namespace OpenSim.Region.Physics.OdePlugin
1910 public override void CrossingFailure() 1934 public override void CrossingFailure()
1911 { 1935 {
1912 m_crossingfailures++; 1936 m_crossingfailures++;
1913 if (m_crossingfailures > 5) 1937 if (m_crossingfailures > _parent_scene.geomCrossingFailuresBeforeOutofbounds)
1914 { 1938 {
1915 base.RaiseOutOfBounds(_position); 1939 base.RaiseOutOfBounds(_position);
1916 return; 1940 return;
1917 } 1941 }
1918 else if (m_crossingfailures == 5) 1942 else if (m_crossingfailures == _parent_scene.geomCrossingFailuresBeforeOutofbounds)
1919 { 1943 {
1920 m_log.Warn("[PHYSICS]: Too many crossing failures for: " + m_primName); 1944 m_log.Warn("[PHYSICS]: Too many crossing failures for: " + m_primName);
1921 } 1945 }
@@ -1982,7 +2006,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1982 { 2006 {
1983 //base.RaiseOutOfBounds(l_position); 2007 //base.RaiseOutOfBounds(l_position);
1984 2008
1985 if (m_crossingfailures < 5) 2009 if (m_crossingfailures < _parent_scene.geomCrossingFailuresBeforeOutofbounds)
1986 { 2010 {
1987 _position = l_position; 2011 _position = l_position;
1988 //_parent_scene.remActivePrim(this); 2012 //_parent_scene.remActivePrim(this);
@@ -2107,7 +2131,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2107 _orientation.y = ori.Y; 2131 _orientation.y = ori.Y;
2108 _orientation.z = ori.Z; 2132 _orientation.z = ori.Z;
2109 m_lastUpdateSent = false; 2133 m_lastUpdateSent = false;
2110 if (!m_throttleUpdates || throttleCounter > 15) 2134 if (!m_throttleUpdates || throttleCounter > _parent_scene.geomUpdatesPerThrottledUpdate)
2111 { 2135 {
2112 if (_parent == null) 2136 if (_parent == null)
2113 base.RequestPhysicsterseUpdate(); 2137 base.RequestPhysicsterseUpdate();
@@ -2164,15 +2188,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2164 Amotor = IntPtr.Zero; 2188 Amotor = IntPtr.Zero;
2165 } 2189 }
2166 2190
2167 float m_tensor = 0f; 2191
2168 if (Environment.OSVersion.Platform == PlatformID.Unix)
2169 {
2170 m_tensor = 2f;
2171 }
2172 else
2173 {
2174 m_tensor = 5f;
2175 }
2176 2192
2177 float axisnum = 3; 2193 float axisnum = 3;
2178 2194