aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorRobert Adams2012-10-12 16:03:03 -0700
committerRobert Adams2012-10-19 10:51:58 -0700
commitfd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c (patch)
tree93606a507aa16538a73e10956735a66f4306fe18 /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentminor: Increase attachment name field from 36 to 50 chars in "attachments sho... (diff)
downloadopensim-SC_OLD-fd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c.zip
opensim-SC_OLD-fd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c.tar.gz
opensim-SC_OLD-fd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c.tar.bz2
opensim-SC_OLD-fd7a097849b8a405bdd62cfe6d4ee2bbf0a3961c.tar.xz
BulletSim: Update BSCharacter to use API2 interface.
Add capsule shape to BSShapeCollection(). Remember last updated values so inter frame diffs can be computed. Parameterize avatarStandingFriction and reduce to 10 from 999. The latter high value made avatars very hard to push. Set CCD parameters for prims and characters of specified.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs66
1 files changed, 44 insertions, 22 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 6a4365c..3421e30 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -172,11 +172,8 @@ public sealed class BSPrim : BSPhysObject
172 } 172 }
173 // Scale is what we set in the physics engine. It is different than 'size' in that 173 // Scale is what we set in the physics engine. It is different than 'size' in that
174 // 'size' can be encorporated into the mesh. In that case, the scale is <1,1,1>. 174 // 'size' can be encorporated into the mesh. In that case, the scale is <1,1,1>.
175 public OMV.Vector3 Scale 175 public override OMV.Vector3 Scale { get; set; }
176 { 176
177 get { return _scale; }
178 set { _scale = value; }
179 }
180 public override PrimitiveBaseShape Shape { 177 public override PrimitiveBaseShape Shape {
181 set { 178 set {
182 _pbs = value; 179 _pbs = value;
@@ -325,9 +322,9 @@ public sealed class BSPrim : BSPhysObject
325 } 322 }
326 323
327 // A version of the sanity check that also makes sure a new position value is 324 // A version of the sanity check that also makes sure a new position value is
328 // pushed back to the physics engine. This routine would be used by anyone 325 // pushed to the physics engine. This routine would be used by anyone
329 // who is not already pushing the value. 326 // who is not already pushing the value.
330 private bool PositionSanityCheck2(bool inTaintTime) 327 private bool PositionSanityCheck(bool inTaintTime)
331 { 328 {
332 bool ret = false; 329 bool ret = false;
333 if (PositionSanityCheck()) 330 if (PositionSanityCheck())
@@ -336,8 +333,8 @@ public sealed class BSPrim : BSPhysObject
336 // just assign to "Position" because of potential call loops. 333 // just assign to "Position" because of potential call loops.
337 BSScene.TaintCallback sanityOperation = delegate() 334 BSScene.TaintCallback sanityOperation = delegate()
338 { 335 {
339 DetailLog("{0},BSPrim.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); 336 DetailLog("{0},BSPrim.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
340 BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); 337 ForcePosition = _position;
341 }; 338 };
342 if (inTaintTime) 339 if (inTaintTime)
343 sanityOperation(); 340 sanityOperation();
@@ -547,13 +544,13 @@ public sealed class BSPrim : BSPhysObject
547 } 544 }
548 545
549 // An object is static (does not move) if selected or not physical 546 // An object is static (does not move) if selected or not physical
550 private bool IsStatic 547 public override bool IsStatic
551 { 548 {
552 get { return _isSelected || !IsPhysical; } 549 get { return _isSelected || !IsPhysical; }
553 } 550 }
554 551
555 // An object is solid if it's not phantom and if it's not doing VolumeDetect 552 // An object is solid if it's not phantom and if it's not doing VolumeDetect
556 public bool IsSolid 553 public override bool IsSolid
557 { 554 {
558 get { return !IsPhantom && !_isVolumeDetect; } 555 get { return !IsPhantom && !_isVolumeDetect; }
559 } 556 }
@@ -631,6 +628,12 @@ public sealed class BSPrim : BSPhysObject
631 BulletSimAPI.SetMassProps2(BSBody.ptr, 0f, OMV.Vector3.Zero); 628 BulletSimAPI.SetMassProps2(BSBody.ptr, 0f, OMV.Vector3.Zero);
632 // There is no inertia in a static object 629 // There is no inertia in a static object
633 BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); 630 BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr);
631 // Set collision detection parameters
632 if (PhysicsScene.Params.ccdMotionThreshold > 0f)
633 {
634 BulletSimAPI.SetCcdMotionThreshold2(BSBody.ptr, PhysicsScene.Params.ccdMotionThreshold);
635 BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius);
636 }
634 // There can be special things needed for implementing linksets 637 // There can be special things needed for implementing linksets
635 Linkset.MakeStatic(this); 638 Linkset.MakeStatic(this);
636 // The activation state is 'disabled' so Bullet will not try to act on it. 639 // The activation state is 'disabled' so Bullet will not try to act on it.
@@ -662,6 +665,13 @@ public sealed class BSPrim : BSPhysObject
662 BulletSimAPI.SetMassProps2(BSBody.ptr, _mass, inertia); 665 BulletSimAPI.SetMassProps2(BSBody.ptr, _mass, inertia);
663 BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); 666 BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr);
664 667
668 // Set collision detection parameters
669 if (PhysicsScene.Params.ccdMotionThreshold > 0f)
670 {
671 BulletSimAPI.SetCcdMotionThreshold2(BSBody.ptr, PhysicsScene.Params.ccdMotionThreshold);
672 BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius);
673 }
674
665 // Various values for simulation limits 675 // Various values for simulation limits
666 BulletSimAPI.SetDamping2(BSBody.ptr, PhysicsScene.Params.linearDamping, PhysicsScene.Params.angularDamping); 676 BulletSimAPI.SetDamping2(BSBody.ptr, PhysicsScene.Params.linearDamping, PhysicsScene.Params.angularDamping);
667 BulletSimAPI.SetDeactivationTime2(BSBody.ptr, PhysicsScene.Params.deactivationTime); 677 BulletSimAPI.SetDeactivationTime2(BSBody.ptr, PhysicsScene.Params.deactivationTime);
@@ -812,14 +822,21 @@ public sealed class BSPrim : BSPhysObject
812 set { 822 set {
813 _buoyancy = value; 823 _buoyancy = value;
814 PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate() 824 PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate()
815 { 825 {
816 // DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 826 ForceBuoyancy = _buoyancy;
817 // Buoyancy is faked by changing the gravity applied to the object
818 float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
819 BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav));
820 }); 827 });
821 } 828 }
822 } 829 }
830 public override float ForceBuoyancy {
831 get { return _buoyancy; }
832 set {
833 _buoyancy = value;
834 // DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
835 // Buoyancy is faked by changing the gravity applied to the object
836 float grav = PhysicsScene.Params.gravity * (1f - _buoyancy);
837 BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav));
838 }
839 }
823 840
824 // Used for MoveTo 841 // Used for MoveTo
825 public override OMV.Vector3 PIDTarget { 842 public override OMV.Vector3 PIDTarget {
@@ -1269,8 +1286,8 @@ public sealed class BSPrim : BSPhysObject
1269 const float VELOCITY_TOLERANCE = 0.001f; 1286 const float VELOCITY_TOLERANCE = 0.001f;
1270 const float POSITION_TOLERANCE = 0.05f; 1287 const float POSITION_TOLERANCE = 0.05f;
1271 const float ACCELERATION_TOLERANCE = 0.01f; 1288 const float ACCELERATION_TOLERANCE = 0.01f;
1272 const float ROTATIONAL_VELOCITY_TOLERANCE = 0.01f; 1289 const float ROTATIONAL_VELOCITY_TOLERANCE = 0.01f;
1273 1290
1274 public override void UpdateProperties(EntityProperties entprop) 1291 public override void UpdateProperties(EntityProperties entprop)
1275 { 1292 {
1276 /* 1293 /*
@@ -1326,11 +1343,13 @@ public sealed class BSPrim : BSPhysObject
1326 _orientation = entprop.Rotation; 1343 _orientation = entprop.Rotation;
1327 _velocity = entprop.Velocity; 1344 _velocity = entprop.Velocity;
1328 _acceleration = entprop.Acceleration; 1345 _acceleration = entprop.Acceleration;
1329 _rotationalVelocity = entprop.RotationalVelocity; 1346 _rotationalVelocity = entprop.RotationalVelocity;
1347
1348 // remember the current and last set values
1349 LastEntityProperties = CurrentEntityProperties;
1350 CurrentEntityProperties = entprop;
1330 1351
1331 PositionSanityCheck2(true); 1352 PositionSanityCheck(true);
1332
1333 Linkset.UpdateProperties(this);
1334 1353
1335 DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 1354 DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
1336 LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); 1355 LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
@@ -1348,6 +1367,9 @@ public sealed class BSPrim : BSPhysObject
1348 entprop.Acceleration, entprop.RotationalVelocity); 1367 entprop.Acceleration, entprop.RotationalVelocity);
1349 } 1368 }
1350 */ 1369 */
1370 // The linkset implimentation might want to know about this.
1371
1372 Linkset.UpdateProperties(this);
1351 } 1373 }
1352} 1374}
1353} 1375}