aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs60
1 files changed, 18 insertions, 42 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index e6b8507..f80084a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -322,6 +322,7 @@ public sealed class BSPrim : BSPhysObject
322 }); 322 });
323 } 323 }
324 } 324 }
325
325 public override OMV.Vector3 ForcePosition { 326 public override OMV.Vector3 ForcePosition {
326 get { 327 get {
327 _position = PhysicsScene.PE.GetPosition(PhysBody) - PositionDisplacement; 328 _position = PhysicsScene.PE.GetPosition(PhysBody) - PositionDisplacement;
@@ -336,25 +337,6 @@ public sealed class BSPrim : BSPhysObject
336 } 337 }
337 } 338 }
338 } 339 }
339 // Override to have position displacement immediately update the physical position.
340 // A feeble attempt to keep the sim and physical positions in sync
341 // Must be called at taint time.
342 public override OMV.Vector3 PositionDisplacement
343 {
344 get
345 {
346 return base.PositionDisplacement;
347 }
348 set
349 {
350 base.PositionDisplacement = value;
351 PhysicsScene.TaintedObject(PhysicsScene.InTaintTime, "BSPrim.setPosition", delegate()
352 {
353 if (PhysBody.HasPhysicalBody)
354 PhysicsScene.PE.SetTranslation(PhysBody, _position + base.PositionDisplacement, _orientation);
355 });
356 }
357 }
358 340
359 // Check that the current position is sane and, if not, modify the position to make it so. 341 // Check that the current position is sane and, if not, modify the position to make it so.
360 // Check for being below terrain and being out of bounds. 342 // Check for being below terrain and being out of bounds.
@@ -371,11 +353,11 @@ public sealed class BSPrim : BSPhysObject
371 return ret; 353 return ret;
372 } 354 }
373 355
374 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); 356 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
375 OMV.Vector3 upForce = OMV.Vector3.Zero; 357 OMV.Vector3 upForce = OMV.Vector3.Zero;
376 if (RawPosition.Z < terrainHeight) 358 if (RawPosition.Z < terrainHeight)
377 { 359 {
378 DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight); 360 DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight);
379 float targetHeight = terrainHeight + (Size.Z / 2f); 361 float targetHeight = terrainHeight + (Size.Z / 2f);
380 // If the object is below ground it just has to be moved up because pushing will 362 // If the object is below ground it just has to be moved up because pushing will
381 // not get it through the terrain 363 // not get it through the terrain
@@ -1606,11 +1588,6 @@ public sealed class BSPrim : BSPhysObject
1606 // Called at taint-time!!! 1588 // Called at taint-time!!!
1607 public void CreateGeomAndObject(bool forceRebuild) 1589 public void CreateGeomAndObject(bool forceRebuild)
1608 { 1590 {
1609 // If this prim is part of a linkset, we must remove and restore the physical
1610 // links if the body is rebuilt.
1611 bool needToRestoreLinkset = false;
1612 bool needToRestoreVehicle = false;
1613
1614 // Create the correct physical representation for this type of object. 1591 // Create the correct physical representation for this type of object.
1615 // Updates PhysBody and PhysShape with the new information. 1592 // Updates PhysBody and PhysShape with the new information.
1616 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. 1593 // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary.
@@ -1619,21 +1596,10 @@ public sealed class BSPrim : BSPhysObject
1619 // Called if the current prim body is about to be destroyed. 1596 // Called if the current prim body is about to be destroyed.
1620 // Remove all the physical dependencies on the old body. 1597 // Remove all the physical dependencies on the old body.
1621 // (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...) 1598 // (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...)
1622 needToRestoreLinkset = Linkset.RemoveBodyDependencies(this); 1599 Linkset.RemoveBodyDependencies(this);
1623 needToRestoreVehicle = _vehicle.RemoveBodyDependencies(this); 1600 _vehicle.RemoveBodyDependencies(this);
1624 }); 1601 });
1625 1602
1626 if (needToRestoreLinkset)
1627 {
1628 // If physical body dependencies were removed, restore them
1629 Linkset.RestoreBodyDependencies(this);
1630 }
1631 if (needToRestoreVehicle)
1632 {
1633 // If physical body dependencies were removed, restore them
1634 _vehicle.RestoreBodyDependencies(this);
1635 }
1636
1637 // Make sure the properties are set on the new object 1603 // Make sure the properties are set on the new object
1638 UpdatePhysicalParameters(); 1604 UpdatePhysicalParameters();
1639 return; 1605 return;
@@ -1653,14 +1619,25 @@ public sealed class BSPrim : BSPhysObject
1653 // entprop.RotationalVelocity = OMV.Vector3.Zero; 1619 // entprop.RotationalVelocity = OMV.Vector3.Zero;
1654 } 1620 }
1655 1621
1622 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1623
1624 // Undo any center-of-mass displacement that might have been done.
1625 if (PositionDisplacement != OMV.Vector3.Zero)
1626 {
1627 // Correct for any rotation around the center-of-mass
1628 // TODO!!!
1629 entprop.Position -= PositionDisplacement;
1630 }
1631
1656 // Assign directly to the local variables so the normal set actions do not happen 1632 // Assign directly to the local variables so the normal set actions do not happen
1657 entprop.Position -= PositionDisplacement;
1658 _position = entprop.Position; 1633 _position = entprop.Position;
1659 _orientation = entprop.Rotation; 1634 _orientation = entprop.Rotation;
1660 _velocity = entprop.Velocity; 1635 _velocity = entprop.Velocity;
1661 _acceleration = entprop.Acceleration; 1636 _acceleration = entprop.Acceleration;
1662 _rotationalVelocity = entprop.RotationalVelocity; 1637 _rotationalVelocity = entprop.RotationalVelocity;
1663 1638
1639 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1640
1664 // The sanity check can change the velocity and/or position. 1641 // The sanity check can change the velocity and/or position.
1665 if (IsPhysical && PositionSanityCheck(true)) 1642 if (IsPhysical && PositionSanityCheck(true))
1666 { 1643 {
@@ -1669,8 +1646,7 @@ public sealed class BSPrim : BSPhysObject
1669 } 1646 }
1670 1647
1671 OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG 1648 OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG
1672 DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},dir={3},vel={4},rotVel={5}", 1649 DetailLog("{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction);
1673 LocalID, _position, _orientation, direction, _velocity, _rotationalVelocity);
1674 1650
1675 // remember the current and last set values 1651 // remember the current and last set values
1676 LastEntityProperties = CurrentEntityProperties; 1652 LastEntityProperties = CurrentEntityProperties;