aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs90
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs50
2 files changed, 100 insertions, 40 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
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index c663fb0..70f0785 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -171,6 +171,25 @@ namespace OpenSim.Region.Physics.OdePlugin
171 private float avMovementDivisorWalk = 1.3f; 171 private float avMovementDivisorWalk = 1.3f;
172 private float avMovementDivisorRun = 0.8f; 172 private float avMovementDivisorRun = 0.8f;
173 173
174 public bool meshSculptedPrim = true;
175
176 public float meshSculptLOD = 32;
177 public float MeshSculptphysicalLOD = 16;
178
179 public float geomDefaultDensity = 10.000006836f;
180
181 public int geomContactPointsStartthrottle = 3;
182 public int geomUpdatesPerThrottledUpdate = 15;
183
184 public float bodyPIDD = 35f;
185 public float bodyPIDG = 25;
186
187 public int geomCrossingFailuresBeforeOutofbounds = 5;
188
189 public float bodyMotorJointMaxforceTensor = 2;
190
191 public int bodyFramesAutoDisable = 20;
192
174 private float[] _heightmap; 193 private float[] _heightmap;
175 194
176 private float[] _watermap; 195 private float[] _watermap;
@@ -320,17 +339,35 @@ namespace OpenSim.Region.Physics.OdePlugin
320 avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f); 339 avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", 0.8f);
321 avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f); 340 avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f);
322 341
342 geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3);
343 geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15);
344 geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_faiures_before_outofbounds", 5);
345
346 geomDefaultDensity = physicsconfig.GetFloat("geometry_default_density", 10.000006836f);
347 bodyFramesAutoDisable = physicsconfig.GetInt("body_frames_auto_disable", 20);
348
349 bodyPIDD = physicsconfig.GetFloat("body_pid_derivative", 35f);
350 bodyPIDG = physicsconfig.GetFloat("body_pid_gain", 25f);
351
352 meshSculptedPrim = physicsconfig.GetBoolean("mesh_sculpted_prim", true);
353 meshSculptLOD = physicsconfig.GetFloat("mesh_lod", 32f);
354 MeshSculptphysicalLOD = physicsconfig.GetFloat("mesh_physical_lod", 16f);
355
356
323 if (Environment.OSVersion.Platform == PlatformID.Unix) 357 if (Environment.OSVersion.Platform == PlatformID.Unix)
324 { 358 {
325 avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 3200.0f); 359 avPIDD = physicsconfig.GetFloat("av_pid_derivative_linux", 3200.0f);
326 avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 1400.0f); 360 avPIDP = physicsconfig.GetFloat("av_pid_proportional_linux", 1400.0f);
327 avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_linux", 2000000f); 361 avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_linux", 2000000f);
362 bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_linux", 2f);
363
328 } 364 }
329 else 365 else
330 { 366 {
331 avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f); 367 avPIDD = physicsconfig.GetFloat("av_pid_derivative_win", 2200.0f);
332 avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f); 368 avPIDP = physicsconfig.GetFloat("av_pid_proportional_win", 900.0f);
333 avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f); 369 avStandupTensor = physicsconfig.GetFloat("av_capsule_standup_tensor_win", 550000f);
370 bodyMotorJointMaxforceTensor = physicsconfig.GetFloat("body_motor_joint_maxforce_tensor_win", 5f);
334 } 371 }
335 } 372 }
336 } 373 }
@@ -765,7 +802,7 @@ namespace OpenSim.Region.Physics.OdePlugin
765 d.JointAttach(joint, b1, b2); 802 d.JointAttach(joint, b1, b2);
766 } 803 }
767 collision_accounting_events(p1, p2, max_collision_depth); 804 collision_accounting_events(p1, p2, max_collision_depth);
768 if (count > 3) 805 if (count > geomContactPointsStartthrottle)
769 { 806 {
770 // If there are more then 3 contact points, it's likely 807 // If there are more then 3 contact points, it's likely
771 // that we've got a pile of objects 808 // that we've got a pile of objects
@@ -1117,7 +1154,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1117 /// support simple box & hollow box now; later, more shapes 1154 /// support simple box & hollow box now; later, more shapes
1118 if (needsMeshing(pbs)) 1155 if (needsMeshing(pbs))
1119 { 1156 {
1120 mesh = mesher.CreateMesh(primName, pbs, size); 1157 mesh = mesher.CreateMesh(primName, pbs, size, 32f);
1121 } 1158 }
1122 1159
1123 break; 1160 break;
@@ -1474,6 +1511,11 @@ namespace OpenSim.Region.Physics.OdePlugin
1474 /// <returns></returns> 1511 /// <returns></returns>
1475 public bool needsMeshing(PrimitiveBaseShape pbs) 1512 public bool needsMeshing(PrimitiveBaseShape pbs)
1476 { 1513 {
1514 if (pbs.SculptEntry && !meshSculptedPrim)
1515 {
1516 return false;
1517 }
1518
1477 if (pbs.ProfileHollow != 0) 1519 if (pbs.ProfileHollow != 0)
1478 return true; 1520 return true;
1479 1521
@@ -1495,7 +1537,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1495 return true; 1537 return true;
1496 1538
1497 if (pbs.ProfileShape == ProfileShape.EquilateralTriangle) 1539 if (pbs.ProfileShape == ProfileShape.EquilateralTriangle)
1498 return true; 1540 return true;
1541
1542
1499 1543
1500 return false; 1544 return false;
1501 } 1545 }