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.

avinationmerge
UbitUmarov 2012-02-15 20:33:31 +00:00 committed by Melanie
parent 3bffdddc9d
commit 819fcdaee1
2 changed files with 45 additions and 20 deletions

View File

@ -166,7 +166,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public int m_roundsUnderMotionThreshold;
private int m_crossingfailures;
public bool outofBounds;
public bool m_outofBounds;
private float m_density = 10.000006836f; // Aluminum g/cm3;
public bool _zeroFlag; // if body has been stopped
@ -732,6 +732,27 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void CrossingFailure()
{
if (m_outofBounds)
{
_position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f);
_position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f);
_position.Z = Util.Clip(_position.Z, -100f, 50000f);
d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
m_lastposition = _position;
_velocity = Vector3.Zero;
m_lastVelocity = _velocity;
if (m_type != Vehicle.TYPE_NONE)
Halt();
d.BodySetLinearVel(Body, 0, 0, 0);
base.RequestPhysicsterseUpdate();
m_outofBounds = false;
}
/*
int tmp = Interlocked.Increment(ref m_crossingfailures);
if (tmp > _parent_scene.geomCrossingFailuresBeforeOutofbounds)
{
@ -742,6 +763,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
m_log.Warn("[PHYSICS]: Too many crossing failures for: " + m_primName);
}
*/
}
public override float Buoyancy
@ -3011,7 +3033,7 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
if(revcount > 0) revcount--;
if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim) // Only move root prims.
if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim && !m_outofBounds) // Only move root prims.
{
// Old public void UpdatePositionAndVelocity(), more accuratley calculated here
bool lastZeroFlag = _zeroFlag; // was it stopped
@ -3124,15 +3146,18 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
_position.Z = Util.Clip(l_position.Z, -100f, 50000f);
d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
d.BodySetLinearVel(Body, 0, 0, 0);
if (Interlocked.Exchange(ref m_crossingfailures, m_crossingfailures) == 0)
{ // tell base code only once
Interlocked.Increment(ref m_crossingfailures);
base.RequestPhysicsterseUpdate();
}
/*
if (Interlocked.Exchange(ref m_crossingfailures, m_crossingfailures) == 0)
{ // tell base code only once
Interlocked.Increment(ref m_crossingfailures);
base.RequestPhysicsterseUpdate();
}
*/
m_outofBounds = true;
base.RequestPhysicsterseUpdate();
return;
}
/*
if (Interlocked.Exchange(ref m_crossingfailures, 0) != 0)
{
// main simulator had a crossing failure
@ -3155,7 +3180,7 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
base.RequestPhysicsterseUpdate();
return;
}
*/
base.RequestPhysicsterseUpdate();
if (l_position.Z < 0)

View File

@ -1536,7 +1536,7 @@ namespace OpenSim.Region.Physics.OdePlugin
List<OdePrim> removeprims = null;
foreach (OdePrim chr in _activeprims)
{
if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled))
if (chr.Body != IntPtr.Zero && d.BodyIsEnabled(chr.Body) && (!chr.m_disabled) && !chr.m_outofBounds)
{
try
{
@ -3410,13 +3410,13 @@ namespace OpenSim.Region.Physics.OdePlugin
public void SetTerrain(float[] heightMap, Vector3 pOffset)
{
uint regionsize = (uint) Constants.RegionSize; // visible region size eg. 256(M)
int regionsize = (int) Constants.RegionSize; // visible region size eg. 256(M)
uint heightmapWidth = regionsize + 1; // ODE map size 257 x 257 (Meters) (1 extra
uint heightmapHeight = regionsize + 1;
int heightmapWidth = regionsize + 2; // ODE map size 257 x 257 (Meters) (1 extra
int heightmapHeight = regionsize + 2;
uint heightmapWidthSamples = (uint)regionsize + 2; // Sample file size, 258 x 258 samples
uint heightmapHeightSamples = (uint)regionsize + 2;
int heightmapWidthSamples = (int)regionsize + 2; // Sample file size, 258 x 258 samples
int heightmapHeightSamples = (int)regionsize + 2;
// Array of height samples for ODE
float[] _heightmap;
@ -3432,10 +3432,10 @@ namespace OpenSim.Region.Physics.OdePlugin
float hfmax = -2000f;
float minele = 0.0f; // Dont allow -ve heights
uint x = 0;
uint y = 0;
uint xx = 0;
uint yy = 0;
int x = 0;
int y = 0;
int xx = 0;
int yy = 0;
// load the height samples array from the heightMap
for ( x = 0; x < heightmapWidthSamples; x++) // 0 to 257