aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorRobert Adams2012-09-13 10:11:39 -0700
committerRobert Adams2012-09-15 15:31:44 -0700
commit7c347f4c5c966848669b979b367e1bc3912621d5 (patch)
tree25c249932b72be0e6174c94b4d9b59fa271cb37e /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentBulletSim: remove unused NeedsMeshing() code from BSScene. (diff)
downloadopensim-SC_OLD-7c347f4c5c966848669b979b367e1bc3912621d5.zip
opensim-SC_OLD-7c347f4c5c966848669b979b367e1bc3912621d5.tar.gz
opensim-SC_OLD-7c347f4c5c966848669b979b367e1bc3912621d5.tar.bz2
opensim-SC_OLD-7c347f4c5c966848669b979b367e1bc3912621d5.tar.xz
BulletSim: Add calls to linkset class when object going static or dynamic.
Reset center of mass on an object when going dynamic.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs20
1 files changed, 14 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 481a8db..04b7be5 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -530,10 +530,14 @@ public sealed class BSPrim : BSPhysObject
530 m_currentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_STATIC_OBJECT); 530 m_currentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_STATIC_OBJECT);
531 // Stop all movement 531 // Stop all movement
532 BulletSimAPI.ClearAllForces2(BSBody.Ptr); 532 BulletSimAPI.ClearAllForces2(BSBody.Ptr);
533 // Center of mass is at the center of the object
534 BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.BSBody.Ptr, _position, _orientation);
533 // Mass is zero which disables a bunch of physics stuff in Bullet 535 // Mass is zero which disables a bunch of physics stuff in Bullet
534 BulletSimAPI.SetMassProps2(BSBody.Ptr, 0f, OMV.Vector3.Zero); 536 BulletSimAPI.SetMassProps2(BSBody.Ptr, 0f, OMV.Vector3.Zero);
535 // There is no inertia in a static object 537 // There is no inertia in a static object
536 BulletSimAPI.UpdateInertiaTensor2(BSBody.Ptr); 538 BulletSimAPI.UpdateInertiaTensor2(BSBody.Ptr);
539 // There can be special things needed for implementing linksets
540 Linkset.MakeStatic(this);
537 // The activation state is 'sleeping' so Bullet will not try to act on it 541 // The activation state is 'sleeping' so Bullet will not try to act on it
538 BulletSimAPI.ForceActivationState2(BSBody.Ptr, ActivationState.ISLAND_SLEEPING); 542 BulletSimAPI.ForceActivationState2(BSBody.Ptr, ActivationState.ISLAND_SLEEPING);
539 } 543 }
@@ -543,10 +547,12 @@ public sealed class BSPrim : BSPhysObject
543 m_currentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_STATIC_OBJECT); 547 m_currentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.CF_STATIC_OBJECT);
544 // A dynamic object has mass 548 // A dynamic object has mass
545 IntPtr collisionShapePtr = BulletSimAPI.GetCollisionShape2(BSBody.Ptr); 549 IntPtr collisionShapePtr = BulletSimAPI.GetCollisionShape2(BSBody.Ptr);
546 OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(collisionShapePtr, _mass); 550 OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(collisionShapePtr, Linkset.LinksetMass);
547 BulletSimAPI.SetMassProps2(BSBody.Ptr, _mass, inertia); 551 BulletSimAPI.SetMassProps2(BSBody.Ptr, _mass, inertia);
548 // Inertia is based on our new mass 552 // Inertia is based on our new mass
549 BulletSimAPI.UpdateInertiaTensor2(BSBody.Ptr); 553 BulletSimAPI.UpdateInertiaTensor2(BSBody.Ptr);
554 // There can be special things needed for implementing linksets
555 Linkset.MakeDynamic(this);
550 // Force activation of the object so Bullet will act on it. 556 // Force activation of the object so Bullet will act on it.
551 BulletSimAPI.Activate2(BSBody.Ptr, true); 557 BulletSimAPI.Activate2(BSBody.Ptr, true);
552 } 558 }
@@ -1055,11 +1061,12 @@ public sealed class BSPrim : BSPhysObject
1055 }// end CalculateMass 1061 }// end CalculateMass
1056 #endregion Mass Calculation 1062 #endregion Mass Calculation
1057 1063
1058 // Create the geometry information in Bullet for later use 1064 // Create the geometry information in Bullet for later use.
1059 // The objects needs a hull if it's physical otherwise a mesh is enough 1065 // The objects needs a hull if it's physical otherwise a mesh is enough.
1060 // No locking here because this is done when we know physics is not simulating 1066 // No locking here because this is done when we know physics is not simulating.
1061 // if 'forceRebuild' is true, the geometry is rebuilt. Otherwise a previously built version is used 1067 // if 'forceRebuild' is true, the geometry is rebuilt. Otherwise a previously built version is used.
1062 // Returns 'true' if the geometry was rebuilt 1068 // Returns 'true' if the geometry was rebuilt.
1069 // Called at taint-time!
1063 private bool CreateGeom(bool forceRebuild) 1070 private bool CreateGeom(bool forceRebuild)
1064 { 1071 {
1065 bool ret = false; 1072 bool ret = false;
@@ -1128,6 +1135,7 @@ public sealed class BSPrim : BSPhysObject
1128 1135
1129 // No locking here because this is done when we know physics is not simulating 1136 // No locking here because this is done when we know physics is not simulating
1130 // Returns 'true' of a mesh was actually rebuild (we could also have one of these specs). 1137 // Returns 'true' of a mesh was actually rebuild (we could also have one of these specs).
1138 // Called at taint-time!
1131 private bool CreateGeomMesh() 1139 private bool CreateGeomMesh()
1132 { 1140 {
1133 // level of detail based on size and type of the object 1141 // level of detail based on size and type of the object