aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorDan Lake2013-02-14 20:06:22 -0800
committerDan Lake2013-02-14 20:06:22 -0800
commite09467b30d5d27181c158961e95df25cd6001be5 (patch)
tree439acb650990a3495187f55d8a69b9a78f359c00 /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentUse SortedDictionary in StatsManager instead of regular Dictionary so stats w... (diff)
parentEnable one sub-test in TestJsonSetValue() which now works (using identifier w... (diff)
downloadopensim-SC-e09467b30d5d27181c158961e95df25cd6001be5.zip
opensim-SC-e09467b30d5d27181c158961e95df25cd6001be5.tar.gz
opensim-SC-e09467b30d5d27181c158961e95df25cd6001be5.tar.bz2
opensim-SC-e09467b30d5d27181c158961e95df25cd6001be5.tar.xz
Merge branch 'master' of git://opensimulator.org/git/opensim
Diffstat (limited to '')
-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