diff options
author | Adam Frisby | 2007-07-06 05:41:22 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-06 05:41:22 +0000 |
commit | e8671a2c05334f8d4d2ad9e9f7b868ccdd59f39a (patch) | |
tree | cca920829c8f63259f0d4cdd2766d60e9cbfd5b1 | |
parent | * Changed XmlRpc to specify utf-8 (diff) | |
download | opensim-SC_OLD-e8671a2c05334f8d4d2ad9e9f7b868ccdd59f39a.zip opensim-SC_OLD-e8671a2c05334f8d4d2ad9e9f7b868ccdd59f39a.tar.gz opensim-SC_OLD-e8671a2c05334f8d4d2ad9e9f7b868ccdd59f39a.tar.bz2 opensim-SC_OLD-e8671a2c05334f8d4d2ad9e9f7b868ccdd59f39a.tar.xz |
* Maintainence: Applying Dan's ODE Patch to Trunk
-rw-r--r-- | OpenSim/OpenSim.Physics/OdePlugin/OdePlugin.cs | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/OpenSim/OpenSim.Physics/OdePlugin/OdePlugin.cs b/OpenSim/OpenSim.Physics/OdePlugin/OdePlugin.cs index 5233042..6758f76 100644 --- a/OpenSim/OpenSim.Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/OpenSim.Physics/OdePlugin/OdePlugin.cs | |||
@@ -84,21 +84,18 @@ namespace OpenSim.Physics.OdePlugin | |||
84 | 84 | ||
85 | public OdeScene() | 85 | public OdeScene() |
86 | { | 86 | { |
87 | contact.surface.mode = d.ContactFlags.Bounce | d.ContactFlags.SoftCFM; | 87 | contact.surface.mode |= d.ContactFlags.Approx1 | d.ContactFlags.SoftCFM | d.ContactFlags.SoftERP; |
88 | contact.surface.mu = d.Infinity; | 88 | contact.surface.mu = 10.0f; |
89 | contact.surface.mu2 = 0.0f; | 89 | contact.surface.bounce = 0.9f; |
90 | contact.surface.bounce = 0.1f; | 90 | contact.surface.soft_erp = 0.005f; |
91 | contact.surface.bounce_vel = 0.1f; | 91 | contact.surface.soft_cfm = 0.00003f; |
92 | contact.surface.soft_cfm = 0.01f; | ||
93 | 92 | ||
94 | world = d.WorldCreate(); | 93 | world = d.WorldCreate(); |
95 | space = d.HashSpaceCreate(IntPtr.Zero); | 94 | space = d.HashSpaceCreate(IntPtr.Zero); |
96 | contactgroup = d.JointGroupCreate(0); | 95 | contactgroup = d.JointGroupCreate(0); |
97 | d.WorldSetGravity(world, 0.0f, 0.0f, -0.5f); | 96 | d.WorldSetGravity(world, 0.0f, 0.0f, -10.0f); |
98 | //d.WorldSetCFM(world, 1e-5f); | ||
99 | d.WorldSetAutoDisableFlag(world, false); | 97 | d.WorldSetAutoDisableFlag(world, false); |
100 | d.WorldSetContactSurfaceLayer(world, 0.001f); | 98 | d.WorldSetContactSurfaceLayer(world, 0.001f); |
101 | // d.CreatePlane(space, 0, 0, 1, 0); | ||
102 | this._heightmap = new double[65536]; | 99 | this._heightmap = new double[65536]; |
103 | } | 100 | } |
104 | 101 | ||
@@ -153,16 +150,19 @@ namespace OpenSim.Physics.OdePlugin | |||
153 | { | 150 | { |
154 | foreach (OdeCharacter actor in _characters) | 151 | foreach (OdeCharacter actor in _characters) |
155 | { | 152 | { |
156 | actor.Move(timeStep * 5f); | 153 | actor.Move(timeStep); |
157 | } | 154 | } |
158 | d.SpaceCollide(space, IntPtr.Zero, nearCallback); | 155 | d.SpaceCollide(space, IntPtr.Zero, nearCallback); |
159 | d.WorldQuickStep(world, timeStep * 5f); | 156 | for (int i = 0; i < 50; i++) |
157 | { | ||
158 | d.WorldQuickStep(world, timeStep * 0.02f); | ||
159 | } | ||
160 | |||
160 | d.JointGroupEmpty(contactgroup); | 161 | d.JointGroupEmpty(contactgroup); |
161 | foreach (OdeCharacter actor in _characters) | 162 | foreach (OdeCharacter actor in _characters) |
162 | { | 163 | { |
163 | actor.UpdatePosition(); | 164 | actor.UpdatePosition(); |
164 | } | 165 | } |
165 | |||
166 | } | 166 | } |
167 | 167 | ||
168 | public override void GetResults() | 168 | public override void GetResults() |
@@ -220,7 +220,7 @@ namespace OpenSim.Physics.OdePlugin | |||
220 | private PhysicsVector _position; | 220 | private PhysicsVector _position; |
221 | private PhysicsVector _velocity; | 221 | private PhysicsVector _velocity; |
222 | private PhysicsVector _acceleration; | 222 | private PhysicsVector _acceleration; |
223 | private bool flying; | 223 | private bool flying = false; |
224 | //private float gravityAccel; | 224 | //private float gravityAccel; |
225 | private IntPtr BoundingCapsule; | 225 | private IntPtr BoundingCapsule; |
226 | IntPtr capsule_geom; | 226 | IntPtr capsule_geom; |
@@ -231,8 +231,8 @@ namespace OpenSim.Physics.OdePlugin | |||
231 | _velocity = new PhysicsVector(); | 231 | _velocity = new PhysicsVector(); |
232 | _position = pos; | 232 | _position = pos; |
233 | _acceleration = new PhysicsVector(); | 233 | _acceleration = new PhysicsVector(); |
234 | d.MassSetCapsule(out capsule_mass, 5.0f, 3, 0.5f, 2f); | 234 | d.MassSetCapsule(out capsule_mass, 50.0f, 3, 0.5f, 2f); |
235 | capsule_geom = d.CreateCapsule(OdeScene.space, 0.5f, 2f); | 235 | capsule_geom = d.CreateSphere(OdeScene.space, 1.0f); /// not a typo! Spheres roll, capsules tumble |
236 | this.BoundingCapsule = d.BodyCreate(OdeScene.world); | 236 | this.BoundingCapsule = d.BodyCreate(OdeScene.world); |
237 | d.BodySetMass(BoundingCapsule, ref capsule_mass); | 237 | d.BodySetMass(BoundingCapsule, ref capsule_mass); |
238 | d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); | 238 | d.BodySetPosition(BoundingCapsule, pos.X, pos.Y, pos.Z); |
@@ -325,13 +325,14 @@ namespace OpenSim.Physics.OdePlugin | |||
325 | public void Move(float timeStep) | 325 | public void Move(float timeStep) |
326 | { | 326 | { |
327 | PhysicsVector vec = new PhysicsVector(); | 327 | PhysicsVector vec = new PhysicsVector(); |
328 | vec.X = this._velocity.X * timeStep; | 328 | d.Vector3 vel = d.BodyGetLinearVel(BoundingCapsule); |
329 | vec.Y = this._velocity.Y * timeStep; | 329 | vec.X = (vel.X - this._velocity.X) * -75000.0f; |
330 | vec.Y = (vel.Y - this._velocity.Y) * -75000.0f; | ||
330 | if (flying) | 331 | if (flying) |
331 | { | 332 | { |
332 | vec.Z = (this._velocity.Z + 0.5f) * timeStep; | 333 | vec.Z = (vel.Z - this._velocity.Z) * -75000.0f; |
333 | } | 334 | } |
334 | d.BodySetLinearVel(this.BoundingCapsule, vec.X, vec.Y, vec.Z); | 335 | d.BodyAddForce(this.BoundingCapsule, vec.X, vec.Y, vec.Z); |
335 | } | 336 | } |
336 | 337 | ||
337 | public void UpdatePosition() | 338 | public void UpdatePosition() |
@@ -339,7 +340,7 @@ namespace OpenSim.Physics.OdePlugin | |||
339 | d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); | 340 | d.Vector3 vec = d.BodyGetPosition(BoundingCapsule); |
340 | this._position.X = vec.X; | 341 | this._position.X = vec.X; |
341 | this._position.Y = vec.Y; | 342 | this._position.Y = vec.Y; |
342 | this._position.Z = vec.Z+1.0f; | 343 | this._position.Z = vec.Z; |
343 | } | 344 | } |
344 | } | 345 | } |
345 | 346 | ||