aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/Manager/PhysicsVector.cs9
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs32
2 files changed, 33 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/Manager/PhysicsVector.cs b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
index 4ec943c..adf4715 100644
--- a/OpenSim/Region/Physics/Manager/PhysicsVector.cs
+++ b/OpenSim/Region/Physics/Manager/PhysicsVector.cs
@@ -130,6 +130,14 @@ namespace OpenSim.Region.Physics.Manager
130 return (float) Math.Sqrt(X*X + Y*Y + Z*Z); 130 return (float) Math.Sqrt(X*X + Y*Y + Z*Z);
131 } 131 }
132 132
133 public static float GetDistanceTo(PhysicsVector a, PhysicsVector b)
134 {
135 float dx = a.X - b.X;
136 float dy = a.Y - b.Y;
137 float dz = a.Z - b.Z;
138 return (float) Math.Sqrt(dx * dx + dy * dy + dz * dz);
139 }
140
133 public static PhysicsVector operator /(PhysicsVector v, float f) 141 public static PhysicsVector operator /(PhysicsVector v, float f)
134 { 142 {
135 return new PhysicsVector(v.X/f, v.Y/f, v.Z/f); 143 return new PhysicsVector(v.X/f, v.Y/f, v.Z/f);
@@ -154,5 +162,6 @@ namespace OpenSim.Region.Physics.Manager
154 162
155 return false; 163 return false;
156 } 164 }
165
157 } 166 }
158} 167}
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 947466f..5a5cf59 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -1192,12 +1192,27 @@ namespace OpenSim.Region.Physics.OdePlugin
1192 PID_D = 2200.0f; 1192 PID_D = 2200.0f;
1193 //PID_P = 900.0f; 1193 //PID_P = 900.0f;
1194 } 1194 }
1195 PID_D = 1.0f; 1195 PID_D = 35f;
1196 //PID_P = 1.0f;
1197 1196
1198 1197
1198 //PID_P = 1.0f;
1199 float PID_G = 25;
1200
1201 if ((m_PIDTau < 1))
1202 {
1203 PID_G = PID_G / m_PIDTau;
1204 }
1205
1206
1207 if ((PID_G - m_PIDTau) <= 0)
1208 {
1209 PID_G = m_PIDTau + 1;
1210 }
1199 //PidStatus = true; 1211 //PidStatus = true;
1200 1212
1213
1214
1215
1201 PhysicsVector vec = new PhysicsVector(); 1216 PhysicsVector vec = new PhysicsVector();
1202 d.Vector3 vel = d.BodyGetLinearVel(Body); 1217 d.Vector3 vel = d.BodyGetLinearVel(Body);
1203 1218
@@ -1205,9 +1220,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1205 d.Vector3 pos = d.BodyGetPosition(Body); 1220 d.Vector3 pos = d.BodyGetPosition(Body);
1206 _target_velocity = 1221 _target_velocity =
1207 new PhysicsVector( 1222 new PhysicsVector(
1208 (m_PIDTarget.X - pos.X) / m_PIDTau, 1223 (m_PIDTarget.X - pos.X) * ((PID_G - m_PIDTau) * timestep),
1209 (m_PIDTarget.Y - pos.Y) / m_PIDTau, 1224 (m_PIDTarget.Y - pos.Y) * ((PID_G - m_PIDTau) * timestep),
1210 (m_PIDTarget.Z - pos.Z) / m_PIDTau 1225 (m_PIDTarget.Z - pos.Z) * ((PID_G - m_PIDTau) * timestep)
1211 ); 1226 );
1212 1227
1213 1228
@@ -1239,8 +1254,8 @@ namespace OpenSim.Region.Physics.OdePlugin
1239 _zeroFlag = false; 1254 _zeroFlag = false;
1240 1255
1241 // We're flying and colliding with something 1256 // We're flying and colliding with something
1242 fx = ((_target_velocity.X / m_PIDTau) - vel.X) * (PID_D / 6); 1257 fx = ((_target_velocity.X) - vel.X) * (PID_D);
1243 fy = ((_target_velocity.Y / m_PIDTau) - vel.Y) * (PID_D / 6); 1258 fy = ((_target_velocity.Y) - vel.Y) * (PID_D);
1244 1259
1245 1260
1246 1261
@@ -1262,6 +1277,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1262 //m_taintdisable = true; 1277 //m_taintdisable = true;
1263 //base.RaiseOutOfBounds(Position); 1278 //base.RaiseOutOfBounds(Position);
1264 //d.BodySetLinearVel(Body, fx, fy, 0f); 1279 //d.BodySetLinearVel(Body, fx, fy, 0f);
1280 enableBodySoft();
1265 d.BodyAddForce(Body, fx, fy, fz); 1281 d.BodyAddForce(Body, fx, fy, fz);
1266 } 1282 }
1267 } 1283 }
@@ -2146,7 +2162,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2146 } 2162 }
2147 public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } } 2163 public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } }
2148 public override bool PIDActive { set { m_usePID = value; } } 2164 public override bool PIDActive { set { m_usePID = value; } }
2149 public override float PIDTau { set { m_PIDTau = (value * 0.6f); } } 2165 public override float PIDTau { set { m_PIDTau = value; } }
2150 2166
2151 private void createAMotor(PhysicsVector axis) 2167 private void createAMotor(PhysicsVector axis)
2152 { 2168 {