aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
authorBlueWall2012-12-12 16:15:32 -0500
committerBlueWall2012-12-12 16:15:32 -0500
commitc5d333c16cddbcbcceb1ed0bc937e5775c99c2bc (patch)
tree644d21cbd5b7e86d9ba3316979fd9a85bc028f51 /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
parentReplace Mono.Addins libraries (diff)
parentBulletSim: do not return the current velocity for targetVelocity. (diff)
downloadopensim-SC-c5d333c16cddbcbcceb1ed0bc937e5775c99c2bc.zip
opensim-SC-c5d333c16cddbcbcceb1ed0bc937e5775c99c2bc.tar.gz
opensim-SC-c5d333c16cddbcbcceb1ed0bc937e5775c99c2bc.tar.bz2
opensim-SC-c5d333c16cddbcbcceb1ed0bc937e5775c99c2bc.tar.xz
Merge branch 'master' of /home/opensim/var/repo/opensim
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs62
1 files changed, 42 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 21aa9be..83c78f6 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -124,7 +124,9 @@ public sealed class BSCharacter : BSPhysObject
124 PhysicsScene.TaintedObject("BSCharacter.destroy", delegate() 124 PhysicsScene.TaintedObject("BSCharacter.destroy", delegate()
125 { 125 {
126 PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null); 126 PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null);
127 PhysBody.Clear();
127 PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null); 128 PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null);
129 PhysShape.Clear();
128 }); 130 });
129 } 131 }
130 132
@@ -194,8 +196,11 @@ public sealed class BSCharacter : BSPhysObject
194 196
195 PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() 197 PhysicsScene.TaintedObject("BSCharacter.setSize", delegate()
196 { 198 {
197 BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); 199 if (PhysShape.HasPhysicalShape)
198 UpdatePhysicalMassProperties(RawMass); 200 {
201 BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale);
202 UpdatePhysicalMassProperties(RawMass);
203 }
199 }); 204 });
200 205
201 } 206 }
@@ -236,7 +241,8 @@ public sealed class BSCharacter : BSPhysObject
236 // Zero some other properties directly into the physics engine 241 // Zero some other properties directly into the physics engine
237 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() 242 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
238 { 243 {
239 BulletSimAPI.ClearAllForces2(PhysBody.ptr); 244 if (PhysBody.HasPhysicalBody)
245 BulletSimAPI.ClearAllForces2(PhysBody.ptr);
240 }); 246 });
241 } 247 }
242 public override void ZeroAngularMotion(bool inTaintTime) 248 public override void ZeroAngularMotion(bool inTaintTime)
@@ -245,10 +251,13 @@ public sealed class BSCharacter : BSPhysObject
245 251
246 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() 252 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate()
247 { 253 {
248 BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); 254 if (PhysBody.HasPhysicalBody)
249 BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); 255 {
250 // The next also get rid of applied linear force but the linear velocity is untouched. 256 BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
251 BulletSimAPI.ClearForces2(PhysBody.ptr); 257 BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero);
258 // The next also get rid of applied linear force but the linear velocity is untouched.
259 BulletSimAPI.ClearForces2(PhysBody.ptr);
260 }
252 }); 261 });
253 } 262 }
254 263
@@ -273,7 +282,8 @@ public sealed class BSCharacter : BSPhysObject
273 PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate() 282 PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate()
274 { 283 {
275 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 284 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
276 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); 285 if (PhysBody.HasPhysicalBody)
286 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
277 }); 287 });
278 } 288 }
279 } 289 }
@@ -332,7 +342,8 @@ public sealed class BSCharacter : BSPhysObject
332 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate() 342 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate()
333 { 343 {
334 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); 344 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
335 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); 345 if (PhysBody.HasPhysicalBody)
346 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
336 }); 347 });
337 ret = true; 348 ret = true;
338 } 349 }
@@ -359,7 +370,8 @@ public sealed class BSCharacter : BSPhysObject
359 PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate() 370 PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate()
360 { 371 {
361 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); 372 DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force);
362 BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); 373 if (PhysBody.HasPhysicalBody)
374 BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
363 }); 375 });
364 } 376 }
365 } 377 }
@@ -398,7 +410,8 @@ public sealed class BSCharacter : BSPhysObject
398 if (_currentFriction != PhysicsScene.Params.avatarStandingFriction) 410 if (_currentFriction != PhysicsScene.Params.avatarStandingFriction)
399 { 411 {
400 _currentFriction = PhysicsScene.Params.avatarStandingFriction; 412 _currentFriction = PhysicsScene.Params.avatarStandingFriction;
401 BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction); 413 if (PhysBody.HasPhysicalBody)
414 BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
402 } 415 }
403 } 416 }
404 else 417 else
@@ -406,7 +419,8 @@ public sealed class BSCharacter : BSPhysObject
406 if (_currentFriction != PhysicsScene.Params.avatarFriction) 419 if (_currentFriction != PhysicsScene.Params.avatarFriction)
407 { 420 {
408 _currentFriction = PhysicsScene.Params.avatarFriction; 421 _currentFriction = PhysicsScene.Params.avatarFriction;
409 BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction); 422 if (PhysBody.HasPhysicalBody)
423 BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction);
410 } 424 }
411 } 425 }
412 _velocity = value; 426 _velocity = value;
@@ -443,8 +457,11 @@ public sealed class BSCharacter : BSPhysObject
443 // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation); 457 // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation);
444 PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate() 458 PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate()
445 { 459 {
446 // _position = BulletSimAPI.GetPosition2(BSBody.ptr); 460 if (PhysBody.HasPhysicalBody)
447 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); 461 {
462 // _position = BulletSimAPI.GetPosition2(BSBody.ptr);
463 BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation);
464 }
448 }); 465 });
449 } 466 }
450 } 467 }
@@ -517,10 +534,13 @@ public sealed class BSCharacter : BSPhysObject
517 _floatOnWater = value; 534 _floatOnWater = value;
518 PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate() 535 PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate()
519 { 536 {
520 if (_floatOnWater) 537 if (PhysBody.HasPhysicalBody)
521 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); 538 {
522 else 539 if (_floatOnWater)
523 CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); 540 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
541 else
542 CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
543 }
524 }); 544 });
525 } 545 }
526 } 546 }
@@ -553,7 +573,8 @@ public sealed class BSCharacter : BSPhysObject
553 DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 573 DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
554 // Buoyancy is faked by changing the gravity applied to the object 574 // Buoyancy is faked by changing the gravity applied to the object
555 float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); 575 float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
556 BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav)); 576 if (PhysBody.HasPhysicalBody)
577 BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav));
557 } 578 }
558 } 579 }
559 580
@@ -599,7 +620,8 @@ public sealed class BSCharacter : BSPhysObject
599 PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate() 620 PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate()
600 { 621 {
601 DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force); 622 DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force);
602 BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); 623 if (PhysBody.HasPhysicalBody)
624 BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force);
603 }); 625 });
604 } 626 }
605 else 627 else