diff options
author | UbitUmarov | 2012-02-15 20:33:31 +0000 |
---|---|---|
committer | UbitUmarov | 2012-02-15 20:33:31 +0000 |
commit | f6c35cf26f759407268a46689d94e246a82b4286 (patch) | |
tree | e07bf46c4366705428d55d2ad79c3937390e66be /OpenSim/Region/Physics/ChOdePlugin | |
parent | don't freeze with a sitted avatar in a border without other sim. Still messy :( (diff) | |
download | opensim-SC_OLD-f6c35cf26f759407268a46689d94e246a82b4286.zip opensim-SC_OLD-f6c35cf26f759407268a46689d94e246a82b4286.tar.gz opensim-SC_OLD-f6c35cf26f759407268a46689d94e246a82b4286.tar.bz2 opensim-SC_OLD-f6c35cf26f759407268a46689d94e246a82b4286.tar.xz |
Now if chode prim.cs detects out of bounds it requests a update and blocks movement and colisions. Base code must do a PhysActor.CrossingFailure() to make it move again inside sim or delete it.
Diffstat (limited to 'OpenSim/Region/Physics/ChOdePlugin')
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 45 | ||||
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | 20 |
2 files changed, 45 insertions, 20 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 073241f..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,6 +732,27 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
732 | 732 | ||
733 | public override void CrossingFailure() | 733 | public override void CrossingFailure() |
734 | { | 734 | { |
735 | if (m_outofBounds) | ||
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 | /* | ||
735 | int tmp = Interlocked.Increment(ref m_crossingfailures); | 756 | int tmp = Interlocked.Increment(ref m_crossingfailures); |
736 | if (tmp > _parent_scene.geomCrossingFailuresBeforeOutofbounds) | 757 | if (tmp > _parent_scene.geomCrossingFailuresBeforeOutofbounds) |
737 | { | 758 | { |
@@ -742,6 +763,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
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 |
@@ -3124,15 +3146,18 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!"); | |||
3124 | _position.Z = Util.Clip(l_position.Z, -100f, 50000f); | 3146 | _position.Z = Util.Clip(l_position.Z, -100f, 50000f); |
3125 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); | 3147 | d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); |
3126 | d.BodySetLinearVel(Body, 0, 0, 0); | 3148 | d.BodySetLinearVel(Body, 0, 0, 0); |
3127 | 3149 | /* | |
3128 | if (Interlocked.Exchange(ref m_crossingfailures, m_crossingfailures) == 0) | 3150 | if (Interlocked.Exchange(ref m_crossingfailures, m_crossingfailures) == 0) |
3129 | { // tell base code only once | 3151 | { // tell base code only once |
3130 | Interlocked.Increment(ref m_crossingfailures); | 3152 | Interlocked.Increment(ref m_crossingfailures); |
3131 | base.RequestPhysicsterseUpdate(); | 3153 | base.RequestPhysicsterseUpdate(); |
3132 | } | 3154 | } |
3155 | */ | ||
3156 | m_outofBounds = true; | ||
3157 | base.RequestPhysicsterseUpdate(); | ||
3133 | return; | 3158 | return; |
3134 | } | 3159 | } |
3135 | 3160 | /* | |
3136 | if (Interlocked.Exchange(ref m_crossingfailures, 0) != 0) | 3161 | if (Interlocked.Exchange(ref m_crossingfailures, 0) != 0) |
3137 | { | 3162 | { |
3138 | // main simulator had a crossing failure | 3163 | // main simulator had a crossing failure |
@@ -3155,7 +3180,7 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!"); | |||
3155 | base.RequestPhysicsterseUpdate(); | 3180 | base.RequestPhysicsterseUpdate(); |
3156 | return; | 3181 | return; |
3157 | } | 3182 | } |
3158 | 3183 | */ | |
3159 | base.RequestPhysicsterseUpdate(); | 3184 | base.RequestPhysicsterseUpdate(); |
3160 | 3185 | ||
3161 | if (l_position.Z < 0) | 3186 | if (l_position.Z < 0) |
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 |