aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorRobert Adams2013-02-12 15:45:44 -0800
committerRobert Adams2013-02-12 15:52:10 -0800
commit0194a3d890b95c8a29fcdf130c378e3a8a629c77 (patch)
treedf1d9993266ab8460809fb8c901e7f08d7b3bdba /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentBulletSim: More work on center-of-mass. Remove linksetinfo and rely on simula... (diff)
downloadopensim-SC_OLD-0194a3d890b95c8a29fcdf130c378e3a8a629c77.zip
opensim-SC_OLD-0194a3d890b95c8a29fcdf130c378e3a8a629c77.tar.gz
opensim-SC_OLD-0194a3d890b95c8a29fcdf130c378e3a8a629c77.tar.bz2
opensim-SC_OLD-0194a3d890b95c8a29fcdf130c378e3a8a629c77.tar.xz
BulletSim: fix density since the simulator/viewer track density in a
funny unit that is 100 times real density (default 1000). Fix avatar drifting slowly when stationary flying. Fix for physical prims getting corrected for being under terrain when it was just its geometric center that was below terrain. Add PreUpdatePropertyAction allowing plugable modifiction of phys parameters returned from Bullet. Fix an exception setting GravityMultiplier on initialization. Update DLLs and SOs for good measure (no functional change).
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs55
1 files changed, 52 insertions, 3 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index a76f8b9..0323b0d 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -242,6 +242,45 @@ public class BSPrim : BSPhysObject
242 public override void LockAngularMotion(OMV.Vector3 axis) 242 public override void LockAngularMotion(OMV.Vector3 axis)
243 { 243 {
244 DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); 244 DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis);
245
246 OMV.Vector3 locking = new OMV.Vector3(1f, 1f, 1f);
247 if (axis.X != 1) locking.X = 0f;
248 if (axis.Y != 1) locking.Y = 0f;
249 if (axis.Z != 1) locking.Z = 0f;
250 LockedAxis = locking;
251
252 /* Not implemented yet
253 if (LockedAxis != LockedAxisFree)
254 {
255 // Something is locked so start the thingy that keeps that axis from changing
256 RegisterPreUpdatePropertyAction("BSPrim.LockAngularMotion", delegate(ref EntityProperties entprop)
257 {
258 if (LockedAxis != LockedAxisFree)
259 {
260 if (IsPhysicallyActive)
261 {
262 // Bullet can lock axis but it only works for global axis.
263 // Check if this prim is aligned on global axis and use Bullet's
264 // system if so.
265
266 ForceOrientation = entprop.Rotation;
267 ForceRotationalVelocity = entprop.RotationalVelocity;
268 }
269 }
270 else
271 {
272 UnRegisterPreUpdatePropertyAction("BSPrim.LockAngularMotion");
273 }
274
275 });
276 }
277 else
278 {
279 // Everything seems unlocked
280 UnRegisterPreUpdatePropertyAction("BSPrim.LockAngularMotion");
281 }
282 */
283
245 return; 284 return;
246 } 285 }
247 286
@@ -311,7 +350,8 @@ public class BSPrim : BSPhysObject
311 350
312 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); 351 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
313 OMV.Vector3 upForce = OMV.Vector3.Zero; 352 OMV.Vector3 upForce = OMV.Vector3.Zero;
314 if (RawPosition.Z < terrainHeight) 353 float approxSize = Math.Max(Size.X, Math.Max(Size.Y, Size.Z));
354 if ((RawPosition.Z + approxSize / 2f) < terrainHeight)
315 { 355 {
316 DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight); 356 DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight);
317 float targetHeight = terrainHeight + (Size.Z / 2f); 357 float targetHeight = terrainHeight + (Size.Z / 2f);
@@ -576,6 +616,8 @@ public class BSPrim : BSPhysObject
576 } 616 }
577 } 617 }
578 } 618 }
619 // The simulator/viewer keep density as 100kg/m3.
620 // Remember to use BSParam.DensityScaleFactor to create the physical density.
579 public override float Density 621 public override float Density
580 { 622 {
581 get { return base.Density; } 623 get { return base.Density; }
@@ -1569,7 +1611,8 @@ public class BSPrim : BSPhysObject
1569 profileEnd = 1.0f - (float)BaseShape.ProfileEnd * 2.0e-5f; 1611 profileEnd = 1.0f - (float)BaseShape.ProfileEnd * 2.0e-5f;
1570 volume *= (profileEnd - profileBegin); 1612 volume *= (profileEnd - profileBegin);
1571 1613
1572 returnMass = Density * volume; 1614 returnMass = Density * BSParam.DensityScaleFactor * volume;
1615 DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass);
1573 1616
1574 returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass); 1617 returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass);
1575 1618
@@ -1607,6 +1650,8 @@ public class BSPrim : BSPhysObject
1607 // the world that things have changed. 1650 // the world that things have changed.
1608 public override void UpdateProperties(EntityProperties entprop) 1651 public override void UpdateProperties(EntityProperties entprop)
1609 { 1652 {
1653 TriggerPreUpdatePropertyAction(ref entprop);
1654
1610 // A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet 1655 // A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet
1611 // TODO: handle physics introduced by Bullet with computed vehicle physics. 1656 // TODO: handle physics introduced by Bullet with computed vehicle physics.
1612 if (VehicleController.IsActive) 1657 if (VehicleController.IsActive)
@@ -1619,7 +1664,11 @@ public class BSPrim : BSPhysObject
1619 // Assign directly to the local variables so the normal set actions do not happen 1664 // Assign directly to the local variables so the normal set actions do not happen
1620 _position = entprop.Position; 1665 _position = entprop.Position;
1621 _orientation = entprop.Rotation; 1666 _orientation = entprop.Rotation;
1622 _velocity = entprop.Velocity; 1667 // _velocity = entprop.Velocity;
1668 // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be
1669 // very sensitive to velocity changes.
1670 if (!entprop.Velocity.ApproxEquals(_velocity, 0.1f))
1671 _velocity = entprop.Velocity;
1623 _acceleration = entprop.Acceleration; 1672 _acceleration = entprop.Acceleration;
1624 _rotationalVelocity = entprop.RotationalVelocity; 1673 _rotationalVelocity = entprop.RotationalVelocity;
1625 1674