Compare commits

...

3 Commits

5 changed files with 125 additions and 43 deletions
@@ -1655,35 +1655,38 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
}
// Offset the positions for the new region across the border
Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
grp.RootPart.GroupPosition = pos;
// NOT here
// If we fail to cross the border, then reset the position of the scene object on that border.
uint x = 0, y = 0;
Utils.LongToUInts(newRegionHandle, out x, out y);
GridRegion destination = scene.GridService.GetRegionByPosition(scene.RegionInfo.ScopeID, (int)x, (int)y);
if (destination == null || !CrossPrimGroupIntoNewRegion(destination, grp, silent))
Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
if (destination != null)
{
m_log.InfoFormat("[ENTITY TRANSFER MODULE] cross region transfer failed for object {0}",grp.UUID);
// Need to turn off the physics flags, otherwise the object will continue to attempt to
// move out of the region creating an infinite loop of failed attempts to cross
grp.UpdatePrimFlags(grp.RootPart.LocalId,false,grp.IsTemporary,grp.IsPhantom,false);
// We are going to move the object back to the old position so long as the old position
// is in the region
oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X,1.0f,(float)Constants.RegionSize-1);
oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y,1.0f,(float)Constants.RegionSize-1);
oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z,1.0f,4096.0f);
grp.AbsolutePosition = oldGroupPosition;
grp.ScheduleGroupForFullUpdate();
grp.RootPart.GroupPosition = pos; // only change this if we think there is anywhere to go
if (CrossPrimGroupIntoNewRegion(destination, grp, silent))
return; // we did it
}
// no one or failed lets go back and tell physics to go on
oldGroupPosition.X = Util.Clamp<float>(oldGroupPosition.X, 0.5f, (float)Constants.RegionSize - 0.5f);
oldGroupPosition.Y = Util.Clamp<float>(oldGroupPosition.Y, 0.5f, (float)Constants.RegionSize - 0.5f);
oldGroupPosition.Z = Util.Clamp<float>(oldGroupPosition.Z, 0.5f, 4096.0f);
grp.AbsolutePosition = oldGroupPosition;
grp.Velocity = Vector3.Zero;
if (grp.RootPart.PhysActor != null)
grp.RootPart.PhysActor.CrossingFailure();
grp.ScheduleGroupForFullUpdate();
}
/// <summary>
/// Move the given scene object into a new region
/// </summary>
@@ -461,8 +461,11 @@ namespace OpenSim.Region.Framework.Scenes
if (Scene != null)
{
if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
|| Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
// if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W)
// || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S))
// && !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
if ((Scene.TestBorderCross(val, Cardinals.E) || Scene.TestBorderCross(val, Cardinals.W)
|| Scene.TestBorderCross(val, Cardinals.N) || Scene.TestBorderCross(val, Cardinals.S))
&& !IsAttachmentCheckFull() && (!Scene.LoadingPrims))
{
IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
@@ -489,7 +492,7 @@ namespace OpenSim.Region.Framework.Scenes
canCross = false;
break;
}
m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName);
}
@@ -534,8 +537,15 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
}
else if (RootPart.PhysActor != null)
{
RootPart.PhysActor.CrossingFailure();
}
val = AbsolutePosition;
Vector3 oldp = AbsolutePosition;
val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f);
val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f);
val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f);
}
}
@@ -2612,9 +2612,9 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 newpos = new Vector3(PhysActor.Position.GetBytes(), 0);
if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N)
| ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S)
| ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E)
| ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W))
|| ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S)
|| ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E)
|| ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W))
{
ParentGroup.AbsolutePosition = newpos;
return;
+77 -8
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,16 +732,38 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void CrossingFailure()
{
m_crossingfailures++;
if (m_crossingfailures > _parent_scene.geomCrossingFailuresBeforeOutofbounds)
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)
{
base.RaiseOutOfBounds(_position);
return;
}
else if (m_crossingfailures == _parent_scene.geomCrossingFailuresBeforeOutofbounds)
else if (tmp == _parent_scene.geomCrossingFailuresBeforeOutofbounds)
{
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
@@ -3042,10 +3064,9 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
d.Vector3 torque = d.BodyGetTorque(Body);
_torque = new Vector3(torque.X, torque.Y, torque.Z);
base.RequestPhysicsterseUpdate();
//Console.WriteLine("Move {0} at {1}", m_primName, l_position);
/*
// Check if outside region
// In Scene.cs/CrossPrimGroupIntoNewRegion the object is checked for 0.1M from border!
if (l_position.X > ((float)_parent_scene.WorldExtents.X - fence))
@@ -3112,7 +3133,55 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
return; // Dont process any other motion?
} // end various methods
} // end outside region horizontally
*/
if (_position.X < 0f || _position.X > _parent_scene.WorldExtents.X
|| _position.Y < 0f || _position.Y > _parent_scene.WorldExtents.Y
)
{
// we are outside current region
// clip position to a stop just outside region and stop it only internally
// do it only once using m_crossingfailures as control
_position.X = Util.Clip(l_position.X, -0.2f, _parent_scene.WorldExtents.X + .2f);
_position.Y = Util.Clip(l_position.Y, -0.2f, _parent_scene.WorldExtents.Y + .2f);
_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();
}
*/
m_outofBounds = true;
base.RequestPhysicsterseUpdate();
return;
}
/*
if (Interlocked.Exchange(ref m_crossingfailures, 0) != 0)
{
// main simulator had a crossing failure
// park it inside region
_position.X = Util.Clip(l_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f);
_position.Y = Util.Clip(l_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f);
_position.Z = Util.Clip(l_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();
return;
}
*/
base.RequestPhysicsterseUpdate();
if (l_position.Z < 0)
{
+10 -10
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