aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorRobert Adams2012-09-19 08:21:29 -0700
committerRobert Adams2012-09-27 22:01:21 -0700
commita27e4ce6cbfb0a2e852624fd4d81121ca829f85c (patch)
treecd467ddf5dcc8a7109eef5d82f1929c1b5bf77b8 /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentBulletSim: Convert BSCharacter to use common BSPhysObject code and variables. (diff)
downloadopensim-SC-a27e4ce6cbfb0a2e852624fd4d81121ca829f85c.zip
opensim-SC-a27e4ce6cbfb0a2e852624fd4d81121ca829f85c.tar.gz
opensim-SC-a27e4ce6cbfb0a2e852624fd4d81121ca829f85c.tar.bz2
opensim-SC-a27e4ce6cbfb0a2e852624fd4d81121ca829f85c.tar.xz
BulletSim: add class and infrastructure for shape and object
tracking in the C# code. Needed for the changing body type (to and from GhostObjects) for volumeDetect.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs47
1 files changed, 41 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 4f10d46..4d17e6c 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -474,12 +474,13 @@ public sealed class BSPrim : BSPhysObject
474 */ 474 */
475 BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.Ptr, BSBody.Ptr); 475 BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.Ptr, BSBody.Ptr);
476 476
477 // Set up the object physicalness (does gravity and collisions move this object)
478 MakeDynamic(IsStatic);
479
480 // Make solid or not (do things bounce off or pass through this object) 477 // Make solid or not (do things bounce off or pass through this object)
478 // This is done first because it can change the collisionObject type.
481 MakeSolid(IsSolid); 479 MakeSolid(IsSolid);
482 480
481 // Set up the object physicalness (does gravity and collisions move this object)
482 MakeDynamic(IsStatic);
483
483 // Arrange for collisions events if the simulator wants them 484 // Arrange for collisions events if the simulator wants them
484 EnableCollisions(SubscribedEvents()); 485 EnableCollisions(SubscribedEvents());
485 486
@@ -554,17 +555,51 @@ public sealed class BSPrim : BSPhysObject
554 } 555 }
555 556
556 // "Making solid" means that other object will not pass through this object. 557 // "Making solid" means that other object will not pass through this object.
558 // To make transparent, we create a Bullet ghost object.
559 // Note: This expects to be called from the UpdatePhysicalParameters() routine as
560 // the functions after this one set up the state of a possibly newly created collision body.
557 private void MakeSolid(bool makeSolid) 561 private void MakeSolid(bool makeSolid)
558 { 562 {
563 CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(BSBody.Ptr);
564 /*
559 if (makeSolid) 565 if (makeSolid)
560 { 566 {
561 // Easy in Bullet -- just remove the object flag that controls collision response 567 if ((bodyType & CollisionObjectTypes.CO_RIGID_BODY) == 0)
562 CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); 568 {
569 // Solid things are made out of rigid bodies. Remove this old body from the world
570 // and use this shape in a new rigid body.
571 BulletBody oldBody = BSBody;
572 BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.Ptr, BSBody.Ptr);
573 BSShape = new BulletShape(BulletSimAPI.GetCollisionShape2(BSBody.Ptr));
574 BSBody = new BulletBody(LocalID, BulletSimAPI.CreateBodyFromShape2(PhysicsScene.World.Ptr, BSShape.Ptr, _position, _orientation));
575 BulletSimAPI.DestroyObject2(PhysicsScene.World.Ptr, oldBody.Ptr);
576 BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.Ptr, BSBody.Ptr);
577 }
563 } 578 }
564 else 579 else
565 { 580 {
566 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); 581 if ((bodyType & CollisionObjectTypes.CO_GHOST_OBJECT) == 0)
582 {
583 // Non-solid things are made out of ghost objects. Remove this old body from the world
584 // and use this shape in a new rigid body.
585 BulletBody oldBody = BSBody;
586 BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.Ptr, BSBody.Ptr);
587 BSShape = new BulletShape(BulletSimAPI.GetCollisionShape2(BSBody.Ptr));
588 BSBody = new BulletBody(LocalID,
589 BulletSimAPI.CreateGhostFromShape2(PhysicsScene.World.Ptr, BSShape.Ptr, _position, _orientation));
590 if (BSBody.Ptr == IntPtr.Zero)
591 {
592 m_log.ErrorFormat("{0} BSPrim.MakeSolid: failed creation of ghost object. LocalID=[1}", LogHeader, LocalID);
593 BSBody = oldBody;
594 }
595 else
596 {
597 BulletSimAPI.DestroyObject2(PhysicsScene.World.Ptr, oldBody.Ptr);
598 BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.Ptr, BSBody.Ptr);
599 }
600 }
567 } 601 }
602 */
568 } 603 }
569 604
570 // Turn on or off the flag controlling whether collision events are returned to the simulator. 605 // Turn on or off the flag controlling whether collision events are returned to the simulator.