diff options
Diffstat (limited to 'OpenSim/Region/Physics/ChOdePlugin')
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 85 | ||||
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | 20 |
2 files changed, 87 insertions, 18 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 42e22ff..a68dcb7 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | |||
@@ -166,7 +166,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
166 | public int m_roundsUnderMotionThreshold; | 166 | public int m_roundsUnderMotionThreshold; |
167 | private int m_crossingfailures; | 167 | private int m_crossingfailures; |
168 | 168 | ||
169 | public bool outofBounds; | 169 | public bool m_outofBounds; |
170 | private float m_density = 10.000006836f; // Aluminum g/cm3; | 170 | private float m_density = 10.000006836f; // Aluminum g/cm3; |
171 | 171 | ||
172 | public bool _zeroFlag; // if body has been stopped | 172 | public bool _zeroFlag; // if body has been stopped |
@@ -732,16 +732,38 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
732 | 732 | ||
733 | public override void CrossingFailure() | 733 | public override void CrossingFailure() |
734 | { | 734 | { |
735 | m_crossingfailures++; | 735 | if (m_outofBounds) |
736 | if (m_crossingfailures > _parent_scene.geomCrossingFailuresBeforeOutofbounds) | 736 | { |
737 | _position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f); | ||
738 | _position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f); | ||
739 | _position.Z = Util.Clip(_position.Z, -100f, 50000f); | ||
740 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); | ||
741 | |||
742 | m_lastposition = _position; | ||
743 | |||
744 | _velocity = Vector3.Zero; | ||
745 | m_lastVelocity = _velocity; | ||
746 | |||
747 | |||
748 | if (m_type != Vehicle.TYPE_NONE) | ||
749 | Halt(); | ||
750 | |||
751 | d.BodySetLinearVel(Body, 0, 0, 0); | ||
752 | base.RequestPhysicsterseUpdate(); | ||
753 | m_outofBounds = false; | ||
754 | } | ||
755 | /* | ||
756 | int tmp = Interlocked.Increment(ref m_crossingfailures); | ||
757 | if (tmp > _parent_scene.geomCrossingFailuresBeforeOutofbounds) | ||
737 | { | 758 | { |
738 | base.RaiseOutOfBounds(_position); | 759 | base.RaiseOutOfBounds(_position); |
739 | return; | 760 | return; |
740 | } | 761 | } |
741 | else if (m_crossingfailures == _parent_scene.geomCrossingFailuresBeforeOutofbounds) | 762 | else if (tmp == _parent_scene.geomCrossingFailuresBeforeOutofbounds) |
742 | { | 763 | { |
743 | m_log.Warn("[PHYSICS]: Too many crossing failures for: " + m_primName); | 764 | m_log.Warn("[PHYSICS]: Too many crossing failures for: " + m_primName); |
744 | } | 765 | } |
766 | */ | ||
745 | } | 767 | } |
746 | 768 | ||
747 | public override float Buoyancy | 769 | public override float Buoyancy |
@@ -3011,7 +3033,7 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!"); | |||
3011 | 3033 | ||
3012 | if(revcount > 0) revcount--; | 3034 | if(revcount > 0) revcount--; |
3013 | 3035 | ||
3014 | if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // Only move root prims. | 3036 | if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim && !m_outofBounds) // Only move root prims. |
3015 | { | 3037 | { |
3016 | // Old public void UpdatePositionAndVelocity(), more accuratley calculated here | 3038 | // Old public void UpdatePositionAndVelocity(), more accuratley calculated here |
3017 | bool lastZeroFlag = _zeroFlag; // was it stopped | 3039 | bool lastZeroFlag = _zeroFlag; // was it stopped |
@@ -3042,10 +3064,9 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!"); | |||
3042 | d.Vector3 torque = d.BodyGetTorque(Body); | 3064 | d.Vector3 torque = d.BodyGetTorque(Body); |
3043 | _torque = new Vector3(torque.X, torque.Y, torque.Z); | 3065 | _torque = new Vector3(torque.X, torque.Y, torque.Z); |
3044 | 3066 | ||
3045 | base.RequestPhysicsterseUpdate(); | ||
3046 | 3067 | ||
3047 | //Console.WriteLine("Move {0} at {1}", m_primName, l_position); | 3068 | //Console.WriteLine("Move {0} at {1}", m_primName, l_position); |
3048 | 3069 | /* | |
3049 | // Check if outside region | 3070 | // Check if outside region |
3050 | // In Scene.cs/CrossPrimGroupIntoNewRegion the object is checked for 0.1M from border! | 3071 | // In Scene.cs/CrossPrimGroupIntoNewRegion the object is checked for 0.1M from border! |
3051 | if (l_position.X > ((float)_parent_scene.WorldExtents.X - fence)) | 3072 | if (l_position.X > ((float)_parent_scene.WorldExtents.X - fence)) |
@@ -3112,7 +3133,55 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!"); | |||
3112 | return; // Dont process any other motion? | 3133 | return; // Dont process any other motion? |
3113 | } // end various methods | 3134 | } // end various methods |
3114 | } // end outside region horizontally | 3135 | } // end outside region horizontally |
3115 | 3136 | */ | |
3137 | if (_position.X < 0f || _position.X > _parent_scene.WorldExtents.X | ||
3138 | || _position.Y < 0f || _position.Y > _parent_scene.WorldExtents.Y | ||
3139 | ) | ||
3140 | { | ||
3141 | // we are outside current region | ||
3142 | // clip position to a stop just outside region and stop it only internally | ||
3143 | // do it only once using m_crossingfailures as control | ||
3144 | _position.X = Util.Clip(l_position.X, -0.2f, _parent_scene.WorldExtents.X + .2f); | ||
3145 | _position.Y = Util.Clip(l_position.Y, -0.2f, _parent_scene.WorldExtents.Y + .2f); | ||
3146 | _position.Z = Util.Clip(l_position.Z, -100f, 50000f); | ||
3147 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); | ||
3148 | d.BodySetLinearVel(Body, 0, 0, 0); | ||
3149 | /* | ||
3150 | if (Interlocked.Exchange(ref m_crossingfailures, m_crossingfailures) == 0) | ||
3151 | { // tell base code only once | ||
3152 | Interlocked.Increment(ref m_crossingfailures); | ||
3153 | base.RequestPhysicsterseUpdate(); | ||
3154 | } | ||
3155 | */ | ||
3156 | m_outofBounds = true; | ||
3157 | base.RequestPhysicsterseUpdate(); | ||
3158 | return; | ||
3159 | } | ||
3160 | /* | ||
3161 | if (Interlocked.Exchange(ref m_crossingfailures, 0) != 0) | ||
3162 | { | ||
3163 | // main simulator had a crossing failure | ||
3164 | // park it inside region | ||
3165 | _position.X = Util.Clip(l_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f); | ||
3166 | _position.Y = Util.Clip(l_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f); | ||
3167 | _position.Z = Util.Clip(l_position.Z, -100f, 50000f); | ||
3168 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); | ||
3169 | |||
3170 | m_lastposition = _position; | ||
3171 | |||
3172 | _velocity = Vector3.Zero; | ||
3173 | m_lastVelocity = _velocity; | ||
3174 | |||
3175 | |||
3176 | if (m_type != Vehicle.TYPE_NONE) | ||
3177 | Halt(); | ||
3178 | |||
3179 | d.BodySetLinearVel(Body, 0, 0, 0); | ||
3180 | base.RequestPhysicsterseUpdate(); | ||
3181 | return; | ||
3182 | } | ||
3183 | */ | ||
3184 | base.RequestPhysicsterseUpdate(); | ||
3116 | 3185 | ||
3117 | if (l_position.Z < 0) | 3186 | if (l_position.Z < 0) |
3118 | { | 3187 | { |
diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs index 353db44..cf7c1d7 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | |||
@@ -1536,7 +1536,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1536 | List<OdePrim> removeprims = null; | 1536 | List<OdePrim> removeprims = null; |
1537 | foreach (OdePrim chr in _activeprims) | 1537 | foreach (OdePrim chr in _activeprims) |
1538 | { | 1538 | { |
1539 | if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled)) | 1539 | if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled) && !chr.m_outofBounds) |
1540 | { | 1540 | { |
1541 | try | 1541 | try |
1542 | { | 1542 | { |
@@ -3410,13 +3410,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3410 | public void SetTerrain(float[] heightMap, Vector3 pOffset) | 3410 | public void SetTerrain(float[] heightMap, Vector3 pOffset) |
3411 | { | 3411 | { |
3412 | 3412 | ||
3413 | uint regionsize = (uint) Constants.RegionSize; // visible region size eg. 256(M) | 3413 | int regionsize = (int) Constants.RegionSize; // visible region size eg. 256(M) |
3414 | 3414 | ||
3415 | uint heightmapWidth = regionsize + 1; // ODE map size 257 x 257 (Meters) (1 extra | 3415 | int heightmapWidth = regionsize + 2; // ODE map size 257 x 257 (Meters) (1 extra |
3416 | uint heightmapHeight = regionsize + 1; | 3416 | int heightmapHeight = regionsize + 2; |
3417 | 3417 | ||
3418 | uint heightmapWidthSamples = (uint)regionsize + 2; // Sample file size, 258 x 258 samples | 3418 | int heightmapWidthSamples = (int)regionsize + 2; // Sample file size, 258 x 258 samples |
3419 | uint heightmapHeightSamples = (uint)regionsize + 2; | 3419 | int heightmapHeightSamples = (int)regionsize + 2; |
3420 | 3420 | ||
3421 | // Array of height samples for ODE | 3421 | // Array of height samples for ODE |
3422 | float[] _heightmap; | 3422 | float[] _heightmap; |
@@ -3432,10 +3432,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3432 | float hfmax = -2000f; | 3432 | float hfmax = -2000f; |
3433 | float minele = 0.0f; // Dont allow -ve heights | 3433 | float minele = 0.0f; // Dont allow -ve heights |
3434 | 3434 | ||
3435 | uint x = 0; | 3435 | int x = 0; |
3436 | uint y = 0; | 3436 | int y = 0; |
3437 | uint xx = 0; | 3437 | int xx = 0; |
3438 | uint yy = 0; | 3438 | int yy = 0; |
3439 | 3439 | ||
3440 | // load the height samples array from the heightMap | 3440 | // load the height samples array from the heightMap |
3441 | for ( x = 0; x < heightmapWidthSamples; x++) // 0 to 257 | 3441 | for ( x = 0; x < heightmapWidthSamples; x++) // 0 to 257 |