diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index ebfd85b..8e6685b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -187,7 +187,7 @@ public sealed class BSPrim : PhysicsActor | |||
187 | { | 187 | { |
188 | _mass = CalculateMass(); // changing size changes the mass | 188 | _mass = CalculateMass(); // changing size changes the mass |
189 | BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical); | 189 | BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical); |
190 | DetailLog("{0}: setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical); | 190 | // DetailLog("{0}: setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical); |
191 | RecreateGeomAndObject(); | 191 | RecreateGeomAndObject(); |
192 | }); | 192 | }); |
193 | } | 193 | } |
@@ -318,7 +318,7 @@ public sealed class BSPrim : PhysicsActor | |||
318 | _force = value; | 318 | _force = value; |
319 | _scene.TaintedObject(delegate() | 319 | _scene.TaintedObject(delegate() |
320 | { | 320 | { |
321 | DetailLog("{0},SetForce,taint,force={1}", LocalID, _force); | 321 | DetailLog("{0},setForce,taint,force={1}", LocalID, _force); |
322 | // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); | 322 | // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); |
323 | BulletSimAPI.SetObjectForce2(Body.Ptr, _force); | 323 | BulletSimAPI.SetObjectForce2(Body.Ptr, _force); |
324 | }); | 324 | }); |
@@ -443,7 +443,7 @@ public sealed class BSPrim : PhysicsActor | |||
443 | _scene.TaintedObject(delegate() | 443 | _scene.TaintedObject(delegate() |
444 | { | 444 | { |
445 | // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); | 445 | // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); |
446 | DetailLog("{0},SetOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 446 | DetailLog("{0},setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
447 | BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); | 447 | BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); |
448 | }); | 448 | }); |
449 | } | 449 | } |
@@ -487,10 +487,8 @@ public sealed class BSPrim : PhysicsActor | |||
487 | // Maybe a VerifyCorrectPhysicalShape() routine? | 487 | // Maybe a VerifyCorrectPhysicalShape() routine? |
488 | // RecreateGeomAndObject(); | 488 | // RecreateGeomAndObject(); |
489 | 489 | ||
490 | float mass = _mass; | 490 | // Bullet wants static objects to have a mass of zero |
491 | // Bullet wants static objects have a mass of zero | 491 | float mass = IsStatic ? 0f : _mass; |
492 | if (IsStatic) | ||
493 | mass = 0f; | ||
494 | 492 | ||
495 | DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass); | 493 | DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass); |
496 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); | 494 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); |
@@ -607,6 +605,7 @@ public sealed class BSPrim : PhysicsActor | |||
607 | 605 | ||
608 | private List<OMV.Vector3> m_accumulatedForces = new List<OMV.Vector3>(); | 606 | private List<OMV.Vector3> m_accumulatedForces = new List<OMV.Vector3>(); |
609 | public override void AddForce(OMV.Vector3 force, bool pushforce) { | 607 | public override void AddForce(OMV.Vector3 force, bool pushforce) { |
608 | // for an object, doesn't matter if force is a pushforce or not | ||
610 | if (force.IsFinite()) | 609 | if (force.IsFinite()) |
611 | { | 610 | { |
612 | // _force += force; | 611 | // _force += force; |
@@ -620,21 +619,17 @@ public sealed class BSPrim : PhysicsActor | |||
620 | } | 619 | } |
621 | _scene.TaintedObject(delegate() | 620 | _scene.TaintedObject(delegate() |
622 | { | 621 | { |
622 | OMV.Vector3 fSum = OMV.Vector3.Zero; | ||
623 | lock (m_accumulatedForces) | 623 | lock (m_accumulatedForces) |
624 | { | 624 | { |
625 | if (m_accumulatedForces.Count > 0) | 625 | foreach (OMV.Vector3 v in m_accumulatedForces) |
626 | { | 626 | { |
627 | OMV.Vector3 fSum = OMV.Vector3.Zero; | 627 | fSum += v; |
628 | foreach (OMV.Vector3 v in m_accumulatedForces) | ||
629 | { | ||
630 | fSum += v; | ||
631 | } | ||
632 | m_accumulatedForces.Clear(); | ||
633 | |||
634 | DetailLog("{0},SetObjectForce,taint,force={1}", LocalID, fSum); | ||
635 | BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, fSum); | ||
636 | } | 628 | } |
629 | m_accumulatedForces.Clear(); | ||
637 | } | 630 | } |
631 | DetailLog("{0},AddObjectForce,taint,force={1}", LocalID, _force); | ||
632 | BulletSimAPI.AddObjectForce2(Body.Ptr, fSum); | ||
638 | }); | 633 | }); |
639 | } | 634 | } |
640 | 635 | ||
@@ -647,11 +642,23 @@ public sealed class BSPrim : PhysicsActor | |||
647 | } | 642 | } |
648 | public override void SubscribeEvents(int ms) { | 643 | public override void SubscribeEvents(int ms) { |
649 | _subscribedEventsMs = ms; | 644 | _subscribedEventsMs = ms; |
650 | // make sure first collision happens | 645 | if (ms > 0) |
651 | _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; | 646 | { |
647 | // make sure first collision happens | ||
648 | _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; | ||
649 | |||
650 | Scene.TaintedObject(delegate() | ||
651 | { | ||
652 | BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | ||
653 | }); | ||
654 | } | ||
652 | } | 655 | } |
653 | public override void UnSubscribeEvents() { | 656 | public override void UnSubscribeEvents() { |
654 | _subscribedEventsMs = 0; | 657 | _subscribedEventsMs = 0; |
658 | Scene.TaintedObject(delegate() | ||
659 | { | ||
660 | BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | ||
661 | }); | ||
655 | } | 662 | } |
656 | public override bool SubscribedEvents() { | 663 | public override bool SubscribedEvents() { |
657 | return (_subscribedEventsMs > 0); | 664 | return (_subscribedEventsMs > 0); |