aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin/ODECharacter.cs')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs114
1 files changed, 56 insertions, 58 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index 9676db4..a118e7c 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -27,11 +27,9 @@
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic;
31using Axiom.Math; 30using Axiom.Math;
32using Ode.NET; 31using Ode.NET;
33using OpenSim.Framework; 32using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using OpenSim.Region.Physics.Manager; 33using OpenSim.Region.Physics.Manager;
36 34
37namespace OpenSim.Region.Physics.OdePlugin 35namespace OpenSim.Region.Physics.OdePlugin
@@ -87,7 +85,9 @@ namespace OpenSim.Region.Physics.OdePlugin
87 _acceleration = new PhysicsVector(); 85 _acceleration = new PhysicsVector();
88 _parent_scene = parent_scene; 86 _parent_scene = parent_scene;
89 87
90 m_StandUpRotation = new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f, -0.004689182f, 0.9998941f); 88 m_StandUpRotation =
89 new d.Matrix3(0.8184158f, -0.5744568f, -0.0139677f, 0.5744615f, 0.8185215f, -0.004074608f, 0.01377355f,
90 -0.004689182f, 0.9998941f);
91 91
92 for (int i = 0; i < 11; i++) 92 for (int i = 0; i < 11; i++)
93 { 93 {
@@ -105,12 +105,9 @@ namespace OpenSim.Region.Physics.OdePlugin
105 d.GeomSetBody(Shell, Body); 105 d.GeomSetBody(Shell, Body);
106 106
107 107
108
109
110 d.BodySetRotation(Body, ref m_StandUpRotation); 108 d.BodySetRotation(Body, ref m_StandUpRotation);
111 109
112 110
113
114 //Amotor = d.JointCreateAMotor(parent_scene.world, IntPtr.Zero); 111 //Amotor = d.JointCreateAMotor(parent_scene.world, IntPtr.Zero);
115 //d.JointAttach(Amotor, Body, IntPtr.Zero); 112 //d.JointAttach(Amotor, Body, IntPtr.Zero);
116 //d.JointSetAMotorMode(Amotor, dAMotorEuler); 113 //d.JointSetAMotorMode(Amotor, dAMotorEuler);
@@ -124,45 +121,47 @@ namespace OpenSim.Region.Physics.OdePlugin
124 //d.JointSetAMotorParam(Amotor, 0, -0); 121 //d.JointSetAMotorParam(Amotor, 0, -0);
125 //d.JointSetAMotorParam(Amotor, 0x200, -0); 122 //d.JointSetAMotorParam(Amotor, 0x200, -0);
126 //d.JointSetAMotorParam(Amotor, 0x100, -0); 123 //d.JointSetAMotorParam(Amotor, 0x100, -0);
127 // d.JointSetAMotorParam(Amotor, 0, 0); 124 // d.JointSetAMotorParam(Amotor, 0, 0);
128 // d.JointSetAMotorParam(Amotor, 3, 0); 125 // d.JointSetAMotorParam(Amotor, 3, 0);
129 // d.JointSetAMotorParam(Amotor, 2, 0); 126 // d.JointSetAMotorParam(Amotor, 2, 0);
130
131
132
133 } 127 }
134 m_name = avName; 128 m_name = avName;
135 parent_scene.geom_name_map[Shell] = avName; 129 parent_scene.geom_name_map[Shell] = avName;
136 parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 130 parent_scene.actor_name_map[Shell] = (PhysicsActor) this;
137 } 131 }
132
138 public override int PhysicsActorType 133 public override int PhysicsActorType
139 { 134 {
140 get { return (int)ActorTypes.Agent; } 135 get { return (int) ActorTypes.Agent; }
141 set { return; } 136 set { return; }
142 } 137 }
138
143 public override bool SetAlwaysRun 139 public override bool SetAlwaysRun
144 { 140 {
145 get { return m_alwaysRun; } 141 get { return m_alwaysRun; }
146 set { m_alwaysRun = value; } 142 set { m_alwaysRun = value; }
147 } 143 }
144
148 public override bool IsPhysical 145 public override bool IsPhysical
149 { 146 {
150 get { return false; } 147 get { return false; }
151 set { return; } 148 set { return; }
152 } 149 }
150
153 public override bool ThrottleUpdates 151 public override bool ThrottleUpdates
154 { 152 {
155 get { return false; } 153 get { return false; }
156 set { return; } 154 set { return; }
157 } 155 }
156
158 public override bool Flying 157 public override bool Flying
159 { 158 {
160 get { return flying; } 159 get { return flying; }
161 set { flying = value; } 160 set { flying = value; }
162 } 161 }
162
163 public override bool IsColliding 163 public override bool IsColliding
164 { 164 {
165
166 get { return m_iscolliding; } 165 get { return m_iscolliding; }
167 set 166 set
168 { 167 {
@@ -193,24 +192,22 @@ namespace OpenSim.Region.Physics.OdePlugin
193 192
194 // Equal truecounts and false counts means we're colliding with something. 193 // Equal truecounts and false counts means we're colliding with something.
195 194
196 if (falsecount > 1.2 * truecount) 195 if (falsecount > 1.2*truecount)
197 { 196 {
198 m_iscolliding = false; 197 m_iscolliding = false;
199 } 198 }
200 else 199 else
201 { 200 {
202 m_iscolliding = true; 201 m_iscolliding = true;
203
204
205 } 202 }
206 if (m_wascolliding != m_iscolliding) 203 if (m_wascolliding != m_iscolliding)
207 { 204 {
208 //base.SendCollisionUpdate(new CollisionEventUpdate()); 205 //base.SendCollisionUpdate(new CollisionEventUpdate());
209
210 } 206 }
211 m_wascolliding = m_iscolliding; 207 m_wascolliding = m_iscolliding;
212 } 208 }
213 } 209 }
210
214 public override bool CollidingGround 211 public override bool CollidingGround
215 { 212 {
216 get { return m_iscollidingGround; } 213 get { return m_iscollidingGround; }
@@ -243,7 +240,7 @@ namespace OpenSim.Region.Physics.OdePlugin
243 240
244 // Equal truecounts and false counts means we're colliding with something. 241 // Equal truecounts and false counts means we're colliding with something.
245 242
246 if (falsecount > 1.2 * truecount) 243 if (falsecount > 1.2*truecount)
247 { 244 {
248 m_iscollidingGround = false; 245 m_iscollidingGround = false;
249 } 246 }
@@ -258,10 +255,12 @@ namespace OpenSim.Region.Physics.OdePlugin
258 m_wascollidingGround = m_iscollidingGround; 255 m_wascollidingGround = m_iscollidingGround;
259 } 256 }
260 } 257 }
258
261 public override bool CollidingObj 259 public override bool CollidingObj
262 { 260 {
263 get { return m_iscollidingObj; } 261 get { return m_iscollidingObj; }
264 set { 262 set
263 {
265 m_iscollidingObj = value; 264 m_iscollidingObj = value;
266 if (value) 265 if (value)
267 m_pidControllerActive = false; 266 m_pidControllerActive = false;
@@ -269,10 +268,12 @@ namespace OpenSim.Region.Physics.OdePlugin
269 m_pidControllerActive = true; 268 m_pidControllerActive = true;
270 } 269 }
271 } 270 }
271
272 public void SetPidStatus(bool status) 272 public void SetPidStatus(bool status)
273 { 273 {
274 m_pidControllerActive = status; 274 m_pidControllerActive = status;
275 } 275 }
276
276 public override PhysicsVector Position 277 public override PhysicsVector Position
277 { 278 {
278 get { return _position; } 279 get { return _position; }
@@ -285,14 +286,16 @@ namespace OpenSim.Region.Physics.OdePlugin
285 } 286 }
286 } 287 }
287 } 288 }
289
288 public override PhysicsVector RotationalVelocity 290 public override PhysicsVector RotationalVelocity
289 { 291 {
290 get { return m_rotationalVelocity; } 292 get { return m_rotationalVelocity; }
291 set { m_rotationalVelocity = value; } 293 set { m_rotationalVelocity = value; }
292 } 294 }
295
293 public override PhysicsVector Size 296 public override PhysicsVector Size
294 { 297 {
295 get { return new PhysicsVector(CAPSULE_RADIUS * 2, CAPSULE_RADIUS * 2, CAPSULE_LENGTH); } 298 get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); }
296 set 299 set
297 { 300 {
298 m_pidControllerActive = true; 301 m_pidControllerActive = true;
@@ -303,7 +306,7 @@ namespace OpenSim.Region.Physics.OdePlugin
303 float capsuleradius = CAPSULE_RADIUS; 306 float capsuleradius = CAPSULE_RADIUS;
304 capsuleradius = 0.2f; 307 capsuleradius = 0.2f;
305 308
306 CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z * 0.43f))); // subtract 43% of the size 309 CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.43f))); // subtract 43% of the size
307 d.BodyDestroy(Body); 310 d.BodyDestroy(Body);
308 d.GeomDestroy(Shell); 311 d.GeomDestroy(Shell);
309 //MainLog.Instance.Verbose("PHYSICS", "Set Avatar Height To: " + (CAPSULE_RADIUS + CAPSULE_LENGTH)); 312 //MainLog.Instance.Verbose("PHYSICS", "Set Avatar Height To: " + (CAPSULE_RADIUS + CAPSULE_LENGTH));
@@ -311,25 +314,27 @@ namespace OpenSim.Region.Physics.OdePlugin
311 d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH); 314 d.MassSetCapsule(out ShellMass, m_density, 3, CAPSULE_RADIUS, CAPSULE_LENGTH);
312 Body = d.BodyCreate(_parent_scene.world); 315 Body = d.BodyCreate(_parent_scene.world);
313 d.BodySetMass(Body, ref ShellMass); 316 d.BodySetMass(Body, ref ShellMass);
314 d.BodySetPosition(Body, _position.X, _position.Y, _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule)); 317 d.BodySetPosition(Body, _position.X, _position.Y,
318 _position.Z + Math.Abs(CAPSULE_LENGTH - prevCapsule));
315 d.GeomSetBody(Shell, Body); 319 d.GeomSetBody(Shell, Body);
316 } 320 }
317 _parent_scene.geom_name_map[Shell] = m_name; 321 _parent_scene.geom_name_map[Shell] = m_name;
318 _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; 322 _parent_scene.actor_name_map[Shell] = (PhysicsActor) this;
319 } 323 }
320 } 324 }
325
321 public override float Mass 326 public override float Mass
322 { 327 {
323 get { 328 get
324 329 {
325 float AVvolume = (float)(Math.PI * Math.Pow(CAPSULE_RADIUS, 2) * CAPSULE_LENGTH); 330 float AVvolume = (float) (Math.PI*Math.Pow(CAPSULE_RADIUS, 2)*CAPSULE_LENGTH);
326 return m_density * AVvolume; 331 return m_density*AVvolume;
327 } 332 }
328 } 333 }
329 334
330 public override PhysicsVector Force 335 public override PhysicsVector Force
331 { 336 {
332 get { return new PhysicsVector(_target_velocity.X,_target_velocity.Y,_target_velocity.Z); } 337 get { return new PhysicsVector(_target_velocity.X, _target_velocity.Y, _target_velocity.Z); }
333 } 338 }
334 339
335 public override PhysicsVector CenterOfMass 340 public override PhysicsVector CenterOfMass
@@ -344,18 +349,17 @@ namespace OpenSim.Region.Physics.OdePlugin
344 349
345 public override PrimitiveBaseShape Shape 350 public override PrimitiveBaseShape Shape
346 { 351 {
347 set 352 set { return; }
348 {
349 return;
350 }
351 } 353 }
352 354
353 public override PhysicsVector Velocity 355 public override PhysicsVector Velocity
354 { 356 {
355 get { return _velocity; } 357 get { return _velocity; }
356 set { 358 set
359 {
357 m_pidControllerActive = true; 360 m_pidControllerActive = true;
358 _target_velocity = value; } 361 _target_velocity = value;
362 }
359 } 363 }
360 364
361 public override bool Kinematic 365 public override bool Kinematic
@@ -390,6 +394,7 @@ namespace OpenSim.Region.Physics.OdePlugin
390 394
391 //m_lastUpdateSent = false; 395 //m_lastUpdateSent = false;
392 } 396 }
397
393 public void doForce(PhysicsVector force) 398 public void doForce(PhysicsVector force)
394 { 399 {
395 if (!collidelock) 400 if (!collidelock)
@@ -413,13 +418,11 @@ namespace OpenSim.Region.Physics.OdePlugin
413 //d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); 418 //d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f);
414 419
415 //m_lastUpdateSent = false; 420 //m_lastUpdateSent = false;
416
417 } 421 }
418
419 } 422 }
423
420 public override void SetMomentum(PhysicsVector momentum) 424 public override void SetMomentum(PhysicsVector momentum)
421 { 425 {
422
423 } 426 }
424 427
425 public void Move(float timeStep) 428 public void Move(float timeStep)
@@ -442,7 +445,6 @@ namespace OpenSim.Region.Physics.OdePlugin
442 else 445 else
443 { 446 {
444 movementdivisor = 0.8f; 447 movementdivisor = 0.8f;
445
446 } 448 }
447 449
448 // if velocity is zero, use position control; otherwise, velocity control 450 // if velocity is zero, use position control; otherwise, velocity control
@@ -457,11 +459,11 @@ namespace OpenSim.Region.Physics.OdePlugin
457 if (m_pidControllerActive) 459 if (m_pidControllerActive)
458 { 460 {
459 d.Vector3 pos = d.BodyGetPosition(Body); 461 d.Vector3 pos = d.BodyGetPosition(Body);
460 vec.X = (_target_velocity.X - vel.X) * PID_D + (_zeroPosition.X - pos.X) * PID_P; 462 vec.X = (_target_velocity.X - vel.X)*PID_D + (_zeroPosition.X - pos.X)*PID_P;
461 vec.Y = (_target_velocity.Y - vel.Y) * PID_D + (_zeroPosition.Y - pos.Y) * PID_P; 463 vec.Y = (_target_velocity.Y - vel.Y)*PID_D + (_zeroPosition.Y - pos.Y)*PID_P;
462 if (flying) 464 if (flying)
463 { 465 {
464 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100) + (_zeroPosition.Z - pos.Z) * PID_P; 466 vec.Z = (_target_velocity.Z - vel.Z)*(PID_D + 5100) + (_zeroPosition.Z - pos.Z)*PID_P;
465 } 467 }
466 } 468 }
467 //PidStatus = true; 469 //PidStatus = true;
@@ -472,21 +474,20 @@ namespace OpenSim.Region.Physics.OdePlugin
472 _zeroFlag = false; 474 _zeroFlag = false;
473 if (m_iscolliding || flying) 475 if (m_iscolliding || flying)
474 { 476 {
475 477 vec.X = ((_target_velocity.X/movementdivisor) - vel.X)*PID_D;
476 vec.X = ((_target_velocity.X / movementdivisor) - vel.X) * PID_D; 478 vec.Y = ((_target_velocity.Y/movementdivisor) - vel.Y)*PID_D;
477 vec.Y = ((_target_velocity.Y / movementdivisor) - vel.Y) * PID_D;
478 } 479 }
479 if (m_iscolliding && !flying && _target_velocity.Z > 0.0f) 480 if (m_iscolliding && !flying && _target_velocity.Z > 0.0f)
480 { 481 {
481 d.Vector3 pos = d.BodyGetPosition(Body); 482 d.Vector3 pos = d.BodyGetPosition(Body);
482 vec.Z = (_target_velocity.Z - vel.Z) * PID_D + (_zeroPosition.Z - pos.Z) * PID_P; 483 vec.Z = (_target_velocity.Z - vel.Z)*PID_D + (_zeroPosition.Z - pos.Z)*PID_P;
483 if (_target_velocity.X > 0) 484 if (_target_velocity.X > 0)
484 { 485 {
485 vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; 486 vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D;
486 } 487 }
487 if (_target_velocity.Y > 0) 488 if (_target_velocity.Y > 0)
488 { 489 {
489 vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; 490 vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D;
490 } 491 }
491 } 492 }
492 else if (!m_iscolliding && !flying) 493 else if (!m_iscolliding && !flying)
@@ -494,19 +495,18 @@ namespace OpenSim.Region.Physics.OdePlugin
494 d.Vector3 pos = d.BodyGetPosition(Body); 495 d.Vector3 pos = d.BodyGetPosition(Body);
495 if (_target_velocity.X > 0) 496 if (_target_velocity.X > 0)
496 { 497 {
497 vec.X = ((_target_velocity.X - vel.X) / 1.2f) * PID_D; 498 vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D;
498 } 499 }
499 if (_target_velocity.Y > 0) 500 if (_target_velocity.Y > 0)
500 { 501 {
501 vec.Y = ((_target_velocity.Y - vel.Y) / 1.2f) * PID_D; 502 vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D;
502 } 503 }
503
504 } 504 }
505 505
506 506
507 if (flying) 507 if (flying)
508 { 508 {
509 vec.Z = (_target_velocity.Z - vel.Z) * (PID_D + 5100); 509 vec.Z = (_target_velocity.Z - vel.Z)*(PID_D + 5100);
510 } 510 }
511 } 511 }
512 if (flying) 512 if (flying)
@@ -546,13 +546,12 @@ namespace OpenSim.Region.Physics.OdePlugin
546 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position); 546 int[] arrayitem = _parent_scene.calculateSpaceArrayItemFromPos(_position);
547 //if (primScenAvatarIn == "0") 547 //if (primScenAvatarIn == "0")
548 //{ 548 //{
549 //MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); 549 //MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in space with no prim. Arr:':" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
550 //} 550 //}
551 //else 551 //else
552 //{ 552 //{
553 // MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString()); 553 // MainLog.Instance.Verbose("Physics", "Avatar " + m_name + " in Prim space':" + primScenAvatarIn + ". Arr:" + arrayitem[0].ToString() + "," + arrayitem[1].ToString());
554 //} 554 //}
555
556 } 555 }
557 } 556 }
558 else 557 else
@@ -586,12 +585,11 @@ namespace OpenSim.Region.Physics.OdePlugin
586 { 585 {
587 lock (OdeScene.OdeLock) 586 lock (OdeScene.OdeLock)
588 { 587 {
589 // d.JointDestroy(Amotor); 588 // d.JointDestroy(Amotor);
590 d.GeomDestroy(Shell); 589 d.GeomDestroy(Shell);
591 _parent_scene.geom_name_map.Remove(Shell); 590 _parent_scene.geom_name_map.Remove(Shell);
592 d.BodyDestroy(Body); 591 d.BodyDestroy(Body);
593 } 592 }
594 } 593 }
595 } 594 }
596 595} \ No newline at end of file
597}