aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorMelanie2013-02-13 01:54:06 +0000
committerMelanie2013-02-13 01:54:06 +0000
commitd0c5e0990bbfe3104afa78c8c6dbe500a451396d (patch)
tree082e368b1d2b5c7cb7cef27e50523c1406aa3e3e /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff)
downloadopensim-SC-d0c5e0990bbfe3104afa78c8c6dbe500a451396d.zip
opensim-SC-d0c5e0990bbfe3104afa78c8c6dbe500a451396d.tar.gz
opensim-SC-d0c5e0990bbfe3104afa78c8c6dbe500a451396d.tar.bz2
opensim-SC-d0c5e0990bbfe3104afa78c8c6dbe500a451396d.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs59
1 files changed, 54 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index cf7aa0f..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);
@@ -442,7 +482,7 @@ public class BSPrim : BSPhysObject
442 RegisterPreStepAction("BSPrim.setForce", LocalID, 482 RegisterPreStepAction("BSPrim.setForce", LocalID,
443 delegate(float timeStep) 483 delegate(float timeStep)
444 { 484 {
445 if (!IsPhysicallyActive) 485 if (!IsPhysicallyActive || _force == OMV.Vector3.Zero)
446 { 486 {
447 UnRegisterPreStepAction("BSPrim.setForce", LocalID); 487 UnRegisterPreStepAction("BSPrim.setForce", LocalID);
448 return; 488 return;
@@ -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; }
@@ -647,7 +689,7 @@ public class BSPrim : BSPhysObject
647 RegisterPreStepAction("BSPrim.setTorque", LocalID, 689 RegisterPreStepAction("BSPrim.setTorque", LocalID,
648 delegate(float timeStep) 690 delegate(float timeStep)
649 { 691 {
650 if (!IsPhysicallyActive) 692 if (!IsPhysicallyActive || _torque == OMV.Vector3.Zero)
651 { 693 {
652 UnRegisterPreStepAction("BSPrim.setTorque", LocalID); 694 UnRegisterPreStepAction("BSPrim.setTorque", LocalID);
653 return; 695 return;
@@ -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