aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs20
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs20
2 files changed, 32 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index dc1de6c..3d73887 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -202,6 +202,24 @@ public class BSLinkset
202 return com; 202 return com;
203 } 203 }
204 204
205 // The object is going dynamic (physical). Do any setup necessary
206 // for a dynamic linkset.
207 // Return 'true' if any properties updated on the passed object.
208 // Called at taint-time!
209 public bool MakeDynamic(BSPhysObject child)
210 {
211 return false;
212 }
213
214 // The object is going static (non-physical). Do any setup necessary
215 // for a static linkset.
216 // Return 'true' if any properties updated on the passed object.
217 // Called at taint-time!
218 public bool MakeStatic(BSPhysObject child)
219 {
220 return false;
221 }
222
205 // When physical properties are changed the linkset needs to recalculate 223 // When physical properties are changed the linkset needs to recalculate
206 // its internal properties. 224 // its internal properties.
207 public void Refresh(BSPhysObject requestor) 225 public void Refresh(BSPhysObject requestor)
@@ -255,13 +273,11 @@ public class BSLinkset
255 if (!somethingMissing) 273 if (!somethingMissing)
256 { 274 {
257 // The root prim takes on the weight of the whole linkset 275 // The root prim takes on the weight of the whole linkset
258 /*
259 OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(LinksetRoot.BSShape.Ptr, linksetMass); 276 OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(LinksetRoot.BSShape.Ptr, linksetMass);
260 BulletSimAPI.SetMassProps2(LinksetRoot.BSBody.Ptr, linksetMass, inertia); 277 BulletSimAPI.SetMassProps2(LinksetRoot.BSBody.Ptr, linksetMass, inertia);
261 OMV.Vector3 centerOfMass = ComputeLinksetCenterOfMass(); 278 OMV.Vector3 centerOfMass = ComputeLinksetCenterOfMass();
262 BulletSimAPI.SetCenterOfMassByPosRot2(LinksetRoot.BSBody.Ptr, centerOfMass, OMV.Quaternion.Identity); 279 BulletSimAPI.SetCenterOfMassByPosRot2(LinksetRoot.BSBody.Ptr, centerOfMass, OMV.Quaternion.Identity);
263 BulletSimAPI.UpdateInertiaTensor2(LinksetRoot.BSBody.Ptr); 280 BulletSimAPI.UpdateInertiaTensor2(LinksetRoot.BSBody.Ptr);
264 */
265 } 281 }
266 } 282 }
267 return; 283 return;
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