diff options
Diffstat (limited to 'OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs')
-rw-r--r-- | OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs | 121 |
1 files changed, 84 insertions, 37 deletions
diff --git a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs index 5e48de6..54a2033 100644 --- a/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/Ode/ODEPrim.cs | |||
@@ -1691,6 +1691,9 @@ Console.WriteLine(" JointCreateFixed"); | |||
1691 | float fy = 0; | 1691 | float fy = 0; |
1692 | float fz = 0; | 1692 | float fz = 0; |
1693 | 1693 | ||
1694 | if (outofBounds) | ||
1695 | return; | ||
1696 | |||
1694 | if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims. | 1697 | if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // KF: Only move root prims. |
1695 | { | 1698 | { |
1696 | if (m_vehicle.Type != Vehicle.TYPE_NONE) | 1699 | if (m_vehicle.Type != Vehicle.TYPE_NONE) |
@@ -2664,16 +2667,38 @@ Console.WriteLine(" JointCreateFixed"); | |||
2664 | 2667 | ||
2665 | public override void CrossingFailure() | 2668 | public override void CrossingFailure() |
2666 | { | 2669 | { |
2667 | m_crossingfailures++; | 2670 | /* |
2668 | if (m_crossingfailures > _parent_scene.geomCrossingFailuresBeforeOutofbounds) | 2671 | m_crossingfailures++; |
2669 | { | 2672 | if (m_crossingfailures > _parent_scene.geomCrossingFailuresBeforeOutofbounds) |
2670 | base.RaiseOutOfBounds(_position); | 2673 | { |
2671 | return; | 2674 | base.RaiseOutOfBounds(_position); |
2672 | } | 2675 | return; |
2673 | else if (m_crossingfailures == _parent_scene.geomCrossingFailuresBeforeOutofbounds) | 2676 | } |
2677 | else if (m_crossingfailures == _parent_scene.geomCrossingFailuresBeforeOutofbounds) | ||
2678 | { | ||
2679 | m_log.Warn("[PHYSICS]: Too many crossing failures for: " + Name); | ||
2680 | } | ||
2681 | */ | ||
2682 | _position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f); | ||
2683 | _position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f); | ||
2684 | _position.Z = Util.Clip(_position.Z + 0.2f, -100f, 50000f); | ||
2685 | |||
2686 | m_lastposition = _position; | ||
2687 | _velocity.X = 0; | ||
2688 | _velocity.Y = 0; | ||
2689 | _velocity.Z = 0; | ||
2690 | |||
2691 | m_lastVelocity = _velocity; | ||
2692 | |||
2693 | if (Body != IntPtr.Zero) | ||
2674 | { | 2694 | { |
2675 | m_log.Warn("[PHYSICS]: Too many crossing failures for: " + Name); | 2695 | d.BodySetLinearVel(Body, 0, 0, 0); // stop it |
2696 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); | ||
2676 | } | 2697 | } |
2698 | |||
2699 | outofBounds = false; | ||
2700 | base.RequestPhysicsterseUpdate(); | ||
2701 | |||
2677 | } | 2702 | } |
2678 | 2703 | ||
2679 | public override float Buoyancy | 2704 | public override float Buoyancy |
@@ -2712,6 +2737,8 @@ Console.WriteLine(" JointCreateFixed"); | |||
2712 | internal void UpdatePositionAndVelocity() | 2737 | internal void UpdatePositionAndVelocity() |
2713 | { | 2738 | { |
2714 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! | 2739 | // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! |
2740 | if (outofBounds) | ||
2741 | return; | ||
2715 | if (_parent == null) | 2742 | if (_parent == null) |
2716 | { | 2743 | { |
2717 | Vector3 pv = Vector3.Zero; | 2744 | Vector3 pv = Vector3.Zero; |
@@ -2728,12 +2755,6 @@ Console.WriteLine(" JointCreateFixed"); | |||
2728 | Vector3 l_position = Vector3.Zero; | 2755 | Vector3 l_position = Vector3.Zero; |
2729 | Quaternion l_orientation = Quaternion.Identity; | 2756 | Quaternion l_orientation = Quaternion.Identity; |
2730 | 2757 | ||
2731 | // kluge to keep things in bounds. ODE lets dead avatars drift away (they should be removed!) | ||
2732 | //if (vec.X < 0.0f) { vec.X = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } | ||
2733 | //if (vec.Y < 0.0f) { vec.Y = 0.0f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } | ||
2734 | //if (vec.X > 255.95f) { vec.X = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } | ||
2735 | //if (vec.Y > 255.95f) { vec.Y = 255.95f; if (Body != (IntPtr)0) d.BodySetAngularVel(Body, 0, 0, 0); } | ||
2736 | |||
2737 | m_lastposition = _position; | 2758 | m_lastposition = _position; |
2738 | m_lastorientation = _orientation; | 2759 | m_lastorientation = _orientation; |
2739 | 2760 | ||
@@ -2745,26 +2766,6 @@ Console.WriteLine(" JointCreateFixed"); | |||
2745 | l_orientation.Z = ori.Z; | 2766 | l_orientation.Z = ori.Z; |
2746 | l_orientation.W = ori.W; | 2767 | l_orientation.W = ori.W; |
2747 | 2768 | ||
2748 | if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || l_position.X < 0f || l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || l_position.Y < 0f) | ||
2749 | { | ||
2750 | //base.RaiseOutOfBounds(l_position); | ||
2751 | |||
2752 | if (m_crossingfailures < _parent_scene.geomCrossingFailuresBeforeOutofbounds) | ||
2753 | { | ||
2754 | _position = l_position; | ||
2755 | //_parent_scene.remActivePrim(this); | ||
2756 | if (_parent == null) | ||
2757 | base.RequestPhysicsterseUpdate(); | ||
2758 | return; | ||
2759 | } | ||
2760 | else | ||
2761 | { | ||
2762 | if (_parent == null) | ||
2763 | base.RaiseOutOfBounds(l_position); | ||
2764 | return; | ||
2765 | } | ||
2766 | } | ||
2767 | |||
2768 | if (l_position.Z < 0) | 2769 | if (l_position.Z < 0) |
2769 | { | 2770 | { |
2770 | // This is so prim that get lost underground don't fall forever and suck up | 2771 | // This is so prim that get lost underground don't fall forever and suck up |
@@ -2774,8 +2775,6 @@ Console.WriteLine(" JointCreateFixed"); | |||
2774 | // It's a hack and will generate a console message if it fails. | 2775 | // It's a hack and will generate a console message if it fails. |
2775 | 2776 | ||
2776 | //IsPhysical = false; | 2777 | //IsPhysical = false; |
2777 | if (_parent == null) | ||
2778 | base.RaiseOutOfBounds(_position); | ||
2779 | 2778 | ||
2780 | _acceleration.X = 0; | 2779 | _acceleration.X = 0; |
2781 | _acceleration.Y = 0; | 2780 | _acceleration.Y = 0; |
@@ -2789,16 +2788,64 @@ Console.WriteLine(" JointCreateFixed"); | |||
2789 | m_rotationalVelocity.Z = 0; | 2788 | m_rotationalVelocity.Z = 0; |
2790 | 2789 | ||
2791 | if (_parent == null) | 2790 | if (_parent == null) |
2791 | base.RaiseOutOfBounds(_position); | ||
2792 | |||
2793 | if (_parent == null) | ||
2792 | base.RequestPhysicsterseUpdate(); | 2794 | base.RequestPhysicsterseUpdate(); |
2793 | 2795 | ||
2794 | m_throttleUpdates = false; | 2796 | m_throttleUpdates = false; |
2795 | throttleCounter = 0; | 2797 | throttleCounter = 0; |
2796 | _zeroFlag = true; | 2798 | _zeroFlag = true; |
2797 | //outofBounds = true; | 2799 | //outofBounds = true; |
2800 | return; | ||
2798 | } | 2801 | } |
2799 | 2802 | ||
2803 | if (l_position.X > ((int)_parent_scene.WorldExtents.X - 0.05f) || l_position.X < 0f || l_position.Y > ((int)_parent_scene.WorldExtents.Y - 0.05f) || l_position.Y < 0f) | ||
2804 | { | ||
2805 | //base.RaiseOutOfBounds(l_position); | ||
2806 | /* | ||
2807 | if (m_crossingfailures < _parent_scene.geomCrossingFailuresBeforeOutofbounds) | ||
2808 | { | ||
2809 | _position = l_position; | ||
2810 | //_parent_scene.remActivePrim(this); | ||
2811 | if (_parent == null) | ||
2812 | base.RequestPhysicsterseUpdate(); | ||
2813 | return; | ||
2814 | } | ||
2815 | else | ||
2816 | { | ||
2817 | if (_parent == null) | ||
2818 | base.RaiseOutOfBounds(l_position); | ||
2819 | return; | ||
2820 | } | ||
2821 | */ | ||
2822 | outofBounds = true; | ||
2823 | // part near the border on outside | ||
2824 | if (l_position.X < 0) | ||
2825 | Util.Clamp(l_position.X, -0.1f, -2f); | ||
2826 | else | ||
2827 | Util.Clamp(l_position.X, _parent_scene.WorldExtents.X + 0.1f, _parent_scene.WorldExtents.X + 2f); | ||
2828 | if (l_position.Y < 0) | ||
2829 | Util.Clamp(l_position.Y, -0.1f, -2f); | ||
2830 | else | ||
2831 | Util.Clamp(l_position.Y, _parent_scene.WorldExtents.Y + 0.1f, _parent_scene.WorldExtents.Y + 2f); | ||
2832 | |||
2833 | d.BodySetPosition(Body, l_position.X, l_position.Y, l_position.Z); | ||
2834 | |||
2835 | // stop it | ||
2836 | d.BodySetAngularVel(Body, 0, 0, 0); | ||
2837 | d.BodySetLinearVel(Body, 0, 0, 0); | ||
2838 | disableBodySoft(); | ||
2839 | |||
2840 | // tell framework to fix it | ||
2841 | if (_parent == null) | ||
2842 | base.RequestPhysicsterseUpdate(); | ||
2843 | return; | ||
2844 | } | ||
2845 | |||
2846 | |||
2800 | //float Adiff = 1.0f - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)); | 2847 | //float Adiff = 1.0f - Math.Abs(Quaternion.Dot(m_lastorientation, l_orientation)); |
2801 | //Console.WriteLine("Adiff " + Name + " = " + Adiff); | 2848 | //Console.WriteLine("Adiff " + Name + " = " + Adiff); |
2802 | if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02) | 2849 | if ((Math.Abs(m_lastposition.X - l_position.X) < 0.02) |
2803 | && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) | 2850 | && (Math.Abs(m_lastposition.Y - l_position.Y) < 0.02) |
2804 | && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02) | 2851 | && (Math.Abs(m_lastposition.Z - l_position.Z) < 0.02) |