diff options
author | UbitUmarov | 2015-10-13 23:03:51 +0100 |
---|---|---|
committer | UbitUmarov | 2015-10-13 23:03:51 +0100 |
commit | 9ec9eee75fdf5a30a81226044691c0a5cc8419e9 (patch) | |
tree | b2670a8214447b0d6e44b8adcc2d69a6d9d1b113 /OpenSim/Region/PhysicsModules/ubOde | |
parent | change fps and dilation (still something not that usefull). make collisions ... (diff) | |
download | opensim-SC_OLD-9ec9eee75fdf5a30a81226044691c0a5cc8419e9.zip opensim-SC_OLD-9ec9eee75fdf5a30a81226044691c0a5cc8419e9.tar.gz opensim-SC_OLD-9ec9eee75fdf5a30a81226044691c0a5cc8419e9.tar.bz2 opensim-SC_OLD-9ec9eee75fdf5a30a81226044691c0a5cc8419e9.tar.xz |
reduce jitter due to viewer interpolators on objects that are really almost at rest
Diffstat (limited to 'OpenSim/Region/PhysicsModules/ubOde')
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | 124 |
1 files changed, 87 insertions, 37 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 229782b..1c215c1 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | |||
@@ -109,7 +109,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
109 | private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. | 109 | private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. |
110 | 110 | ||
111 | private int body_autodisable_frames; | 111 | private int body_autodisable_frames; |
112 | public int bodydisablecontrol; | 112 | public int bodydisablecontrol = 0; |
113 | private float m_gravmod = 1.0f; | 113 | private float m_gravmod = 1.0f; |
114 | 114 | ||
115 | // Default we're a Geometry | 115 | // Default we're a Geometry |
@@ -1633,7 +1633,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1633 | UpdateCollisionCatFlags(); | 1633 | UpdateCollisionCatFlags(); |
1634 | ApplyCollisionCatFlags(); | 1634 | ApplyCollisionCatFlags(); |
1635 | 1635 | ||
1636 | _zeroFlag = true; | ||
1636 | d.BodyEnable(Body); | 1637 | d.BodyEnable(Body); |
1638 | |||
1637 | } | 1639 | } |
1638 | } | 1640 | } |
1639 | resetCollisionAccounting(); | 1641 | resetCollisionAccounting(); |
@@ -1788,9 +1790,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1788 | 1790 | ||
1789 | d.BodySetAutoDisableFlag(Body, true); | 1791 | d.BodySetAutoDisableFlag(Body, true); |
1790 | d.BodySetAutoDisableSteps(Body, body_autodisable_frames); | 1792 | d.BodySetAutoDisableSteps(Body, body_autodisable_frames); |
1791 | d.BodySetAutoDisableAngularThreshold(Body, 0.01f); | 1793 | d.BodySetAutoDisableAngularThreshold(Body, 0.05f); |
1792 | d.BodySetAutoDisableLinearThreshold(Body, 0.01f); | 1794 | d.BodySetAutoDisableLinearThreshold(Body, 0.05f); |
1793 | d.BodySetDamping(Body, .005f, .001f); | 1795 | d.BodySetDamping(Body, .008f, .005f); |
1794 | 1796 | ||
1795 | if (m_targetSpace != IntPtr.Zero) | 1797 | if (m_targetSpace != IntPtr.Zero) |
1796 | { | 1798 | { |
@@ -1872,15 +1874,17 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1872 | createAMotor(m_angularlock); | 1874 | createAMotor(m_angularlock); |
1873 | } | 1875 | } |
1874 | 1876 | ||
1875 | |||
1876 | if (m_isSelected || m_disabled) | 1877 | if (m_isSelected || m_disabled) |
1877 | { | 1878 | { |
1878 | d.BodyDisable(Body); | 1879 | d.BodyDisable(Body); |
1880 | _zeroFlag = true; | ||
1879 | } | 1881 | } |
1880 | else | 1882 | else |
1881 | { | 1883 | { |
1882 | d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); | 1884 | d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); |
1883 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); | 1885 | d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); |
1886 | _zeroFlag = false; | ||
1887 | bodydisablecontrol = 0; | ||
1884 | } | 1888 | } |
1885 | _parent_scene.addActiveGroups(this); | 1889 | _parent_scene.addActiveGroups(this); |
1886 | } | 1890 | } |
@@ -2634,7 +2638,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2634 | if (!childPrim) | 2638 | if (!childPrim) |
2635 | { | 2639 | { |
2636 | if (Body != IntPtr.Zero && !m_disabled) | 2640 | if (Body != IntPtr.Zero && !m_disabled) |
2641 | { | ||
2642 | _zeroFlag = true; | ||
2637 | d.BodyEnable(Body); | 2643 | d.BodyEnable(Body); |
2644 | } | ||
2638 | } | 2645 | } |
2639 | // else if (_parent != null) | 2646 | // else if (_parent != null) |
2640 | // ((OdePrim)_parent).ChildSelectedChange(false); | 2647 | // ((OdePrim)_parent).ChildSelectedChange(false); |
@@ -2664,7 +2671,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2664 | { | 2671 | { |
2665 | FixInertia(newPos); | 2672 | FixInertia(newPos); |
2666 | if (!d.BodyIsEnabled(Body)) | 2673 | if (!d.BodyIsEnabled(Body)) |
2674 | { | ||
2675 | _zeroFlag = true; | ||
2667 | d.BodyEnable(Body); | 2676 | d.BodyEnable(Body); |
2677 | } | ||
2668 | } | 2678 | } |
2669 | } | 2679 | } |
2670 | else | 2680 | else |
@@ -2675,7 +2685,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2675 | _position = newPos; | 2685 | _position = newPos; |
2676 | } | 2686 | } |
2677 | if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) | 2687 | if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) |
2688 | { | ||
2689 | _zeroFlag = true; | ||
2678 | d.BodyEnable(Body); | 2690 | d.BodyEnable(Body); |
2691 | } | ||
2679 | } | 2692 | } |
2680 | } | 2693 | } |
2681 | else | 2694 | else |
@@ -2733,7 +2746,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2733 | createAMotor(m_angularlock); | 2746 | createAMotor(m_angularlock); |
2734 | } | 2747 | } |
2735 | if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) | 2748 | if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) |
2749 | { | ||
2750 | _zeroFlag = true; | ||
2736 | d.BodyEnable(Body); | 2751 | d.BodyEnable(Body); |
2752 | } | ||
2737 | } | 2753 | } |
2738 | } | 2754 | } |
2739 | else | 2755 | else |
@@ -2788,7 +2804,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
2788 | _position = newPos; | 2804 | _position = newPos; |
2789 | } | 2805 | } |
2790 | if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) | 2806 | if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) |
2807 | { | ||
2808 | _zeroFlag = true; | ||
2791 | d.BodyEnable(Body); | 2809 | d.BodyEnable(Body); |
2810 | } | ||
2792 | } | 2811 | } |
2793 | } | 2812 | } |
2794 | else | 2813 | else |
@@ -3265,14 +3284,20 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
3265 | // let vehicles sleep | 3284 | // let vehicles sleep |
3266 | if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) | 3285 | if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) |
3267 | return; | 3286 | return; |
3268 | |||
3269 | if (++bodydisablecontrol < 20) | ||
3270 | return; | ||
3271 | 3287 | ||
3288 | if (++bodydisablecontrol < 50) | ||
3289 | return; | ||
3290 | |||
3291 | // clear residuals | ||
3292 | d.BodySetAngularVel(Body,0f,0f,0f); | ||
3293 | d.BodySetLinearVel(Body,0f,0f,0f); | ||
3294 | _zeroFlag = true; | ||
3272 | d.BodyEnable(Body); | 3295 | d.BodyEnable(Body); |
3296 | bodydisablecontrol = -4; | ||
3273 | } | 3297 | } |
3274 | 3298 | ||
3275 | bodydisablecontrol = 0; | 3299 | if(bodydisablecontrol < 0) |
3300 | bodydisablecontrol ++; | ||
3276 | 3301 | ||
3277 | d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator | 3302 | d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator |
3278 | 3303 | ||
@@ -3440,6 +3465,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
3440 | if (_parent == null && !m_disabled && !m_building && !m_outbounds && Body != IntPtr.Zero) | 3465 | if (_parent == null && !m_disabled && !m_building && !m_outbounds && Body != IntPtr.Zero) |
3441 | { | 3466 | { |
3442 | bool bodyenabled = d.BodyIsEnabled(Body); | 3467 | bool bodyenabled = d.BodyIsEnabled(Body); |
3468 | |||
3469 | if(bodydisablecontrol < 0) | ||
3470 | return; | ||
3471 | |||
3443 | if (bodyenabled || !_zeroFlag) | 3472 | if (bodyenabled || !_zeroFlag) |
3444 | { | 3473 | { |
3445 | bool lastZeroFlag = _zeroFlag; | 3474 | bool lastZeroFlag = _zeroFlag; |
@@ -3532,24 +3561,61 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
3532 | // use positions since this are integrated quantities | 3561 | // use positions since this are integrated quantities |
3533 | // tolerance values depende a lot on simulation noise... | 3562 | // tolerance values depende a lot on simulation noise... |
3534 | // use simple math.abs since we dont need to be exact | 3563 | // use simple math.abs since we dont need to be exact |
3535 | 3564 | if(!bodyenabled) | |
3536 | if (!bodyenabled || | ||
3537 | (Math.Abs(_position.X - lpos.X) < 0.005f) | ||
3538 | && (Math.Abs(_position.Y - lpos.Y) < 0.005f) | ||
3539 | && (Math.Abs(_position.Z - lpos.Z) < 0.005f) | ||
3540 | && (Math.Abs(_orientation.X - ori.X) < 0.0005f) | ||
3541 | && (Math.Abs(_orientation.Y - ori.Y) < 0.0005f) | ||
3542 | && (Math.Abs(_orientation.Z - ori.Z) < 0.0005f) // ignore W | ||
3543 | ) | ||
3544 | { | 3565 | { |
3545 | _zeroFlag = true; | 3566 | _zeroFlag = true; |
3546 | } | 3567 | } |
3547 | else | 3568 | else |
3548 | _zeroFlag = false; | 3569 | { |
3570 | float poserror; | ||
3571 | float angerror; | ||
3572 | if(_zeroFlag) | ||
3573 | { | ||
3574 | poserror = 0.01f; | ||
3575 | angerror = 0.001f; | ||
3576 | } | ||
3577 | else | ||
3578 | { | ||
3579 | poserror = 0.005f; | ||
3580 | angerror = 0.0005f; | ||
3581 | } | ||
3549 | 3582 | ||
3550 | // update velocities and aceleration | 3583 | if ( |
3584 | (Math.Abs(_position.X - lpos.X) < poserror) | ||
3585 | && (Math.Abs(_position.Y - lpos.Y) < poserror) | ||
3586 | && (Math.Abs(_position.Z - lpos.Z) < poserror) | ||
3587 | && (Math.Abs(_orientation.X - ori.X) < angerror) | ||
3588 | && (Math.Abs(_orientation.Y - ori.Y) < angerror) | ||
3589 | && (Math.Abs(_orientation.Z - ori.Z) < angerror) // ignore W | ||
3590 | ) | ||
3591 | _zeroFlag = true; | ||
3592 | else | ||
3593 | _zeroFlag = false; | ||
3594 | } | ||
3595 | |||
3596 | // update position | ||
3551 | if (!(_zeroFlag && lastZeroFlag)) | 3597 | if (!(_zeroFlag && lastZeroFlag)) |
3552 | { | 3598 | { |
3599 | _position.X = lpos.X; | ||
3600 | _position.Y = lpos.Y; | ||
3601 | _position.Z = lpos.Z; | ||
3602 | |||
3603 | _orientation.X = ori.X; | ||
3604 | _orientation.Y = ori.Y; | ||
3605 | _orientation.Z = ori.Z; | ||
3606 | _orientation.W = ori.W; | ||
3607 | } | ||
3608 | |||
3609 | // update velocities and aceleration | ||
3610 | if (_zeroFlag || lastZeroFlag) | ||
3611 | { | ||
3612 | // disable interpolators | ||
3613 | _velocity = Vector3.Zero; | ||
3614 | _acceleration = Vector3.Zero; | ||
3615 | m_rotationalVelocity = Vector3.Zero; | ||
3616 | } | ||
3617 | else | ||
3618 | { | ||
3553 | d.Vector3 vel = d.BodyGetLinearVel(Body); | 3619 | d.Vector3 vel = d.BodyGetLinearVel(Body); |
3554 | 3620 | ||
3555 | _acceleration = _velocity; | 3621 | _acceleration = _velocity; |
@@ -3591,26 +3657,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
3591 | m_rotationalVelocity.Y = vel.Y; | 3657 | m_rotationalVelocity.Y = vel.Y; |
3592 | m_rotationalVelocity.Z = vel.Z; | 3658 | m_rotationalVelocity.Z = vel.Z; |
3593 | } | 3659 | } |
3594 | // } | ||
3595 | |||
3596 | _position.X = lpos.X; | ||
3597 | _position.Y = lpos.Y; | ||
3598 | _position.Z = lpos.Z; | ||
3599 | |||
3600 | _orientation.X = ori.X; | ||
3601 | _orientation.Y = ori.Y; | ||
3602 | _orientation.Z = ori.Z; | ||
3603 | _orientation.W = ori.W; | ||
3604 | } | 3660 | } |
3661 | |||
3605 | if (_zeroFlag) | 3662 | if (_zeroFlag) |
3606 | { | 3663 | { |
3607 | if (lastZeroFlag) | ||
3608 | { | ||
3609 | _velocity = Vector3.Zero; | ||
3610 | _acceleration = Vector3.Zero; | ||
3611 | m_rotationalVelocity = Vector3.Zero; | ||
3612 | } | ||
3613 | |||
3614 | if (!m_lastUpdateSent) | 3664 | if (!m_lastUpdateSent) |
3615 | { | 3665 | { |
3616 | base.RequestPhysicsterseUpdate(); | 3666 | base.RequestPhysicsterseUpdate(); |