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/ODECharacter.cs11
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs83
2 files changed, 91 insertions, 3 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index de09691..f2906cf 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -605,6 +605,12 @@ namespace OpenSim.Region.Physics.OdePlugin
605 } 605 }
606 } 606 }
607 607
608 public override PhysicsVector Torque
609 {
610 get { return PhysicsVector.Zero; }
611 set { return; }
612 }
613
608 public override float CollisionScore 614 public override float CollisionScore
609 { 615 {
610 get { return 0f; } 616 get { return 0f; }
@@ -665,6 +671,11 @@ namespace OpenSim.Region.Physics.OdePlugin
665 //m_lastUpdateSent = false; 671 //m_lastUpdateSent = false;
666 } 672 }
667 673
674 public override void AddAngularForce(PhysicsVector force, bool pushforce)
675 {
676
677 }
678
668 /// <summary> 679 /// <summary>
669 /// After all of the forces add up with 'add force' we apply them with doForce 680 /// After all of the forces add up with 'add force' we apply them with doForce
670 /// </summary> 681 /// </summary>
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index eeef893..6f5abfa 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -47,6 +47,7 @@ namespace OpenSim.Region.Physics.OdePlugin
47 47
48 public PhysicsVector _position; 48 public PhysicsVector _position;
49 private PhysicsVector _velocity; 49 private PhysicsVector _velocity;
50 private PhysicsVector _torque = new PhysicsVector(0,0,0);
50 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);
51 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);
52 private PhysicsVector m_rotationalVelocity; 53 private PhysicsVector m_rotationalVelocity;
@@ -56,7 +57,8 @@ namespace OpenSim.Region.Physics.OdePlugin
56 private Quaternion _orientation; 57 private Quaternion _orientation;
57 private PhysicsVector m_taintposition; 58 private PhysicsVector m_taintposition;
58 private PhysicsVector m_taintsize; 59 private PhysicsVector m_taintsize;
59 private PhysicsVector m_taintVelocity = PhysicsVector.Zero; 60 private PhysicsVector m_taintVelocity = new PhysicsVector(0, 0, 0);
61 private PhysicsVector m_taintTorque = new PhysicsVector(0, 0, 0);
60 private Quaternion m_taintrot; 62 private Quaternion m_taintrot;
61 private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f); 63 private PhysicsVector m_angularlock = new PhysicsVector(1f, 1f, 1f);
62 private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f); 64 private PhysicsVector m_taintAngularLock = new PhysicsVector(1f, 1f, 1f);
@@ -102,8 +104,10 @@ namespace OpenSim.Region.Physics.OdePlugin
102 private CollisionLocker ode; 104 private CollisionLocker ode;
103 105
104 private bool m_taintforce = false; 106 private bool m_taintforce = false;
107 private bool m_taintaddangularforce = false;
105 private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f); 108 private PhysicsVector m_force = new PhysicsVector(0.0f, 0.0f, 0.0f);
106 private List<PhysicsVector> m_forcelist = new List<PhysicsVector>(); 109 private List<PhysicsVector> m_forcelist = new List<PhysicsVector>();
110 private List<PhysicsVector> m_angularforcelist = new List<PhysicsVector>();
107 111
108 private IMesh _mesh; 112 private IMesh _mesh;
109 private PrimitiveBaseShape _pbs; 113 private PrimitiveBaseShape _pbs;
@@ -838,6 +842,12 @@ namespace OpenSim.Region.Physics.OdePlugin
838 if (m_taintforce) 842 if (m_taintforce)
839 changeAddForce(timestep); 843 changeAddForce(timestep);
840 844
845 if (m_taintaddangularforce)
846 changeAddAngularForce(timestep);
847
848 if (!m_taintTorque.IsIdentical(PhysicsVector.Zero, 0.001f))
849 changeSetTorque(timestep);
850
841 if (m_taintdisable) 851 if (m_taintdisable)
842 changedisable(timestep); 852 changedisable(timestep);
843 853
@@ -2058,6 +2068,49 @@ namespace OpenSim.Region.Physics.OdePlugin
2058 2068
2059 } 2069 }
2060 2070
2071
2072
2073 public void changeSetTorque(float timestamp)
2074 {
2075 if (!m_isSelected)
2076 {
2077 if (IsPhysical && Body != IntPtr.Zero)
2078 {
2079 d.BodySetTorque(Body, m_taintTorque.X, m_taintTorque.Y, m_taintTorque.Z);
2080 }
2081 }
2082
2083 m_taintTorque = new PhysicsVector(0, 0, 0);
2084 }
2085
2086 public void changeAddAngularForce(float timestamp)
2087 {
2088 if (!m_isSelected)
2089 {
2090 lock (m_angularforcelist)
2091 {
2092 //m_log.Info("[PHYSICS]: dequeing forcelist");
2093 if (IsPhysical)
2094 {
2095 PhysicsVector iforce = new PhysicsVector();
2096 for (int i = 0; i < m_angularforcelist.Count; i++)
2097 {
2098 iforce = iforce + (m_angularforcelist[i] * 100);
2099 }
2100 d.BodyEnable(Body);
2101 d.BodyAddTorque(Body, iforce.X, iforce.Y, iforce.Z);
2102
2103 }
2104 m_angularforcelist.Clear();
2105 }
2106
2107 m_collisionscore = 0;
2108 m_interpenetrationcount = 0;
2109 }
2110
2111 m_taintaddangularforce = false;
2112 }
2113
2061 private void changevelocity(float timestep) 2114 private void changevelocity(float timestep)
2062 { 2115 {
2063 if (!m_isSelected) 2116 if (!m_isSelected)
@@ -2070,7 +2123,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2070 d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z); 2123 d.BodySetLinearVel(Body, m_taintVelocity.X, m_taintVelocity.Y, m_taintVelocity.Z);
2071 } 2124 }
2072 } 2125 }
2073 2126
2074 //resetCollisionAccounting(); 2127 //resetCollisionAccounting();
2075 } 2128 }
2076 m_taintVelocity = PhysicsVector.Zero; 2129 m_taintVelocity = PhysicsVector.Zero;
@@ -2216,6 +2269,23 @@ namespace OpenSim.Region.Physics.OdePlugin
2216 } 2269 }
2217 } 2270 }
2218 2271
2272 public override PhysicsVector Torque
2273 {
2274 get
2275 {
2276 if (!m_isphysical || Body == IntPtr.Zero)
2277 return new PhysicsVector(0,0,0);
2278
2279 return _torque;
2280 }
2281
2282 set
2283 {
2284 m_taintTorque = value;
2285 _parent_scene.AddPhysicsActorTaint(this);
2286 }
2287 }
2288
2219 public override float CollisionScore 2289 public override float CollisionScore
2220 { 2290 {
2221 get { return m_collisionscore; } 2291 get { return m_collisionscore; }
@@ -2252,6 +2322,12 @@ namespace OpenSim.Region.Physics.OdePlugin
2252 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); 2322 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
2253 } 2323 }
2254 2324
2325 public override void AddAngularForce(PhysicsVector force, bool pushforce)
2326 {
2327 m_angularforcelist.Add(force);
2328 m_taintaddangularforce = true;
2329 }
2330
2255 public override PhysicsVector RotationalVelocity 2331 public override PhysicsVector RotationalVelocity
2256 { 2332 {
2257 get 2333 get
@@ -2323,7 +2399,8 @@ namespace OpenSim.Region.Physics.OdePlugin
2323 d.Quaternion ori = d.BodyGetQuaternion(Body); 2399 d.Quaternion ori = d.BodyGetQuaternion(Body);
2324 d.Vector3 vel = d.BodyGetLinearVel(Body); 2400 d.Vector3 vel = d.BodyGetLinearVel(Body);
2325 d.Vector3 rotvel = d.BodyGetAngularVel(Body); 2401 d.Vector3 rotvel = d.BodyGetAngularVel(Body);
2326 2402 d.Vector3 torque = d.BodyGetTorque(Body);
2403 _torque.setValues(torque.X, torque.Y, torque.Z);
2327 PhysicsVector l_position = new PhysicsVector(); 2404 PhysicsVector l_position = new PhysicsVector();
2328 2405
2329 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) 2406 // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!)