aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-12-26 12:58:02 +0000
committerTeravus Ovares2008-12-26 12:58:02 +0000
commitec2dc354b485491d7879686b4a78027971e3ed92 (patch)
tree3ea0771a55524ce1b9dec3c3c66f0dac24a006ef /OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
parentPrevent exception in terrain module if just the word terrain is entered at th... (diff)
downloadopensim-SC_OLD-ec2dc354b485491d7879686b4a78027971e3ed92.zip
opensim-SC_OLD-ec2dc354b485491d7879686b4a78027971e3ed92.tar.gz
opensim-SC_OLD-ec2dc354b485491d7879686b4a78027971e3ed92.tar.bz2
opensim-SC_OLD-ec2dc354b485491d7879686b4a78027971e3ed92.tar.xz
* Applying Nlin's NINJA Joint patch. v2. Mantis# 2874
* Thanks nlin! * To try it out, set ninja joints active in the ODEPhysicsSettings and use the example at: * http://forge.opensimulator.org/gf/download/frsrelease/142/304/demo-playground.tgz. * Don't forget to change the .tgz to .oar and load it with load-oar.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODEPrim.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs29
1 files changed, 27 insertions, 2 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index b9c0936..8dc8f78 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -50,6 +50,7 @@ namespace OpenSim.Region.Physics.OdePlugin
50 private PhysicsVector _torque = new PhysicsVector(0,0,0); 50 private PhysicsVector _torque = new PhysicsVector(0,0,0);
51 private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); 51 private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f);
52 private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f); 52 private PhysicsVector m_lastposition = new PhysicsVector(0.0f, 0.0f, 0.0f);
53 private Quaternion m_lastorientation = new Quaternion();
53 private PhysicsVector m_rotationalVelocity; 54 private PhysicsVector m_rotationalVelocity;
54 private PhysicsVector _size; 55 private PhysicsVector _size;
55 private PhysicsVector _acceleration; 56 private PhysicsVector _acceleration;
@@ -1182,6 +1183,23 @@ namespace OpenSim.Region.Physics.OdePlugin
1182 // in between the disabling and the collision properties setting 1183 // in between the disabling and the collision properties setting
1183 // which would wake the physical body up from a soft disabling and potentially cause it to fall 1184 // which would wake the physical body up from a soft disabling and potentially cause it to fall
1184 // through the ground. 1185 // through the ground.
1186
1187 // NOTE FOR JOINTS: this doesn't always work for jointed assemblies because if you select
1188 // just one part of the assembly, the rest of the assembly is non-selected and still simulating,
1189 // so that causes the selected part to wake up and continue moving.
1190
1191 // even if you select all parts of a jointed assembly, it is not guaranteed that the entire
1192 // assembly will stop simulating during the selection, because of the lack of atomicity
1193 // of select operations (their processing could be interrupted by a thread switch, causing
1194 // simulation to continue before all of the selected object notifications trickle down to
1195 // the physics engine).
1196
1197 // e.g. we select 100 prims that are connected by joints. non-atomically, the first 50 are
1198 // selected and disabled. then, due to a thread switch, the selection processing is
1199 // interrupted and the physics engine continues to simulate, so the last 50 items, whose
1200 // selection was not yet processed, continues to simulate. this wakes up ALL of the
1201 // first 50 again. then the last 50 are disabled. then the first 50, which were just woken
1202 // up, start simulating again, which in turn wakes up the last 50.
1185 1203
1186 if (m_isphysical) 1204 if (m_isphysical)
1187 { 1205 {
@@ -2398,7 +2416,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2398 { 2416 {
2399 PhysicsVector pv = new PhysicsVector(0, 0, 0); 2417 PhysicsVector pv = new PhysicsVector(0, 0, 0);
2400 bool lastZeroFlag = _zeroFlag; 2418 bool lastZeroFlag = _zeroFlag;
2401 if (Body != (IntPtr)0) 2419 if (Body != (IntPtr)0) // FIXME -> or if it is a joint
2402 { 2420 {
2403 d.Vector3 vec = d.BodyGetPosition(Body); 2421 d.Vector3 vec = d.BodyGetPosition(Body);
2404 d.Quaternion ori = d.BodyGetQuaternion(Body); 2422 d.Quaternion ori = d.BodyGetQuaternion(Body);
@@ -2407,6 +2425,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2407 d.Vector3 torque = d.BodyGetTorque(Body); 2425 d.Vector3 torque = d.BodyGetTorque(Body);
2408 _torque.setValues(torque.X, torque.Y, torque.Z); 2426 _torque.setValues(torque.X, torque.Y, torque.Z);
2409 PhysicsVector l_position = new PhysicsVector(); 2427 PhysicsVector l_position = new PhysicsVector();
2428 Quaternion l_orientation = new Quaternion();
2410 2429
2411 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 2430 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)
2412 //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } 2431 //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
@@ -2415,10 +2434,15 @@ namespace OpenSim.Region.Physics.OdePlugin
2415 //if (vec.Y > 255.95f) { vec.Y = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } 2434 //if (vec.Y > 255.95f) { vec.Y = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); }
2416 2435
2417 m_lastposition = _position; 2436 m_lastposition = _position;
2437 m_lastorientation = _orientation;
2418 2438
2419 l_position.X = vec.X; 2439 l_position.X = vec.X;
2420 l_position.Y = vec.Y; 2440 l_position.Y = vec.Y;
2421 l_position.Z = vec.Z; 2441 l_position.Z = vec.Z;
2442 l_orientation.X = ori.X;
2443 l_orientation.Y = ori.Y;
2444 l_orientation.Z = ori.Z;
2445 l_orientation.W = ori.W;
2422 2446
2423 if (l_position.X > 255.95f || l_position.X < 0f || l_position.Y > 255.95f || l_position.Y < 0f) 2447 if (l_position.X > 255.95f || l_position.X < 0f || l_position.Y > 255.95f || l_position.Y < 0f)
2424 { 2448 {
@@ -2474,7 +2498,8 @@ namespace OpenSim.Region.Physics.OdePlugin
2474 2498
2475 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02) 2499 if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02)
2476 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) 2500 && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02)
2477 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02)) 2501 && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02)
2502 && (1.0 - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)) < 0.01 ))
2478 { 2503 {
2479 _zeroFlag = true; 2504 _zeroFlag = true;
2480 m_throttleUpdates = false; 2505 m_throttleUpdates = false;