aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs105
1 files changed, 79 insertions, 26 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
index faa9488..4cac0aa 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs
@@ -25,7 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28/* Revision 2011/12 by Ubit Umarov 28/* Revision 2011/12/13 by Ubit Umarov
29 * 29 *
30 * 30 *
31 */ 31 */
@@ -115,7 +115,7 @@ namespace OpenSim.Region.Physics.OdePlugin
115 115
116 private int body_autodisable_frames; 116 private int body_autodisable_frames;
117 public int bodydisablecontrol; 117 public int bodydisablecontrol;
118 118 private float m_gravmod = 1.0f;
119 119
120 // Default we're a Geometry 120 // Default we're a Geometry
121 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom); 121 private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
@@ -914,6 +914,55 @@ namespace OpenSim.Region.Physics.OdePlugin
914 bounce = _parent_scene.m_materialContactsData[pMaterial].bounce; 914 bounce = _parent_scene.m_materialContactsData[pMaterial].bounce;
915 } 915 }
916 916
917 public override float Density
918 {
919 get
920 {
921 return m_density * 100f;
922 }
923 set
924 {
925 m_density = value / 100f;
926 // for not prim mass is not updated since this implies full rebuild of body inertia TODO
927 }
928 }
929 public override float GravModifier
930 {
931 get
932 {
933 return m_gravmod;
934 }
935 set
936 {
937 m_gravmod = value;
938 if (m_vehicle != null)
939 m_vehicle.GravMod = m_gravmod;
940 }
941 }
942 public override float Friction
943 {
944 get
945 {
946 return mu;
947 }
948 set
949 {
950 mu = value;
951 }
952 }
953
954 public override float Restitution
955 {
956 get
957 {
958 return bounce;
959 }
960 set
961 {
962 bounce = value;
963 }
964 }
965
917 public void setPrimForRemoval() 966 public void setPrimForRemoval()
918 { 967 {
919 AddChange(changes.Remove, null); 968 AddChange(changes.Remove, null);
@@ -1736,7 +1785,9 @@ namespace OpenSim.Region.Physics.OdePlugin
1736 1785
1737 d.BodySetAutoDisableFlag(Body, true); 1786 d.BodySetAutoDisableFlag(Body, true);
1738 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 1787 d.BodySetAutoDisableSteps(Body, body_autodisable_frames);
1739 d.BodySetDamping(Body, .005f, .005f); 1788 d.BodySetAutoDisableAngularThreshold(Body, 0.01f);
1789 d.BodySetAutoDisableLinearThreshold(Body, 0.01f);
1790 d.BodySetDamping(Body, .005f, .001f);
1740 1791
1741 if (m_targetSpace != IntPtr.Zero) 1792 if (m_targetSpace != IntPtr.Zero)
1742 { 1793 {
@@ -2144,7 +2195,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2144 2195
2145 _mass = primMass; // just in case 2196 _mass = primMass; // just in case
2146 2197
2147 d.MassSetBoxTotal(out primdMass, primMass, m_OBB.X, m_OBB.Y, m_OBB.Z); 2198 d.MassSetBoxTotal(out primdMass, primMass, 2.0f * m_OBB.X, 2.0f * m_OBB.Y, 2.0f * m_OBB.Z);
2148 2199
2149 d.MassTranslate(ref primdMass, 2200 d.MassTranslate(ref primdMass,
2150 m_OBBOffset.X, 2201 m_OBBOffset.X,
@@ -2362,6 +2413,7 @@ namespace OpenSim.Region.Physics.OdePlugin
2362 MakeBody(); 2413 MakeBody();
2363 } 2414 }
2364 2415
2416
2365 #region changes 2417 #region changes
2366 2418
2367 private void changeadd() 2419 private void changeadd()
@@ -3213,7 +3265,6 @@ namespace OpenSim.Region.Physics.OdePlugin
3213 3265
3214 if (++bodydisablecontrol < 20) 3266 if (++bodydisablecontrol < 20)
3215 return; 3267 return;
3216
3217 3268
3218 d.BodyEnable(Body); 3269 d.BodyEnable(Body);
3219 } 3270 }
@@ -3334,7 +3385,7 @@ namespace OpenSim.Region.Physics.OdePlugin
3334 } 3385 }
3335 else 3386 else
3336 { 3387 {
3337 float b = (1.0f - m_buoyancy); 3388 float b = (1.0f - m_buoyancy) * m_gravmod;
3338 fx = _parent_scene.gravityx * b; 3389 fx = _parent_scene.gravityx * b;
3339 fy = _parent_scene.gravityy * b; 3390 fy = _parent_scene.gravityy * b;
3340 fz = _parent_scene.gravityz * b; 3391 fz = _parent_scene.gravityz * b;
@@ -3381,11 +3432,12 @@ namespace OpenSim.Region.Physics.OdePlugin
3381 } 3432 }
3382 } 3433 }
3383 3434
3384 public void UpdatePositionAndVelocity() 3435 public void UpdatePositionAndVelocity(int frame)
3385 { 3436 {
3386 if (_parent == null && !m_disabled && !m_building && !m_outbounds && Body != IntPtr.Zero) 3437 if (_parent == null && !m_disabled && !m_building && !m_outbounds && Body != IntPtr.Zero)
3387 { 3438 {
3388 if (d.BodyIsEnabled(Body) || !_zeroFlag) 3439 bool bodyenabled = d.BodyIsEnabled(Body);
3440 if (bodyenabled || !_zeroFlag)
3389 { 3441 {
3390 bool lastZeroFlag = _zeroFlag; 3442 bool lastZeroFlag = _zeroFlag;
3391 3443
@@ -3478,13 +3530,13 @@ namespace OpenSim.Region.Physics.OdePlugin
3478 // tolerance values depende a lot on simulation noise... 3530 // tolerance values depende a lot on simulation noise...
3479 // use simple math.abs since we dont need to be exact 3531 // use simple math.abs since we dont need to be exact
3480 3532
3481 if ( 3533 if (!bodyenabled ||
3482 (Math.Abs(_position.X - lpos.X) < 0.001f) 3534 (Math.Abs(_position.X - lpos.X) < 0.005f)
3483 && (Math.Abs(_position.Y - lpos.Y) < 0.001f) 3535 && (Math.Abs(_position.Y - lpos.Y) < 0.005f)
3484 && (Math.Abs(_position.Z - lpos.Z) < 0.001f) 3536 && (Math.Abs(_position.Z - lpos.Z) < 0.005f)
3485 && (Math.Abs(_orientation.X - ori.X) < 0.0001f) 3537 && (Math.Abs(_orientation.X - ori.X) < 0.0005f)
3486 && (Math.Abs(_orientation.Y - ori.Y) < 0.0001f) 3538 && (Math.Abs(_orientation.Y - ori.Y) < 0.0005f)
3487 && (Math.Abs(_orientation.Z - ori.Z) < 0.0001f) // ignore W 3539 && (Math.Abs(_orientation.Z - ori.Z) < 0.0005f) // ignore W
3488 ) 3540 )
3489 { 3541 {
3490 _zeroFlag = true; 3542 _zeroFlag = true;
@@ -3499,9 +3551,9 @@ namespace OpenSim.Region.Physics.OdePlugin
3499 3551
3500 _acceleration = _velocity; 3552 _acceleration = _velocity;
3501 3553
3502 if ((Math.Abs(vel.X) < 0.001f) && 3554 if ((Math.Abs(vel.X) < 0.005f) &&
3503 (Math.Abs(vel.Y) < 0.001f) && 3555 (Math.Abs(vel.Y) < 0.005f) &&
3504 (Math.Abs(vel.Z) < 0.001f)) 3556 (Math.Abs(vel.Z) < 0.005f))
3505 { 3557 {
3506 _velocity = Vector3.Zero; 3558 _velocity = Vector3.Zero;
3507 float t = -m_invTimeStep; 3559 float t = -m_invTimeStep;
@@ -3538,6 +3590,15 @@ namespace OpenSim.Region.Physics.OdePlugin
3538 } 3590 }
3539 } 3591 }
3540 3592
3593 _position.X = lpos.X;
3594 _position.Y = lpos.Y;
3595 _position.Z = lpos.Z;
3596
3597 _orientation.X = ori.X;
3598 _orientation.Y = ori.Y;
3599 _orientation.Z = ori.Z;
3600 _orientation.W = ori.W;
3601
3541 if (_zeroFlag) 3602 if (_zeroFlag)
3542 { 3603 {
3543 if (lastZeroFlag) 3604 if (lastZeroFlag)
@@ -3556,14 +3617,6 @@ namespace OpenSim.Region.Physics.OdePlugin
3556 return; 3617 return;
3557 } 3618 }
3558 3619
3559 _position.X = lpos.X;
3560 _position.Y = lpos.Y;
3561 _position.Z = lpos.Z;
3562
3563 _orientation.X = ori.X;
3564 _orientation.Y = ori.Y;
3565 _orientation.Z = ori.Z;
3566 _orientation.W = ori.W;
3567 base.RequestPhysicsterseUpdate(); 3620 base.RequestPhysicsterseUpdate();
3568 m_lastUpdateSent = false; 3621 m_lastUpdateSent = false;
3569 } 3622 }