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/OdePlugin.cs41
1 files changed, 21 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 486fa9e..4b1d3f0 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -85,21 +85,18 @@ namespace OpenSim.Region.Physics.OdePlugin
85 85
86 public OdeScene() 86 public OdeScene()
87 { 87 {
88 contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM; 88 contact.surface.mode |= d.ContactFlags.Approx1 | d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP;
89 contact.surface.mu = d.Infinity; 89 contact.surface.mu = 10.0f;
90 contact.surface.mu2 = 0.0f; 90 contact.surface.bounce = 0.9f;
91 contact.surface.bounce = 0.1f; 91 contact.surface.soft_erp = 0.005f;
92 contact.surface.bounce_vel = 0.1f; 92 contact.surface.soft_cfm = 0.00003f;
93 contact.surface.soft_cfm = 0.01f;
94 93
95 world = d.WorldCreate(); 94 world = d.WorldCreate();
96 space = d.HashSpaceCreate(IntPtr.Zero); 95 space = d.HashSpaceCreate(IntPtr.Zero);
97 contactgroup = d.JointGroupCreate(0); 96 contactgroup = d.JointGroupCreate(0);
98 d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f); 97 d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f);
99 //d.WorldSetCFM(world, 1e-5f);
100 d.WorldSetAutoDisableFlag(world, false); 98 d.WorldSetAutoDisableFlag(world, false);
101 d.WorldSetContactSurfaceLayer(world, 0.001f); 99 d.WorldSetContactSurfaceLayer(world, 0.001f);
102 // d.CreatePlane(space, 0, 0, 1, 0);
103 this._heightmap = new double[65536]; 100 this._heightmap = new double[65536];
104 } 101 }
105 102
@@ -154,16 +151,19 @@ namespace OpenSim.Region.Physics.OdePlugin
154 { 151 {
155 foreach (OdeCharacter actor in _characters) 152 foreach (OdeCharacter actor in _characters)
156 { 153 {
157 actor.Move(timeStep * 5f); 154 actor.Move(timeStep);
158 } 155 }
159 d.SpaceCollide(space, IntPtr.Zero, nearCallback); 156 d.SpaceCollide(space, IntPtr.Zero, nearCallback);
160 d.WorldQuickStep(world, timeStep * 5f); 157 for (int i = 0; i < 50; i++)
158 {
159 d.WorldQuickStep(world, timeStep * 0.02f);
160 }
161
161 d.JointGroupEmpty(contactgroup); 162 d.JointGroupEmpty(contactgroup);
162 foreach (OdeCharacter actor in _characters) 163 foreach (OdeCharacter actor in _characters)
163 { 164 {
164 actor.UpdatePosition(); 165 actor.UpdatePosition();
165 } 166 }
166
167 } 167 }
168 168
169 public override void GetResults() 169 public override void GetResults()
@@ -221,7 +221,7 @@ namespace OpenSim.Region.Physics.OdePlugin
221 private PhysicsVector _position; 221 private PhysicsVector _position;
222 private PhysicsVector _velocity; 222 private PhysicsVector _velocity;
223 private PhysicsVector _acceleration; 223 private PhysicsVector _acceleration;
224 private bool flying; 224 private bool flying = false;
225 //private float gravityAccel; 225 //private float gravityAccel;
226 private IntPtr BoundingCapsule; 226 private IntPtr BoundingCapsule;
227 IntPtr capsule_geom; 227 IntPtr capsule_geom;
@@ -232,8 +232,8 @@ namespace OpenSim.Region.Physics.OdePlugin
232 _velocity = new PhysicsVector(); 232 _velocity = new PhysicsVector();
233 _position = pos; 233 _position = pos;
234 _acceleration = new PhysicsVector(); 234 _acceleration = new PhysicsVector();
235 d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f); 235 d.MassSetCapsule(out capsule_mass, 50.0f, 3, 0.5f, 2f);
236 capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f); 236 capsule_geom = d.CreateSphere(OdeScene.space, 1.0f); /// not a typo! Spheres roll, capsules tumble
237 this.BoundingCapsule = d.BodyCreate(OdeScene.world); 237 this.BoundingCapsule = d.BodyCreate(OdeScene.world);
238 d.BodySetMass(BoundingCapsule, ref capsule_mass); 238 d.BodySetMass(BoundingCapsule, ref capsule_mass);
239 d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); 239 d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z);
@@ -326,13 +326,14 @@ namespace OpenSim.Region.Physics.OdePlugin
326 public void Move(float timeStep) 326 public void Move(float timeStep)
327 { 327 {
328 PhysicsVector vec = new PhysicsVector(); 328 PhysicsVector vec = new PhysicsVector();
329 vec.X = this._velocity.X * timeStep; 329 d.Vector3 vel = d.BodyGetLinearVel(BoundingCapsule);
330 vec.Y = this._velocity.Y * timeStep; 330 vec.X = (vel.X - this._velocity.X) * -75000.0f;
331 vec.Y = (vel.Y - this._velocity.Y) * -75000.0f;
331 if (flying) 332 if (flying)
332 { 333 {
333 vec.Z = (this._velocity.Z + 0.5f) * timeStep; 334 vec.Z = (vel.Z - this._velocity.Z) * -75000.0f;
334 } 335 }
335 d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z); 336 d.BodyAddForce(this.BoundingCapsule, vec.X, vec.Y, vec.Z);
336 } 337 }
337 338
338 public void UpdatePosition() 339 public void UpdatePosition()
@@ -340,7 +341,7 @@ namespace OpenSim.Region.Physics.OdePlugin
340 d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); 341 d.Vector3 vec = d.BodyGetPosition(BoundingCapsule);
341 this._position.X = vec.X; 342 this._position.X = vec.X;
342 this._position.Y = vec.Y; 343 this._position.Y = vec.Y;
343 this._position.Z = vec.Z+1.0f; 344 this._position.Z = vec.Z;
344 } 345 }
345 } 346 }
346 347